writerfilter/source/dmapper/DomainMapper_Impl.cxx |   45 +++++++++++-----------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |   27 +++++--------
 2 files changed, 35 insertions(+), 37 deletions(-)

New commits:
commit 3b76d1ebdde08252e9e3896555a3bdb6c83bf28e
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Feb 6 13:57:23 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Apr 16 16:56:26 2025 +0200

    writerfilter: move even more members to SubstreamContext
    
    +a change in DomainMapper_Impl.hxx from
    5eb0a569e31771277263262bfeafb2c6fcf57dba
    "loplugin:unnecessarymethods"
    
    Conflicts:
          writerfilter/source/dmapper/DomainMapper_Impl.cxx
          writerfilter/source/dmapper/DomainMapper_Impl.hxx
    
    Change-Id: I5d080353075b17d8752ad6509240f77563c4306f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163053
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit e6783f42ae706da76fd347790c15ac3397ce4530)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184261
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9d964a51efff..83251d3e2cec 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -367,12 +367,8 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bIsParaMarkerChange( false ),
         m_bIsParaMarkerMove( false ),
         m_bRedlineImageInPreviousRun( false ),
-        m_bTextFrameInserted(false),
         m_bIsLastSectionGroup( false ),
         m_bUsingEnhancedFields( false ),
-        m_bSdt(false),
-        m_bIsFirstRun(false),
-        m_bIsOutsideAParagraph(true),
         m_nAnnotationId( -1 ),
         m_aSmartTagHandler(m_xComponentContext, m_xTextDocument),
         
m_xInsertTextRange(rMediaDesc.getUnpackedValueOrDefault("TextInsertModeRange", 
uno::Reference<text::XTextRange>())),
@@ -962,7 +958,7 @@ void 
DomainMapper_Impl::SetIsDummyParaAddedForTableInSection( bool bIsAdded )
 
 void DomainMapper_Impl::SetIsTextFrameInserted( bool bIsInserted )
 {
-    m_bTextFrameInserted  = bIsInserted;
+    m_StreamStateStack.top().bTextFrameInserted = bIsInserted;
 }
 
 void DomainMapper_Impl::SetParaSectpr(bool bParaSectpr)
@@ -972,15 +968,15 @@ void DomainMapper_Impl::SetParaSectpr(bool bParaSectpr)
 
 void DomainMapper_Impl::SetSdt(bool bSdt)
 {
-    m_bSdt = bSdt;
+    m_StreamStateStack.top().bSdt = bSdt;
 
-    if (m_bSdt && !m_aTextAppendStack.empty())
+    if (m_StreamStateStack.top().bSdt && !m_aTextAppendStack.empty())
     {
-        m_xSdtEntryStart = GetTopTextAppend()->getEnd();
+        m_StreamStateStack.top().xSdtEntryStart = GetTopTextAppend()->getEnd();
     }
     else
     {
-        m_xSdtEntryStart.clear();
+        m_StreamStateStack.top().xSdtEntryStart.clear();
     }
 }
 
