writerfilter/source/dmapper/DomainMapper_Impl.cxx |  111 ++++++++++------------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |  109 ++++++++++-----------
 2 files changed, 108 insertions(+), 112 deletions(-)

New commits:
commit e6783f42ae706da76fd347790c15ac3397ce4530
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Feb 6 13:57:23 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Feb 6 15:27:17 2024 +0100

    writerfilter: move even more members to SubstreamContext
    
    Change-Id: I5d080353075b17d8752ad6509240f77563c4306f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163053
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d4625035cd85..bb5472f43174 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -365,12 +365,8 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bIsParaMarkerMove( false ),
         m_bRedlineImageInPreviousRun( false ),
         m_bDummyParaAddedForTableInSection( 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>())),
@@ -956,7 +952,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)
@@ -966,15 +962,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();
     }
 }
 
@@ -1236,7 +1232,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);
@@ -1299,7 +1295,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())
@@ -3169,8 +3165,12 @@ void DomainMapper_Impl::applyToggleAttributes(const 
PropertyMapPtr& pPropertyMap
         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;
@@ -6740,7 +6740,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;
@@ -6750,7 +6750,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();
 
@@ -6991,7 +6992,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
@@ -7007,14 +7008,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);
         }
     }
 
@@ -8611,7 +8612,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
@@ -9594,16 +9595,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 e87ac5bf9df9..34b178853060 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -249,11 +249,18 @@ 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;
+    std::map<sal_Int32, css::uno::Any> deferredCharacterProperties;
 };
 
 /// Information about a paragraph to be finished after a field end.
@@ -639,13 +646,8 @@ private:
     bool                            m_bRedlineImageInPreviousRun;
 
     bool                            m_bDummyParaAddedForTableInSection;
-    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;
 
@@ -662,11 +664,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;
@@ -763,7 +763,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)
@@ -776,7 +776,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();
@@ -1086,10 +1085,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();
 
commit 115569f6895f48b28e8e9e649ffbc72968a3bdeb
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Feb 6 13:19:48 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Feb 6 15:27:03 2024 +0100

    writerfilter: move yet more members to SubstreamContext
    
    Change-Id: I708375204226fbad502155f4d2efc81ecc206a31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163052
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1d429c82463f..d4625035cd85 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -340,8 +340,6 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bSetCitation( false ),
         m_bSetDateValue( false ),
         m_bIsFirstSection( true ),
-        m_bSdtEndDeferred(false),
-        m_bParaSdtEndDeferred(false),
         m_bStartTOC(false),
         m_bStartTOCHeaderFooter(false),
         m_bStartedTOC(false),
@@ -357,15 +355,12 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bInNumberingImport(false),
         m_bInAnyTableImport( false ),
         m_bDiscardHeaderFooter( false ),
-        m_bHasFootnoteStyle(false),
-        m_bCheckFootnoteStyle(false),
         m_eSkipFootnoteState(SkipFootnoteSeparator::OFF),
         m_nFootnotes(-1),
         m_nEndnotes(-1),
         m_nFirstFootnoteIndex(-1),
         m_nFirstEndnoteIndex(-1),
         m_bLineNumberingSet( false ),
-        m_bIsInFootnoteProperties( false ),
         m_bIsParaMarkerChange( false ),
         m_bIsParaMarkerMove( false ),
         m_bRedlineImageInPreviousRun( false ),
@@ -380,7 +375,6 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_aSmartTagHandler(m_xComponentContext, m_xTextDocument),
         
m_xInsertTextRange(rMediaDesc.getUnpackedValueOrDefault("TextInsertModeRange", 
uno::Reference<text::XTextRange>())),
         
m_xAltChunkStartingRange(rMediaDesc.getUnpackedValueOrDefault("AltChunkStartingRange",
 uno::Reference<text::XTextRange>())),
