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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 10 07:09:16 UTC 2020


 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                |   14 +++++++++++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |    7 +++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx        |   19 +++++++++++++++
 3 files changed, 40 insertions(+)

New commits:
commit 20ba8d8d9f4fcf7d5826fcb3366a9bff0d6a8ca1
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Jun 9 14:42:26 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Jun 10 09:08:40 2020 +0200

    tdf#131070 DOCX import: fix indentation of direct numbering
    
    Indentation came from direct numbering has precedence over
    table style.
    
    Also paragraph style based right indentation affects DOCX list
    items with not paragraph style based numbering, unlike Writer.
    
    Keep all indentation values using direct paragraph formatting.
    
    Change-Id: Ia66645269a4fcd06f0be4f02c775007c83d22a0b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95954
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8847b6413a54..07b6ebb8b69d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -374,6 +374,20 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf118812, "tdf118812_tableStyles-compre
     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:color", 1);
     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:color", "val", "AAAA00");
     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[6]/w:tc/w:p/w:r[2]/w:rPr/w:sz", "val", "16");
+
+    // tdf#131070 keep paragraph style based right indentation with indentation of direct numbering
+    // cell A7 - This was <w:ind w:start="1440" w:hanging="0"/>
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[7]/w:tc/w:p/w:pPr/w:ind", 0);
+    // cell A8
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "start", "714");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "end", "1701");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[8]/w:tc/w:p/w:pPr/w:ind", "hanging", "357");
+    // cell A9
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "end", "1440");
+    // This was 1440
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "start", "720");
+    // This was 0
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[9]/w:tc/w:p/w:pPr/w:ind", "hanging", "360");
 }
 
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf107626, "tdf107626.odt")
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 9c3d87de1552..7da44a475efd 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1074,6 +1074,13 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
         // if there is no direct paragraph formatting
         if ( !rParaProp.m_pPropertyMap->isSet(eId) )
         {
+            if ( (eId == PROP_PARA_LEFT_MARGIN || eId == PROP_PARA_FIRST_LINE_INDENT) &&
+                    rParaProp.m_pPropertyMap->isSet(PROP_NUMBERING_RULES) )
+            {
+                // indentation of direct numbering has bigger precedence, than table style
+                continue;
+            }
+
             OUString sPropertyName = getPropertyName(eId);
             auto pCellProp = std::find_if(rCellProperties.begin(), rCellProperties.end(),
                 [&](const beans::PropertyValue& rProp) { return rProp.Name == sPropertyName; });
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0fd359de5af6..e06c98145b23 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1443,6 +1443,25 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                 pParaContext->Insert(PROP_PARA_RIGHT_MARGIN, uno::makeAny(nParaRightMargin), /*bOverwrite=*/false);
             }
         }
+        // Paragraph style based right paragraph indentation affects not paragraph style based lists in DOCX.
+        // Apply it as direct formatting, also left and first line indentation of numbering to keep them.
+        else if (isNumberingViaRule)
+        {
+            uno::Any aRightMargin = GetPropertyFromParaStyleSheet(PROP_PARA_RIGHT_MARGIN);
+            if ( aRightMargin != uno::Any() )
+            {
+                pParaContext->Insert(PROP_PARA_RIGHT_MARGIN, aRightMargin, /*bOverwrite=*/false);
+
+                sal_Int32 nListId2(static_cast<ParagraphPropertyMap*>(pPropertyMap.get())->GetListId());
+
+                const sal_Int32 nFirstLineIndent = getNumberingProperty(nListId2, nListLevel, "FirstLineIndent");
+                const sal_Int32 nParaLeftMargin  = getNumberingProperty(nListId2, nListLevel, "IndentAt");
+                if (nFirstLineIndent != 0)
+                    pParaContext->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent), /*bOverwrite=*/false);
+                if (nParaLeftMargin != 0)
+                    pParaContext->Insert(PROP_PARA_LEFT_MARGIN, uno::makeAny(nParaLeftMargin), /*bOverwrite=*/false);
+            }
+        }
     }
 
     // apply AutoSpacing: it has priority over all other margin settings


More information about the Libreoffice-commits mailing list