From 10e80d0ecb26394c583e581469b8119d866933b2 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 10 May 2018 10:51:42 +0200 Subject: dont use SwClient/SwModify in unocore: NumberingRules Change-Id: I20ee1662310f33831757015659a70d3ffd855b3e --- sw/inc/pagedesc.hxx | 4 +++- sw/source/core/unocore/unosett.cxx | 32 +++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index c12d4349173a..3dd5a1d2d9e1 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -134,7 +134,9 @@ namespace o3tl { template<> struct typed_flags : is_typed_flags {}; } -class SW_DLLPUBLIC SwPageDesc : public SwModify +class SW_DLLPUBLIC SwPageDesc + : public SwModify + , public sw::BroadcasterMixin { friend class SwDoc; friend class SwPageDescs; diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index a283a7954e7d..aaedae061d17 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -73,6 +73,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -82,6 +83,14 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::text; using namespace ::com::sun::star::style; + +namespace +{ + inline static SvtBroadcaster& GetPageDescNotifier(SwDoc* pDoc) + { + return pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier(); + } +} // Constants for the css::text::ColumnSeparatorStyle #define API_COL_LINE_NONE 0 #define API_COL_LINE_SOLID 1 @@ -999,15 +1008,13 @@ OSL_FAIL("not implemented"); static const char aInvalidStyle[] = "__XXX___invalid"; -class SwXNumberingRules::Impl : public SwClient +class SwXNumberingRules::Impl + : public SvtListener { -private: SwXNumberingRules& m_rParent; -public: - explicit Impl(SwXNumberingRules& rParent) : m_rParent(rParent) {} -protected: - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify(const SfxHint&) override; + public: + explicit Impl(SwXNumberingRules& rParent) : m_rParent(rParent) {} }; bool SwXNumberingRules::isInvalidStyle(const OUString &rName) @@ -1074,7 +1081,7 @@ SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) : } } if(pDoc) - pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); + m_pImpl->StartListening(GetPageDescNotifier(pDoc)); for(sal_uInt16 i = 0; i < MAXLEVEL; ++i) { m_sNewCharStyleNames[i] = aInvalidStyle; @@ -1090,7 +1097,7 @@ SwXNumberingRules::SwXNumberingRules(SwDocShell& rDocSh) : m_pPropertySet(GetNumberingRulesSet()), bOwnNumRuleCreated(false) { - pDocShell->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); + m_pImpl->StartListening(GetPageDescNotifier(pDocShell->GetDoc())); } SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) : @@ -1101,7 +1108,7 @@ SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) : m_pPropertySet(GetNumberingRulesSet()), bOwnNumRuleCreated(false) { - rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); + m_pImpl->StartListening(GetPageDescNotifier(&rDoc)); m_sCreatedNumRuleName = rDoc.GetUniqueNumRuleName(); rDoc.MakeNumRule( m_sCreatedNumRuleName, nullptr, false, // #i89178# @@ -2234,10 +2241,9 @@ void SwXNumberingRules::setName(const OUString& /*rName*/) throw aExcept; } -void SwXNumberingRules::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXNumberingRules::Impl::Notify(const SfxHint& rHint) { - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) + if(rHint.GetId() == SfxHintId::Dying) { if(m_rParent.bOwnNumRuleCreated) delete m_rParent.pNumRule; -- cgit