@@ -1281,7 +1277,7 @@ void    DomainMapper_Impl::PushProperties(ContextType eId)
     if(eId == CONTEXT_PARAGRAPH && m_bIsSplitPara)
     {
         // Some paragraph properties only apply at the beginning of the 
paragraph - apply only once.
-        if (!m_bIsFirstRun)
+        if (!IsFirstRun())
         {
             auto pParaContext = 
static_cast<ParagraphPropertyMap*>(GetTopContextOfType(eId).get());
             pParaContext->props().SetListId(-1);
@@ -1344,7 +1340,7 @@ void    DomainMapper_Impl::PopProperties(ContextType eId)
         m_pLastCharacterContext = m_aPropertyStacks[eId].top();
         // Sadly an assert about deferredCharacterProperties being empty is 
not possible
         // here, because appendTextPortion() may not be called for every 
character section.
-        m_deferredCharacterProperties.clear();
+        m_StreamStateStack.top().deferredCharacterProperties.clear();
     }
 
     if (!IsInFootOrEndnote() && IsInCustomFootnote() && 
!m_aPropertyStacks[eId].empty())
@@ -3252,8 +3248,12 @@ void 
DomainMapper_Impl::MergeAtContentImageRedlineWithNext(const css::uno::Refer
         return;
     // Before placing call to processDeferredCharacterProperties(), 
TopContextType should be CONTEXT_CHARACTER
     // processDeferredCharacterProperties() invokes only if character inserted
-    if( pPropertyMap == m_pTopContext && 
!m_deferredCharacterProperties.empty() && (GetTopContextType() == 
CONTEXT_CHARACTER) )
+    if (pPropertyMap == m_pTopContext
+        && !m_StreamStateStack.top().deferredCharacterProperties.empty()
+        && (GetTopContextType() == CONTEXT_CHARACTER))
+    {
         processDeferredCharacterProperties();
+    }
     uno::Reference< text::XTextAppend >  xTextAppend = 
m_aTextAppendStack.top().xTextAppend;
     if (!xTextAppend.is() || !hasTableManager() || 
getTableManager().isIgnore())
         return;
@@ -6836,7 +6836,7 @@ static uno::Sequence< beans::PropertyValues > 
lcl_createTOXLevelHyperlinks( bool
 /// Returns title of the TOC placed in paragraph(s) before TOC field inside 
STD-frame
 OUString DomainMapper_Impl::extractTocTitle()
 {
-    if (!m_xSdtEntryStart.is())
+    if (!m_StreamStateStack.top().xSdtEntryStart.is())
         return OUString();
 
     uno::Reference< text::XTextAppend > xTextAppend = 
m_aTextAppendStack.top().xTextAppend;
@@ -6846,7 +6846,8 @@ OUString DomainMapper_Impl::extractTocTitle()
     // try-catch was added in the same way as inside appendTextSectionAfter()
     try
     {
-        uno::Reference<text::XParagraphCursor> 
xCursor(xTextAppend->createTextCursorByRange(m_xSdtEntryStart), 
uno::UNO_QUERY_THROW);
+        uno::Reference<text::XParagraphCursor> const xCursor(
+            
xTextAppend->createTextCursorByRange(m_StreamStateStack.top().xSdtEntryStart), 
uno::UNO_QUERY_THROW);
         if (!xCursor.is())
             return OUString();
 
@@ -7115,7 +7116,7 @@ void DomainMapper_Impl::handleToc
         if (aTocTitle.isEmpty() || bTableOfFigures)
         {
             // reset marker of the TOC title
-            m_xSdtEntryStart.clear();
+            m_StreamStateStack.top().xSdtEntryStart.clear();
 
             // Create section before setting m_bStartTOC: finishing paragraph
             // inside StartIndexSectionChecked could do the wrong thing 
otherwise
@@ -7131,14 +7132,14 @@ void DomainMapper_Impl::handleToc
         {
             // create TOC section
             css::uno::Reference<css::text::XTextRange> 
xTextRangeEndOfTocHeader = GetTopTextAppend()->getEnd();
-            xTOC = createSectionForRange(m_xSdtEntryStart, 
xTextRangeEndOfTocHeader, sTOCServiceName, false);
+            xTOC = 
createSectionForRange(m_StreamStateStack.top().xSdtEntryStart, 
xTextRangeEndOfTocHeader, sTOCServiceName, false);
 
             // init [xTOCMarkerCursor]
             uno::Reference< text::XText > xText = xTextAppend->getText();
             m_xTOCMarkerCursor = xText->createTextCursor();
 
             // create header of the TOC with the TOC title inside
-            createSectionForRange(m_xSdtEntryStart, xTextRangeEndOfTocHeader, 
"com.sun.star.text.IndexHeaderSection", true);
+            createSectionForRange(m_StreamStateStack.top().xSdtEntryStart, 
xTextRangeEndOfTocHeader, "com.sun.star.text.IndexHeaderSection", true);
         }
     }
 
@@ -8740,7 +8741,7 @@ void DomainMapper_Impl::PopFieldContext()
                     if (m_bStartedTOC || m_bStartIndex || m_bStartBibliography)
                     {
                         // inside SDT, last empty paragraph is also part of 
index
-                        if (!m_StreamStateStack.top().bParaChanged && 
!m_xSdtEntryStart)
+                        if (!m_StreamStateStack.top().bParaChanged && 
!m_StreamStateStack.top().xSdtEntryStart)
                         {
                             // End of index is the first item on a new 
paragraph - this paragraph
                             // should not be part of index
@@ -9708,16 +9709,16 @@ SectionPropertyMap * 
DomainMapper_Impl::GetSectionContext()
 
 void DomainMapper_Impl::deferCharacterProperty(sal_Int32 id, const 
css::uno::Any& value)
 {
-    m_deferredCharacterProperties[ id ] = value;
+    m_StreamStateStack.top().deferredCharacterProperties[ id ] = value;
 }
 
 void DomainMapper_Impl::processDeferredCharacterProperties(bool bCharContext)
 {
     // Actually process in DomainMapper, so that it's the same source file 
like normal processing.
-    if( !m_deferredCharacterProperties.empty())
+    if (!m_StreamStateStack.top().deferredCharacterProperties.empty())
     {
-        
m_rDMapper.processDeferredCharacterProperties(m_deferredCharacterProperties, 
bCharContext);
-        m_deferredCharacterProperties.clear();
+        
m_rDMapper.processDeferredCharacterProperties(m_StreamStateStack.top().deferredCharacterProperties,
 bCharContext);
+        m_StreamStateStack.top().deferredCharacterProperties.clear();
     }
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 1f4e7dc79863..72ae1bb7898f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -249,12 +249,19 @@ struct SubstreamContext
     bool bSdtEndDeferred = false;
     /// If we want to set "paragraph sdt end" on the next paragraph context.
     bool bParaSdtEndDeferred = false;
+    /// If the current paragraph is inside a structured document element.
+    bool bSdt = false;
+    css::uno::Reference<css::text::XTextRange> xSdtEntryStart;
     OUString sCurrentParaStyleName; ///< highly inaccurate. Overwritten by 
"overlapping" paragraphs like flys.
     bool bHasFootnoteStyle = false;
     bool bCheckFootnoteStyle = false;
     bool bIsInFootnoteProperties = false;
     RubyInfo aRubyInfo;
+    bool bTextFrameInserted = false;
+    bool bIsFirstRun = false;
+    bool bIsOutsideAParagraph = true;
     bool bDummyParaAddedForTableInSection = false; // tdf#161631
+    std::map<sal_Int32, css::uno::Any> deferredCharacterProperties;
 };
 
 /// Information about a paragraph to be finished after a field end.
@@ -642,13 +649,8 @@ private:
     // text ZWSPs to keep the change tracking of the image in Writer.)
     bool                            m_bRedlineImageInPreviousRun;
 
-    bool                            m_bTextFrameInserted;
     bool                            m_bIsLastSectionGroup;
     bool                            m_bUsingEnhancedFields;
-    /// If the current paragraph is inside a structured document element.
-    bool                            m_bSdt;
-    bool                            m_bIsFirstRun;
-    bool                            m_bIsOutsideAParagraph;
 
     css::uno::Reference< css::text::XTextCursor > m_xTOCMarkerCursor;
 
@@ -667,11 +669,9 @@ private:
     css::uno::Reference<css::beans::XPropertySet> 
FindOrCreateFieldMaster(const char* pFieldMasterService, const OUString& 
rFieldMasterName);
     css::uno::Reference<css::beans::XPropertySet> const & 
GetDocumentSettings();
 
-    std::map<sal_Int32, css::uno::Any> m_deferredCharacterProperties;
     SmartTagHandler m_aSmartTagHandler;
 
     css::uno::Reference<css::text::XTextRange> m_xGlossaryEntryStart;
-    css::uno::Reference<css::text::XTextRange> m_xSdtEntryStart;
     std::stack<BookmarkInsertPosition> m_xSdtStarts;
 
     std::queue< css::uno::Reference< css::text::XTextFrame > > 
m_xPendingTextBoxFrames;
@@ -770,7 +770,7 @@ public:
 
     /// Track if a textframe has been inserted into this section
     void SetIsTextFrameInserted( bool bIsInserted );
-    bool GetIsTextFrameInserted() const { return m_bTextFrameInserted;}
+    bool GetIsTextFrameInserted() const { return 
m_StreamStateStack.top().bTextFrameInserted; }
     void SetIsTextDeleted(bool bIsTextDeleted) { m_bTextDeleted = 
bIsTextDeleted; }
 
     void SetIsPreviousParagraphFramed(bool const bIsFramed)
@@ -783,7 +783,6 @@ public:
     void SetSymbolFont( OUString const &rName ) { m_aSymbolData.sFont = rName; 
}
     const SymbolData & GetSymbolData() const { return m_aSymbolData;}
 
-    /// Setter method for m_bSdt.
     void SetSdt(bool bSdt);
 
     void PushSdt();
@@ -791,8 +790,6 @@ public:
     /// Gives access to the currently open run/inline SDTs.
     const std::stack<BookmarkInsertPosition>& GetSdtStarts() const;
 
-    /// Getter method for m_bSdt.
-    bool GetSdt() const { return m_bSdt;}
     bool GetParaChanged() const { return 
m_StreamStateStack.top().bParaChanged; }
     bool GetParaHadField() const { return 
m_StreamStateStack.top().bParaHadField; }
     bool GetRemoveThisPara() const { return 
m_StreamStateStack.top().bRemoveThisParagraph; }
@@ -1095,10 +1092,10 @@ public:
     void SetCurrentRedlineIsRead();
     void RemoveTopRedline( );
     void SetCurrentRedlineInitials( const OUString& sInitials );
-    bool IsFirstRun() const { return m_bIsFirstRun;}
-    void SetIsFirstRun(bool bval) { m_bIsFirstRun = bval;}
-    bool IsOutsideAParagraph() const { return m_bIsOutsideAParagraph;}
-    void SetIsOutsideAParagraph(bool bval) { m_bIsOutsideAParagraph = bval;}
+    bool IsFirstRun() const { return m_StreamStateStack.top().bIsFirstRun; }
+    void SetIsFirstRun(bool const bval) { m_StreamStateStack.top().bIsFirstRun 
= bval; }
+    bool IsOutsideAParagraph() const { return 
m_StreamStateStack.top().bIsOutsideAParagraph; }
+    void SetIsOutsideAParagraph(bool const bval) { 
m_StreamStateStack.top().bIsOutsideAParagraph = bval; }
 
     void ApplySettingsTable();
 

Reply via email to