summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-11-17 16:54:12 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-11-17 16:55:12 +0100
commitc03b691a7cd8eba128204c851b99e0b75c580c0c (patch)
treeecb0cc408f689c65170f91d707cedc291dd74939 /writerfilter
parent521185705d062e9526a8a3e0bc485c943e83eb0e (diff)
DOCX import: handle <w:numId> from parent styles as well
Without this, we may miss the <w:numId> of a paragraph and set no numbering style name; and that leads to not restarting numberings when needed. Change-Id: I9a4896266c5b7f1d7cc2adc43b84e227c004da7c
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx29
1 files changed, 27 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c393ad9fed45..5b00fd6ad43d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1099,6 +1099,30 @@ static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl*
return bExchangeLeftRight;
}
+/// Check if the style or its parent has a list id, recursively.
+static sal_Int32 lcl_getListId(const StyleSheetEntryPtr pEntry, const StyleSheetTablePtr pStyleTable)
+{
+ const StyleSheetPropertyMap* pEntryProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry->pProperties.get());
+ if (!pEntryProperties)
+ return -1;
+
+ sal_Int32 nListId = pEntryProperties->GetListId();
+ // The style itself has a list id.
+ if (nListId >= 0)
+ return nListId;
+
+ // The style has no parent.
+ if (pEntry->sBaseStyleIdentifier.isEmpty())
+ return -1;
+
+ const StyleSheetEntryPtr pParent = pStyleTable->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
+ // No such parent style or loop in the style hierarchy.
+ if (!pParent || pParent == pEntry)
+ return -1;
+
+ return lcl_getListId(pParent, pStyleTable);
+}
+
void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
{
// These SPRM's are not specific to any section, so it's expected that there is no context yet.
@@ -1976,10 +2000,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
OSL_ENSURE( pEntry.get(), "no style sheet found" );
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
- if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
+ sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, pStyleTable) : -1;
+ if( pStyleSheetProperties && nListId >= 0 )
{
rContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny(
- ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), false);
+ ListDef::GetStyleName( nListId ) ), 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;