From cee02e81cd3b55fb46eacf5db5713e8bf4363bcd Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 11 Apr 2017 21:01:45 +0300 Subject: ooxmlexport: roundtrip tdf#103975's unit tests MS documentation for splitPgBreakAndParaMark only mentions page breaks, not column breaks. (Always Move Paragraph Mark to Page after a Page Break) This element specifies whether a page break shall automatically complete the line on which it appears, moving the end of the paragraph to a new line on the next page, or if it shall behave as true run-level content within its current paragraph. Typically, a page break defined using the br element is treated as run-level content, which means that although it delimits the end of the page, if there is no content after it within the current paragraph, that the paragraph shall also end on that page. This element, when present with a val attribute value of true (or equivalent), specifies that a page break shall always immediately end the current page, moving the paragraph mark which delimits the end of its parent paragraph to a new line on the next page. Note that this setting only affects the case where there is no run-level content after the page break within the paragraph - if any further run content appears in the paragraph it shall appear on subsequent lines on the next page I borrowed the !footnote code from the if newline ELSE section. It seemed appropriate to take the same precautions here. || bSingleParagraph was added specifically for COLUMN_BREAK. That is obsolete now, so removing. There is a lot of old code here that I have questions about. I tried to change as little as possible, but likely lots of the existing logic is just wrong. Change-Id: Ib988c6623acb2b6152118098b706314bfbfb99e3 Reviewed-on: https://gerrit.libreoffice.org/36421 Tested-by: Jenkins Reviewed-by: Justin Luth --- .../ooxmlexport/data/tdf103975_notPageBreakB.docx | Bin 0 -> 13971 bytes .../ooxmlexport/data/tdf103975_notPageBreakC.docx | Bin 0 -> 13955 bytes .../ooxmlexport/data/tdf103975_notPageBreakD.docx | Bin 0 -> 21482 bytes .../ooxmlexport/data/tdf103975_notPageBreakE.docx | Bin 0 -> 14047 bytes sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 71 +++++++++++++++++++++ .../ooxmlimport/data/tdf103975_notPageBreakB.docx | Bin 13971 -> 0 bytes .../ooxmlimport/data/tdf103975_notPageBreakC.docx | Bin 13955 -> 0 bytes .../ooxmlimport/data/tdf103975_notPageBreakD.docx | Bin 21482 -> 0 bytes .../ooxmlimport/data/tdf103975_notPageBreakE.docx | Bin 14047 -> 0 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 70 -------------------- writerfilter/source/dmapper/DomainMapper.cxx | 12 +++- 11 files changed, 80 insertions(+), 73 deletions(-) create mode 100755 sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx create mode 100755 sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx create mode 100755 sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx create mode 100755 sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx delete mode 100755 sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx delete mode 100755 sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx delete mode 100755 sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx delete mode 100755 sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx new file mode 100755 index 000000000000..a7b880d00e60 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx new file mode 100755 index 000000000000..52767abb8ce3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx new file mode 100755 index 000000000000..37c752499f08 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx new file mode 100755 index 000000000000..ac3eb9f7c7ff Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 186f7a8d1eb9..d38a6ff46364 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -259,6 +260,76 @@ DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx") CPPUNIT_ASSERT_EQUAL( 2, getPages() ); } +DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx") +{ + // turn on View Formatting Marks to see these documents. + uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(2), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(3), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(4), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); + + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); + CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() ); + CPPUNIT_ASSERT_EQUAL( 1, getPages() ); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx") +{ + // turn on View Formatting Marks to see these documents. + uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(2), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(3), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); + + xTextSection = getProperty< uno::Reference >(getParagraph(4), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); + + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); + CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() ); + CPPUNIT_ASSERT_EQUAL( 1, getPages() ); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx") +{ + // The problem was that the column break was moving outside of the columns, making a page break. + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); + CPPUNIT_ASSERT_EQUAL( 1, getPages() ); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx") +{ + // The problem was that the column break was getting lost. + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); +} + + DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx deleted file mode 100755 index a7b880d00e60..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx deleted file mode 100755 index 52767abb8ce3..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx deleted file mode 100755 index 37c752499f08..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx b/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx deleted file mode 100755 index ac3eb9f7c7ff..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 90e36f1ef593..dee3ad3d3596 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -142,75 +141,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103931, "tdf103931.docx") CPPUNIT_ASSERT_EQUAL(static_cast(3), xTextSections->getCount()); } -DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx") -{ - // turn on View Formatting Marks to see these documents. - uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(2), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(3), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(4), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); - - CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); - CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() ); - CPPUNIT_ASSERT_EQUAL( 1, getPages() ); -} - -DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx") -{ - // turn on View Formatting Marks to see these documents. - uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(2), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(3), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); - - xTextSection = getProperty< uno::Reference >(getParagraph(4), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); - - CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); - CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() ); - CPPUNIT_ASSERT_EQUAL( 1, getPages() ); -} - -DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx") -{ - // The problem was that the column break was moving outside of the columns, making a page break. - CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); - CPPUNIT_ASSERT_EQUAL( 1, getPages() ); -} - -DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx") -{ - // The problem was that the column break was getting lost. - CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty(getParagraph(2), "BreakType")); -} - DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx") { uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 2f3df2fa01fc..95db1c41a893 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3306,10 +3306,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) const bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection(); PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH); - if (pContext && (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark() || bSingleParagraph)) + if (pContext && !pContext->GetFootnote().is()) { if (m_pImpl->isBreakDeferred(PAGE_BREAK)) - pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE)); + { + if (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark()) + { + pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE)); + m_pImpl->clearDeferredBreaks(); + } + } else if (m_pImpl->isBreakDeferred(COLUMN_BREAK)) { if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() ) @@ -3320,8 +3326,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) } pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE)); + m_pImpl->clearDeferredBreaks(); } - m_pImpl->clearDeferredBreaks(); } // If the paragraph contains only the section properties and it has -- cgit v1.2.3