writerfilter/source/dmapper/DomainMapper_Impl.cxx |   30 +++++++++++-----------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    5 +--
 2 files changed, 17 insertions(+), 18 deletions(-)

New commits:
commit 30323c813977eb0127251848fecd2532dce75749
Author:     Michael Stahl <[email protected]>
AuthorDate: Wed Jan 31 15:03:32 2024 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Feb 1 09:34:44 2024 +0100

    writerfilter: move m_bFirstParagraphInCell to SubstreamContext
    
    This is a change to set it for all substreams.
    
    Change-Id: I44ed9a5485000f40f8ccfe3ec885ef8f05f5aab2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162841
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index be38c93cd628..08e81899b94f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -402,8 +402,6 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bIsSplitPara(false),
         m_bIsActualParagraphFramed( false ),
         m_bParaAutoBefore(false),
-        m_bFirstParagraphInCell(true),
-        m_bSaveFirstParagraphInCell(false),
         m_bParaWithInlineObject(false),
         m_bSaxError(false)
 {
@@ -2357,7 +2355,7 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
         {
             if ( GetIsFirstParagraphInShape() ||
                  (GetIsFirstParagraphInSection() && GetSectionContext() && 
GetSectionContext()->IsFirstSection()) ||
-                (m_bFirstParagraphInCell
+                (m_StreamStateStack.top().bFirstParagraphInCell
                  && 0 < m_StreamStateStack.top().nTableDepth
                  && m_StreamStateStack.top().nTableDepth == m_nTableCellDepth))
             {
@@ -2655,9 +2653,10 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
                                 TOOLS_WARN_EXCEPTION("writerfilter", 
"DomainMapper_Impl::finishParagraph NumberingRules");
                             }
                         }
-                        else if ( 
m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName")
 &&
+                        else if 
(m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName")
                                 // don't update before tables
-                                (m_StreamStateStack.top().nTableDepth == 0 || 
!m_bFirstParagraphInCell))
+                            && (m_StreamStateStack.top().nTableDepth == 0
+                                || 
!m_StreamStateStack.top().bFirstParagraphInCell))
                         {
                             aCurrentNumberingName = GetListStyleName(nListId);
                             
m_xPreviousParagraph->getPropertyValue("NumberingStyleName") >>= 
aPreviousNumberingName;
@@ -3024,7 +3023,7 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
         && m_StreamStateStack.top().nTableDepth == m_nTableCellDepth
         && !IsInShape() && !m_bIsInComments)
     {
-        m_bFirstParagraphInCell = false;
+        m_StreamStateStack.top().bFirstParagraphInCell = false;
     }
 
     m_bParaAutoBefore = false;
@@ -3955,7 +3954,6 @@ void DomainMapper_Impl::PushFootOrEndnote( bool 
bIsFootnote )
     m_bInFootOrEndnote = true;
     m_bInFootnote = bIsFootnote;
     m_bCheckFirstFootnoteTab = true;
-    m_bSaveFirstParagraphInCell = m_bFirstParagraphInCell;
     try
     {
         // Redlines outside the footnote should not affect footnote content
@@ -4484,7 +4482,6 @@ void DomainMapper_Impl::PopFootOrEndnote()
     m_eSkipFootnoteState = SkipFootnoteSeparator::OFF;
     m_bInFootOrEndnote = m_bInFootnote = false;
     m_pFootnoteContext = nullptr;
-    m_bFirstParagraphInCell = m_bSaveFirstParagraphInCell;
 }
 
 void DomainMapper_Impl::PopAnnotation()
@@ -4973,7 +4970,7 @@ void DomainMapper_Impl::ClearPreviousParagraph()
     m_xPreviousParagraph.clear();
 
     // next table paragraph will be first paragraph in a cell
-    m_bFirstParagraphInCell = true;
+    m_StreamStateStack.top().bFirstParagraphInCell = true;
 }
 
 void DomainMapper_Impl::HandleAltChunk(const OUString& rStreamName)
@@ -8900,8 +8897,11 @@ void DomainMapper_Impl::StartOrEndBookmark( const 
OUString& rId )
                     // keep bookmark range, if it doesn't exceed cell boundary
                     uno::Reference< text::XTextRange > xStart = 
xCursor->getStart();
                     xCursor->goLeft( 1, false );
-                    if (m_StreamStateStack.top().nTableDepth == 0 || 
!m_bFirstParagraphInCell)
+                    if (m_StreamStateStack.top().nTableDepth == 0
+                        || !m_StreamStateStack.top().bFirstParagraphInCell)
+                    {
                         xCursor->gotoRange(xStart, true );
+                    }
                 }
                 uno::Reference< container::XNamed > xBkmNamed( xBookmark, 
uno::UNO_QUERY_THROW );
                 SAL_WARN_IF(aBookmarkIter->second.m_sBookmarkName.isEmpty(), 
"writerfilter.dmapper", "anonymous bookmark");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 518f490cf12c..1250cf97307b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -189,6 +189,8 @@ struct SubstreamContext
     sal_Int32 nLineBreaksDeferred = 0;
     /// Current paragraph had at least one field in it.
     bool      bParaHadField = false;
