diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-09-03 15:46:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-09-04 13:02:56 +0200 |
commit | f2d096099a220e4caa2d532a5230785cbdb91eed (patch) | |
tree | 230bcc7ab089d2948c321c6d2df3a089f064bc0b /sc/source/ui/unoobj | |
parent | 12f5c69ead6765dd3711db335763caf2df4e049f (diff) |
use less dynamic_cast when broadcasting SfxHint in sc
Change-Id: I25ee079b5b14f82012f868ae6b348fa6982571a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172853
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r-- | sc/source/ui/unoobj/PivotTableDataProvider.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 21 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/datauno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/unoobj/editsrc.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fielduno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/linkuno.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/unoobj/unoreflist.cxx | 2 |
10 files changed, 37 insertions, 33 deletions
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx index 16a8237e391b..5dc82b93bff0 100644 --- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx +++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx @@ -160,8 +160,9 @@ void PivotTableDataProvider::Notify(SfxBroadcaster& /*rBroadcaster*/, const SfxH } else if (m_pDocument) { - if (auto pDataPilotHint = dynamic_cast<const ScDataPilotModifiedHint*>(&rHint)) + if (rHint.GetId() == SfxHintId::ScDataPilotModified) { + auto pDataPilotHint = static_cast<const ScDataPilotModifiedHint*>(&rHint); if (pDataPilotHint->GetName() == m_sPivotTableName) { m_bNeedsUpdate = true; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 2c777b43178b..4d4bf1a03c5a 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1531,8 +1531,9 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) if ( !aValueListeners.empty() ) bGotDataChangedHint = true; } - else if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + else if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { + auto pRefHint = static_cast<const ScUpdateRefHint*>(&rHint); ScDocument& rDoc = pDocShell->GetDocument(); std::unique_ptr<ScRangeList> pUndoRanges; if ( rDoc.HasUnoRefUndo() ) @@ -1563,8 +1564,9 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) rDoc.AddUnoRefChange( nObjectId, *pUndoRanges ); } } - else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) + else if ( rHint.GetId() == SfxHintId::ScUnoRefUndo ) { + auto pUndoHint = static_cast<const ScUnoRefUndoHint*>(&rHint); if ( pUndoHint->GetObjectId() == nObjectId ) { // restore ranges from hint @@ -8584,8 +8586,9 @@ ScCellsObj::~ScCellsObj() void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { + auto pRefHint = static_cast<const ScUpdateRefHint*>(&rHint); aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(), pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ); } @@ -8695,9 +8698,9 @@ void ScCellsEnumeration::Advance_Impl() void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - const ScUpdateRefHint* pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint); - if ( pRefHint ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { + const ScUpdateRefHint* pRefHint = static_cast<const ScUpdateRefHint*>(&rHint); if (pDocShell) { aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(), @@ -8767,7 +8770,7 @@ ScCellFormatsObj::~ScCellFormatsObj() void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! aTotalRange... } @@ -8929,7 +8932,7 @@ rtl::Reference<ScCellRangeObj> ScCellFormatsEnumeration::NextObject_Impl() void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! and now??? } @@ -8978,7 +8981,7 @@ ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj() void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! aTotalRange... } @@ -9234,7 +9237,7 @@ ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration() void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! and now ??? } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index dbfd8887d810..8957416e4025 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2802,7 +2802,7 @@ void ScChart2DataSequence::StopListeningToAllExternalRefs() void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { // Create a range list from the token list, have the range list // updated, and bring the change back to the token list. @@ -2846,8 +2846,9 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint m_pDocument->AddUnoRefChange(m_nObjectId, *pUndoRanges); } } - else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) + else if ( rHint.GetId() == SfxHintId::ScUnoRefUndo ) { + auto pUndoHint = static_cast<const ScUnoRefUndoHint*>(&rHint); do { if (pUndoHint->GetObjectId() != m_nObjectId) diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index dde9fded610f..5e3871481456 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1219,8 +1219,9 @@ void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if (pDataPilotHint->GetName() == aName) Refreshed_Impl(); } - else if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + else if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { + auto pRefHint = static_cast<const ScUpdateRefHint*>(&rHint); ScRange aRange( 0, 0, nTab ); ScRangeList aRanges( aRange ); if ( aRanges.UpdateReference( pRefHint->GetMode(), &GetDocShell()->GetDocument(), pRefHint->GetRange(), diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 839e328b420f..bb31d5f9e7fc 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1592,8 +1592,9 @@ void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) if ( rHint.GetId() == SfxHintId::Dying ) pDocShell = nullptr; - else if ( auto pRefreshHint = dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) ) + else if ( rHint.GetId() == SfxHintId::ScDBRangeRefreshed ) { + auto pRefreshHint = static_cast<const ScDBRangeRefreshedHint*>(&rHint); ScDBData* pDBData = GetDBData_Impl(); ScImportParam aParam; pDBData->GetImportParam(aParam); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 9ace7d808b48..e1a4fdb9ec14 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -4527,7 +4527,7 @@ ScTableColumnsObj::~ScTableColumnsObj() void ScTableColumnsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! update of references for sheet and its start/end } @@ -4782,7 +4782,7 @@ ScTableRowsObj::~ScTableRowsObj() void ScTableRowsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! update of references for sheet and its start/end } @@ -5201,7 +5201,7 @@ ScScenariosObj::~ScScenariosObj() void ScScenariosObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! update of references for sheet and its start/end } diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx index d39358e61f7d..5bedf4ece637 100644 --- a/sc/source/ui/unoobj/editsrc.cxx +++ b/sc/source/ui/unoobj/editsrc.cxx @@ -183,7 +183,7 @@ void ScAnnotationEditSource::UpdateData() void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! reference update } diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index e3359d02d0e4..e14cfaa4cfcb 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -299,7 +299,7 @@ ScCellFieldsObj::~ScCellFieldsObj() void ScCellFieldsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScUpdateRef ) { //! update of references } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 33d27d8c8f8d..53e34a58a059 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -94,8 +94,9 @@ void ScSheetLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( auto pRefreshHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScLinkRefreshed ) { + auto pRefreshHint = static_cast<const ScLinkRefreshedHint*>(&rHint); if ( pRefreshHint->GetLinkType() == ScLinkRefType::SHEET && pRefreshHint->GetUrl() == aFileName ) Refreshed_Impl(); } @@ -590,8 +591,9 @@ void ScAreaLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( auto pRefreshedHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScLinkRefreshed ) { + auto pRefreshedHint = static_cast<const ScLinkRefreshedHint*>(&rHint); if ( pRefreshedHint->GetLinkType() == ScLinkRefType::AREA ) { // get this link to compare dest position @@ -600,11 +602,8 @@ void ScAreaLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) Refreshed_Impl(); } } - else - { - if ( rHint.GetId() == SfxHintId::Dying ) - pDocShell = nullptr; // pointer is invalid - } + else if ( rHint.GetId() == SfxHintId::Dying ) + pDocShell = nullptr; // pointer is invalid } // XFileLink @@ -1010,19 +1009,17 @@ void ScDDELinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) //! notify if links in document are changed // UpdateRef is not needed here - if ( auto pRefreshedHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) ) + if ( rHint.GetId() == SfxHintId::ScLinkRefreshed ) { + auto pRefreshedHint = static_cast<const ScLinkRefreshedHint*>(&rHint); if ( pRefreshedHint->GetLinkType() == ScLinkRefType::DDE && pRefreshedHint->GetDdeAppl() == aAppl && pRefreshedHint->GetDdeTopic() == aTopic && pRefreshedHint->GetDdeItem() == aItem ) //! mode is ignored Refreshed_Impl(); } - else - { - if ( rHint.GetId() == SfxHintId::Dying ) - pDocShell = nullptr; // pointer is invalid - } + else if ( rHint.GetId() == SfxHintId::Dying ) + pDocShell = nullptr; // pointer is invalid } // XNamed diff --git a/sc/source/ui/unoobj/unoreflist.cxx b/sc/source/ui/unoobj/unoreflist.cxx index fff4d0fd9d08..101d0c9995fa 100644 --- a/sc/source/ui/unoobj/unoreflist.cxx +++ b/sc/source/ui/unoobj/unoreflist.cxx @@ -44,7 +44,7 @@ void ScUnoRefList::Undo( ScDocument* pDoc ) } ScUnoRefUndoHint::ScUnoRefUndoHint( ScUnoRefEntry aRefEntry ) : - aEntry(std::move( aRefEntry )) + SfxHint(SfxHintId::ScUnoRefUndo), aEntry(std::move( aRefEntry )) { } |