sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 3 +++ writerfilter/source/dmapper/DomainMapper.cxx | 10 ++++++++++ 2 files changed, 13 insertions(+)
New commits: commit ce0b9f3eb3f57f57a2315e099a0093c33987e6ca Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Mon Feb 13 17:47:36 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Tue Feb 14 14:21:42 2023 +0000 tdf#153602 writerfilter: clear isDummyPara after processing table. Once the table is processed, the fact that we had a dummy paragraph is no longer relevant to the section. So, after carefully figuring out that we have had some other paragraph in the main text body, clear the dummy status used to control bRemove. This fixes the problem of adding an empty paragraph each round-trip. Unfortunately, this would still fail if for example there was only another table following the first one. Well, it wouldn't fail that badly because the first save would add an empty paragraph, and then following saves would use that single empty paragraph as the one that resets things. So we always have at least one CR following a table, but at least they aren't multiplying. Unfortunately this isn't at all clean, because as soon as the table starts, we no longer know that it is the first paragraph in the section. (The other table paragraphs and potentially header, comment, footnote, shape etc can all set IsFirstParagraphInSection to off. Basically, most flags are completely useless since they are not stacked in any way. So we are left with a multitude of conditions to check for everything. Change-Id: Ic6a9795a6c529f8b5dd4f5d1cccc89db01b03d28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146955 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index bccfbddb7eb0..5bd2c3164fc8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -789,6 +789,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo53985, "fdo53985.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("TextSection is protected", true, getProperty<bool>(xSect, "IsProtected")); xSect.set(xSections->getByIndex(3), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL_MESSAGE("Section3 is protected", false, getProperty<bool>(xSect, "IsProtected")); + + // This was increasing by 3 every round-trip - an extra paragraph after each table in sections + CPPUNIT_ASSERT_EQUAL(9, getParagraphs()); } DECLARE_OOXMLEXPORT_TEST(testFdo59638, "fdo59638.docx") diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c6fd96eb7407..62f2ad548e64 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -4131,6 +4131,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) finishParagraph(bRemove, bNoNumbering); if (bRemove) m_pImpl->RemoveLastParagraph(); + + // When the table is closed and the section's initial dummy paragraph has been processed + // then any following sectPr paragraph in the section must be eligible for removal. + if (!bRemove && m_pImpl->GetIsDummyParaAddedForTableInSectionPage() && !IsInTable() + && !m_pImpl->GetFootnoteContext() && !m_pImpl->IsInComments() && !IsInHeaderFooter() + && !IsInShape()) + { + m_pImpl->SetIsDummyParaAddedForTableInSectionPage(false); + } + m_pImpl->SetParaSectpr(false); } else