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>
This commit is contained in:
@@ -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() );
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -434,6 +434,7 @@ namespace sdr::properties
|
||||
break;
|
||||
}
|
||||
case SfxHintId::StyleSheetModified :
|
||||
case SfxHintId::StyleSheetModifiedExtended:
|
||||
case SfxHintId::StyleSheetChanged :
|
||||
{
|
||||
// notify change
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user