sw/source/uibase/utlui/content.cxx | 26 ++++++++++++++++---------- sw/source/uibase/utlui/glbltree.cxx | 32 +++++++++++++++++++------------- 2 files changed, 35 insertions(+), 23 deletions(-)
New commits: commit 9376df3c03d361a4c01493066db2a11a770d6cc9 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon May 27 21:34:14 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue May 28 09:03:24 2024 +0200 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.gran...@collabora.co.uk> 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: */