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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed May 13 13:09:03 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf132807.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx         |   19 ++++++++++++++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   19 ++++++++++++++-----
 3 files changed, 32 insertions(+), 6 deletions(-)

New commits:
commit 162d74ae7a53eb1cde738f0a7558f297b8162f7a
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed May 13 12:01:35 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed May 13 15:08:27 2020 +0200

    tdf#132807 DOCX import: fix top auto margin in lists
    
    at paragraph style based numbering.
    
    See also commit 99b2d53346d4b01b491cd1f7fae3304ac0572e12
    (tdf#132802 DOCX import: fix list bottom auto margins).
    
    Change-Id: I6bfea3ace5c94f9d45267e309a21ac8a97c20a37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94111
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf132807.docx b/sw/qa/extras/ooxmlexport/data/tdf132807.docx
new file mode 100644
index 000000000000..b1e4115c5d8a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf132807.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8a31375fd561..37c76c477f6f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -185,7 +185,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf122342, "tdf122342.docx")
     // These were 494, style based numbering rules with automatic spacing meant 0
     // before/autospacing for all text nodes, even for ones at the start/end of
     // a numbered text node block.
-    // TODO fix for ParaTopMargin, too.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
     // last list item
@@ -208,6 +207,24 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132802, "tdf132802.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "280");
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132807, "tdf132807.docx")
+{
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "before", "280");
+    // This was 240 (list auto spacing is zero in lists)
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:spacing", "before", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "0");
+
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
+    // This was 240 (list auto spacing is zero in lists)
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "0");
+
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc/w:p[2]/w:pPr/w:spacing", "before", "280");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p[1]/w:pPr/w:spacing", "before", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:pPr/w:spacing", "before", "280");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf129575_directBefore, "tdf129575-directBefore.docx")
 {
     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6d8f0822e7ce..e34268cb04d2 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1653,9 +1653,21 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
 
                         if (!aPreviousNumberingName.isEmpty() && aCurrentNumberingName == aPreviousNumberingName)
                         {
-
+                            uno::Sequence<beans::PropertyValue> aPrevPropertiesSeq;
+                            m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq;
+                            auto aPrevProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aPrevPropertiesSeq);
+                            bool bPrevParaAutoBefore;
+                            if (isNumberingViaRule)
+                                bPrevParaAutoBefore = false;
+                            else
+                            {
+                                bPrevParaAutoBefore = std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue)
+                                {
+                                    return rValue.Name == "ParaTopMarginBeforeAutoSpacing";
+                                });
+                            }
                             // There was a previous textnode and it had the same numbering.
-                            if (m_bParaAutoBefore)
+                            if (m_bParaAutoBefore || bPrevParaAutoBefore)
                             {
                                 // This before spacing is set to auto, set before space to 0.
                                 auto itParaTopMargin = std::find_if(aProperties.begin(), aProperties.end(), [](const beans::PropertyValue& rValue)
@@ -1668,9 +1680,6 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                                     aProperties.push_back(comphelper::makePropertyValue("ParaTopMargin", static_cast<sal_Int32>(0)));
                             }
 
-                            uno::Sequence<beans::PropertyValue> aPrevPropertiesSeq;
-                            m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq;
-                            auto aPrevProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aPrevPropertiesSeq);
                             bool bPrevParaAutoAfter = std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue)
                             {
                                 return rValue.Name == "ParaBottomMarginAfterAutoSpacing";


More information about the Libreoffice-commits mailing list