sw/qa/extras/ooxmlexport/data/tdf136589_paraHadField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx                |    6 ++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx         |    4 ++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx         |    1 +
 4 files changed, 11 insertions(+)

New commits:
commit a0d2e45f2efbe4e82b78c777d21b5eabec3a0924
Author:     Justin Luth <[email protected]>
AuthorDate: Wed Sep 9 11:08:32 2020 +0300
Commit:     Justin Luth <[email protected]>
CommitDate: Wed Sep 9 15:56:08 2020 +0200

    tdf#136589 writerfilter: reset ParaHadField
    
    ::finishParagraph normally resets this, but it exited
    early because of m_bDiscardHeaderFooter, so the setting
    spilled over into the following paragraph.
    
    This is a bit of a bandaid - likely stacks of paragraphs
    and sections need to be used so each can hold its
    own settings and not worry about them being clobbered.
    But this particular case seems to a single level problem,
    isolated to headers/footers, so the change should
    both be enough and regression-safe.
    
    Change-Id: I84c9a5d6bf95c35c4996a9b31e53f18c05ade727
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102314
    Tested-by: Justin Luth <[email protected]>
    Reviewed-by: Justin Luth <[email protected]>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf136589_paraHadField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf136589_paraHadField.docx
new file mode 100644
index 000000000000..c4cf7a139a03
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf136589_paraHadField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 999ef57a38af..b3c3d79962a0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -299,6 +299,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135216_evenOddFooter, 
"tdf135216_evenOddFooter.o
     getParagraph(2, "2");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf136589_paraHadField, 
"tdf136589_paraHadField.docx")
+{
+    // The section break should not add an additional CR - which equals an 
empty page two.
+    CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf133370_columnBreak, 
"tdf133370_columnBreak.odt")
 {
     // Since non-DOCX formats ignores column breaks in non-column situations, 
don't export to docx.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index e7b571de687b..e7ecfffd4338 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -313,6 +313,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bIsActualParagraphFramed( false ),
         m_vTextFramesForChaining(),
         m_bParaHadField(false),
+        m_bSaveParaHadField(false),
         m_bParaAutoBefore(false),
         m_bFirstParagraphInCell(true),
         m_bSaveFirstParagraphInCell(false),
@@ -2438,6 +2439,7 @@ void DomainMapper_Impl::appendGlossaryEntry()
 
 void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, 
SectionPropertyMap::PageType eType)
 {
+    m_bSaveParaHadField = m_bParaHadField;
     m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted, 
m_nTableDepth));
     m_bTextInserted = false;
     m_nTableDepth = 0;
@@ -2538,6 +2540,8 @@ void DomainMapper_Impl::PopPageHeaderFooter()
         m_nTableDepth = m_aHeaderFooterStack.top().getTableDepth();
         m_aHeaderFooterStack.pop();
     }
+
+    m_bParaHadField = m_bSaveParaHadField;
 }
 
 void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 33ec662c5feb..1a9f9340bac6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -1074,6 +1074,7 @@ private:
     std::vector<css::uno::Reference< css::drawing::XShape > > 
m_vTextFramesForChaining ;
     /// Current paragraph had at least one field in it.
     bool m_bParaHadField;
+    bool m_bSaveParaHadField;
     css::uno::Reference<css::beans::XPropertySet> m_xPreviousParagraph;
     /// Current paragraph has automatic before spacing.
     bool m_bParaAutoBefore;
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to