sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 28 ++++++++++++++----- sw/source/writerfilter/dmapper/DomainMapper.cxx | 2 - sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 4 +- 3 files changed, 24 insertions(+), 10 deletions(-)
New commits: commit 9551a53e8d3cfe701862bb95fbfae3498611eef9 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Feb 8 20:00:38 2025 -0500 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Feb 12 17:09:42 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> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 207568ee8b76..5ba9a7f02ff2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -40,15 +40,29 @@ public: } }; -DECLARE_OOXMLEXPORT_TEST(testTdf161631, "tdf161631.docx") +CPPUNIT_TEST_FIXTURE(Test, testTdf161631) { - CPPUNIT_ASSERT_EQUAL(1, getPages()); - CPPUNIT_ASSERT_EQUAL(1, getParagraphs()); + 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); + } + }; - // 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()); + 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 c5fde2a1ab4e..c743f19aa542 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -1501,7 +1501,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 24712f454782..1e5b365e975f 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -689,8 +689,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())