sw/inc/docufld.hxx | 2 - sw/source/core/fields/docufld.cxx | 8 +------ sw/source/core/inc/unoport.hxx | 6 ++--- sw/source/core/unocore/unoport.cxx | 41 +++++++++++++++++-------------------- 4 files changed, 25 insertions(+), 32 deletions(-)
New commits: commit 82ff1317a3f4627d25399e93da0f9bc88fe89205 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> Date: Wed Jan 31 23:12:14 2018 +0100 use sw::WriterMultiListener instead of SwDepend in SwXTextPortion - also switch from old Modify() handler to new SwClientNotify() - also simplify some sequence generation with C++11 Change-Id: I219f626ce51e07c581ddf49d0cf5dc66e2d6a997 Reviewed-on: https://gerrit.libreoffice.org/49567 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx index d0cef52f7c70..2cb9ddb38402 100644 --- a/sw/source/core/inc/unoport.hxx +++ b/sw/source/core/inc/unoport.hxx @@ -115,8 +115,8 @@ private: std::unique_ptr< css::uno::Any > m_pRubyPosition; sw::UnoCursorPointer m_pUnoCursor; - const SwDepend m_FrameDepend; - SwFrameFormat * m_pFrameFormat; + sw::WriterMultiListener m_aDepends; + SwFrameFormat* m_pFrameFormat; const SwTextPortionType m_ePortionType; bool m_bIsCollapsed; @@ -148,7 +148,7 @@ protected: virtual ~SwXTextPortion() override; //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override; public: SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > const& rParent, SwTextPortionType eType ); diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 09092d1501d1..80f707ef2526 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -71,7 +71,7 @@ SwXTextPortion::SwXTextPortion( ? PROPERTY_MAP_REDLINE_PORTION : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) , m_xParentText(rParent) - , m_FrameDepend(this, nullptr) + , m_aDepends(*this) , m_pFrameFormat(nullptr) , m_ePortionType(eType) , m_bIsCollapsed(false) @@ -86,11 +86,12 @@ SwXTextPortion::SwXTextPortion( : m_pPropSet(aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) , m_xParentText(rParent) - , m_FrameDepend(this, &rFormat) + , m_aDepends(*this) , m_pFrameFormat(&rFormat) , m_ePortionType(PORTION_FRAME) , m_bIsCollapsed(false) { + m_aDepends.StartListening(&rFormat); init( pPortionCursor); } @@ -107,7 +108,7 @@ SwXTextPortion::SwXTextPortion( , m_pRubyAdjust ( bIsEnd ? nullptr : new uno::Any ) , m_pRubyIsAbove( bIsEnd ? nullptr : new uno::Any ) , m_pRubyPosition( bIsEnd ? nullptr : new uno::Any ) - , m_FrameDepend(this, nullptr) + , m_aDepends(*this) , m_pFrameFormat(nullptr) , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) , m_bIsCollapsed(false) @@ -129,7 +130,7 @@ SwXTextPortion::~SwXTextPortion() { SolarMutexGuard aGuard; m_pUnoCursor.reset(nullptr); - const_cast<SwDepend*>(&m_FrameDepend)->EndListeningAll(); + m_aDepends.EndListeningAll(); } uno::Reference< text::XText > SwXTextPortion::getText() @@ -798,14 +799,12 @@ sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId ) uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames() { - SolarMutexGuard aGuard; - uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" }; - return aRet; + return { "com.sun.star.text.TextContent" }; } OUString SwXTextPortion::getImplementationName() { - return OUString("SwXTextPortion"); + return { "SwXTextPortion" }; } sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) @@ -815,24 +814,22 @@ sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames() { - uno::Sequence< OUString > aRet(7); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextPortion"; - pArray[1] = "com.sun.star.style.CharacterProperties"; - pArray[2] = "com.sun.star.style.CharacterPropertiesAsian"; - pArray[3] = "com.sun.star.style.CharacterPropertiesComplex"; - pArray[4] = "com.sun.star.style.ParagraphProperties"; - pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian"; - pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex"; - return aRet; + return { "com.sun.star.text.TextPortion", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex" }; } -void SwXTextPortion::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXTextPortion::SwClientNotify(const SwModify&, const SfxHint& rHint) { - ClientModify(this, pOld, pNew); - if (!m_FrameDepend.GetRegisteredIn()) + if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - m_pFrameFormat = nullptr; + ClientModify(this, pLegacyHint->m_pOld, pLegacyHint->m_pNew); + if(!m_aDepends.IsListeningTo(m_pFrameFormat)) + m_pFrameFormat = nullptr; } } commit f4ab54c17ce2fb1959886377a1e37111aed80000 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> Date: Mon Jan 29 23:54:03 2018 +0100 use sw::WriterMultiListener instead of SwDepend in SwJumpEditFieldType Change-Id: I93f6dbf4eda561d68146be714e633576394d5a75 Reviewed-on: https://gerrit.libreoffice.org/49566 Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> Tested-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 6d7fcd2f95c9..fd699b563356 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -632,7 +632,7 @@ public: class SwJumpEditFieldType : public SwFieldType { SwDoc* m_pDoc; - SwDepend m_aDep; + sw::WriterMultiListener m_aDep; public: SwJumpEditFieldType( SwDoc* pDoc ); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 3ae4dcf8639c..fa08469d50fe 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -2394,7 +2394,7 @@ bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) // field type to jump to and edit SwJumpEditFieldType::SwJumpEditFieldType( SwDoc* pD ) - : SwFieldType( SwFieldIds::JumpEdit ), m_pDoc( pD ), m_aDep( this, nullptr ) + : SwFieldType( SwFieldIds::JumpEdit ), m_pDoc( pD ), m_aDep( *this ) { } @@ -2406,11 +2406,7 @@ SwFieldType* SwJumpEditFieldType::Copy() const SwCharFormat* SwJumpEditFieldType::GetCharFormat() { SwCharFormat* pFormat = m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( RES_POOLCHR_JUMPEDIT ); - - // not registered yet? - if( !m_aDep.GetRegisteredIn() ) - pFormat->Add( &m_aDep ); // register - + m_aDep.StartListening(pFormat); return pFormat; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits