summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx56
1 files changed, 56 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4866e2d3b4b2..8f9476acbba9 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1443,6 +1443,38 @@ void DomainMapper::lcl_sprm(Sprm & rSprm)
sprmWithProps( rSprm, m_pImpl->GetTopContext() );
}
+sal_Int32 lcl_getCurrentNumberingProperty(uno::Reference<container::XIndexAccess> xNumberingRules, sal_Int32 nNumberingLevel, OUString aProp)
+{
+ sal_Int32 nRet = 0;
+
+ try
+ {
+ if (nNumberingLevel < 0) // It seems it's valid to omit numbering level, and in that case it means zero.
+ nNumberingLevel = 0;
+ if (xNumberingRules.is())
+ {
+ uno::Sequence<beans::PropertyValue> aProps;
+ xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aProps[i];
+
+ if (rProp.Name == aProp)
+ {
+ rProp.Value >>= nRet;
+ break;
+ }
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ // This can happen when the doc contains some hand-crafted invalid list level.
+ }
+
+ return nRet;
+}
+
void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmType )
{
OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!");
@@ -2970,9 +3002,33 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
+ {
rContext->Insert( PROP_NUMBERING_STYLE_NAME, true, uno::makeAny(
ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), 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 = pStyleTable->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
+ const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : 0);
+ if (pParentProperties->find( PropertyDefinition( PROP_PARA_RIGHT_MARGIN, true )) != pParentProperties->end())
+ nParaRightMargin = pParentProperties->find( PropertyDefinition( PROP_PARA_RIGHT_MARGIN, true ))->second.get<sal_Int32>();
+ }
+ if (nParaRightMargin != 0)
+ {
+ // If we're setting the right margin, we should set the first / left margin as well from the numbering style.
+ sal_Int32 nFirstLineIndent = lcl_getCurrentNumberingProperty(m_pImpl->GetCurrentNumberingRules(), pStyleSheetProperties->GetListLevel(), "FirstLineIndent");
+ sal_Int32 nParaLeftMargin = lcl_getCurrentNumberingProperty(m_pImpl->GetCurrentNumberingRules(), pStyleSheetProperties->GetListLevel(), "IndentAt");
+ if (nFirstLineIndent != 0)
+ rContext->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
+ if (nParaLeftMargin != 0)
+ rContext->Insert(PROP_PARA_LEFT_MARGIN, true, uno::makeAny(nParaLeftMargin));
+
+ rContext->Insert(PROP_PARA_RIGHT_MARGIN, true, uno::makeAny(nParaRightMargin));
+ }
+ }
+
if( pStyleSheetProperties && pStyleSheetProperties->GetListLevel() >= 0 )
rContext->Insert( PROP_NUMBERING_LEVEL, true, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
}