summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-05-15 12:51:29 +0300
committerJustin Luth <justin_luth@sil.org>2020-05-25 19:40:10 +0200
commit1f0fea553232c0b761d438b82644527a20dbc15a (patch)
tree068d1f6b372060451a4062fb723d5167aba2d977 /writerfilter
parent4bf172040dd2bd301b42269abf690188a2f9d698 (diff)
NFC writerfilter: reorganize and re-use variables
My previous patch for tdf#133000 modified the code flow a bit. I kept these "formatting" changes separate so that they wouldn't interfere in understanding the functional code changes (which is very important for this extremely fragile numbering code). In this patch, I relocate two lines to group them with their logically similar counterpart and the variables that control it. I also got really confused by one of my earlier code comments which seems to be completely wrong or at best misleading, so I modified it to be what I think is much more accurate. Change-Id: I3ab0bbfab436f70f81adc4af6db4c5b6c9eca8b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94367 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3021aec15c6c..155105c466df 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1373,12 +1373,14 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
bool isNumberingViaStyle(false);
bool isNumberingViaRule = pParaContext && pParaContext->GetListId() > -1;
- //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 )
{
+ //apply numbering level/style to paragraph if it was set at the style, but only if the paragraph itself
+ //does not specify the numbering
const sal_Int16 nListLevel = pStyleSheetProperties->GetListLevel();
+ if ( !isNumberingViaRule && nListLevel >= 0 )
+ pParaContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny(nListLevel), false );
bool bNumberingFromBaseStyle = false;
nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
@@ -1406,10 +1408,10 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
if ( isNumberingViaStyle )
{
- // Indent properties from the paragraph style have priority
- // over the ones from the numbering styles in Word
- // but in Writer numbering styles have priority,
- // so insert directly into the paragraph properties to compensate.
+ // When numbering is defined by the paragraph style, then the para-style indents have priority.
+ // But since import has just copied para-style's PROP_NUMBERING_STYLE_NAME directly onto the paragraph,
+ // the numbering indents now have the priority.
+ // So now import must also copy the para-style indents directly onto the paragraph to compensate.
std::optional<PropertyMap::Property> oProperty;
const StyleSheetEntryPtr pParent = (!pEntry->sBaseStyleIdentifier.isEmpty()) ? GetStyleSheetTable()->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier) : nullptr;
const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : nullptr);
@@ -1431,8 +1433,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
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");
- const sal_Int32 nParaLeftMargin = getNumberingProperty(nListId, pStyleSheetProperties->GetListLevel(), "IndentAt");
+ const sal_Int32 nFirstLineIndent = getNumberingProperty(nListId, nListLevel, "FirstLineIndent");
+ const sal_Int32 nParaLeftMargin = getNumberingProperty(nListId, nListLevel, "IndentAt");
if (nFirstLineIndent != 0)
pParaContext->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent), /*bOverwrite=*/false);
if (nParaLeftMargin != 0)
@@ -1441,8 +1443,6 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
pParaContext->Insert(PROP_PARA_RIGHT_MARGIN, uno::makeAny(nParaRightMargin), /*bOverwrite=*/false);
}
}
- if ( !isNumberingViaRule && pStyleSheetProperties->GetListLevel() >= 0 )
- pParaContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
}
// apply AutoSpacing: it has priority over all other margin settings