diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-06 09:31:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-06 12:40:59 +0200 |
commit | 757a73379dba01fde853443a09583d862c404531 (patch) | |
tree | 1438883003eed76e6477c2967dacd7580db16a9d /sw | |
parent | cb5285d544a355026a38c69ccf5473956d60e4ee (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>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uno/unoatxt.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/utlui/navipi.cxx | 4 |
5 files changed, 19 insertions, 17 deletions
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(); |