diff options
author | Justin Luth <justin_luth@sil.org> | 2017-03-09 18:13:50 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-13 11:23:53 +0000 |
commit | 4605bd46984125a99b0e993b71efa6edb411699f (patch) | |
tree | 3e33aa14c3dc34d0e27abd773ec418cccf236d15 | |
parent | 3902bb7a45f6266c51e01eddcda4e25b34814957 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx (renamed from sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx) | bin | 9993 -> 9993 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/multi-column-separator-with-line.docx (renamed from sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx) | bin | 11618 -> 11618 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/unbalanced-columns.docx (renamed from sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx) | bin | 12820 -> 12820 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 37 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 36 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 3 |
6 files changed, 39 insertions, 37 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx b/sw/qa/extras/ooxmlexport/data/default-sect-break-cols.docx Binary files differindex b66b844f16ee..b66b844f16ee 100644 --- a/sw/qa/extras/ooxmlimport/data/default-sect-break-cols.docx +++ b/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 Binary files differindex c19ed697b55c..c19ed697b55c 100644 --- a/sw/qa/extras/ooxmlimport/data/multi-column-separator-with-line.docx +++ b/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 Binary files differindex da6f93f760ae..da6f93f760ae 100644 --- a/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx +++ b/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 99b274412e79..d60b3320d23c 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 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<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 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<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || bTreatAsContinuous) { |