[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - sw/qa sw/source writerfilter/source

Justin Luth justin_luth at sil.org
Mon Jul 4 15:35:10 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf90697_complexBreaksHeaders.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx                        |   29 ++++++++--
 sw/source/core/layout/flowfrm.cxx                                |    5 +
 writerfilter/source/dmapper/PropertyMap.cxx                      |    4 +
 4 files changed, 33 insertions(+), 5 deletions(-)

New commits:
commit e4197fbec8abe21a8bb0d222ac6e06664798ce1d
Author: Justin Luth <justin_luth at sil.org>
Date:   Sat Jun 11 10:30:18 2016 +0300

    tdf#76349 writer: treat single-column break as page break
    
    Writerfilter imports docx-defined column breaks that exist without
    being in a column.  Word treats these as if they were a page break.
    Writer basically just preserved and ignored them.
    
    I limited the fix to only consider SVX_BREAK_COLUMN_BEFORE since
    writerfilter is only given “column break” and treats it as column_before.
    
    Reviewed-on: https://gerrit.libreoffice.org/26181
    Tested-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 2721111437706372eaac9bf1d748723196c573ac)
    
    Change-Id: I0d974441d53243c4426048dd7cb60b3897b803f6

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 0174e70..41eeb9d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -363,9 +363,15 @@ DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
      * The <w:br w:type="column" /> was missing after roundtrip
      */
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
-    if (!pXmlDoc)
-        return;
-    assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
+    if (pXmlDoc)
+        assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
+
+    //tdf76349 match Word's behavior of treating breaks in single columns as page breaks.
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf90697_complexBreaksHeaders,"tdf90697_complexBreaksHeaders.docx")
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 2a4c1f4..5320fd1 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1120,8 +1120,11 @@ bool SwFlowFrm::IsPageBreak( bool bAct ) const
                     return false;
             }
 
+            //for compatibility, also break at column break if no columns exist
             const SvxBreak eBreak = pSet->GetBreak().GetBreak();
-            if ( eBreak == SVX_BREAK_PAGE_BEFORE || eBreak == SVX_BREAK_PAGE_BOTH )
+            if ( eBreak == SVX_BREAK_PAGE_BEFORE ||
+                 eBreak == SVX_BREAK_PAGE_BOTH ||
+                 (eBreak == SVX_BREAK_COLUMN_BEFORE && !m_rThis.FindColFrm()) )
                 return true;
             else
             {
commit e6e962a2db0b82efe1054bb85e56406ada4f4c69
Author: Justin Luth <justin_luth at sil.org>
Date:   Sat Jun 25 22:21:08 2016 +0300

    tdf#90697 docx - don't change continuous break into page break
    
    As soon as you set PROP_PAGE_DESC_NAME, you are inserting that
    style as a page break.  Setting a pagebreak via a continous break
    was first introduced in commit 50cb1667020494906afaacb68d4163d1eda527cf
    but the unittest for that commit no longer uses this code.
    I'm suggesting it be reverted.  It really messes up round-tripping
    when continuous breaks are removed/replaced with hard page breaks.
    
    There are a few odd cases where the very first section needs to set the
    page break via the continuous break, so it hasn't been eliminated
    completely.
    
    Reviewed-on: https://gerrit.libreoffice.org/26662
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 50bf96d31ab2eb546f6c71cc93c1fa5dd4bf3044)
    
    Change-Id: I5b0e4bb7612ee9df47e5c49b8c2316dc001b5238

diff --git a/sw/qa/extras/ooxmlexport/data/tdf90697_complexBreaksHeaders.docx b/sw/qa/extras/ooxmlexport/data/tdf90697_complexBreaksHeaders.docx
new file mode 100644
index 0000000..b5e7ef0
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf90697_complexBreaksHeaders.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 1a16cba..0174e70 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/XTextSection.hpp>
+#include <com/sun/star/text/XTextColumns.hpp>
 #include <com/sun/star/style/CaseMap.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/style/LineSpacing.hpp>
@@ -367,6 +368,22 @@ DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf90697_complexBreaksHeaders,"tdf90697_complexBreaksHeaders.docx")
+{
+// This is a complex document using many types of section breaks and re-defined headers.
+// Paragraphs 44-47 were in two columns
+    uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(45), "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());
+
+// after that, the section break should switch things back to one column.
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(50), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx")
 {
     // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index d2e1b41..afa0815 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1140,7 +1140,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
             {
                 try
                 {
-                    xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
+                    if( m_bIsFirstSection )
+                        xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
+
                     uno::Reference<beans::XPropertySet> xPageStyle (rDM_Impl.GetPageStyles()->getByName(aName), uno::UNO_QUERY_THROW);
                     HandleMarginsHeaderFooter(rDM_Impl);
                     if (rDM_Impl.IsNewDoc())


More information about the Libreoffice-commits mailing list