diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-01-08 15:40:32 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-04 11:55:36 +0200 |
commit | 072af1b01c783b4ee7c9005ac2c15355e8a2f74d (patch) | |
tree | fa659879140fb038d44d7538f5bc948ddab56543 /writerfilter/qa | |
parent | a30ce1e1e1bc3a46997e31b5fb105510bf558ce9 (diff) |
DOCX import: fix lost page break when footer ends with a table
Regression from commit 7d3778e0ef9f54f3c8988f1b84d58e7002d6c625
(bnc#816593 DOCX import: ignore page breaks in tables, 2013-09-02), the
page break was ignored because the preceding footer ended with a table
(no empty paragraph at the end of the footer stream).
Fix the problem by saving/loading the table state around header/footers,
that way the page break is not ignored.
Adjust testTdf102466 to test the page number from Word.
(cherry picked from commit a86a2a1c1ceb7203857d4317913c5b1bb9feb4aa)
Conflicts:
writerfilter/CppunitTest_writerfilter_dmapper.mk
writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
Change-Id: Ia4c22452ee2c37f7f941dfd922db04c851644d0c
Diffstat (limited to 'writerfilter/qa')
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx | 27 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/page-break-footer-table.docx | bin | 0 -> 15416 bytes |
2 files changed, 27 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx index a7274c653805..dff03f974a66 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx @@ -54,6 +54,33 @@ void Test::tearDown() char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/"; +CPPUNIT_TEST_FIXTURE(Test, testPageBreakFooterTable) +{ + // Load a document which refers to a footer which ends with a table, and there is a page break + // in the body text right after the footer reference. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "page-break-footer-table.docx"; + getComponent() = loadFromDesktop(aURL); + + // Check the last paragraph. + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<beans::XPropertySet> xPara; + while (xParaEnum->hasMoreElements()) + { + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + } + style::BreakType eType = style::BreakType_NONE; + xPara->getPropertyValue("BreakType") >>= eType; + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4 + // - Actual : 0 + // i.e. there was no page break before the last paragraph. + CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, eType); +} + CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent) { OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "num-restart-style-parent.docx"; diff --git a/writerfilter/qa/cppunittests/dmapper/data/page-break-footer-table.docx b/writerfilter/qa/cppunittests/dmapper/data/page-break-footer-table.docx Binary files differnew file mode 100644 index 000000000000..376a1fb1e483 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/page-break-footer-table.docx |