lok: Hide file linking in section
[LibreOffice.git] / sw / inc / deletelistener.hxx
blobbfdc0926d3b68f17c5e1fcdd8e25a01d48602410
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 (auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
25 if (pLegacy->m_pOld && pLegacy->m_pOld->Which() == RES_OBJECTDYING)
27 m_pModify->Remove(this);
28 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 bObjectDeleted;
55 public:
56 explicit SvtDeleteListener(SvtBroadcaster& rNotifier)
57 : bObjectDeleted(false)
59 StartListening(rNotifier);
62 virtual void Notify(const SfxHint& rHint) override
64 if (rHint.GetId() == SfxHintId::Dying)
65 bObjectDeleted = true;
68 bool WasDeleted() const { return bObjectDeleted; }
71 class SfxDeleteListener final : public SfxListener
73 private:
74 bool bObjectDeleted;
76 public:
77 explicit SfxDeleteListener(SfxBroadcaster& rNotifier)
78 : bObjectDeleted(false)
80 StartListening(rNotifier);
83 virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
85 if (rHint.GetId() == SfxHintId::Dying)
86 bObjectDeleted = true;
89 bool WasDeleted() const { return bObjectDeleted; }
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */