writerfilter/source/dmapper/DomainMapper_Impl.cxx |   16 +++++++++-------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit cf226535f9903a048b1c105b180ae3a50a776e68
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Tue Jan 14 16:46:58 2020 +0100
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Tue Jan 14 18:56:13 2020 +0100

    tdf#129805 writerfilter: fix import of nested generic field
    
    The problem was that the end of the outer nested generic field did not
    call PopFieldmark(), so the end of the field was at the end of the
    document.
    
    (regression from f610f9b611fe9f206b872ed06f7e859d688385fc)
    
    Change-Id: If5928b14dd35f7dd509370c2b8eef4c31bd149dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86785
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3bc15298442f..75b6133e312c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -261,7 +261,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bStartedTOC(false),
         m_bStartIndex(false),
         m_bStartBibliography(false),
-        m_bStartGenericField(false),
+        m_nStartGenericField(0),
         m_bTextInserted(false),
         m_sCurrentPermId(0),
         m_pLastSectionContext( ),
@@ -1878,7 +1878,7 @@ void DomainMapper_Impl::appendTextPortion( const 
OUString& rString, const Proper
             }
             else
             {
-                if (m_bStartTOC || m_bStartIndex || m_bStartBibliography || 
m_bStartGenericField)
+                if (m_bStartTOC || m_bStartIndex || m_bStartBibliography || 
m_nStartGenericField != 0)
                 {
                     if (IsInHeaderFooter() && !m_bStartTOCHeaderFooter)
                     {
@@ -1890,15 +1890,17 @@ void DomainMapper_Impl::appendTextPortion( const 
OUString& rString, const Proper
                         uno::Reference< text::XTextCursor > xTOCTextCursor = 
xTextAppend->getEnd()->getText( )->createTextCursor( );
                         assert(xTOCTextCursor.is());
                         xTOCTextCursor->gotoEnd(false);
-                        if (m_bStartGenericField)
+                        if (m_nStartGenericField != 0)
+                        {
                             xTOCTextCursor->goLeft(1, false);
+                        }
                         xTextRange = xTextAppend->insertTextPortion(rString, 
aValues, xTOCTextCursor);
                         SAL_WARN_IF(!xTextRange.is(), "writerfilter.dmapper", 
"insertTextPortion failed");
                         if (!xTextRange.is())
                             throw uno::Exception("insertTextPortion failed", 
nullptr);
                         m_bTextInserted = true;
                         xTOCTextCursor->gotoRange(xTextRange->getEnd(), true);
-                        if (!m_bStartGenericField)
+                        if (m_nStartGenericField == 0)
                         {
                             
m_aTextAppendStack.push(TextAppendContext(xTextAppend, xTOCTextCursor));
                         }
@@ -5390,7 +5392,7 @@ void DomainMapper_Impl::CloseFieldCommand()
                     InsertFieldmark(m_aTextAppendStack, xFormField, 
pContext->GetStartRange(),
                             pContext->GetFieldId());
                     xFormField->setFieldType(ODF_UNHANDLED);
-                    m_bStartGenericField = true;
+                    ++m_nStartGenericField;
                     pContext->SetFormField( xFormField );
                     uno::Reference<container::XNameContainer> const 
xNameCont(xFormField->getParameters());
                     // note: setting the code to empty string is *required* in
@@ -5806,9 +5808,9 @@ void DomainMapper_Impl::PopFieldContext()
                                 }
                             }
                         }
-                        else if(m_bStartGenericField)
+                        else if (m_nStartGenericField != 0)
                         {
-                            m_bStartGenericField = false;
+                            --m_nStartGenericField;
                             PopFieldmark(m_aTextAppendStack, xCrsr, 
pContext->GetFieldId());
                             if(m_bTextInserted)
                             {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 6340b2da34d0..2a512eb44f8e 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -472,7 +472,7 @@ private:
     bool                                                                       
     m_bStartedTOC;
     bool                                                                       
     m_bStartIndex;
     bool                                                                       
     m_bStartBibliography;
-    bool                                                                       
     m_bStartGenericField;
+    unsigned int                                                               
     m_nStartGenericField;
     bool                                                                       
     m_bTextInserted;
     LineNumberSettings                                                         
     m_aLineNumberSettings;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to