sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c12v3.docx |binary sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14.docx |binary sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14v2.docx |binary sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c15.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 46 ++++++++++ writerfilter/source/dmapper/PropertyMap.cxx | 28 ++++-- 6 files changed, 67 insertions(+), 7 deletions(-)
New commits: commit 75b45d43b53abd457c98f47078ca7ff3c492ce2c Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Aug 1 12:08:51 2020 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Aug 7 10:11:52 2020 +0200 tdf#135343 writerfilter: compat15 treats section nextCol as nextPage ... and also handle a document that starts with a nextColumn break ... and also handle a nextColumn with a different number of columns. Starting in Word 2013's compatibilityMode=15, it appears (based on testing, but no documentation found to prove it) that the hard-to-create column-section-break is always handled the same way as a page break. It already was like this if it occurred when the previous section did not have columns. Only when the previous section had the same # of columns did it act as a regular column break. In any case, LO never handled any of it well. P.S. I never liked "lastContext" since it isn't clear whether it means the very last something or something earlier. So I changed it to PrevSection which is much nicer. still to do: figure out how to just do a regular column break in the previous section. Change-Id: I3cef4a1ab185d25dfde90b85338706e8909b72dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99936 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c12v3.docx b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c12v3.docx new file mode 100644 index 000000000000..b51e53124b2e Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c12v3.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14.docx b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14.docx new file mode 100644 index 000000000000..25505bdddaea Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14v2.docx b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14v2.docx new file mode 100644 index 000000000000..064e62f70719 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c14v2.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c15.docx b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c15.docx new file mode 100644 index 000000000000..f4bd1ff12e35 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135343_columnSectionBreak_c15.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 009867c72f11..cd9656c94ef7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> #include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> @@ -115,6 +116,51 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133370_columnBreak, "tdf133370_columnBreak.odt") CPPUNIT_ASSERT_EQUAL(1, getPages()); } +DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14, "tdf135343_columnSectionBreak_c14.docx") +{ + uno::Reference<beans::XPropertySet> xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(1), "TextSection"); + uno::Reference<text::XTextColumns> xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(2), xTextColumns->getColumnCount()); + + // Old Word 2010 version - nextColumn breaks inside column sections are just treated as regular column breaks. + //xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(12, "RTL 2"), "TextSection"); + //xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + //CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns->getColumnCount()); + //CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c14v2, "tdf135343_columnSectionBreak_c14v2.docx") +{ + // In this Word 2010 v2, section three was changed to start with a nextColumn break instead of a continuous break. + // The previous section has no columns, so this time start the columns on a new page. + uno::Reference<beans::XPropertySet> xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(10, ""), "TextSection"); + uno::Reference<text::XTextColumns> xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section three's columns", sal_Int16(3), xTextColumns->getColumnCount()); + //CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c12v3, "tdf135343_columnSectionBreak_c12v3.docx") +{ + // In this Word 20-3 v3, section one and two have different number of columns. It acts like a page break. + uno::Reference<beans::XPropertySet> xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(1, "Four columns,"), "TextSection"); + uno::Reference<text::XTextColumns> xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section one's columns", sal_Int16(4), xTextColumns->getColumnCount()); + + xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(6, "RTL 2"), "TextSection"); + xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section two's columns", sal_Int16(2), xTextColumns->getColumnCount()); + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf135343_columnSectionBreak_c15, "tdf135343_columnSectionBreak_c15.docx") +{ + // Word 2013+ version - nextColumn breaks inside column sections are always handled like nextPage breaks. + uno::Reference<beans::XPropertySet> xTextSection = getProperty<uno::Reference<beans::XPropertySet>>(getParagraph(12, "RTL 2"), "TextSection"); + uno::Reference<text::XTextColumns> xTextColumns = getProperty<uno::Reference<text::XTextColumns>>(xTextSection, "TextColumns"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Section four's columns", sal_Int16(3), xTextColumns->getColumnCount()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Fits on two pages", 2, getPages()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf129452_excessBorder, "tdf129452_excessBorder.docx") { uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index c1980623b072..6b5af2fd9404 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1324,14 +1324,29 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { + SectionPropertyMap* pPrevSection = rDM_Impl.GetLastSectionContext(); + // The default section type is nextPage. if ( m_nBreakType == -1 ) m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage; - // if page orientation differs from previous section, it can't be treated as continuous + else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextColumn ) + { + // Word 2013+ seems to treat a section column break as a page break all the time. + // It always acts like a page break if there are no columns, or a different number of columns. + // Also, if this is the first section, the break type is basically irrelevant - works best as nextPage. + if ( rDM_Impl.GetSettingsTable()->GetWordCompatibilityMode() > 14 + || !pPrevSection + || m_nColumnCount < 2 + || m_nColumnCount != pPrevSection->ColumnCount() + ) + { + m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage; + } + } else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_continuous ) { - SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext(); - if ( pLastContext ) + // if page orientation differs from previous section, it can't be treated as continuous + if ( pPrevSection ) { bool bIsLandscape = false; std::optional< PropertyMap::Property > pProp = getProperty( PROP_IS_LANDSCAPE ); @@ -1339,7 +1354,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) pProp->second >>= bIsLandscape; bool bPrevIsLandscape = false; - pProp = pLastContext->getProperty( PROP_IS_LANDSCAPE ); + pProp = pPrevSection->getProperty( PROP_IS_LANDSCAPE ); if ( pProp ) pProp->second >>= bPrevIsLandscape; @@ -1562,9 +1577,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } // these BreakTypes are effectively page-breaks: don't evenly distribute text in columns before a page break; - SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext(); - if ( pLastContext && pLastContext->ColumnCount() ) - pLastContext->DontBalanceTextColumns(); + if ( pPrevSection && pPrevSection->ColumnCount() ) + pPrevSection->DontBalanceTextColumns(); //prepare text grid properties sal_Int32 nHeight = 1; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits