From f2bc27972c13f54c4860a3ca995017bc5ad84e6e Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Fri, 6 Sep 2019 23:36:23 +0200 Subject: [PATCH] kill SwXShape SwClient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this completely removes calbck.hxx from sw/source/core/unocore -- may it never return. Change-Id: Ie4c8b3a29fd4038a19c34116d47672b504ee9f2c Reviewed-on: https://gerrit.libreoffice.org/78735 Tested-by: Jenkins Reviewed-by: Björn Michaelsen --- sw/inc/unodraw.hxx | 14 +++++++++++--- sw/source/core/unocore/unodraw.cxx | 25 +++++++++++++++---------- sw/source/core/unocore/unofield.cxx | 1 - sw/source/core/unocore/unoframe.cxx | 1 - 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx index 6bfa4839eba7..2938e7a79114 100644 --- a/sw/inc/unodraw.hxx +++ b/sw/inc/unodraw.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_INC_UNODRAW_HXX #include +#include #include #include "calbck.hxx" #include "frmfmt.hxx" @@ -130,12 +131,13 @@ cppu::WeakAggImplHelper6 css::drawing::XShape > SwXShapeBaseClass; -class SwXShape : public SwXShapeBaseClass, public SwClient +class SwXShape : public SwXShapeBaseClass, public SvtListener { friend class SwXGroupShape; friend class SwXDrawPage; friend class SwFmDrawPage; const SwFmDrawPage* m_pPage; + SwFrameFormat* m_pFormat; css::uno::Reference< css::uno::XAggregation > xShapeAgg; // reference to , determined in the @@ -197,13 +199,19 @@ class SwXShape : public SwXShapeBaseClass, public SwClient @throws css::uno::RuntimeException */ css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName ); + void SetFrameFormat(SwFrameFormat* pFormat) + { + EndListeningAll(); + StartListening(pFormat->GetNotifier()); + m_pFormat = pFormat; + } protected: virtual ~SwXShape() override; - void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; public: SwXShape(css::uno::Reference & xShape, SwDoc const*const pDoc); + virtual void Notify(const SfxHint&) override; static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; @@ -248,7 +256,7 @@ public: virtual OUString SAL_CALL getShapeType( ) override; SwShapeDescriptor_Impl* GetDescImpl() {return pImpl.get();} - SwFrameFormat* GetFrameFormat() const { return const_cast(static_cast(GetRegisteredIn())); } + SwFrameFormat* GetFrameFormat() const { return m_pFormat; } const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() {return xShapeAgg;} // helper diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index e91e4168c7fb..be29668a6b40 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -72,7 +72,6 @@ #include #include #include -#include using namespace ::com::sun::star; @@ -575,7 +574,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) static_cast< cppu::OWeakObject * > ( this ) ); // we're already registered in the model / SwXDrawPage::add() already called - if(pShape->m_pPage || pShape->GetRegisteredIn() || !pShape->m_bDescriptor ) + if(pShape->m_pPage || pShape->m_pFormat || !pShape->m_bDescriptor ) return; // we're inserted elsewhere already @@ -711,7 +710,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) pDoc->getIDocumentContentOperations().InsertDrawObj( *pTemp, *pObj, aSet ); SwFrameFormat* pFormat = ::FindFrameFormat( pObj ); if(pFormat) - pFormat->Add(pShape); + pShape->SetFrameFormat(pFormat); pShape->m_bDescriptor = false; pPam.reset(); @@ -871,6 +870,7 @@ SwXShape::SwXShape( uno::Reference & xShape, SwDoc const*const pDoc) : m_pPage(nullptr) + , m_pFormat(nullptr) , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)) , m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)) , pImpl(new SwShapeDescriptor_Impl(pDoc)) @@ -907,9 +907,9 @@ SwXShape::SwXShape( SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr; if(pObj) { - SwFrameFormat* pFormat = ::FindFrameFormat( pObj ); + auto pFormat = ::FindFrameFormat( pObj ); if(pFormat) - pFormat->Add(this); + SetFrameFormat(pFormat); lcl_addShapePropertyEventFactories( *pObj, *this ); pImpl->bInitializedPropertyNotifier = true; @@ -936,9 +936,9 @@ void SwXShape::AddExistingShapeToFormat( SdrObject const & _rObj ) { if ( pSwShape->m_bDescriptor ) { - SwFrameFormat* pFormat = ::FindFrameFormat( pCurrent ); + auto pFormat = ::FindFrameFormat( pCurrent ); if ( pFormat ) - pFormat->Add( pSwShape ); + pSwShape->SetFrameFormat(pFormat); pSwShape->m_bDescriptor = false; } @@ -1984,9 +1984,13 @@ void SwXShape::removeVetoableChangeListener( OSL_FAIL("not implemented"); } -void SwXShape::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXShape::Notify(const SfxHint& rHint) { - ClientModify(this, pOld, pNew); + if(rHint.GetId() == SfxHintId::Dying) + { + m_pFormat = nullptr; + EndListeningAll(); + } } void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) @@ -2754,8 +2758,9 @@ void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) pSwShape->m_bDescriptor = false; //add the group member to the format of the group SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() ); + if(pShapeFormat) - pFormat->Add(pSwShape); + pSwShape->SetFrameFormat(pShapeFormat); } } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 729bc6ecb1e3..a23a88b85121 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -96,7 +96,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 5ed7b51c6cc6..aa978f2962ea 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -125,7 +125,6 @@ #include #include #include -#include #include #include #include