n#758883 dmapper: paragraph-level run props should affect numberings as well

Change-Id: I707105f6da53a6cb790d743738875acde561e20f
This commit is contained in:
Miklos Vajna
2012-06-19 09:30:11 +02:00
parent 14d6cf1f8f
commit 2123ede032
3 changed files with 53 additions and 0 deletions
@@ -1437,6 +1437,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
Value::Pointer_t pValue = rSprm.getValue();
sal_Int32 nIntValue = pValue->getInt();
rtl::OUString sStringValue = pValue->getString();
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
switch(nSprmId)
{
@@ -1983,6 +1984,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
rContext->Insert(ePropertyId, true, aBold );
if( nSprmId != NS_sprm::LN_CFBoldBi ) // sprmCFBoldBi
rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, true, aBold );
uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold);
}
break;
case 61: /*sprmCFItalic*/
@@ -2060,6 +2065,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
//Asian get the same value as Western
rContext->Insert( PROP_CHAR_HEIGHT, true, aVal );
rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, true, aVal );
uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal);
}
}
break;
@@ -3561,6 +3561,48 @@ void DomainMapper_Impl::ApplySettingsTable()
}
}
uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharStyle()
{
uno::Reference<beans::XPropertySet> xRet;
OUString aStyle = GetCurrentParaStyleId();
if (aStyle.isEmpty() || GetTopContextType() != CONTEXT_PARAGRAPH)
return xRet;
const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByISTD(aStyle);
if (!pEntry)
return xRet;
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
sal_Int32 nListId = pStyleSheetProperties->GetListId();
sal_Int32 nListLevel = pStyleSheetProperties->GetListLevel();
if (nListId < 0 || nListLevel < 0)
return xRet;
// So we are in a paragraph style and it has numbering. Look up the relevant character style.
OUString aListName = ListDef::GetStyleName(nListId);
uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xNumberingStyles;
xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xLevels(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(nListLevel) >>= aProps;
for (int i = 0; i < aProps.getLength(); ++i)
{
const beans::PropertyValue& rProp = aProps[i];
if (rProp.Name == "CharStyleName")
{
OUString aCharStyle;
rProp.Value >>= aCharStyle;
uno::Reference<container::XNameAccess> xCharacterStyles;
xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY);
break;
}
}
return xRet;
}
SectionPropertyMap * DomainMapper_Impl::GetSectionContext()
{
SectionPropertyMap* pSectionContext = 0;
@@ -613,6 +613,8 @@ public:
void ApplySettingsTable();
SectionPropertyMap * GetSectionContext();
/// If the current paragraph has a numbering style associated, this method returns its character style
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
};
} //namespace dmapper
} //namespace writerfilter