tdf#108493 DOCX import: fix hanging indent of lists

when its value comes from the numbering style, but
the left indentation is overwritten by paragraph
settings. The problem caused by that these settings
are not independent in Writer core.

Change-Id: I5d6759bb215b82dfcaa5cbd3e191ac7ea8a8bb00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93478
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf108493.docx b/sw/qa/extras/ooxmlexport/data/tdf108493.docx
new file mode 100644
index 0000000..f1a5152
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf108493.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 806f4d0..51395c0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -1083,6 +1083,15 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf95374, "tdf95374.docx")
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:ind", "start", "1136");
}

DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf108493, "tdf108493.docx")
{
    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    // set in the paragraph
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "start", "709");
    // set in the numbering style (this was 0)
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[7]/w:pPr/w:ind", "hanging", "709");
}

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 0465981..bbef066 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1376,10 +1376,11 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
    bool isNumberingViaStyle(false);
    //apply numbering to paragraph if it was set at the style, but only if the paragraph itself
    //does not specify the numbering
    sal_Int32 nListId = -1;
    if ( !bRemove && pStyleSheetProperties && pParaContext && !pParaContext->isSet(PROP_NUMBERING_RULES) )
    {
        bool bNumberingFromBaseStyle = false;
        sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
        nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
        auto const pList(GetListTable()->GetList(nListId));
        if (pList && nListId >= 0 && !pParaContext->isSet(PROP_NUMBERING_STYLE_NAME))
        {
@@ -1679,10 +1680,10 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                        assert(dynamic_cast<ParagraphPropertyMap*>(pPropertyMap.get()));
                        // Use lcl_getListId(), so we find the list ID in parent styles as well.
                        bool bNumberingFromBaseStyle = false;
                        sal_Int32 const nListId( isNumberingViaStyle
                        sal_Int32 const nListId2( isNumberingViaStyle
                            ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle)
                            : static_cast<ParagraphPropertyMap*>(pPropertyMap.get())->GetListId());
                        if (ListDef::Pointer const& pList = m_pListTable->GetList(nListId))
                        if (ListDef::Pointer const& pList = m_pListTable->GetList(nListId2))
                        {   // styles could refer to non-existing lists...
                            AbstractListDef::Pointer const& pAbsList =
                                    pList->GetAbstractDefinition();
@@ -1858,6 +1859,12 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                            uno::Any aMargin = GetPropertyFromParaStyleSheet(PROP_PARA_LEFT_MARGIN);
                            if ( aMargin != uno::Any() )
                                xParaProps->setPropertyValue("ParaLeftMargin", aMargin);
                            else if (isNumberingViaStyle)
                            {
                                const sal_Int32 nParaLeftMargin = getNumberingProperty(nListId, pStyleSheetProperties->GetListLevel(), "IndentAt");
                                if (nParaLeftMargin != 0)
                                    xParaProps->setPropertyValue("ParaLeftMargin", uno::makeAny(nParaLeftMargin));
                            }
                        }
                        if ( !bRightSet )
                        {
@@ -1870,6 +1877,12 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                            uno::Any aMargin = GetPropertyFromParaStyleSheet(PROP_PARA_FIRST_LINE_INDENT);
                            if ( aMargin != uno::Any() )
                                xParaProps->setPropertyValue("ParaFirstLineIndent", aMargin);
                            else if (isNumberingViaStyle)
                            {
                                const sal_Int32 nFirstLineIndent = getNumberingProperty(nListId, pStyleSheetProperties->GetListLevel(), "FirstLineIndent");
                                if (nFirstLineIndent != 0)
                                    xParaProps->setPropertyValue("ParaFirstLineIndent", uno::makeAny(nFirstLineIndent));
                            }
                        }
                    }
                }