sw/inc/calbck.hxx | 9 ++++--- sw/source/core/attr/calbck.cxx | 46 ++++++++++++++++++++++++++++++++++++- sw/source/core/unocore/unoobj2.cxx | 2 - 3 files changed, 51 insertions(+), 6 deletions(-)
New commits: commit 36847ce41aae7c81ad7ca9d22a7215a640378929 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> Date: Sun May 6 06:06:32 2018 +0200 make SwDepend an implementation detail of sw::WriterMultiListener - ... and rename it to ListenerEntry Change-Id: Ie0f77f1d381da469899420f864995e1697e4c639 Reviewed-on: https://gerrit.libreoffice.org/53909 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index c9d81f8df8f7..440a822b8a15 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -251,18 +251,19 @@ private: namespace sw { + class ListenerEntry; class SW_DLLPUBLIC WriterMultiListener final { #ifdef WNT - typedef std::shared_ptr<SwDepend> pointer_t; + typedef std::shared_ptr<ListenerEntry> pointer_t; #else - typedef std::unique_ptr<SwDepend> pointer_t; + typedef std::unique_ptr<ListenerEntry> pointer_t; #endif SwClient& m_rToTell; std::vector<pointer_t> m_vDepends; public: - WriterMultiListener(SwClient& rToTell) - : m_rToTell(rToTell) {} + WriterMultiListener(SwClient& rToTell); + ~WriterMultiListener(); void StartListening(SwModify* pDepend); void EndListening(SwModify* pDepend); bool IsListeningTo(const SwModify* const pDepend); diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index ca75f06904df..e9774a10a716 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -25,6 +25,43 @@ #include <tools/debug.hxx> #include <algorithm> +namespace sw +{ + class ListenerEntry final : public SwClient + { + SwClient *m_pToTell; + + public: + ListenerEntry(SwClient* pTellHim, SwModify * pDepend) : SwClient(pDepend), m_pToTell(pTellHim) {} + ListenerEntry(ListenerEntry&) = delete; + + /** get Client information */ + virtual bool GetInfo( SfxPoolItem& rInfo) const override + { return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); } + private: + virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem *pNewValue ) override + { + SwClientNotify(*GetRegisteredIn(), sw::LegacyModifyHint(pOldValue, pNewValue)); + } + virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override + { + if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) + { + if( pLegacyHint->m_pNew && pLegacyHint->m_pNew->Which() == RES_OBJECTDYING ) + { + auto pModifyChanged = CheckRegistration(pLegacyHint->m_pOld); + if(pModifyChanged) + m_pToTell->SwClientNotify(rModify, *pModifyChanged); + } + else if( m_pToTell ) + m_pToTell->ModifyNotification(pLegacyHint->m_pOld, pLegacyHint->m_pNew); + } + else if(m_pToTell) + m_pToTell->SwClientNotifyCall(rModify, rHint); + } + }; +} + sw::LegacyModifyHint::~LegacyModifyHint() {} sw::ModifyChangedHint::~ModifyChangedHint() {} @@ -296,10 +333,17 @@ void SwModify::CheckCaching( const sal_uInt16 nWhich ) } } +sw::WriterMultiListener::WriterMultiListener(SwClient& rToTell) + : m_rToTell(rToTell) +{} + +sw::WriterMultiListener::~WriterMultiListener() +{} + void sw::WriterMultiListener::StartListening(SwModify* pDepend) { EndListening(nullptr); - m_vDepends.emplace_back(pointer_t( new SwDepend(&m_rToTell, pDepend))); + m_vDepends.emplace_back(pointer_t(new ListenerEntry(&m_rToTell, pDepend))); } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 67bb83861cde..05854b1faf0f 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1582,7 +1582,7 @@ struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration } else { - // removing orphaned SwDepends + // removing orphaned Clients const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(), [] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); }); m_vFrames.erase(iter, m_vFrames.end()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits