diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-05-27 21:34:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-28 09:03:24 +0200 |
commit | 9376df3c03d361a4c01493066db2a11a770d6cc9 (patch) | |
tree | c0002d184c178ddfb461059dd677ad65c981d6fc | |
parent | 4b53712cccfa48fc7d1f754d6a596204e041d554 (diff) |
no need to dynamic_cast here
Change-Id: Ib2e08e58fc2f09161eda0cd32bf7ba2704387070
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168124
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/utlui/glbltree.cxx | 32 |
2 files changed, 35 insertions, 23 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index f462148fa7d8..d044b611eb59 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3664,18 +3664,24 @@ void SwContentTree::SetConstantShell(SwWrtShell* pSh) void SwContentTree::Notify(SfxBroadcaster & rBC, SfxHint const& rHint) { - SfxViewEventHint const*const pVEHint(dynamic_cast<SfxViewEventHint const*>(&rHint)); - SwXTextView* pDyingShell = nullptr; - if (m_pActiveShell && pVEHint && pVEHint->GetEventName() == "OnViewClosed") - pDyingShell = dynamic_cast<SwXTextView*>(pVEHint->GetController().get()); - if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView()) + if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint) { - SetActiveShell(nullptr); // our view is dying, clear our pointers to it - } - else - { - SfxListener::Notify(rBC, rHint); + const SfxEventHint* pEventHint = static_cast<const SfxEventHint*>(&rHint); + if (pEventHint->GetEventId() == SfxEventHintId::CloseView) + { + SfxViewEventHint const*const pVEHint(static_cast<SfxViewEventHint const*>(&rHint)); + if (m_pActiveShell) + { + SwXTextView* pDyingShell = dynamic_cast<SwXTextView*>(pVEHint->GetController().get()); + if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView()) + { + SetActiveShell(nullptr); // our view is dying, clear our pointers to it + } + } + return; + } } + SfxListener::Notify(rBC, rHint); switch (rHint.GetId()) { case SfxHintId::SwNavigatorUpdateTracking: diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx index 448f2655727a..7d7d0104fc7b 100644 --- a/sw/source/uibase/utlui/glbltree.cxx +++ b/sw/source/uibase/utlui/glbltree.cxx @@ -1164,21 +1164,27 @@ IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, vo void SwGlobalTree::Notify(SfxBroadcaster& rBC, SfxHint const& rHint) { - SfxViewEventHint const*const pVEHint(dynamic_cast<SfxViewEventHint const*>(&rHint)); - SwXTextView* pDyingShell = nullptr; - if (m_pActiveShell && pVEHint && pVEHint->GetEventName() == "OnViewClosed") - pDyingShell = dynamic_cast<SwXTextView*>(pVEHint->GetController().get()); - if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView()) + if (rHint.GetId() == SfxHintId::ThisIsAnSfxEventHint) { - EndListening(*m_pActiveShell->GetView().GetDocShell()); - m_pActiveShell = nullptr; - } - else - { - SfxListener::Notify(rBC, rHint); - if (rHint.GetId() == SfxHintId::SwNavigatorUpdateTracking) - UpdateTracking(); + const SfxEventHint* pEventHint = static_cast<const SfxEventHint*>(&rHint); + if (pEventHint->GetEventId() == SfxEventHintId::CloseView) + { + SfxViewEventHint const*const pVEHint(static_cast<SfxViewEventHint const*>(&rHint)); + if (m_pActiveShell) + { + SwXTextView* pDyingShell = dynamic_cast<SwXTextView*>(pVEHint->GetController().get()); + if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView()) + { + EndListening(*m_pActiveShell->GetView().GetDocShell()); + m_pActiveShell = nullptr; + } + } + return; + } } + SfxListener::Notify(rBC, rHint); + if (rHint.GetId() == SfxHintId::SwNavigatorUpdateTracking) + UpdateTracking(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |