sw/qa/extras/ooxmlexport/data/tdf161631.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 25 +++++++++++++++++++ sw/source/writerfilter/dmapper/DomainMapper.cxx | 2 - sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 4 +-- 4 files changed, 28 insertions(+), 3 deletions(-)
New commits: commit 663e8084233590da7eeeeffd5edce6a797eb05af Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Feb 8 20:00:38 2025 -0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 10 20:55:44 2025 +0100 tdf#164876 tdf#165117 writerfilter: no dummy paragraphs in header The problem was that an extra CR was being added (often every round-trip) to headers that started with a table. This is a long-standing bug (see moz1211781-1.docx) that got more exposure recently from changes to 7.6.6 (via 86ad08f9d25110e91e92a0badf6de75e785b3644) and 24.8.0 (via ef77086255821d61838a7e26fee9baadaca0b9e0) make CppunitTest_sw_ooxmlexport21 CPPUNIT_TEST_NAME=testTdf161631 Change-Id: Idb6a0efda246fa064822f01a9ce097f686810b5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181307 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> (cherry picked from commit 44eda1f72b4d67b9627155741067d3e57a1f9747) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181354 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181368 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 445c7c5c368c..42c856f15f1f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -38,15 +38,29 @@ public: } }; -DECLARE_OOXMLEXPORT_TEST(testTdf161631, "tdf161631.docx") +CPPUNIT_TEST_FIXTURE(Test, testTdf161631) { - CPPUNIT_ASSERT_EQUAL(1, getPages()); - CPPUNIT_ASSERT_EQUAL(1, getParagraphs()); - - // Without the fix in place, this test would have failed with - // - Expected: Some text - // - Actual : - CPPUNIT_ASSERT_EQUAL(u"Some text"_ustr, getParagraph(1)->getString()); + auto verify = [this](bool bIsExport = false) { + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(1, getParagraphs()); + + // Without the fix in place, this test would have failed with + // - Expected : Some text + // - Actual: + CPPUNIT_ASSERT_EQUAL(u"Some text"_ustr, getParagraph(1)->getString()); + + if (bIsExport) + { + // tdf#164876 tdf#165117: don't add an empty paragraph every round-trip + xmlDocUniquePtr pXmlDoc1 = parseExport(u"word/footer2.xml"_ustr); + assertXPath(pXmlDoc1, "/w:ftr/w:p", 1); + } + }; + + createSwDoc("tdf161631.docx"); + verify(); + saveAndReload(mpFilter); + verify(/*bIsExport*/ true); } DECLARE_OOXMLEXPORT_TEST(testTdf158597, "tdf158597.docx") diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 29b67f0798ce..1a0ea66e58dd 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -3408,7 +3408,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) if (m_pImpl->m_StreamStateStack.top().nTableDepth == 0 && m_pImpl->GetIsFirstParagraphInSection() && !m_pImpl->GetIsDummyParaAddedForTableInSection() && !m_pImpl->GetIsTextFrameInserted() - && !m_pImpl->GetIsPreviousParagraphFramed() && !IsInHeaderFooter()) + && !m_pImpl->GetIsPreviousParagraphFramed()) { m_pImpl->AddDummyParaForTableInSection(); } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 988ee222370c..411213cd9f96 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -670,8 +670,8 @@ void DomainMapper_Impl::RemoveDummyParaForTableInSection() } void DomainMapper_Impl::AddDummyParaForTableInSection() { - // Shapes and textboxes can't have sections. - if (IsInShape() || m_StreamStateStack.top().bIsInTextBox) + // Shapes, headers, and textboxes can't have sections. + if (IsInShape() || IsInHeaderFooter() || m_StreamStateStack.top().bIsInTextBox) return; if (!m_aTextAppendStack.empty()) commit 8dbe6383d9c4691ee29ba8c6299e659a8c8c4348 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Jun 21 17:07:39 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 10 20:55:38 2025 +0100 tdf#161631: sw_ooxmlexport21: Add unittest Change-Id: I1496b82e67c5f408bd682b4998e3afaf74c37318 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169339 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181369 diff --git a/sw/qa/extras/ooxmlexport/data/tdf161631.docx b/sw/qa/extras/ooxmlexport/data/tdf161631.docx new file mode 100644 index 000000000000..a1e91c05633c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf161631.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 1cffe717bed1..445c7c5c368c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -38,6 +38,17 @@ public: } }; +DECLARE_OOXMLEXPORT_TEST(testTdf161631, "tdf161631.docx") +{ + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(1, getParagraphs()); + + // Without the fix in place, this test would have failed with + // - Expected: Some text + // - Actual : + CPPUNIT_ASSERT_EQUAL(u"Some text"_ustr, getParagraph(1)->getString()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf158597, "tdf158597.docx") { // test with 2 properties: font size, italic (toggle)