+    /// Current paragraph in a table is first paragraph of a cell
+    bool      bFirstParagraphInCell = true;
 };
 
 /// Information about a paragraph to be finished after a field end.
@@ -1232,9 +1234,6 @@ private:
     css::uno::Reference<css::beans::XPropertySet> m_xPreviousParagraph;
     /// Current paragraph has automatic before spacing.
     bool m_bParaAutoBefore;
-    /// Current paragraph in a table is first paragraph of a cell
-    bool m_bFirstParagraphInCell;
-    bool m_bSaveFirstParagraphInCell;
     /// Current paragraph had at least one inline object in it.
     bool m_bParaWithInlineObject;
     /// SAXException was seen so document will be abandoned
commit 95b01848b18283fd2f903c982108ccdb8efee022
Author:     Michael Stahl <[email protected]>
AuthorDate: Wed Jan 31 14:56:22 2024 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Feb 1 09:34:32 2024 +0100

    writerfilter: use SubstreamContext for all substreams
    
    <vmiklos> possibly just nobody needed that so far. could be some more
    general SubstreamContext, i don't see an obvious problem reusing that at
    more places.
    
    Change-Id: If0749155452f65f8dfc4ac2b10f91bb8e48a6b2b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162840
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8f56f102e65f..be38c93cd628 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3788,8 +3788,6 @@ bool isContentEmpty(uno::Reference<text::XText> const& 
xText, uno::Reference<tex
 
 void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, 
PageType eType)
 {
-    m_StreamStateStack.emplace();
-
     bool bHeader = ePagePartType == PagePartType::Header;
 
     const PropertyIds ePropIsOn = bHeader ? PROP_HEADER_IS_ON: 
PROP_FOOTER_IS_ON;
@@ -3949,9 +3947,6 @@ void DomainMapper_Impl::PopPageHeaderFooter(PagePartType 
ePagePartType, PageType
         m_bDiscardHeaderFooter = false;
     }
     m_eInHeaderFooterImport = HeaderFooterImportState::none;
-
-    assert(!m_StreamStateStack.empty());
-    m_StreamStateStack.pop();
 }
 
 void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
@@ -9752,6 +9747,8 @@ void DomainMapper_Impl::substream(Id rName,
     appendTableHandler();
     getTableManager().startLevel();
 
+    m_StreamStateStack.emplace();
+
     //import of page header/footer
     //Ensure that only one header/footer per section is pushed
 
@@ -9823,6 +9820,9 @@ void DomainMapper_Impl::substream(Id rName,
     break;
     }
 
+    assert(!m_StreamStateStack.empty());
+    m_StreamStateStack.pop();
+
     getTableManager().endLevel();
     popTableManager();
     m_bHasFtn = bHasFtn;

Reply via email to