diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2019-01-12 12:04:04 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@libreoffice.org> | 2019-01-12 13:09:01 +0100 |
commit | 18bb85aa303c17b7705a9ccb0dd3d76673a1955e (patch) | |
tree | c57334b8aece87f5779c046d08ff46725ea2fb90 /sw | |
parent | ead0a04e413018f94a307a1b621e53a5f4d25a70 (diff) |
make SwFormat a ::sw::BroadcastingModify
- clean up SwSection..Hint: Lazily reusing the Dying HintId is evil
- switch the SwChartDataSequence to SvtListener
- add some description to RuntimeException
Change-Id: I897a63030f207cabe4d1ba7de0c25c6c581ffd1f
Reviewed-on: https://gerrit.libreoffice.org/65816
Tested-by: Jenkins
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/calbck.hxx | 3 | ||||
-rw-r--r-- | sw/inc/format.hxx | 2 | ||||
-rw-r--r-- | sw/inc/frmfmt.hxx | 1 | ||||
-rw-r--r-- | sw/inc/section.hxx | 2 | ||||
-rw-r--r-- | sw/inc/unochart.hxx | 14 | ||||
-rw-r--r-- | sw/source/core/attr/format.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/layout/sectfrm.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unochart.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/unocore/unosect.cxx | 7 |
9 files changed, 48 insertions, 41 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 4d33243ed277..5cc590989c8a 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -237,7 +237,8 @@ namespace sw // used anymore, in which case a BroadcasterMixin should be enough instead // then. class SW_DLLPUBLIC BroadcastingModify : public SwModify, public BroadcasterMixin { - virtual void CallSwClientNotify(const SfxHint& rHint) const override; + public: + virtual void CallSwClientNotify(const SfxHint& rHint) const override; }; // this should be hidden but sadly SwIterator template needs it... class ListenerEntry final : public SwClient diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index 870cfff0367e..cbeda7237f66 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -40,7 +40,7 @@ namespace drawinglayer { namespace attribute { }} /// Base class for various Writer styles. -class SW_DLLPUBLIC SwFormat : public SwModify +class SW_DLLPUBLIC SwFormat : public sw::BroadcastingModify { friend class SwFrameFormat; diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 4469a2c8b4c0..bb8a9622d2be 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -56,7 +56,6 @@ class SwFrameFormats; /// Style of a layout element. class SW_DLLPUBLIC SwFrameFormat : public SwFormat - , public sw::BroadcasterMixin { friend class SwDoc; friend class SwPageDesc; ///< Is allowed to call protected CTor. diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 30b582b89a80..d0fcff0078bd 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -252,7 +252,7 @@ class SwSectionFrameMoveAndDeleteHint : public SfxHint { public: SwSectionFrameMoveAndDeleteHint( const bool bSaveContent ) - : SfxHint( SfxHintId::Dying ) + : SfxHint( SfxHintId::SwSectionFrameMoveAndDelete ) , mbSaveContent( bSaveContent ) {} diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index 0b4e9c73e752..bb5b8fa7afc4 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -44,6 +44,7 @@ #include <cppuhelper/weakref.hxx> #include <rtl/ref.hxx> +#include <svl/listener.hxx> #include <tools/link.hxx> #include <vcl/timer.hxx> @@ -229,8 +230,9 @@ SwChartDataSequenceBaseClass; class SwChartDataSequence : public SwChartDataSequenceBaseClass, - public SwClient + public SvtListener { + SwFrameFormat* m_pFormat; ::comphelper::OInterfaceContainerHelper2 m_aEvtListeners; ::comphelper::OInterfaceContainerHelper2 m_aModifyListeners; css::chart2::data::DataSequenceRole m_aRole; @@ -249,10 +251,6 @@ class SwChartDataSequence : SwChartDataSequence( const SwChartDataSequence &rObj ); SwChartDataSequence & operator = ( const SwChartDataSequence & ) = delete; -protected: - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; - public: SwChartDataSequence( SwChartDataProvider &rProvider, SwFrameFormat &rTableFormat, @@ -309,12 +307,14 @@ public: virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; - SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); } - bool DeleteBox( const SwTableBox &rBox ); + SwFrameFormat* GetFrameFormat() const { return m_pFormat; } + bool DeleteBox( const SwTableBox &rBox ); void FillRangeDesc( SwRangeDescriptor &rRangeDesc ) const; void ExtendTo( bool bExtendCol, sal_Int32 nFirstNew, sal_Int32 nCount ); std::vector< css::uno::Reference< css::table::XCell > > GetCells(); + + virtual void Notify(const SfxHint& rHint) override; }; typedef cppu::WeakImplHelper diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 15de4023eaca..da052acfef0d 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -40,8 +40,7 @@ using namespace com::sun::star; SwFormat::SwFormat( SwAttrPool& rPool, const sal_Char* pFormatNm, const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrame, - sal_uInt16 nFormatWhich ) - : SwModify( pDrvdFrame ), + sal_uInt16 nFormatWhich ) : m_aFormatName( OUString::createFromAscii(pFormatNm) ), m_aSet( rPool, pWhichRanges ), m_nWhichId( nFormatWhich ), @@ -54,13 +53,15 @@ SwFormat::SwFormat( SwAttrPool& rPool, const sal_Char* pFormatNm, m_bFormatInDTOR = m_bHidden = false; if( pDrvdFrame ) + { + pDrvdFrame->Add(this); m_aSet.SetParent( &pDrvdFrame->m_aSet ); + } } SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm, const sal_uInt16* pWhichRanges, SwFormat* pDrvdFrame, - sal_uInt16 nFormatWhich ) - : SwModify( pDrvdFrame ), + sal_uInt16 nFormatWhich ) : m_aFormatName( rFormatNm ), m_aSet( rPool, pWhichRanges ), m_nWhichId( nFormatWhich ), @@ -73,11 +74,13 @@ SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm, m_bFormatInDTOR = m_bHidden = false; if( pDrvdFrame ) + { + pDrvdFrame->Add(this); m_aSet.SetParent( &pDrvdFrame->m_aSet ); + } } -SwFormat::SwFormat( const SwFormat& rFormat ) - : SwModify( rFormat.DerivedFrom() ), +SwFormat::SwFormat( const SwFormat& rFormat ) : m_aFormatName( rFormat.m_aFormatName ), m_aSet( rFormat.m_aSet ), m_nWhichId( rFormat.m_nWhichId ), @@ -90,8 +93,11 @@ SwFormat::SwFormat( const SwFormat& rFormat ) m_bHidden = rFormat.m_bHidden; m_bAutoUpdateFormat = rFormat.m_bAutoUpdateFormat; - if( rFormat.DerivedFrom() ) - m_aSet.SetParent( &rFormat.DerivedFrom()->m_aSet ); + if( auto pDerived = rFormat.DerivedFrom() ) + { + pDerived->Add(this); + m_aSet.SetParent( &pDerived->m_aSet ); + } // a few special treatments for attributes m_aSet.SetModifyAtAttr( this ); } diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 5c1b39e242e4..6cd503bce7e7 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -2598,12 +2598,12 @@ void SwSectionFrame::SwClientNotify( const SwModify& rMod, const SfxHint& rHint { SwFrame::SwClientNotify(rMod, rHint); // #i117863# - const SwSectionFrameMoveAndDeleteHint* pHint = - dynamic_cast<const SwSectionFrameMoveAndDeleteHint*>(&rHint); - if (pHint && pHint->GetId() == SfxHintId::Dying && &rMod == GetDep()) - { - SwSectionFrame::MoveContentAndDelete( this, pHint->IsSaveContent() ); - } + if(&rMod != GetDep()) + return; + const auto pHint = dynamic_cast<const SwSectionFrameMoveAndDeleteHint*>(&rHint); + if(!pHint) + return; + SwSectionFrame::MoveContentAndDelete( this, pHint->IsSaveContent() ); } void SwSectionFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index ab597d0ae587..35dd1e8f478c 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1798,10 +1798,10 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSource::getSupportedServiceNames( } SwChartDataSequence::SwChartDataSequence( - SwChartDataProvider &rProvider, - SwFrameFormat &rTableFormat, + SwChartDataProvider& rProvider, + SwFrameFormat& rTableFormat, const std::shared_ptr<SwUnoCursor>& pTableCursor ) : - SwClient( &rTableFormat ), + m_pFormat(&rTableFormat), m_aEvtListeners( GetChartMutex() ), m_aModifyListeners( GetChartMutex() ), m_aRowLabelText( SwResId( STR_CHART2_ROW_LABEL_TEXT ) ), @@ -1810,6 +1810,7 @@ SwChartDataSequence::SwChartDataSequence( m_pTableCursor( pTableCursor ), m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_CHART2_DATA_SEQUENCE ) ) { + StartListening(rTableFormat.GetNotifier()); m_bDisposed = false; acquire(); @@ -1846,7 +1847,8 @@ SwChartDataSequence::SwChartDataSequence( SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : SwChartDataSequenceBaseClass(rObj), - SwClient( rObj.GetFrameFormat() ), + SvtListener(), + m_pFormat( rObj.m_pFormat ), m_aEvtListeners( GetChartMutex() ), m_aModifyListeners( GetChartMutex() ), m_aRole( rObj.m_aRole ), @@ -1856,6 +1858,8 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : m_pTableCursor( rObj.m_pTableCursor ), m_pPropSet( rObj.m_pPropSet ) { + if(m_pFormat) + StartListening(m_pFormat->GetNotifier()); m_bDisposed = false; acquire(); @@ -2190,13 +2194,13 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getSupportedServiceNames return { "com.sun.star.chart2.data.DataSequence" }; } -void SwChartDataSequence::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwChartDataSequence::Notify( const SfxHint& rHint) { - ClientModify(this, pOld, pNew ); - - // table was deleted or cursor was deleted - if(!GetRegisteredIn() || !m_pTableCursor) + if(rHint.GetId() == SfxHintId::Dying) + m_pFormat = nullptr; + if(!m_pFormat || !m_pTableCursor) { + m_pFormat = nullptr; m_pTableCursor.reset(nullptr); dispose(); } @@ -2292,10 +2296,10 @@ void SAL_CALL SwChartDataSequence::dispose( ) //exception threw out. Recorrect the logic of code in //SwChartDataSequence::Dispose(), release the relationship //here... - SwModify* pLclRegisteredIn = GetRegisteredInNonConst(); - if (pLclRegisteredIn && pLclRegisteredIn->HasWriterListeners()) + if (m_pFormat && m_pFormat->HasWriterListeners()) { EndListeningAll(); + m_pFormat = nullptr; m_pTableCursor.reset(nullptr); } } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 661157edd083..47380a275dd9 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -497,10 +497,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextSection::getPropertySetInfo() { SolarMutexGuard g; - - static const uno::Reference< beans::XPropertySetInfo > aRef = - m_pImpl->m_rPropSet.getPropertySetInfo(); - return aRef; + return m_pImpl->m_rPropSet.getPropertySetInfo(); } static void @@ -952,7 +949,7 @@ SwXTextSection::Impl::GetPropertyValues_Impl( SwSectionFormat *const pFormat = GetSectionFormat(); if (!pFormat && !m_bIsDescriptor) { - throw uno::RuntimeException(); + throw uno::RuntimeException( "non-descriptor section without format"); } uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); |