diff options
author | László Németh <nemeth@numbertext.org> | 2019-09-05 16:23:00 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-09-06 13:38:34 +0200 |
commit | 9f6d1d5c4c75c51f36815178507e336c504025fb (patch) | |
tree | 8f3823416e4bd67886a6ea5d09ad7cd9ec7a6333 /writerfilter | |
parent | 04163422234d1becac05b16c7460518277294d6b (diff) |
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@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 33 |
1 files changed, 17 insertions, 16 deletions
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"); |