tdf#158773 reduce dynamic_cast'ing in CustomShapeProperties::Notify
shaves 2% off the load time
Change-Id: I579825bd6101b57a44b0f3118ede17ec2393d9d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164477
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 0469d43..6b1a303 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -152,7 +152,7 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() );
RemoveStyleFromParagraphs( pStyle );
}
else if ( nId == SfxHintId::StyleSheetModified )
else if ( nId == SfxHintId::StyleSheetModified || nId == SfxHintId::StyleSheetModifiedExtended )
{
const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint);
SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() );
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index ec0c7b1..860ea42 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -104,6 +104,7 @@ enum class SfxHintId {
// SFX stylesheet
StyleSheetCreated, // new
StyleSheetModified, // changed
StyleSheetModifiedExtended, // changed, but using the SfxStyleSheetModifiedHint, not the SfxStyleSheetHint
StyleSheetChanged, // erased and re-created (replaced)
StyleSheetErased, // erased
StyleSheetInDestruction, // in the process of being destructed
@@ -229,6 +230,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
case SfxHintId::ScAccWindowResized: return stream << "ScAccWindowResized";
case SfxHintId::StyleSheetCreated: return stream << "StyleSheetCreated";
case SfxHintId::StyleSheetModified: return stream << "StyleSheetModified";
case SfxHintId::StyleSheetModifiedExtended: return stream << "StyleSheetModifiedExtended";
case SfxHintId::StyleSheetChanged: return stream << "StyleSheetChanged";
case SfxHintId::StyleSheetErased: return stream << "StyleSheetErased";
case SfxHintId::StyleSheetInDestruction: return stream << "StyleSheetInDestruction";
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index ade0ced..860e8c2 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -419,7 +419,7 @@ void UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument* pDoc)
void ScConditionFrmtEntry::Notify(SfxBroadcaster&, const SfxHint& rHint)
{
if(rHint.GetId() == SfxHintId::StyleSheetModified)
if(rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetModifiedExtended)
{
if(!mbIsInStyleCreate)
UpdateStyleList(*mxLbStyle, mpDoc);
@@ -1282,7 +1282,7 @@ void ScDateFrmtEntry::SetInactive()
void ScDateFrmtEntry::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
if(rHint.GetId() == SfxHintId::StyleSheetModified)
if(rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetModifiedExtended)
{
if(!mbIsInStyleCreate)
UpdateStyleList(*mxLbStyle, mpDoc);
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx b/sc/source/ui/condformat/condformateasydlg.cxx
index a368ec3..ba28d1e 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -154,7 +154,8 @@ ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() {}
void ConditionalFormatEasyDialog::Notify(SfxBroadcaster&, const SfxHint& rHint)
{
if (rHint.GetId() == SfxHintId::StyleSheetModified)
if (rHint.GetId() == SfxHintId::StyleSheetModified
|| rHint.GetId() == SfxHintId::StyleSheetModifiedExtended)
UpdateStyleList(mpDocument, *mxStyles);
}
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index ca2f5d2..a9419db 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1677,16 +1677,17 @@ void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint )
if ( pStyle->GetFamily() == SfxStyleFamily::Page )
{
if ( nId == SfxHintId::StyleSheetModified )
if ( nId == SfxHintId::StyleSheetModified || nId == SfxHintId::StyleSheetModifiedExtended )
{
ScDocShellModificator aModificator( *this );
const OUString& aNewName = pStyle->GetName();
OUString aOldName = aNewName;
const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint); // name changed?
if (pExtendedHint)
aOldName = pExtendedHint->GetOldName();
if ( nId == SfxHintId::StyleSheetModifiedExtended )
{
const SfxStyleSheetModifiedHint& rExtendedHint = static_cast<const SfxStyleSheetModifiedHint&>(rHint); // name changed?
aOldName = rExtendedHint.GetOldName();
}
if ( aNewName != aOldName )
m_pDocument->RenamePageStyleInUse( aOldName, aNewName );
@@ -1701,7 +1702,7 @@ void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint )
aModificator.SetDocumentModified();
if (pExtendedHint)
if (nId == SfxHintId::StyleSheetModifiedExtended)
{
SfxBindings* pBindings = GetViewBindings();
if (pBindings)
@@ -1717,13 +1718,11 @@ void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint )
}
else if ( pStyle->GetFamily() == SfxStyleFamily::Para )
{
if ( nId == SfxHintId::StyleSheetModified)
if (nId == SfxHintId::StyleSheetModifiedExtended)
{
const SfxStyleSheetModifiedHint& rExtendedHint = static_cast<const SfxStyleSheetModifiedHint&>(rHint);
const OUString& aNewName = pStyle->GetName();
OUString aOldName = aNewName;
const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint);
if (pExtendedHint)
aOldName = pExtendedHint->GetOldName();
const OUString& aOldName = rExtendedHint.GetOldName();
if ( aNewName != aOldName )
{
for(SCTAB i = 0; i < m_pDocument->GetTableCount(); ++i)
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index 2b347c8..9fc6707 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -434,6 +434,7 @@ namespace sdr::properties
break;
}
case SfxHintId::StyleSheetModified :
case SfxHintId::StyleSheetModifiedExtended:
case SfxHintId::StyleSheetChanged :
{
// notify change
diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx
index c48e4d3..ddf530e 100644
--- a/svx/source/sdr/properties/customshapeproperties.cxx
+++ b/svx/source/sdr/properties/customshapeproperties.cxx
@@ -206,7 +206,9 @@ namespace sdr::properties
bool bRemoveRenderGeometry = false;
if (rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetChanged)
if (rHint.GetId() == SfxHintId::StyleSheetModified ||
rHint.GetId() == SfxHintId::StyleSheetModifiedExtended ||
rHint.GetId() == SfxHintId::StyleSheetChanged)
{
const SfxStyleSheetHint* pStyleHint = static_cast<const SfxStyleSheetHint*>(&rHint);
if ( pStyleHint->GetStyleSheet() == GetStyleSheet() )
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 17f63d0..42a71dd 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -588,24 +588,22 @@ namespace sdr::properties
pParaObj->ClearPortionInfo();
}
}
else if (nId == SfxHintId::StyleSheetModified && dynamic_cast<const SfxStyleSheetBasePool *>(&rBC) != nullptr)
else if (nId == SfxHintId::StyleSheetModifiedExtended)
{
const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint);
if (pExtendedHint)
{
const OUString& aOldName(pExtendedHint->GetOldName());
OUString aNewName(pExtendedHint->GetStyleSheet()->GetName());
SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily();
assert(dynamic_cast<const SfxStyleSheetBasePool *>(&rBC) != nullptr);
const SfxStyleSheetModifiedHint& rExtendedHint = static_cast<const SfxStyleSheetModifiedHint&>(rHint);
const OUString& aOldName(rExtendedHint.GetOldName());
OUString aNewName(rExtendedHint.GetStyleSheet()->GetName());
SfxStyleFamily eFamily = rExtendedHint.GetStyleSheet()->GetFamily();
if(aOldName != aNewName)
if(aOldName != aNewName)
{
sal_Int32 nText = rTextProvider.getTextCount();
while (nText--)
{
sal_Int32 nText = rTextProvider.getTextCount();
while (nText--)
{
OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject();
if( pParaObj )
pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName);
}
OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject();
if( pParaObj )
pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName);
}
}
}
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index da560fe..d7f46bd 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -173,7 +173,8 @@ StylePoolChangeListener::~StylePoolChangeListener()
void StylePoolChangeListener::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
{
if (rHint.GetId() == SfxHintId::StyleSheetModified)
if (rHint.GetId() == SfxHintId::StyleSheetModified
|| rHint.GetId() == SfxHintId::StyleSheetModifiedExtended)
StylePreviewCache::ClearCache(true);
m_pPreviewControl->RequestStylesListUpdate();
}
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 7863c45..89cf505 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -142,13 +142,15 @@ public:
auto nId = pHint->GetId();
auto pDocStyleSheet = pHint->GetStyleSheet();
auto pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint);
const SfxStyleSheetModifiedHint* pExtendedHint = nullptr;
if (nId == SfxHintId::StyleSheetModifiedExtended)
pExtendedHint = static_cast<const SfxStyleSheetModifiedHint*>(&rHint);
const OUString aName = pExtendedHint ? pExtendedHint->GetOldName() : pDocStyleSheet->GetName();
auto pStyleSheet = SfxStyleSheetPool::Find(aName, pDocStyleSheet->GetFamily());
if (!pStyleSheet)
return;
if (nId == SfxHintId::StyleSheetModified)
if (nId == SfxHintId::StyleSheetModified || nId == SfxHintId::StyleSheetModifiedExtended)
{
pStyleSheet->SetName(pDocStyleSheet->GetName());
UpdateStyleHierarchyFrom(pStyleSheet, pDocStyleSheet);