summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-06 09:31:28 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-06 12:40:59 +0200
commit757a73379dba01fde853443a09583d862c404531 (patch)
tree1438883003eed76e6477c2967dacd7580db16a9d
parentcb5285d544a355026a38c69ccf5473956d60e4ee (diff)
Related: cool#7373 add an SfxHintId::ThisIsAnSfxEventHint
to avoid cost of dynamic_cast of SdrHint to SfxEventHint Change-Id: Ie0366b7d7ba828d8ffabeed4d65d7c7b275a3ed4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157633 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r--include/sfx2/event.hxx12
-rw-r--r--include/svl/hint.hxx3
-rw-r--r--sc/source/ui/app/inputwin.cxx6
-rw-r--r--sc/source/ui/docshell/docsh.cxx11
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx6
-rw-r--r--sc/source/ui/navipi/navipi.cxx5
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx10
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx8
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx13
-rw-r--r--sfx2/source/view/viewfrm.cxx4
-rw-r--r--sfx2/source/view/viewsh.cxx6
-rw-r--r--svx/source/form/fmundo.cxx4
-rw-r--r--sw/source/uibase/app/apphdl.cxx7
-rw-r--r--sw/source/uibase/app/docsh2.cxx15
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx5
-rw-r--r--sw/source/uibase/uno/unoatxt.cxx5
-rw-r--r--sw/source/uibase/utlui/navipi.cxx4
17 files changed, 62 insertions, 62 deletions
diff --git a/include/sfx2/event.hxx b/include/sfx2/event.hxx
index 021472830ab8..1024dd5b2423 100644
--- a/include/sfx2/event.hxx
+++ b/include/sfx2/event.hxx
@@ -196,11 +196,13 @@ class SFX2_DLLPUBLIC SfxEventHint : public SfxHint
SfxEventHintId nEventId;
public:
- SfxEventHint( SfxEventHintId nId, OUString aName, SfxObjectShell *pObj )
- : pObjShell(pObj),
- aEventName(std::move(aName)),
- nEventId(nId)
- {}
+ SfxEventHint(SfxEventHintId nId, OUString aName, SfxObjectShell *pObj)
+ : SfxHint(SfxHintId::ThisIsAnSfxEventHint)
+ , pObjShell(pObj)
+ , aEventName(std::move(aName))
+ , nEventId(nId)
+ {
+ }
SfxEventHintId GetEventId() const
{ return nEventId; }
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index 91533d4ffdbb..ec0c7b1d9872 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -155,7 +155,8 @@ enum class SfxHintId {
SwVirtPageNumHint,
SwAutoFormatUsedHint,
- ThisIsAnSdrHint
+ ThisIsAnSdrHint,
+ ThisIsAnSfxEventHint
};
template< typename charT, typename traits >
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 802d2d7087e5..2bb29146da07 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -2443,16 +2443,16 @@ void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
if ( bFormulaMode )
return;
+ const SfxHintId nHintId = rHint.GetId();
// Does the list of range names need updating?
- if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+ if (nHintId == SfxHintId::ThisIsAnSfxEventHint)
{
- SfxEventHintId nEventId = pEventHint->GetEventId();
+ SfxEventHintId nEventId = static_cast<const SfxEventHint&>(rHint).GetEventId();
if ( nEventId == SfxEventHintId::ActivateDoc )
FillRangeNames();
}
else
{
- const SfxHintId nHintId = rHint.GetId();
if (nHintId == SfxHintId::ScAreasChanged || nHintId == SfxHintId::ScNavigatorUpdateAll)
FillRangeNames();
}
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index a869e740083c..96a1ff9407ff 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -707,11 +707,9 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
m_pAutoStyleList.reset( new ScAutoStyleList(this) );
m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
}
- else if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+ else if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- SfxEventHintId nEventId = pEventHint->GetEventId();
-
- switch ( nEventId )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::LoadFinished:
{
@@ -1080,11 +1078,10 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
}
- const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if (!pSfxEventHint)
+ if (rHint.GetId() != SfxHintId::ThisIsAnSfxEventHint)
return;
- switch( pSfxEventHint->GetEventId() )
+ switch(static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::CreateDoc:
{
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 523bd746cb84..24fb7a808e6d 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -3289,12 +3289,10 @@ void ScExternalRefManager::transformUnsavedRefToSavedRef( SfxObjectShell* pShell
void ScExternalRefManager::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if ( !pEventHint )
+ if (rHint.GetId() != SfxHintId::ThisIsAnSfxEventHint)
return;
- SfxEventHintId nEventId = pEventHint->GetEventId();
- switch ( nEventId )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::PrepareCloseDoc:
{
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index d7682d93a101..1c83bd703623 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -488,9 +488,10 @@ ScNavigatorDlg::~ScNavigatorDlg()
void ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- if (const SfxEventHint* pHint = dynamic_cast<const SfxEventHint*>(&rHint))
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- if (pHint->GetEventId() == SfxEventHintId::ActivateDoc)
+ const SfxEventHint& rEventHint = static_cast<const SfxEventHint&>(rHint);
+ if (rEventHint.GetEventId() == SfxEventHintId::ActivateDoc)
{
UpdateSheetLimits();
bool bRefreshed = m_xLbEntries->ActiveDocChanged();
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 6ad6d454be57..9737245f89ff 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -402,10 +402,11 @@ void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
{
SfxViewShell::Notify(rBC, rHint);
- const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if (pEventHint)
+ const SfxHintId nHintId = rHint.GetId();
+
+ if (nHintId == SfxHintId::ThisIsAnSfxEventHint)
{
- switch (pEventHint->GetEventId())
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::OpenDoc:
if( GetDocument() && GetDocument()->IsStartWithPresentation() )
@@ -421,8 +422,7 @@ void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
}
else
{
- const SfxHintId nSlot = rHint.GetId();
- switch ( nSlot )
+ switch (nHintId)
{
case SfxHintId::LanguageChanged:
{
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index bc7a339bc853..cb3b0d5872be 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -161,16 +161,16 @@ void SfxPickListImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
INetURLHistory::GetOrCreate()->PutUrl( INetURLObject( pOpenUrlHint->GetDocumentURL() ));
}
- const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if ( !pEventHint )
+ if (rHint.GetId() != SfxHintId::ThisIsAnSfxEventHint)
return;
+ const SfxEventHint& rEventHint = static_cast<const SfxEventHint&>(rHint);
// only ObjectShell-related events with media interest
- SfxObjectShell* pDocSh = pEventHint->GetObjShell();
+ SfxObjectShell* pDocSh = rEventHint.GetObjShell();
if( !pDocSh )
return;
- switch ( pEventHint->GetEventId() )
+ switch (rEventHint.GetEventId())
{
case SfxEventHintId::CreateDoc:
{
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 43d4bf3bdc19..b3d0d78b5e2a 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -2873,12 +2873,10 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
if ( rHint.GetId() == SfxHintId::DocChanged )
changing();
-
- const SfxEventHint* pNamedHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if ( pNamedHint )
+ else if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
-
- switch ( pNamedHint->GetEventId() )
+ const SfxEventHint& rNamedHint = static_cast<const SfxEventHint&>(rHint);
+ switch (rNamedHint.GetEventId())
{
case SfxEventHintId::StorageChanged:
{
@@ -2945,10 +2943,9 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
if (const SfxPrintingHint* pPrintingHint = dynamic_cast<const SfxPrintingHint*>(&rHint))
aSupplement <<= pPrintingHint->GetWhich();
const SfxViewEventHint* pViewHint = dynamic_cast<const SfxViewEventHint*>(&rHint);
- postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >(), aSupplement );
+ postEvent_Impl( rNamedHint.GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >(), aSupplement );
}
-
- if ( rHint.GetId() == SfxHintId::TitleChanged )
+ else if ( rHint.GetId() == SfxHintId::TitleChanged )
{
addTitle_Impl( m_pData->m_seqArguments, m_pData->m_pObjectShell->GetTitle() );
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 8906fdce681e..f6077147157e 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1437,12 +1437,12 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
return;
// we know only SfxEventHint or simple SfxHint
- if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint))
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
// When the Document is loaded asynchronously, was the Dispatcher
// set as ReadOnly, to what must be returned when the document itself
// is not read only, and the loading is finished.
- switch ( pEventHint->GetEventId() )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::ModifyChanged:
{
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 34298882fe71..7eb479e57156 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2549,9 +2549,11 @@ SfxViewShell* SfxViewShell::GetNext
void SfxViewShell::Notify( SfxBroadcaster& rBC,
const SfxHint& rHint )
{
- const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if ( !(pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished) )
+ if (rHint.GetId() != SfxHintId::ThisIsAnSfxEventHint ||
+ static_cast<const SfxEventHint&>(rHint).GetEventId() != SfxEventHintId::LoadFinished)
+ {
return;
+ }
if ( !GetController().is() )
return;
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx
index 62374ff96ca8..80aea1c8a35e 100644
--- a/svx/source/form/fmundo.cxx
+++ b/svx/source/form/fmundo.cxx
@@ -321,9 +321,9 @@ void FmXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
default: break;
}
}
- else if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint))
+ else if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- switch (pEventHint->GetEventId())
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::CreateDoc:
case SfxEventHintId::OpenDoc:
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index fd687268eebd..cd073097f771 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -868,13 +868,14 @@ void SwModule::ExecOther(SfxRequest& rReq)
// Catch hint for DocInfo
void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
- if( const SfxEventHint* pEvHint = dynamic_cast<const SfxEventHint*>( &rHint) )
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- SwDocShell* pDocSh = dynamic_cast<SwDocShell*>( pEvHint->GetObjShell() );
+ const SfxEventHint& rEvHint = static_cast<const SfxEventHint&>(rHint);
+ SwDocShell* pDocSh = dynamic_cast<SwDocShell*>(rEvHint.GetObjShell());
if( pDocSh )
{
SwWrtShell* pWrtSh = pDocSh->GetWrtShell();
- switch( pEvHint->GetEventId() )
+ switch (rEvHint.GetEventId())
{
case SfxEventHintId::LoadFinished:
// if it is a new document created from a template,
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 978601285ce0..e812abb5d543 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -213,12 +213,11 @@ void SwDocShell::DoFlushDocInfo()
static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint )
{
using namespace com::sun::star::script::vba::VBAEventId;
- const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if ( !pSfxEventHint )
+ if (rHint.GetId() != SfxHintId::ThisIsAnSfxEventHint)
return;
uno::Sequence< uno::Any > aArgs;
- switch( pSfxEventHint->GetEventId() )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::CreateDoc:
xVbaEvents->processVbaEvent(AUTO_NEW, aArgs);
@@ -245,9 +244,9 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
if( xVbaEvents.is() )
lcl_processCompatibleSfxHint( xVbaEvents, rHint );
- if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- switch( pSfxEventHint->GetEventId() )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::ActivateDoc:
case SfxEventHintId::CreateDoc:
@@ -261,7 +260,7 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
break;
}
- switch( pSfxEventHint->GetEventId() )
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
{
case SfxEventHintId::CreateDoc:
{
@@ -285,8 +284,8 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
sal_uInt16 nAction = 0;
- auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
- if( pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished )
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint &&
+ static_cast<const SfxEventHint&>(rHint).GetEventId() == SfxEventHintId::LoadFinished)
{
// #i38126# - own action id
nAction = 3;
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 64f5ff4f47d5..1cd06889f4bc 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -343,9 +343,10 @@ void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- if ( pSfxEventHint->GetEventId() == SfxEventHintId::SwEventLayoutFinished )
+ const SfxEventHint& rSfxEventHint = static_cast<const SfxEventHint&>(rHint);
+ if (rSfxEventHint.GetEventId() == SfxEventHintId::SwEventLayoutFinished)
{
if ( !mbWaitingForCalcRects && !mvPostItFields.empty())
{
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index 336d4ce6d244..071aef8c05ea 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -680,9 +680,10 @@ void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
return;
// it's our document
- if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&_rHint))
+ if (_rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- if (SfxEventHintId::PrepareCloseDoc == pEventHint->GetEventId())
+ const SfxEventHint& rEventHint = static_cast<const SfxEventHint&>(_rHint);
+ if (SfxEventHintId::PrepareCloseDoc == rEventHint.GetEventId())
{
implFlushDocument();
mxBodyText.clear();
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index 460d4347766f..ad89c6b1a7bb 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -866,9 +866,9 @@ void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
}
else
{
- if (const SfxEventHint* pHint = dynamic_cast<const SfxEventHint*>(&rHint))
+ if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint)
{
- SfxEventHintId eEventId = pHint->GetEventId();
+ SfxEventHintId eEventId = static_cast<const SfxEventHint&>(rHint).GetEventId();
if (eEventId == SfxEventHintId::OpenDoc)
{
SwView *pActView = GetCreateView();