[Libreoffice-commits] core.git: writerfilter/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jul 11 09:55:52 UTC 2021
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 14 +++++++-------
writerfilter/source/dmapper/NumberingManager.cxx | 5 ++---
writerfilter/source/dmapper/StyleSheetTable.cxx | 17 ++++++++---------
writerfilter/source/dmapper/StyleSheetTable.hxx | 2 +-
4 files changed, 18 insertions(+), 20 deletions(-)
New commits:
commit 6b0029887edc57b51e2abd8b5c8f373f5d11418d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sun Jul 11 10:24:37 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 11 11:55:17 2021 +0200
pProperties in StyleSheetEntry is always StyleSheetPropertyMap
so we can avoid some dynamic casting, suggested by jluth
Change-Id: I9895d16c6228e01f802b369f4bdcf1ccc9bf6bfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118735
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c3d6e4efbe6d..1ab11e0b149f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -127,7 +127,7 @@ static void lcl_linenumberingHeaderFooter( const uno::Reference<container::XName
const StyleSheetEntryPtr pEntry = dmapper->GetStyleSheetTable()->FindStyleSheetByISTD( rname );
if (!pEntry)
return;
- const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>( pEntry->pProperties.get() );
+ const StyleSheetPropertyMap* pStyleSheetProperties = pEntry->pProperties.get();
if ( !pStyleSheetProperties )
return;
sal_Int32 nListId = pStyleSheetProperties->GetListId();
@@ -1204,7 +1204,7 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
if ( pParaStyle )
{
- const ParagraphProperties* pStyleProperties = dynamic_cast<const ParagraphProperties*>( pParaStyle->pProperties.get() );
+ const StyleSheetPropertyMap* pStyleProperties = pParaStyle->pProperties.get();
if (!pStyleProperties)
return;
sal_Int32 nWidth =
@@ -1424,7 +1424,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, bool & rNumberingFromBaseStyle)
{
- const StyleSheetPropertyMap* pEntryProperties = dynamic_cast<const StyleSheetPropertyMap*>(rEntry->pProperties.get());
+ const StyleSheetPropertyMap* pEntryProperties = rEntry->pProperties.get();
if (!pEntryProperties)
return -1;
@@ -1465,7 +1465,7 @@ sal_Int16 DomainMapper_Impl::GetListLevel(const StyleSheetEntryPtr& pEntry,
if (!pEntry)
return -1;
- const StyleSheetPropertyMap* pEntryProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry->pProperties.get());
+ const StyleSheetPropertyMap* pEntryProperties = pEntry->pProperties.get();
if (!pEntryProperties)
return -1;
@@ -1532,7 +1532,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( GetCurrentParaStyleName() );
OSL_ENSURE( pEntry, "no style sheet found" );
- const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
+ const StyleSheetPropertyMap* pStyleSheetProperties = pEntry ? pEntry->pProperties.get() : nullptr;
sal_Int32 nListId = pParaContext ? pParaContext->GetListId() : -1;
bool isNumberingViaStyle(false);
bool isNumberingViaRule = nListId > -1;
@@ -1585,7 +1585,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
// 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);
+ const StyleSheetPropertyMap* pParentProperties = pParent ? pParent->pProperties.get() : nullptr;
if (!pEntry->sBaseStyleIdentifier.isEmpty())
{
oProperty = pStyleSheetProperties->getProperty(PROP_PARA_FIRST_LINE_INDENT);
@@ -7612,7 +7612,7 @@ uno::Reference<container::XIndexAccess> DomainMapper_Impl::GetCurrentNumberingRu
const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(aStyle);
if (!pEntry)
return xRet;
- const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry->pProperties.get());
+ const StyleSheetPropertyMap* pStyleSheetProperties = pEntry->pProperties.get();
if (!pStyleSheetProperties)
return xRet;
sal_Int32 nListId = pStyleSheetProperties->GetListId();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 8f810b435365..f312d7080dcb 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -493,8 +493,7 @@ sal_uInt16 ListDef::GetChapterNumberingWeight() const
const StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle();
if (!pParaStyle)
continue;
- const StyleSheetPropertyMap& rProps =
- *static_cast<StyleSheetPropertyMap*>(pParaStyle->pProperties.get());
+ const StyleSheetPropertyMap& rProps = *pParaStyle->pProperties;
// In LO, the level's paraStyle outlineLevel always matches this listLevel.
// An undefined listLevel is treated as the first level.
sal_Int8 nListLevel = std::clamp<sal_Int8>(rProps.GetListLevel(), 0, 9);
@@ -1135,7 +1134,7 @@ AbstractListDef::Pointer ListsManager::GetAbstractList( sal_Int32 nId )
pStylesTable->FindStyleSheetByISTD(listDef->GetNumStyleLink() );
const StyleSheetPropertyMap* pStyleSheetProperties =
- dynamic_cast<const StyleSheetPropertyMap*>(pStyleSheetEntry ? pStyleSheetEntry->pProperties.get() : nullptr);
+ pStyleSheetEntry ? pStyleSheetEntry->pProperties.get() : nullptr;
if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
{
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 57df581ac9c8..ae9440be8381 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -172,7 +172,7 @@ PropertyMapPtr StyleSheetEntry::GetMergedInheritedProperties(const StyleSheetTab
if ( !pRet )
pRet = new PropertyMap;
- pRet->InsertProps(pProperties);
+ pRet->InsertProps(pProperties.get());
return pRet;
}
@@ -763,10 +763,10 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
break;
tools::SvRef<TablePropertiesHandler> pTblHandler(new TablePropertiesHandler());
- pTblHandler->SetProperties( m_pImpl->m_pCurrentEntry->pProperties );
+ pTblHandler->SetProperties( m_pImpl->m_pCurrentEntry->pProperties.get() );
if ( !pTblHandler->sprm( rSprm ) )
{
- m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties );
+ m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties.get() );
PropertyMapPtr pProps(new PropertyMap());
if (m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
@@ -802,7 +802,7 @@ void StyleSheetTable::lcl_entry(writerfilter::Reference<Properties>::Pointer_t r
OSL_ENSURE( !m_pImpl->m_pCurrentEntry, "current entry has to be NULL here");
StyleSheetEntryPtr pNewEntry( new StyleSheetEntry );
m_pImpl->m_pCurrentEntry = pNewEntry;
- m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties );
+ m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties.get() );
ref->resolve(*this);
//append it to the table
m_pImpl->m_rDMapper.PopStyleSheetProperties();
@@ -909,7 +909,7 @@ void StyleSheetTable::ApplyNumberingStyleNameToParaStyles()
for ( auto& pEntry : m_pImpl->m_aStyleSheetEntries )
{
StyleSheetPropertyMap* pStyleSheetProperties = nullptr;
- if ( pEntry->nStyleTypeCode == STYLE_TYPE_PARA && (pStyleSheetProperties = dynamic_cast<StyleSheetPropertyMap*>(pEntry->pProperties.get())) )
+ if ( pEntry->nStyleTypeCode == STYLE_TYPE_PARA && (pStyleSheetProperties = pEntry->pProperties.get()) )
{
// ListId 0 means turn off numbering - to cancel inheritance - so make sure that can be set.
if (pStyleSheetProperties->GetListId() > -1)
@@ -1003,7 +1003,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle ) );
xStyle.set(xStyles->getByName(sConvertedStyleName), uno::UNO_QUERY_THROW);
- StyleSheetPropertyMap* pPropertyMap = dynamic_cast<StyleSheetPropertyMap*>(pEntry->pProperties.get());
+ StyleSheetPropertyMap* pPropertyMap = pEntry->pProperties.get();
if (pPropertyMap && pPropertyMap->GetListId() == -1)
{
// No properties? Word default is 'none', Writer one is 'arabic', handle this.
@@ -1094,7 +1094,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
}
// Set the outline levels
- StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
+ StyleSheetPropertyMap* pStyleSheetProperties = pEntry ? pEntry->pProperties.get() : nullptr;
if ( pStyleSheetProperties )
{
@@ -1116,8 +1116,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
if (findIt != m_pImpl->m_aStyleSheetEntriesMap.end())
{
const auto& aSheetProps = findIt->second;
- StyleSheetPropertyMap& rStyleSheetProps
- = dynamic_cast<StyleSheetPropertyMap&>(*aSheetProps->pProperties);
+ StyleSheetPropertyMap& rStyleSheetProps = *aSheetProps->pProperties;
pStyleSheetProperties->SetListLevel(rStyleSheetProps.GetListLevel());
pStyleSheetProperties->SetOutlineLevel(rStyleSheetProps.GetOutlineLevel());
}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index 94e7d4112430..081d5ef0aa30 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -58,7 +58,7 @@ public:
OUString sBaseStyleIdentifier;
OUString sNextStyleIdentifier;
OUString sStyleName;
- const PropertyMapPtr pProperties; ///< always StyleSheetPropertyMap
+ const tools::SvRef<StyleSheetPropertyMap> pProperties;
OUString sConvertedStyleName;
std::vector<css::beans::PropertyValue> aLatentStyles; ///< Attributes of latentStyles
std::vector<css::beans::PropertyValue> aLsdExceptions; ///< List of lsdException attribute lists
More information about the Libreoffice-commits
mailing list