a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent
[LibreOffice.git] / sw / inc / deletelistener.hxx
blob023e5e638720d2579d95ca1f05cda9f121b50e4d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <svl/listener.hxx>
13 #include <svl/lstner.hxx>
14 #include "calbck.hxx"
16 class SwDeleteListener final : public SwClient
18 private:
19 SwModify* m_pModify;
21 virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override
23 if (rHint.GetId() != SfxHintId::SwLegacyModify)
24 return;
25 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
26 if (pLegacy->GetWhich() == RES_OBJECTDYING)
28 m_pModify->Remove(*this);
29 m_pModify = nullptr;
33 public:
34 SwDeleteListener(SwModify& rModify)
35 : m_pModify(&rModify)
37 m_pModify->Add(*this);
40 bool WasDeleted() const { return !m_pModify; }
42 virtual ~SwDeleteListener() override
44 if (!m_pModify)
45 return;
46 m_pModify->Remove(*this);
50 class SvtDeleteListener final : public SvtListener
52 private:
53 bool m_bObjectDeleted;
55 public:
56 explicit SvtDeleteListener(SvtBroadcaster& rNotifier)
57 : m_bObjectDeleted(false)
59 StartListening(rNotifier);
62 virtual void Notify(const SfxHint& rHint) override
64 if (rHint.GetId() == SfxHintId::Dying)
65 m_bObjectDeleted = true;
68 bool WasDeleted() const { return m_bObjectDeleted; }
71 class SfxDeleteListener final : public SfxListener
73 private:
74 bool m_bObjectDeleted;
76 public:
77 explicit SfxDeleteListener(SfxBroadcaster& rNotifier)
78 : m_bObjectDeleted(false)
80 StartListening(rNotifier);
83 virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
85 if (rHint.GetId() == SfxHintId::Dying)
86 m_bObjectDeleted = true;
89 bool WasDeleted() const { return m_bObjectDeleted; }
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */