[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth justin_luth at sil.org
Fri May 19 11:31:48 UTC 2017


 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |   71 +++++++++++++++++++++++++++
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx     |   70 --------------------------
 writerfilter/source/dmapper/DomainMapper.cxx |   12 +++-
 3 files changed, 80 insertions(+), 73 deletions(-)

New commits:
commit cee02e81cd3b55fb46eacf5db5713e8bf4363bcd
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue Apr 11 21:01:45 2017 +0300

    ooxmlexport: roundtrip tdf#103975's unit tests
    
    MS documentation for splitPgBreakAndParaMark
    only mentions page breaks, not column breaks.
    
    (Always Move Paragraph Mark to Page after a Page Break)
    This element specifies whether a page break shall automatically
    complete the line on which it appears, moving
    the end of the paragraph to a new line on the next page,
    or if it shall behave as true run-level content within its
    current paragraph.
    Typically, a page break defined using the br element
    is treated as run-level content, which means that
    although it delimits the end of the page, if there is no content
    after it within the current paragraph, that the
    paragraph shall also end on that page. This element, when
    present with a val attribute value of true (or
    equivalent), specifies that a page break shall always
    immediately end the current page, moving the paragraph
    mark which delimits the end of its parent paragraph to
    a new line on the next page.
    Note that this setting only affects the case where there
    is no run-level content after the page break within the
    paragraph - if any further run content appears in the
    paragraph it shall appear on subsequent lines on the next
    page
    
    I borrowed the !footnote code from the if newline ELSE
    section. It seemed appropriate to take the same
    precautions here.
    
    || bSingleParagraph was added specifically for
    COLUMN_BREAK. That is obsolete now, so removing.
    
    There is a lot of old code here that I have questions
    about. I tried to change as little as possible, but
    likely lots of the existing logic is just wrong.
    
    Change-Id: Ib988c6623acb2b6152118098b706314bfbfb99e3
    Reviewed-on: https://gerrit.libreoffice.org/36421
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakB.docx
rename to sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakB.docx
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakC.docx
rename to sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakC.docx
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakD.docx
rename to sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakD.docx
diff --git a/sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx b/sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/tdf103975_notPageBreakE.docx
rename to sw/qa/extras/ooxmlexport/data/tdf103975_notPageBreakE.docx
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 186f7a8d1eb9..d38a6ff46364 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -19,6 +19,7 @@
 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/style/BreakType.hpp>
 #include <com/sun/star/style/PageStyleLayout.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -259,6 +260,76 @@ DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
     CPPUNIT_ASSERT_EQUAL( 2, getPages() );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx")
+{
+    // turn on View Formatting Marks to see these documents.
+    uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+    CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
+    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx")
+{
+    // turn on View Formatting Marks to see these documents.
+    uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
+    CPPUNIT_ASSERT(xTextSection.is());
+    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+    CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
+    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx")
+{
+    // The problem was that the column break was moving outside of the columns, making a page break.
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx")
+{
+    // The problem was that the column break was getting lost.
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+}
+
+
 DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 90e36f1ef593..dee3ad3d3596 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -26,7 +26,6 @@
 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/style/BreakType.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
@@ -142,75 +141,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf103931, "tdf103931.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xTextSections->getCount());
 }
 
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakB, "tdf103975_notPageBreakB.docx")
-{
-    // turn on View Formatting Marks to see these documents.
-    uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
-    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
-    CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
-    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakC, "tdf103975_notPageBreakC.docx")
-{
-    // turn on View Formatting Marks to see these documents.
-    uno::Reference<beans::XPropertySet> xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(1), "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());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(2), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(3), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
-    xTextSection = getProperty< uno::Reference<beans::XPropertySet> >(getParagraph(4), "TextSection");
-    CPPUNIT_ASSERT(xTextSection.is());
-    xTextColumns = getProperty< uno::Reference<text::XTextColumns> >(xTextSection, "TextColumns");
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
-
-    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
-    CPPUNIT_ASSERT_EQUAL( 4, getParagraphs() );
-    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakD, "tdf103975_notPageBreakD.docx")
-{
-    // The problem was that the column break was moving outside of the columns, making a page break.
-    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
-    CPPUNIT_ASSERT_EQUAL( 1, getPages() );
-}
-
-DECLARE_OOXMLIMPORT_TEST(testTdf103975_notPageBreakE, "tdf103975_notPageBreakE.docx")
-{
-    // The problem was that the column break was getting lost.
-    CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
-}
-
 DECLARE_OOXMLIMPORT_TEST(testN751017, "n751017.docx")
 {
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 2f3df2fa01fc..95db1c41a893 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3306,10 +3306,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
 
             const bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
             PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
-            if (pContext && (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark() || bSingleParagraph))
+            if (pContext && !pContext->GetFootnote().is())
             {
                 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
-                    pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
+                {
+                    if (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
+                    {
+                        pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
+                        m_pImpl->clearDeferredBreaks();
+                    }
+                }
                 else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
                 {
                     if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() )
@@ -3320,8 +3326,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
                     }
 
                     pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
+                    m_pImpl->clearDeferredBreaks();
                 }
-                m_pImpl->clearDeferredBreaks();
             }
 
             // If the paragraph contains only the section properties and it has


More information about the Libreoffice-commits mailing list