sw/source/filter/basflt/fltshell.cxx | 34 +++++++++++++++------------------- sw/source/filter/inc/fltshell.hxx | 25 ++++++++++++------------- 2 files changed, 27 insertions(+), 32 deletions(-)
New commits: commit 6170da5135683735a34b9fac992a9a668b95ffe5 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Fri Sep 20 01:11:59 2019 +0200 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Fri Sep 20 02:39:55 2019 +0200 no more SwClient in sw/source/filter/basflt/ Change-Id: I56c9d140bc92ad517cb808e99cdb942f89cdbedc Reviewed-on: https://gerrit.libreoffice.org/79263 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 0181e0a3ed12..d530d73c77ac 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -943,15 +943,15 @@ void SwFltControlStack::Delete(const SwPaM &rPam) SwFltAnchor::SwFltAnchor(SwFrameFormat* pFormat) : SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(pFormat) { - pClient.reset( new SwFltAnchorClient(this) ); - pFrameFormat->Add(pClient.get()); + pListener.reset(new SwFltAnchorListener(this)); + pListener->StartListening(pFrameFormat->GetNotifier()); } SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) : SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(rCpy.pFrameFormat) { - pClient.reset( new SwFltAnchorClient(this) ); - pFrameFormat->Add(pClient.get()); + pListener.reset(new SwFltAnchorListener(this)); + pListener->StartListening(pFrameFormat->GetNotifier()); } SwFltAnchor::~SwFltAnchor() @@ -974,24 +974,20 @@ SfxPoolItem* SwFltAnchor::Clone(SfxItemPool*) const return new SwFltAnchor(*this); } -SwFltAnchorClient::SwFltAnchorClient(SwFltAnchor * pFltAnchor) -: m_pFltAnchor(pFltAnchor) -{ -} +SwFltAnchorListener::SwFltAnchorListener(SwFltAnchor* pFltAnchor) + : m_pFltAnchor(pFltAnchor) +{ } -void SwFltAnchorClient::Modify(const SfxPoolItem *, const SfxPoolItem * pNew) +void SwFltAnchorListener::Notify(const SfxHint& rHint) { - if (pNew->Which() == RES_FMT_CHG) + if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - const SwFormatChg * pFormatChg = dynamic_cast<const SwFormatChg *> (pNew); - - if (pFormatChg != nullptr) - { - SwFrameFormat * pFrameFormat = dynamic_cast<SwFrameFormat *> (pFormatChg->pChangedFormat); - - if (pFrameFormat != nullptr) - m_pFltAnchor->SetFrameFormat(pFrameFormat); - } + if(pLegacyHint->m_pNew->Which() != RES_FMT_CHG) + return; + auto pFormatChg = dynamic_cast<const SwFormatChg*>(pLegacyHint->m_pNew); + auto pFrameFormat = pFormatChg ? dynamic_cast<SwFrameFormat*>(pFormatChg->pChangedFormat) : nullptr; + if(pFrameFormat) + m_pFltAnchor->SetFrameFormat(pFrameFormat); } } diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index d7991b096884..e3f24316dde5 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX #include <hintids.hxx> +#include <svl/listener.hxx> #include <tools/datetime.hxx> #include <mdiexp.hxx> #include <ndindex.hxx> @@ -177,12 +178,12 @@ public: void DeleteAndDestroy(Entries::size_type nCnt); }; -class SwFltAnchorClient; +class SwFltAnchorListener; -class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem +class SW_DLLPUBLIC SwFltAnchor: public SfxPoolItem { SwFrameFormat* pFrameFormat; - std::unique_ptr<SwFltAnchorClient> pClient; + std::unique_ptr<SwFltAnchorListener> pListener; public: SwFltAnchor(SwFrameFormat* pFlyFormat); @@ -192,19 +193,17 @@ public: // "purely virtual methods" of SfxPoolItem virtual bool operator==(const SfxPoolItem&) const override; virtual SfxPoolItem* Clone(SfxItemPool* = nullptr) const override; - void SetFrameFormat(SwFrameFormat * _pFrameFormat); - const SwFrameFormat* GetFrameFormat() const { return pFrameFormat;} - SwFrameFormat* GetFrameFormat() { return pFrameFormat;} + void SetFrameFormat(SwFrameFormat* _pFrameFormat); + const SwFrameFormat* GetFrameFormat() const { return pFrameFormat; } + SwFrameFormat* GetFrameFormat() { return pFrameFormat; } }; -class SwFltAnchorClient : public SwClient +class SwFltAnchorListener : public SvtListener { - SwFltAnchor * m_pFltAnchor; - -public: - SwFltAnchorClient(SwFltAnchor * pFltAnchor); - - virtual void Modify (const SfxPoolItem *pOld, const SfxPoolItem *pNew) override; + SwFltAnchor* m_pFltAnchor; + public: + SwFltAnchorListener(SwFltAnchor* pFltAnchor); + virtual void Notify(const SfxHint&) override; }; class SW_DLLPUBLIC SwFltRedline : public SfxPoolItem _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits