dev/null |binary sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx |binary sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx |binary sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 37 ++++++++++ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 36 --------- writerfilter/source/dmapper/PropertyMap.cxx | 3 7 files changed, 39 insertions(+), 37 deletions(-)
New commits: commit 4605bd46984125a99b0e993b71efa6edb411699f Author: Justin Luth <justin_l...@sil.org> Date: Thu Mar 9 18:13:50 2017 +0300 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 <c...@libreoffice.org> Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx b/sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx similarity index 100% rename from sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx rename to sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx diff --git a/sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx b/sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx similarity index 100% rename from sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx rename to sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx diff --git a/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx b/sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx similarity index 100% rename from sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx rename to sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 99b27441..d60b332 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextFramesSupplier.hpp> #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> @@ -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<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); + xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection"); + CPPUNIT_ASSERT(xTextSection.is()); + uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was false, last section was balanced, but it's unbalanced in Word. + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index a37f16e..bbc8ef0 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<sal_Int32>(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<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First."), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); - xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1, "First data."), "TextSection"); - CPPUNIT_ASSERT(xTextSection.is()); - uno::Reference<text::XTextColumns> xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(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<drawing::XShape> 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<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); - // This was false, last section was balanced, but it's unbalanced in Word. - CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns")); -} - DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.docx") { uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 354be34..c4edba3 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<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || bTreatAsContinuous) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits