[Libreoffice-commits] core.git: sw/qa writerfilter/source
Attila Szűcs (via logerrit)
logerrit at kemper.freedesktop.org
Sat Mar 20 13:28:22 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, 25 insertions(+), 1 deletion(-)
New commits:
commit 9dfaf0fa1977f70341e4b9add2ecd2afb35bf1f2
Author: Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Fri Feb 26 11:19:01 2021 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Sat Mar 20 14:27:42 2021 +0100
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>
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 5ce06fdacb6c..c9049e893827 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 964abf0e58fd..b36ec059cfde 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3253,7 +3253,10 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
case 0x0c: //page break
// page breaks aren't supported in footnotes and endnotes
if (!m_pImpl->IsInFootOrEndnote())
+ {
m_pImpl->deferBreak(PAGE_BREAK);
+ m_pImpl->SetIsDummyParaAddedForTableInSectionPage(false);
+ }
return;
case 0x0e: //column break
m_pImpl->deferBreak(COLUMN_BREAK);
@@ -3589,7 +3592,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 c102d7bcc565..311515fbc9a1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -318,6 +318,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 ),
@@ -628,6 +629,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 4a654822fb90..0538b68e95a9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -565,6 +565,7 @@ private:
bool m_bIsFirstParaInSectionAfterRedline;
bool m_bIsFirstParaInShape = false;
bool m_bDummyParaAddedForTableInSection;
+ bool m_bDummyParaAddedForTableInSectionPage;
bool m_bTextFrameInserted;
bool m_bIsPreviousParagraphFramed;
bool m_bIsLastParaInSection;
@@ -665,6 +666,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