include/svl/hint.hxx | 6 ++++++ sc/inc/brdcst.hxx | 3 ++- sc/source/core/tool/chartlis.cxx | 3 +-- sc/source/core/tool/dbdata.cxx | 7 ++----- sc/source/core/tool/lookupcache.cxx | 3 +-- sc/source/core/tool/rangecache.cxx | 4 +--- sw/inc/tox.hxx | 5 +++-- sw/source/core/tox/tox.cxx | 8 ++++++-- 8 files changed, 22 insertions(+), 17 deletions(-)
New commits: commit 25446db3a951549492fba19fecb54c9347dd18ae Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 12 16:50:15 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 12 18:55:42 2022 +0200 elide some dynamic_cast Change-Id: I32c804e64cf219364e27ad6d9549c68c1f737a19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137003 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 3db9889a53fb..12f66eb5323a 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -70,6 +70,7 @@ enum class SfxHintId { ScReference, ScDrawLayerNew, ScDbAreasChanged, + ScAreaChanged, ScAreasChanged, ScTablesChanged, ScTablesRenamed, @@ -116,6 +117,8 @@ enum class SfxHintId { SwNavigatorUpdateTracking, SwNavigatorSelectOutlinesWithSelections, SwLegacyModify, + SwCollectTextMarks, + SwCollectTextTOXMarksForLayout, ThisIsAnSdrHint // used to avoid dynamic_cast }; @@ -163,6 +166,7 @@ inline std::basic_ostream<charT, traits> & operator <<( case SfxHintId::ScReference: return stream << "ScReference"; case SfxHintId::ScDrawLayerNew: return stream << "ScDrawLayerNew"; case SfxHintId::ScDbAreasChanged: return stream << "ScDbAreasChanged"; + case SfxHintId::ScAreaChanged: return stream << "ScAreaChanged"; case SfxHintId::ScAreasChanged: return stream << "ScAreasChanged"; case SfxHintId::ScTablesChanged: return stream << "ScTablesChanged"; case SfxHintId::ScTablesRenamed: return stream << "ScTablesRenamed"; @@ -200,6 +204,8 @@ inline std::basic_ostream<charT, traits> & operator <<( case SfxHintId::SwNavigatorUpdateTracking: return stream << "SwNavigatorUpdateTracking"; case SfxHintId::SwNavigatorSelectOutlinesWithSelections: return stream << "SwNavigatorSelectOutlinesWithSelections"; + case SfxHintId::SwCollectTextMarks: return stream << "SwCollectTextMarks"; + case SfxHintId::SwCollectTextTOXMarksForLayout: return stream << "SwCollectTextTOXMarksForLayout"; case SfxHintId::ThisIsAnSdrHint: return stream << "SdrHint"; default: return stream << "unk(" << std::to_string(int(id)) << ")"; } diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx index 9558723ba0ac..8b872857340b 100644 --- a/sc/inc/brdcst.hxx +++ b/sc/inc/brdcst.hxx @@ -42,7 +42,8 @@ class ScAreaChangedHint final : public SfxHint private: ScRange aNewRange; public: - ScAreaChangedHint(const ScRange& rRange) : aNewRange(rRange) {} + ScAreaChangedHint(const ScRange& rRange) + : SfxHint(SfxHintId::ScAreaChanged), aNewRange(rRange) {} const ScRange& GetRange() const { return aNewRange; } }; diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index 2fe7f97ee7ac..cadf8686bf0d 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -153,8 +153,7 @@ uno::Reference< chart::XChartData > ScChartListener::GetUnoSource() const void ScChartListener::Notify( const SfxHint& rHint ) { - const ScHint* p = dynamic_cast<const ScHint*>(&rHint); - if (p && (p->GetId() == SfxHintId::ScDataChanged)) + if (rHint.GetId() == SfxHintId::ScDataChanged) SetUpdateQueue(); } diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index e060fb25e422..841a863f15f0 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -916,12 +916,9 @@ OUString ScDBData::GetTableColumnName( SCCOL nCol ) const void ScDBData::Notify( const SfxHint& rHint ) { - const ScHint* pScHint = dynamic_cast<const ScHint*>(&rHint); - if (!pScHint) - return; - - if (pScHint->GetId() != SfxHintId::ScDataChanged) + if (rHint.GetId() != SfxHintId::ScDataChanged) return; + const ScHint* pScHint = static_cast<const ScHint*>(&rHint); mbTableColumnNamesDirty = true; if (!mpContainer) diff --git a/sc/source/core/tool/lookupcache.cxx b/sc/source/core/tool/lookupcache.cxx index 979eca0338ae..487fc18970e0 100644 --- a/sc/source/core/tool/lookupcache.cxx +++ b/sc/source/core/tool/lookupcache.cxx @@ -116,8 +116,7 @@ void ScLookupCache::Notify( const SfxHint& rHint ) { if (!mpDoc->IsInDtorClear()) { - const ScHint* p = dynamic_cast<const ScHint*>(&rHint); - if ((p && (p->GetId() == SfxHintId::ScDataChanged)) || dynamic_cast<const ScAreaChangedHint*>(&rHint)) + if (rHint.GetId() == SfxHintId::ScDataChanged || rHint.GetId() == SfxHintId::ScAreaChanged) { mpDoc->RemoveLookupCache( *this); delete this; diff --git a/sc/source/core/tool/rangecache.cxx b/sc/source/core/tool/rangecache.cxx index 7f1e9cfe8235..e94c9a77c72e 100644 --- a/sc/source/core/tool/rangecache.cxx +++ b/sc/source/core/tool/rangecache.cxx @@ -173,9 +173,7 @@ void ScSortedRangeCache::Notify(const SfxHint& rHint) { if (!mpDoc->IsInDtorClear()) { - const ScHint* p = dynamic_cast<const ScHint*>(&rHint); - if ((p && (p->GetId() == SfxHintId::ScDataChanged)) - || dynamic_cast<const ScAreaChangedHint*>(&rHint)) + if (rHint.GetId() == SfxHintId::ScDataChanged || rHint.GetId() == SfxHintId::ScAreaChanged) { mpDoc->RemoveSortedRangeCache(*this); delete this; diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 2e0c94b61e40..f4e47cbbf6a6 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -49,7 +49,7 @@ typedef std::vector<SwTOXMark*> SwTOXMarks; namespace sw { struct CollectTextMarksHint final : SfxHint { SwTOXMarks& m_rMarks; - CollectTextMarksHint(SwTOXMarks& rMarks) : m_rMarks(rMarks) {} + CollectTextMarksHint(SwTOXMarks& rMarks) : SfxHint(SfxHintId::SwCollectTextMarks), m_rMarks(rMarks) {} }; struct FindContentFrameHint final : SfxHint { SwContentFrame*& m_rpContentFrame; @@ -64,7 +64,8 @@ namespace sw { struct CollectTextTOXMarksForLayoutHint final : SfxHint { std::vector<std::reference_wrapper<SwTextTOXMark>>& m_rMarks; const SwRootFrame* m_pLayout; - CollectTextTOXMarksForLayoutHint(std::vector<std::reference_wrapper<SwTextTOXMark>>& rMarks, const SwRootFrame* pLayout) : m_rMarks(rMarks), m_pLayout(pLayout) {} + CollectTextTOXMarksForLayoutHint(std::vector<std::reference_wrapper<SwTextTOXMark>>& rMarks, const SwRootFrame* pLayout) + : SfxHint(SfxHintId::SwCollectTextTOXMarksForLayout), m_rMarks(rMarks), m_pLayout(pLayout) {} }; SW_DLLPUBLIC auto PrepareJumpToTOXMark(SwDoc const& rDoc, OUString const& rName) -> std::optional<std::pair<SwTOXMark, sal_Int32>>; diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 53fc36d38297..f636d171238e 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -159,12 +159,16 @@ void SwTOXMark::Notify(const SfxHint& rHint) CallSwClientNotify(rHint); if (pLegacyHint->m_pOld && (RES_REMOVE_UNO_OBJECT == pLegacyHint->m_pOld->Which())) SetXTOXMark(css::uno::Reference<css::text::XDocumentIndexMark>(nullptr)); - } else if (auto pCollectHint = dynamic_cast<const sw::CollectTextMarksHint*>(&rHint)) + } + else if (rHint.GetId() == SfxHintId::SwCollectTextMarks) { + auto pCollectHint = static_cast<const sw::CollectTextMarksHint*>(&rHint); if(GetTextTOXMark()) pCollectHint->m_rMarks.push_back(this); - } else if (auto pCollectLayoutHint = dynamic_cast<const sw::CollectTextTOXMarksForLayoutHint*>(&rHint)) + } + else if (rHint.GetId() == SfxHintId::SwCollectTextTOXMarksForLayout) { + auto pCollectLayoutHint = static_cast<const sw::CollectTextTOXMarksForLayoutHint*>(&rHint); if(!GetTextTOXMark()) return; auto& rTextMark = *GetTextTOXMark();