[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa writerfilter/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 3 17:42:46 UTC 2021


 sw/qa/extras/ooxmlexport/data/tdf137655.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    8 ++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   18 +++++++++++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 694e11ae11aeac7fba8dc1937f8f6159b7e9d867
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Jan 25 15:48:46 2021 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Mar 3 18:42:07 2021 +0100

    tdf#137655 DOCX table import: fix zero para top margin
    
    when only w:beforeAutospacing=0 was specified, but not
    PARA_TOP_MARGIN (see default_spacing = -1 in processing
    of LN_CT_Spacing_beforeAutospacing).
    
    Follow-up of commit 61821277ed4974debd05af89cb7284602512088f
    (tdf#104354 writerfilter: rewrite Autospacing).
    
    Change-Id: I5fff7a8b62450ebaf8ef6b552ecbb2b1cfb24381
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109914
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 9e21215d45b2eea31019711282445580fad0d753)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111913
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf137655.docx b/sw/qa/extras/ooxmlexport/data/tdf137655.docx
new file mode 100644
index 000000000000..d87d434b324d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf137655.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index c6c2a3461cdd..e28eb2a4952b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -534,6 +534,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113258_noBeforeAutospacing, "tdf113258_noBeforeA
                          getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf137655, "tdf137655.docx")
+{
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    // These were 280.
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:p[1]/w:pPr/w:spacing", "before", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:p[1]/w:pPr/w:spacing", "before", "0");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf120511_eatenSection, "tdf120511_eatenSection.docx")
 {
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5986266f4de4..7e1ec2415329 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1494,12 +1494,23 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
     const bool bAllowAdjustments = !GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing();
     sal_Int32 nBeforeAutospacing = -1;
     bool bIsAutoSet = pParaContext && pParaContext->isSet(PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING);
+    bool bIsZeroAutospacingWithoutTopmargin = false;
+    const bool bNoTopmargin = pParaContext && !pParaContext->isSet(PROP_PARA_TOP_MARGIN);
     // apply INHERITED autospacing only if top margin is not set
-    if ( bIsAutoSet || (pParaContext && !pParaContext->isSet(PROP_PARA_TOP_MARGIN)) )
+    if ( bIsAutoSet || bNoTopmargin )
+    {
         GetAnyProperty(PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, pPropertyMap) >>= nBeforeAutospacing;
+        // tdf#137655 only w:beforeAutospacing=0 was specified, but not PARA_TOP_MARGIN
+        // (see default_spacing = -1 in processing of LN_CT_Spacing_beforeAutospacing)
+        if ( bNoTopmargin && nBeforeAutospacing == ConversionHelper::convertTwipToMM100(-1) )
+        {
+            nBeforeAutospacing = 0;
+            bIsZeroAutospacingWithoutTopmargin = true;
+        }
+    }
     if ( nBeforeAutospacing > -1 && pParaContext )
     {
-        if ( bAllowAdjustments )
+        if ( bAllowAdjustments && !bIsZeroAutospacingWithoutTopmargin )
         {
             if ( GetIsFirstParagraphInShape() ||
                  (GetIsFirstParagraphInSection() && GetSectionContext() && GetSectionContext()->IsFirstSection()) ||
@@ -1511,7 +1522,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                     pParaContext->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( sal_Int32(0) ),true, PARA_GRAB_BAG );
             }
         }
-        pParaContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(nBeforeAutospacing));
+        if ( !bIsZeroAutospacingWithoutTopmargin || (m_nTableDepth > 0 && m_nTableDepth == m_nTableCellDepth) )
+            pParaContext->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(nBeforeAutospacing));
     }
 
     sal_Int32 nAfterAutospacing = -1;


More information about the Libreoffice-commits mailing list