-        m_bIsInTextBox(false),
         m_bIsNewDoc(!rMediaDesc.getUnpackedValueOrDefault("InsertMode", 
false)),
         m_bIsAltChunk(rMediaDesc.getUnpackedValueOrDefault("AltChunkMode", 
false)),
         
m_bIsReadGlossaries(rMediaDesc.getUnpackedValueOrDefault("ReadGlossaries", 
false)),
@@ -680,7 +674,7 @@ void DomainMapper_Impl::RemoveDummyParaForTableInSection()
 void DomainMapper_Impl::AddDummyParaForTableInSection()
 {
     // Shapes and textboxes can't have sections.
-    if (IsInShape() || m_bIsInTextBox)
+    if (IsInShape() || m_StreamStateStack.top().bIsInTextBox)
         return;
 
     if (!m_aTextAppendStack.empty())
@@ -1403,7 +1397,7 @@ OUString DomainMapper_Impl::GetCurrentParaStyleName()
     // tdf#134784 except in the case of first paragraph of shapes to avoid bad 
fallback.
     // TODO fix this "highly inaccurate" m_sCurrentParaStyleName
     if ( !IsInShape() )
-        sName = m_sCurrentParaStyleName;
+        sName = m_StreamStateStack.top().sCurrentParaStyleName;
 
     PropertyMapPtr pParaContext = GetTopContextOfType(CONTEXT_PARAGRAPH);
     if ( pParaContext && pParaContext->isSet(PROP_PARA_STYLE_NAME) )
@@ -1642,22 +1636,22 @@ void DomainMapper_Impl::clearDeferredBreaks()
 
 void DomainMapper_Impl::setSdtEndDeferred(bool bSdtEndDeferred)
 {
-    m_bSdtEndDeferred = bSdtEndDeferred;
+    m_StreamStateStack.top().bSdtEndDeferred = bSdtEndDeferred;
 }
 
 bool DomainMapper_Impl::isSdtEndDeferred() const
 {
-    return m_bSdtEndDeferred;
+    return m_StreamStateStack.top().bSdtEndDeferred;
 }
 
 void DomainMapper_Impl::setParaSdtEndDeferred(bool bParaSdtEndDeferred)
 {
-    m_bParaSdtEndDeferred = bParaSdtEndDeferred;
+    m_StreamStateStack.top().bParaSdtEndDeferred = bParaSdtEndDeferred;
 }
 
 bool DomainMapper_Impl::isParaSdtEndDeferred() const
 {
-    return m_bParaSdtEndDeferred;
+    return m_StreamStateStack.top().bParaSdtEndDeferred;
 }
 
 static void lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& 
rFrameProperties,
@@ -3057,7 +3051,8 @@ void DomainMapper_Impl::applyToggleAttributes(const 
PropertyMapPtr& pPropertyMap
             nCharStyleRelief != css::awt::FontRelief::NONE || 
bCharStyleContoured || bCharStyleShadowed ||
             nCharStyleStrikeThrough == awt::FontStrikeout::SINGLE || 
bCharStyleHidden)
         {
-            uno::Reference<beans::XPropertySet> xParaStylePropertySet = 
GetParagraphStyles()->getByName(m_sCurrentParaStyleName).get<uno::Reference<beans::XPropertySet>>();
+            uno::Reference<beans::XPropertySet> const xParaStylePropertySet =
+                
GetParagraphStyles()->getByName(m_StreamStateStack.top().sCurrentParaStyleName).get<uno::Reference<beans::XPropertySet>>();
             float fParaStyleBold = css::awt::FontWeight::NORMAL;
             float fParaStyleBoldComplex = css::awt::FontWeight::NORMAL;
             css::awt::FontSlant eParaStylePosture = css::awt::FontSlant_NONE;
@@ -4200,15 +4195,15 @@ void DomainMapper_Impl::StartCustomFootnote(const 
PropertyMapPtr pContext)
         return;
 
     assert(pContext->GetFootnote().is());
-    m_bHasFootnoteStyle = true;
-    m_bCheckFootnoteStyle = !pContext->GetFootnoteStyle().isEmpty();
+    m_StreamStateStack.top().bHasFootnoteStyle = true;
+    m_StreamStateStack.top().bCheckFootnoteStyle = 
!pContext->GetFootnoteStyle().isEmpty();
     m_pFootnoteContext = pContext;
 }
 
 void DomainMapper_Impl::EndCustomFootnote()
 {
-    m_bHasFootnoteStyle = false;
-    m_bCheckFootnoteStyle = false;
+    m_StreamStateStack.top().bHasFootnoteStyle = false;
+    m_StreamStateStack.top().bCheckFootnoteStyle = false;
 }
 
 void DomainMapper_Impl::PushAnnotation()
@@ -4668,14 +4663,14 @@ void DomainMapper_Impl::PushShapeContext( const 
uno::Reference< drawing::XShape
             m_aAnchoredStack.push(AnchoredContext(xTextContent));
             uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, 
uno::UNO_QUERY);
 
-            
m_xEmbedded.set(m_xTextFactory->createInstance("com.sun.star.text.TextEmbeddedObject"),
 uno::UNO_QUERY_THROW);
-            uno::Reference<beans::XPropertySet> 
xEmbeddedProperties(m_xEmbedded, uno::UNO_QUERY_THROW);
+            
m_StreamStateStack.top().xEmbedded.set(m_xTextFactory->createInstance("com.sun.star.text.TextEmbeddedObject"),
 uno::UNO_QUERY_THROW);
+            uno::Reference<beans::XPropertySet> 
xEmbeddedProperties(m_StreamStateStack.top().xEmbedded, uno::UNO_QUERY_THROW);
             
xEmbeddedProperties->setPropertyValue(getPropertyName(PROP_EMBEDDED_OBJECT), 
xShapePropertySet->getPropertyValue(getPropertyName(PROP_EMBEDDED_OBJECT)));
             
xEmbeddedProperties->setPropertyValue(getPropertyName(PROP_ANCHOR_TYPE), 
uno::Any(text::TextContentAnchorType_AS_CHARACTER));
             // So that the original bitmap-only shape will be replaced by the 
embedded object.
             m_aAnchoredStack.top().bToRemove = true;
             m_aTextAppendStack.pop();
-            appendTextContent(m_xEmbedded, 
uno::Sequence<beans::PropertyValue>());
+            appendTextContent(m_StreamStateStack.top().xEmbedded, 
uno::Sequence<beans::PropertyValue>());
         }
         else
         {
@@ -4816,7 +4811,7 @@ void DomainMapper_Impl::UpdateEmbeddedShapeProps(const 
uno::Reference< drawing::
     if (!xShape.is())
         return;
 
-    uno::Reference<beans::XPropertySet> xEmbeddedProperties(m_xEmbedded, 
uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> const 
xEmbeddedProperties(m_StreamStateStack.top().xEmbedded, uno::UNO_QUERY_THROW);
     awt::Size aSize = xShape->getSize( );
     xEmbeddedProperties->setPropertyValue(getPropertyName(PROP_WIDTH), 
uno::Any(sal_Int32(aSize.Width)));
     xEmbeddedProperties->setPropertyValue(getPropertyName(PROP_HEIGHT), 
uno::Any(sal_Int32(aSize.Height)));
@@ -4826,7 +4821,7 @@ void DomainMapper_Impl::UpdateEmbeddedShapeProps(const 
uno::Reference< drawing::
         xShapeProps->getPropertyValue(getPropertyName(PROP_DESCRIPTION)));
     xEmbeddedProperties->setPropertyValue(getPropertyName(PROP_TITLE),
         xShapeProps->getPropertyValue(getPropertyName(PROP_TITLE)));
-    uno::Reference<container::XNamed> const xEmbedName(m_xEmbedded, 
uno::UNO_QUERY);
+    uno::Reference<container::XNamed> const 
xEmbedName(m_StreamStateStack.top().xEmbedded, uno::UNO_QUERY);
     uno::Reference<container::XNamed> const xShapeName(xShape, uno::UNO_QUERY);
     OUString const name(xShapeName->getName());
     if (!name.isEmpty()) // setting empty name will throw
@@ -5082,22 +5077,22 @@ void DomainMapper_Impl::HandleLineBreakClear(sal_Int32 
nClear)
     {
         case NS_ooxml::LN_Value_ST_BrClear_left:
             // SwLineBreakClear::LEFT
-            m_oLineBreakClear = 1;
+            m_StreamStateStack.top().oLineBreakClear = 1;
             break;
         case NS_ooxml::LN_Value_ST_BrClear_right:
             // SwLineBreakClear::RIGHT
-            m_oLineBreakClear = 2;
+            m_StreamStateStack.top().oLineBreakClear = 2;
             break;
         case NS_ooxml::LN_Value_ST_BrClear_all:
             // SwLineBreakClear::ALL
-            m_oLineBreakClear = 3;
+            m_StreamStateStack.top().oLineBreakClear = 3;
             break;
     }
 }
 
 void DomainMapper_Impl::HandleLineBreak(const PropertyMapPtr& pPropertyMap)
 {
-    if (!m_oLineBreakClear.has_value())
+    if (!m_StreamStateStack.top().oLineBreakClear.has_value())
     {
         appendTextPortion("
", pPropertyMap);
         return;
@@ -5108,10 +5103,10 @@ void DomainMapper_Impl::HandleLineBreak(const 
PropertyMapPtr& pPropertyMap)
         uno::Reference<text::XTextContent> xLineBreak(
             GetTextFactory()->createInstance("com.sun.star.text.LineBreak"), 
uno::UNO_QUERY);
         uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, 
uno::UNO_QUERY);
-        xLineBreakProps->setPropertyValue("Clear", 
uno::Any(*m_oLineBreakClear));
+        xLineBreakProps->setPropertyValue("Clear", 
uno::Any(*m_StreamStateStack.top().oLineBreakClear));
         appendTextContent(xLineBreak, pPropertyMap->GetPropertyValues());
     }
-    m_oLineBreakClear.reset();
+    m_StreamStateStack.top().oLineBreakClear.reset();
 }
 
 static sal_Int16 lcl_ParseNumberingType( std::u16string_view rCommand )
@@ -5710,7 +5705,7 @@ void DomainMapper_Impl::ChainTextFrames()
 
 void DomainMapper_Impl::PushTextBoxContent()
 {
-    if (m_bIsInTextBox)
+    if (m_StreamStateStack.top().bIsInTextBox)
         return;
 
     try
@@ -5725,7 +5720,7 @@ void DomainMapper_Impl::PushTextBoxContent()
         m_xPendingTextBoxFrames.push(xTBoxFrame);
 
         
m_aTextAppendStack.push(TextAppendContext(uno::Reference<text::XTextAppend>(xTBoxFrame,
 uno::UNO_QUERY_THROW), {}));
-        m_bIsInTextBox = true;
+        m_StreamStateStack.top().bIsInTextBox = true;
 
         appendTableManager();
         appendTableHandler();
@@ -5739,7 +5734,7 @@ void DomainMapper_Impl::PushTextBoxContent()
 
 void DomainMapper_Impl::PopTextBoxContent()
 {
-    if (!m_bIsInTextBox || m_xPendingTextBoxFrames.empty())
+    if (!m_StreamStateStack.top().bIsInTextBox || 
m_xPendingTextBoxFrames.empty())
         return;
 
     if (uno::Reference<text::XTextFrame>(m_aTextAppendStack.top().xTextAppend, 
uno::UNO_QUERY).is())
@@ -5752,7 +5747,7 @@ void DomainMapper_Impl::PopTextBoxContent()
         RemoveLastParagraph();
 
         m_aTextAppendStack.pop();
-        m_bIsInTextBox = false;
+        m_StreamStateStack.top().bIsInTextBox = false;
     }
 }
 
@@ -9163,7 +9158,8 @@ void  DomainMapper_Impl::ImportGraphic(const 
writerfilter::Reference<Properties>
 
 
     // Update the shape properties if it is embedded object.
-    if(m_xEmbedded.is()){
+    if (m_StreamStateStack.top().xEmbedded.is())
+    {
         if (m_pGraphicImport->GetXShapeObject())
                 m_pGraphicImport->GetXShapeObject()->setPosition(
                     m_pGraphicImport->GetGraphicObjectPosition());
@@ -9172,7 +9168,7 @@ void  DomainMapper_Impl::ImportGraphic(const 
writerfilter::Reference<Properties>
         UpdateEmbeddedShapeProps(xShape);
         if (m_eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
         {
-            uno::Reference<beans::XPropertySet> xEmbeddedProps(m_xEmbedded, 
uno::UNO_QUERY);
+            uno::Reference<beans::XPropertySet> const 
xEmbeddedProps(m_StreamStateStack.top().xEmbedded, uno::UNO_QUERY);
             xEmbeddedProps->setPropertyValue("AnchorType", 
uno::Any(text::TextContentAnchorType_AT_CHARACTER));
             xEmbeddedProps->setPropertyValue("IsFollowingTextFlow", 
uno::Any(m_pGraphicImport->GetLayoutInCell()));
             uno::Reference<beans::XPropertySet> xShapeProps(xShape, 
uno::UNO_QUERY);
@@ -9258,7 +9254,7 @@ void  DomainMapper_Impl::ImportGraphic(const 
writerfilter::Reference<Properties>
     // Clear the reference, so in case the embedded object is inside a
     // TextFrame, we won't try to resize it (to match the size of the
     // TextFrame) here.
-    m_xEmbedded.clear();
+    m_StreamStateStack.top().xEmbedded.clear();
     m_pGraphicImport.clear();
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index bd1d55253298..e87ac5bf9df9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -163,6 +163,24 @@ enum StoredRedlines
     NONE
 };
 
+struct RubyInfo
+{
+    OUString    sRubyText;
+    OUString    sRubyStyle;
+    sal_uInt32  nSprmId;
+    sal_uInt32  nRubyAlign;
+    sal_uInt32  nHps;
+    sal_uInt32  nHpsBaseText;
+
+    RubyInfo():
+        nSprmId(0),
+        nRubyAlign(0),
+        nHps(0),
+        nHpsBaseText(0)
+    {
+    }
+};
+
 enum class SubstreamType
 {
     Body,
@@ -224,6 +242,18 @@ struct SubstreamContext
     sal_Int32 nTableCellDepth = 0;
     /// If the next tab should be ignored, used for footnotes.
     bool bCheckFirstFootnoteTab = false;
+    std::optional<sal_Int16> oLineBreakClear;
+    bool bIsInTextBox = false;
+    css::uno::Reference<css::text::XTextContent> xEmbedded;
+    /// If we want to set "sdt end" on the next character context.
+    bool bSdtEndDeferred = false;
+    /// If we want to set "paragraph sdt end" on the next paragraph context.
+    bool bParaSdtEndDeferred = false;
+    OUString sCurrentParaStyleName; ///< highly inaccurate. Overwritten by 
"overlapping" paragraphs like flys.
+    bool bHasFootnoteStyle = false;
+    bool bCheckFootnoteStyle = false;
+    bool bIsInFootnoteProperties = false;
+    RubyInfo aRubyInfo;
 };
 
 /// Information about a paragraph to be finished after a field end.
@@ -416,24 +446,6 @@ struct AnnotationPosition
     css::uno::Reference<css::text::XTextRange> m_xEnd;
 };
 
-struct RubyInfo
-{
-    OUString    sRubyText;
-    OUString    sRubyStyle;
-    sal_uInt32  nSprmId;
-    sal_uInt32  nRubyAlign;
-    sal_uInt32  nHps;
-    sal_uInt32  nHpsBaseText;
-
-    RubyInfo():
-        nSprmId(0),
-        nRubyAlign(0),
-        nHps(0),
-        nHpsBaseText(0)
-    {
-    }
-};
-
 struct LineNumberSettings
 {
     sal_Int32   nDistance;
@@ -518,7 +530,6 @@ private:
     // cache next available number, expensive to repeatedly compute
     std::optional<int> m_xNextUnusedCharacterStyleNo;
     css::uno::Reference<css::text::XText> m_xBodyText;
-    css::uno::Reference<css::text::XTextContent> m_xEmbedded;
 
     std::stack<TextAppendContext>                                              
     m_aTextAppendStack;
     std::stack<AnchoredContext>                                                
     m_aAnchoredStack;
@@ -535,10 +546,6 @@ private:
     bool                                                                       
     m_bSetCitation;
     bool                                                                       
     m_bSetDateValue;
     bool                                                                       
     m_bIsFirstSection;
-    /// If we want to set "sdt end" on the next character context.
-    bool                                                                       
     m_bSdtEndDeferred;
-    /// If we want to set "paragraph sdt end" on the next paragraph context.
-    bool                                                                       
     m_bParaSdtEndDeferred;
     bool                                                                       
     m_bStartTOC;
     bool                                                                       
     m_bStartTOCHeaderFooter;
     /// If we got any text that is the pre-rendered result of the TOC field.
@@ -592,7 +599,6 @@ private:
     PropertyMapPtr           m_pLastCharacterContext;
 
     ::std::vector<DeletableTabStop> m_aCurrentTabStops;
-    OUString                        m_sCurrentParaStyleName; //highly 
inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
     OUString                        m_sDefaultParaStyleName; //caches the 
ConvertedStyleName of the default paragraph style
     bool                            m_bInDocDefaultsImport;
     bool                            m_bInStyleSheetImport; //in import of 
fonts, styles, lists or lfos
@@ -600,8 +606,6 @@ private:
     bool                            m_bInAnyTableImport; //in import of fonts, 
styles, lists or lfos
     bool                            m_bDiscardHeaderFooter;
     PropertyMapPtr m_pFootnoteContext;
-    bool m_bHasFootnoteStyle;
-    bool m_bCheckFootnoteStyle;
     /// Skip paragraphs from the <w:separator/> footnote
     SkipFootnoteSeparator           m_eSkipFootnoteState;
     /// preload footnotes and endnotes
@@ -612,9 +616,7 @@ private:
     sal_Int32                       m_nFirstEndnoteIndex;
 
     bool                            m_bLineNumberingSet;
-    bool                            m_bIsInFootnoteProperties;
 
-    RubyInfo                        m_aRubyInfo;
     //registered frame properties
     std::vector<css::beans::PropertyValue> m_aFrameProperties;
     css::uno::Reference<css::text::XTextRange> m_xFrameStartRange;
@@ -675,12 +677,10 @@ public:
     std::deque<sal_Int32> m_aFootnoteIds;
     std::deque<sal_Int32> m_aEndnoteIds;
 
-    bool m_bIsInTextBox;
 private:
     bool m_bIsNewDoc;
     bool m_bIsAltChunk = false;
     bool m_bIsReadGlossaries;
-    std::optional<sal_Int16> m_oLineBreakClear;
 
 public:
     DomainMapper_Impl(
@@ -743,13 +743,13 @@ public:
     void SetIsDecimalComma() { m_bIsDecimalComma = true; };
     void SetIsLastParagraphInSection( bool bIsLast );
     bool GetIsLastParagraphInSection() const { return 
m_StreamStateStack.top().bIsLastParaInSection; }
-    void SetRubySprmId( sal_uInt32 nSprmId) { m_aRubyInfo.nSprmId = nSprmId ; }
+    void SetRubySprmId(sal_uInt32 const nSprmId) { 
m_StreamStateStack.top().aRubyInfo.nSprmId = nSprmId; }
     void SetRubyText( OUString const &sText, OUString const &sStyle) {
-        m_aRubyInfo.sRubyText = sText;
-        m_aRubyInfo.sRubyStyle = sStyle;
+        m_StreamStateStack.top().aRubyInfo.sRubyText = sText;
+        m_StreamStateStack.top().aRubyInfo.sRubyStyle = sStyle;
     }
-    const RubyInfo & GetRubyInfo() const { return m_aRubyInfo;}
-    void SetRubyInfo(const RubyInfo & rInfo) { m_aRubyInfo = rInfo;}
+    const RubyInfo & GetRubyInfo() const { return 
m_StreamStateStack.top().aRubyInfo; }
+    void SetRubyInfo(const RubyInfo & rInfo) { 
m_StreamStateStack.top().aRubyInfo = rInfo; }
 
     void SetIsLastSectionGroup( bool bIsLast );
     bool GetIsLastSectionGroup() const { return m_bIsLastSectionGroup;}
@@ -875,7 +875,7 @@ public:
     void    IncorporateTabStop( const DeletableTabStop &aTabStop );
     css::uno::Sequence<css::style::TabStop> GetCurrentTabStopAndClear();
 
-    void            SetCurrentParaStyleName(const OUString& sStringValue) 
{m_sCurrentParaStyleName = sStringValue;}
+    void SetCurrentParaStyleName(const OUString& rString) { 
m_StreamStateStack.top().sCurrentParaStyleName = rString; }
     OUString  GetCurrentParaStyleName();
     OUString  GetDefaultParaStyleName();
 
@@ -919,10 +919,10 @@ public:
 
     void StartCustomFootnote(const PropertyMapPtr pContext);
     void EndCustomFootnote();
-    bool IsInCustomFootnote() const { return m_bHasFootnoteStyle; }
-    bool CheckFootnoteStyle() const { return m_bCheckFootnoteStyle; }
-    void SetHasFootnoteStyle(bool bVal) { m_bHasFootnoteStyle = bVal; }
-    void SetCheckFootnoteStyle(bool bVal) { m_bCheckFootnoteStyle = bVal; }
+    bool IsInCustomFootnote() const { return 
m_StreamStateStack.top().bHasFootnoteStyle; }
+    bool CheckFootnoteStyle() const { return 
m_StreamStateStack.top().bCheckFootnoteStyle; }
+    void SetHasFootnoteStyle(bool const bVal) { 
m_StreamStateStack.top().bHasFootnoteStyle = bVal; }
+    void SetCheckFootnoteStyle(bool const bVal) { 
m_StreamStateStack.top().bCheckFootnoteStyle = bVal; }
 
     const PropertyMapPtr& GetFootnoteContext() const { return 
m_pFootnoteContext; }
 
@@ -1062,8 +1062,8 @@ public:
     const LineNumberSettings& GetLineNumberSettings() const { return 
m_aLineNumberSettings;}
     void SetLineNumberSettings(const LineNumberSettings& rSet) { 
m_aLineNumberSettings = rSet;}
 
-    void SetInFootnoteProperties(bool bSet) { m_bIsInFootnoteProperties = 
bSet;}
-    bool IsInFootnoteProperties() const { return m_bIsInFootnoteProperties;}
+    void SetInFootnoteProperties(bool const bSet) { 
m_StreamStateStack.top().bIsInFootnoteProperties = bSet; }
+    bool IsInFootnoteProperties() const { return 
m_StreamStateStack.top().bIsInFootnoteProperties; }
 
     bool IsInComments() const { return m_StreamStateStack.top().eSubstreamType 
== SubstreamType::Annotation; };
 

Reply via email to