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

Miklos Vajna vmiklos at collabora.co.uk
Tue Apr 11 09:04:05 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf106970.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx         |    9 +++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   18 +++++++++++++++---
 3 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit e1c83d0514e6123faa50ad0a7aa6a9031b271c9a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 11 08:54:36 2017 +0200

    tdf#106970 DOCX import: don't collapse para auto space for different nums
    
    Commit 1bf7f6a1a50ee9f24a3687240fe6ae390b905a6b (tdf#106690 DOCX import:
    fix automatic spacing before/after numbered para block, 2017-04-04) made
    sure that autospacing is only collapsed in case the adjacent text nodes
    both have a numbering rule.
    
    It turns out there is an additional condition: even if both text nodes
    have a numbering rule, do the collapsing only in case they have the same
    numbering rule.
    
    Change-Id: Idb7a2b24d7eaa9094cc36f86b8a483045a33d028
    Reviewed-on: https://gerrit.libreoffice.org/36400
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf106970.docx b/sw/qa/extras/ooxmlexport/data/tdf106970.docx
new file mode 100644
index 000000000000..8a534558b641
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf106970.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 178c71b6fcc0..a7d53cf39661 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -70,6 +70,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106690, "tdf106690.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf106970, "tdf106970.docx")
+{
+    // The second paragraph (first numbered one) had 0 bottom margin:
+    // autospacing was even collapsed between different numbering styles.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(3), "ParaBottomMargin"));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraph(4), "ParaBottomMargin"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.docx")
 {
     // the paragraph style should set table's text-flow break-before-page
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f8eeb4c6a15b..c9369de68e31 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1180,10 +1180,22 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
                     });
                     if (itNumberingRules != aProperties.end())
                     {
-                        // This textnode has numbering.
-                        if (m_xPreviousParagraph.is() && m_xPreviousParagraph->getPropertyValue("NumberingRules").hasValue())
+                        // This textnode has numbering. Look up the numbering style name of the current and previous paragraph.
+                        OUString aCurrentNumberingRuleName;
+                        uno::Reference<container::XNamed> xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
+                        if (xCurrentNumberingRules.is())
+                            aCurrentNumberingRuleName = xCurrentNumberingRules->getName();
+                        OUString aPreviousNumberingRuleName;
+                        if (m_xPreviousParagraph.is())
                         {
-                            // There was a previous textnode and it had numbering.
+                            uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+                            if (xPreviousNumberingRules.is())
+                                aPreviousNumberingRuleName = xPreviousNumberingRules->getName();
+                        }
+
+                        if (!aPreviousNumberingRuleName.isEmpty() && aCurrentNumberingRuleName == aPreviousNumberingRuleName)
+                        {
+                            // There was a previous textnode and it had the same numbering.
                             if (m_bParaAutoBefore)
                             {
                                 // This before spacing is set to auto, set before space to 0.


More information about the Libreoffice-commits mailing list