sw/inc/unoredline.hxx | 32 +++++++++++++++++++------------- sw/source/core/unocore/unoredline.cxx | 12 +++++++----- sw/source/core/unocore/unoredlines.cxx | 20 ++++++-------------- 3 files changed, 32 insertions(+), 32 deletions(-)
New commits: commit b3394345c900548f1b4c91246d3188aa04e30e8c Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Mon Feb 25 21:11:37 2019 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Tue Feb 26 20:11:39 2019 +0100 UNO redline: uno SvtListener instead of SwClient Change-Id: Ic580df179c6aa1dedc866cf0882c124d5b13fcb3 Reviewed-on: https://gerrit.libreoffice.org/68360 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/unoredline.hxx b/sw/inc/unoredline.hxx index ffed204d15f3..ac2b658b5a8f 100644 --- a/sw/inc/unoredline.hxx +++ b/sw/inc/unoredline.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_SW_INC_UNOREDLINE_HXX #define INCLUDED_SW_INC_UNOREDLINE_HXX +#include <svl/listener.hxx> #include "unotext.hxx" #include "ndindex.hxx" @@ -59,16 +60,12 @@ public: virtual sal_Bool SAL_CALL hasElements( ) override; }; -typedef -cppu::WeakImplHelper -< - css::container::XEnumerationAccess -> -SwXRedlineBaseClass; -class SwXRedline : - public SwXRedlineBaseClass, - public SwXText, - public SwClient +typedef cppu::WeakImplHelper<css::container::XEnumerationAccess> SwXRedlineBaseClass; + +class SwXRedline + : public SwXRedlineBaseClass + , public SwXText + , public SvtListener { SwDoc* pDoc; SwRangeRedline* pRedline; @@ -105,10 +102,19 @@ public: virtual sal_Bool SAL_CALL hasElements( ) override; const SwRangeRedline* GetRedline() const {return pRedline;} -protected: - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify( const SfxHint& ) override; }; + +namespace sw +{ + struct SW_DLLPUBLIC FindRedlineHint final: SfxHint + { + const SwRangeRedline& m_rRedline; + SwXRedline** m_ppXRedline; + FindRedlineHint(const SwRangeRedline& rRedline, SwXRedline** ppXRedline) : m_rRedline(rRedline), m_ppXRedline(ppXRedline) {} + }; +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 281a010690a4..c5492af982dd 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -348,7 +348,7 @@ SwXRedline::SwXRedline(SwRangeRedline& rRedline, SwDoc& rDoc) : pDoc(&rDoc), pRedline(&rRedline) { - pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); + StartListening(pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier()); } SwXRedline::~SwXRedline() @@ -491,13 +491,15 @@ void SwXRedline::removeVetoableChangeListener( { } -void SwXRedline::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXRedline::Notify( const SfxHint& rHint ) { - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - { + if(rHint.GetId() == SfxHintId::Dying) + { pDoc = nullptr; pRedline = nullptr; + } else if(auto pHint = dynamic_cast<const sw::FindRedlineHint*>(&rHint)) { + if(!*pHint->m_ppXRedline && &pHint->m_rRedline == GetRedline()) + *pHint->m_ppXRedline = this; } } diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index 3012bffc071d..5776064cd7a9 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -105,20 +105,12 @@ uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames() return uno::Sequence< OUString >(); } -beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc ) -{ - SwPageDesc* pStdDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD); - SwIterator<SwXRedline,SwPageDesc> aIter(*pStdDesc); - SwXRedline* pxRedline = aIter.First(); - while(pxRedline) - { - if(pxRedline->GetRedline() == &rRedline) - break; - pxRedline = aIter.Next(); - } - if( !pxRedline ) - pxRedline = new SwXRedline(rRedline, rDoc); - return pxRedline; +beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc ) +{ + SwXRedline* pXRedline(nullptr); + sw::FindRedlineHint aHint(rRedline, &pXRedline); + rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier().Broadcast(aHint); + return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc); } SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) : _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits