sw/qa/extras/ooxmlexport/data/tdf140182_extraPagebreak.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 +++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 3 ++- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++++++ writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 +++ 5 files changed, 23 insertions(+), 1 deletion(-)
New commits: commit 25a6133bfc8778cde6d93510b45d6c5ed8358448 Author: Attila Szűcs <[email protected]> AuthorDate: Fri Feb 26 11:19:01 2021 +0100 Commit: Gabor Kelemen <[email protected]> CommitDate: Tue Jun 29 10:15:07 2021 +0200 tdf#140182 DOCX table import: fix extra page break Hack with m_bDummyParaAddedForTableInSection didn't handle the case, when a page break (empty w:p with a w:br) after the table followed by a paragraph with a section break, resulting 2 page breaks after the table instead of a single one. Co-authored-by: Tibor Nagy (NISZ) Change-Id: Ibd8ab5444becdfd09d0d05eb246e6853914e1f05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111600 Tested-by: László Németh <[email protected]> Reviewed-by: László Németh <[email protected]> (cherry picked from commit 9dfaf0fa1977f70341e4b9add2ecd2afb35bf1f2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118064 Tested-by: Gabor Kelemen <[email protected]> Reviewed-by: Gabor Kelemen <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf140182_extraPagebreak.docx b/sw/qa/extras/ooxmlexport/data/tdf140182_extraPagebreak.docx new file mode 100644 index 000000000000..be47d79c5b0a Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf140182_extraPagebreak.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 89ec02bbafed..daf6e5d4bd4e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -96,6 +96,17 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121666_lostPage, "tdf121666_lostPage. assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:sectPr/w:type", "val", "nextPage"); } +DECLARE_OOXMLEXPORT_TEST(testTdf140182_extraPagebreak, "tdf140182_extraPagebreak.docx") +{ + // Table, page break, section break should be only 2 pages + // 2 breaks would normally results in 3 pages, but page break + section break is a special case + // that is handled so to break only 1 page that result only 2 pages. + // Because of the table, a hack (m_bDummyParaAddedForTableInSection) is set for the entire section, + // that canceled the page break + section break special case handling, resulting 3 pages. + // The accompanying fix eliminates this cancelation. + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf95848, "tdf95848.docx") { OUString listId; diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index b2765a8c572c..fefdbac10477 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3249,6 +3249,7 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len) return; case 0x0c: //page break m_pImpl->deferBreak(PAGE_BREAK); + m_pImpl->SetIsDummyParaAddedForTableInSectionPage(false); return; case 0x0e: //column break m_pImpl->deferBreak(COLUMN_BREAK); @@ -3561,7 +3562,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && !bSingleParagraphAfterRedline && !m_pImpl->GetParaHadField() - && !m_pImpl->GetIsDummyParaAddedForTableInSection() + && (!m_pImpl->GetIsDummyParaAddedForTableInSectionPage()) && !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) ) && !m_pImpl->GetIsPreviousParagraphFramed() && !m_pImpl->HasTopAnchoredObjects() diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 291924abce81..3ae632e3f1a2 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -314,6 +314,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bIsFirstParaInSection( true ), m_bIsFirstParaInSectionAfterRedline( true ), m_bDummyParaAddedForTableInSection( false ), + m_bDummyParaAddedForTableInSectionPage( false ), m_bTextFrameInserted(false), m_bIsPreviousParagraphFramed( false ), m_bIsLastParaInSection( false ), @@ -624,6 +625,12 @@ void DomainMapper_Impl::SetIsFirstParagraphInShape(bool bIsFirst) void DomainMapper_Impl::SetIsDummyParaAddedForTableInSection( bool bIsAdded ) { m_bDummyParaAddedForTableInSection = bIsAdded; + m_bDummyParaAddedForTableInSectionPage = bIsAdded; +} + +void DomainMapper_Impl::SetIsDummyParaAddedForTableInSectionPage( bool bIsAdded ) +{ + m_bDummyParaAddedForTableInSectionPage = bIsAdded; } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 6dbf46952d6a..70048e22c540 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -551,6 +551,7 @@ private: bool m_bIsFirstParaInSectionAfterRedline; bool m_bIsFirstParaInShape = false; bool m_bDummyParaAddedForTableInSection; + bool m_bDummyParaAddedForTableInSectionPage; bool m_bTextFrameInserted; bool m_bIsPreviousParagraphFramed; bool m_bIsLastParaInSection; @@ -651,6 +652,8 @@ public: bool GetIsFirstParagraphInShape() const { return m_bIsFirstParaInShape; } void SetIsDummyParaAddedForTableInSection( bool bIsAdded ); bool GetIsDummyParaAddedForTableInSection() const { return m_bDummyParaAddedForTableInSection;} + void SetIsDummyParaAddedForTableInSectionPage(bool bIsAdded); + bool GetIsDummyParaAddedForTableInSectionPage() const { return m_bDummyParaAddedForTableInSectionPage; } /// Track if a textframe has been inserted into this section void SetIsTextFrameInserted( bool bIsInserted ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
