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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 6 11:39:43 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf124604.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    7 ++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   33 +++++++++++-----------
 3 files changed, 24 insertions(+), 16 deletions(-)

New commits:
commit 9f6d1d5c4c75c51f36815178507e336c504025fb
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Thu Sep 5 16:23:00 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Sep 6 13:38:34 2019 +0200

    tdf#124604 DOCX import: fix indentation at numbering
    
    If the actual numbering style was associated to a base
    paragraph style, indentation of the base paragraph
    style has also priority over the indentation defined
    in the numbering style.
    
    Change-Id: Ic57b6b854be291c75c0eb7a9dfd4c376585fe26b
    Reviewed-on: https://gerrit.libreoffice.org/78659
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf124604.docx b/sw/qa/extras/ooxmlexport/data/tdf124604.docx
new file mode 100644
index 000000000000..1bac640ecce3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf124604.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 70ee26bbd2f4..953f6d3de38b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -915,6 +915,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125546, "tdf125546.docx")
     assertXPath(pXmlDoc, "//w:rPrChange", 2);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf124604, "tdf124604.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    // If the numbering comes from a base style, indentation of the base style has also priority.
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", "0");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf118691, "tdf118691.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 bf88f1e699ca..42521e06e228 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1184,7 +1184,7 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 }
 
 /// Check if the style or its parent has a list id, recursively.
-static sal_Int32 lcl_getListId(const StyleSheetEntryPtr& rEntry, const StyleSheetTablePtr& rStyleTable)
+static sal_Int32 lcl_getListId(const StyleSheetEntryPtr& rEntry, const StyleSheetTablePtr& rStyleTable, bool & rNumberingFromBaseStyle)
 {
     const StyleSheetPropertyMap* pEntryProperties = dynamic_cast<const StyleSheetPropertyMap*>(rEntry->pProperties.get());
     if (!pEntryProperties)
@@ -1204,7 +1204,9 @@ static sal_Int32 lcl_getListId(const StyleSheetEntryPtr& rEntry, const StyleShee
     if (!pParent || pParent == rEntry)
         return -1;
 
-    return lcl_getListId(pParent, rStyleTable);
+    rNumberingFromBaseStyle = true;
+
+    return lcl_getListId(pParent, rStyleTable, rNumberingFromBaseStyle);
 }
 
 void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, const bool bRemove )
@@ -1233,8 +1235,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
     //does not specify the numbering
     if ( !bRemove && pStyleSheetProperties && pParaContext && !pParaContext->isSet(PROP_NUMBERING_RULES) )
     {
-
-        sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable()) : -1;
+        bool bNumberingFromBaseStyle = false;
+        sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
         if (nListId >= 0 && !pParaContext->isSet(PROP_NUMBERING_STYLE_NAME))
         {
             pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( ListDef::GetStyleName( nListId ) ), false);
@@ -1245,22 +1247,21 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
             // but in Writer numbering styles have priority,
             // so insert directly into the paragraph properties to compensate.
             boost::optional<PropertyMap::Property> oProperty;
-            if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_FIRST_LINE_INDENT)) )
+            const StyleSheetEntryPtr pParent = (!pEntry->sBaseStyleIdentifier.isEmpty()) ? GetStyleSheetTable()->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier) : nullptr;
+            const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : nullptr);
+            if (!pEntry->sBaseStyleIdentifier.isEmpty())
+
+            if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_FIRST_LINE_INDENT))
+                // If the numbering comes from a base style, indent of the base style has also priority.
+                || (bNumberingFromBaseStyle && pParentProperties && (oProperty = pParentProperties->getProperty(PROP_PARA_FIRST_LINE_INDENT))) )
                 pParaContext->Insert(PROP_PARA_FIRST_LINE_INDENT, oProperty->second, /*bOverwrite=*/false);
-            if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_LEFT_MARGIN)) )
+            if ( (oProperty = pStyleSheetProperties->getProperty(PROP_PARA_LEFT_MARGIN))
+                || (bNumberingFromBaseStyle && pParentProperties && (oProperty = pParentProperties->getProperty(PROP_PARA_LEFT_MARGIN))) )
                 pParaContext->Insert(PROP_PARA_LEFT_MARGIN, oProperty->second, /*bOverwrite=*/false);
 
             // We're inheriting properties from a numbering style. Make sure a possible right margin is inherited from the base style.
-            sal_Int32 nParaRightMargin = 0;
-            if (!pEntry->sBaseStyleIdentifier.isEmpty())
-            {
-                const StyleSheetEntryPtr pParent = GetStyleSheetTable()->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
-                const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : nullptr);
-                boost::optional<PropertyMap::Property> pPropMargin;
-                if (pParentProperties && (pPropMargin = pParentProperties->getProperty(PROP_PARA_RIGHT_MARGIN)) )
-                    nParaRightMargin = pPropMargin->second.get<sal_Int32>();
-            }
-            if (nParaRightMargin != 0)
+            sal_Int32 nParaRightMargin;
+            if  ( pParentProperties && (oProperty = pParentProperties->getProperty(PROP_PARA_RIGHT_MARGIN)) && (nParaRightMargin = oProperty->second.get<sal_Int32>()) != 0 )
             {
                 // If we're setting the right margin, we should set the first / left margin as well from the numbering style.
                 const sal_Int32 nFirstLineIndent = getNumberingProperty(nListId, pStyleSheetProperties->GetListLevel(), "FirstLineIndent");


More information about the Libreoffice-commits mailing list