[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa writerfilter/source
Attila Szűcs (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 29 12:08:38 UTC 2021
sw/qa/extras/ooxmlexport/data/tdf140182_extraPagebreak.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 +++++++++++
writerfilter/source/dmapper/DomainMapper.cxx | 5 +++--
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 +++
5 files changed, 24 insertions(+), 2 deletions(-)
New commits:
commit b83fc213bc90d00ca7304e7de964b4437fce5867
Author: Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Fri Feb 26 11:19:01 2021 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Apr 29 14:08:02 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 <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 9dfaf0fa1977f70341e4b9add2ecd2afb35bf1f2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114859
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
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 cbdc5e2df8d8..3d0c044d2a2c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -90,6 +90,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 1bada3877e29..e31c9e7d9246 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3197,7 +3197,8 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
m_pImpl->SetFieldLocked();
return;
case 0x0c: //page break
- m_pImpl->deferBreak(PAGE_BREAK);
+ m_pImpl->deferBreak(PAGE_BREAK);
+ m_pImpl->SetIsDummyParaAddedForTableInSectionPage(false);
return;
case 0x0e: //column break
m_pImpl->deferBreak(COLUMN_BREAK);
@@ -3509,7 +3510,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
bool bRemove = (!m_pImpl->GetParaChanged() && m_pImpl->GetRemoveThisPara()) ||
(!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr()
&& !bSingleParagraphAfterRedline
- && !m_pImpl->GetIsDummyParaAddedForTableInSection()
+ && (!m_pImpl->GetIsDummyParaAddedForTableInSectionPage())
&& !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) )
&& !m_pImpl->GetIsPreviousParagraphFramed()
&& !m_pImpl->IsParaWithInlineObject());
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 16b3743ee2fc..7ed43f9a062f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -284,6 +284,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 ),
@@ -586,6 +587,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 d4a78a2b0237..40a5c5fceb06 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -548,6 +548,7 @@ private:
bool m_bIsFirstParaInSectionAfterRedline;
bool m_bIsFirstParaInShape = false;
bool m_bDummyParaAddedForTableInSection;
+ bool m_bDummyParaAddedForTableInSectionPage;
bool m_bTextFrameInserted;
bool m_bIsPreviousParagraphFramed;
bool m_bIsLastParaInSection;
@@ -646,6 +647,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 );
More information about the Libreoffice-commits
mailing list