1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include <svl/listener.hxx>
13 #include <svl/lstner.hxx>
16 class SwDeleteListener final
: public SwClient
21 virtual void SwClientNotify(const SwModify
&, const SfxHint
& rHint
) override
23 if (rHint
.GetId() != SfxHintId::SwLegacyModify
)
25 auto pLegacy
= static_cast<const sw::LegacyModifyHint
*>(&rHint
);
26 if (pLegacy
->GetWhich() == RES_OBJECTDYING
)
28 m_pModify
->Remove(*this);
34 SwDeleteListener(SwModify
& rModify
)
37 m_pModify
->Add(*this);
40 bool WasDeleted() const { return !m_pModify
; }
42 virtual ~SwDeleteListener() override
46 m_pModify
->Remove(*this);
50 class SvtDeleteListener final
: public SvtListener
53 bool m_bObjectDeleted
;
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
74 bool m_bObjectDeleted
;
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: */