summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-05-05 14:00:12 +0200
committerLászló Németh <nemeth@numbertext.org>2020-05-06 09:01:19 +0200
commit38016653cb9b338d6287c06a49663252f636f548 (patch)
tree6ffdea78c17c1ea574dc504a625436d9118aeb60
parentdadbdf6674154d2052f4ae14afed3bcee392010d (diff)
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>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf108493.docxbin0 -> 27322 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx19
3 files changed, 25 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf108493.docx b/sw/qa/extras/ooxmlexport/data/tdf108493.docx
new file mode 100644
index 000000000000..f1a51525ee71
--- /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 806f4d0097df..51395c0f1b54 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 0465981ca6ba..bbef06695434 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));
+ }
}
}
}