From 4605bd46984125a99b0e993b71efa6edb411699f Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 9 Mar 2017 18:13:50 +0300 Subject: tdf#103931 writerfilter breaktype: same for implicit and explicit MSWord normally does NOT specify "nextPage" for the sectionBreak, since that is the default type. That is imported as BreakType == -1. However, Writer ALWAYS exports the section type name, which of course is imported explicitly. **There is an import hack that treats the very first -1 section as continuous IF there are columns**. Since Writer explicitly defines the section type, these documents import differently. When Writer round-trips these types of files, they get totally messed up in Writer, although they look fine in Word. So, treat both implicit and explicit nextPage identically for bTreatAsContinuous during import. Another unit test demonstrated that headers/footers are lost when treating as continuous, so preventing that situation now also. This fix allows several import-only unit tests to round-trip. Change-Id: I37fa861d82e8da564d28d8e9089fe0f2777650fb Reviewed-on: https://gerrit.libreoffice.org/35013 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna --- .../ooxmlexport/data/default-sect-break-cols.docx | Bin 0 -> 9993 bytes .../data/multi-column-separator-with-line.docx | Bin 0 -> 11618 bytes .../ooxmlexport/data/unbalanced-columns.docx | Bin 0 -> 12820 bytes sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 37 +++++++++++++++++++++ .../ooxmlimport/data/default-sect-break-cols.docx | Bin 9993 -> 0 bytes .../data/multi-column-separator-with-line.docx | Bin 11618 -> 0 bytes .../ooxmlimport/data/unbalanced-columns.docx | Bin 12820 -> 0 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 36 -------------------- writerfilter/source/dmapper/PropertyMap.cxx | 3 +- 9 files changed, 39 insertions(+), 37 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx create mode 100644 sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx create mode 100644 sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx delete mode 100644 sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx diff --git a/sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx b/sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx new file mode 100644 index 000000000000..b66b844f16ee Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx b/sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx new file mode 100644 index 000000000000..c19ed697b55c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx b/sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx new file mode 100644 index 000000000000..da6f93f760ae Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 99b274412e79..d60b3320d23c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -340,6 +341,42 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106001_2, "tdf106001-2.odt") assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:w","val","600"); } +DECLARE_OOXMLEXPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx") +{ + // First problem: the first two paragraphs did not have their own text section, so the whole document had two columns. + uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1, "First."), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + + // Second problem: the page style had two columns, while it shouldn't have any. + uno::Reference xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + xTextColumns = getProperty< uno::Reference >(xPageStyle, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); + // Check for the Column Separator value.It should be FALSE as the document does not contain separator line. + bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn"); + CPPUNIT_ASSERT(!bValue) ; +} + +DECLARE_OOXMLEXPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx") +{ + uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1, "First data."), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); + // Check for the Column Separator value.It should be TRUE as the document contains separator line. + bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn"); + CPPUNIT_ASSERT(bValue); +} + +DECLARE_OOXMLEXPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx") +{ + uno::Reference xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was false, last section was balanced, but it's unbalanced in Word. + CPPUNIT_ASSERT_EQUAL(true, getProperty(xTextSections->getByIndex(2), "DontBalanceTextColumns")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx b/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx deleted file mode 100644 index b66b844f16ee..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx b/sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx deleted file mode 100644 index c19ed697b55c..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx b/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx deleted file mode 100644 index da6f93f760ae..000000000000 Binary files a/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index a37f16efdeea..bbc8ef0fa8d5 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -671,23 +671,6 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeSdt, "groupshape-sdt.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(20), getProperty(getRun(getParagraphOfText(1, xShape->getText()), 1), "CharKerning")); } -DECLARE_OOXMLIMPORT_TEST(testDefaultSectBreakCols, "default-sect-break-cols.docx") -{ - // First problem: the first two paragraphs did not have their own text section, so the whole document had two columns. - uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1, "First."), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - - // Second problem: the page style had two columns, while it shouldn't have any. - uno::Reference xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - xTextColumns = getProperty< uno::Reference >(xPageStyle, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount()); - // Check for the Column Separator value.It should be FALSE as the document does not contain separator line. - bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn"); - CPPUNIT_ASSERT(!bValue) ; -} - void lcl_countTextFrames(css::uno::Reference< lang::XComponent >& xComponent, sal_Int32 nExpected ) { @@ -764,17 +747,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573_lostTable, "tdf75573_lostTable.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("# of pages", 3, getPages() ); } -DECLARE_OOXMLIMPORT_TEST(testMultiColumnSeparator, "multi-column-separator-with-line.docx") -{ - uno::Reference xTextSection = getProperty< uno::Reference >(getParagraph(1, "First data."), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference xTextColumns = getProperty< uno::Reference >(xTextSection, "TextColumns"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount()); - // Check for the Column Separator value.It should be TRUE as the document contains separator line. - bool bValue = getProperty< bool >(xTextColumns, "SeparatorLineIsOn"); - CPPUNIT_ASSERT(bValue); -} - DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx") { uno::Reference xShape = getShape(1); @@ -939,14 +911,6 @@ DECLARE_OOXMLIMPORT_TEST(testFdo76803, "fdo76803.docx") CPPUNIT_ASSERT_EQUAL(double(0), aPolygon.getB2DPoint(3).getY()); } -DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx") -{ - uno::Reference xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); - // This was false, last section was balanced, but it's unbalanced in Word. - CPPUNIT_ASSERT_EQUAL(true, getProperty(xTextSections->getByIndex(2), "DontBalanceTextColumns")); -} - DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.docx") { uno::Reference xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 354be3488b04..c4edba3d18ca 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1181,8 +1181,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) // depending on the break type no page styles should be created // If the section type is missing, but we have columns without new style info, then this should be // handled as a continuous section break. - const bool bTreatAsContinuous = m_nBreakType == -1 + const bool bTreatAsContinuous = (m_nBreakType == -1 || m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextPage) && m_nColumnCount > 0 + && !HasHeader(m_bTitlePage) && !HasFooter(m_bTitlePage) && (m_bIsFirstSection || m_sFollowPageStyleName.isEmpty() || (m_sFirstPageStyleName.isEmpty() && m_bTitlePage)); if(m_nBreakType == static_cast(NS_ooxml::LN_Value_ST_SectionMark_continuous) || bTreatAsContinuous) { -- cgit