diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2019-09-25 11:35:10 +0200 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@libreoffice.org> | 2019-09-26 12:47:29 +0200 |
commit | e412401edcf0a979f9f19c051990c0fb08987048 (patch) | |
tree | 81da213604cd84c6a961e23b548e6523e771fd94 /sw | |
parent | 7258c47364a8a9b7cd108cc076243c96f1c1c0f2 (diff) |
source/core/access: no more SwClient
- also, move BroadcastingModify up from TextNode to ContentNode
Change-Id: I4e6e8767aaecb9cce20d5ec3da789532686dfe2a
Reviewed-on: https://gerrit.libreoffice.org/79525
Tested-by: Jenkins
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/ndtxt.hxx | 1 | ||||
-rw-r--r-- | sw/inc/node.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/access/accframebase.cxx | 68 | ||||
-rw-r--r-- | sw/source/core/access/accframebase.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/access/accnotextframe.cxx | 115 | ||||
-rw-r--r-- | sw/source/core/access/accnotextframe.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/access/acctextframe.cxx | 105 | ||||
-rw-r--r-- | sw/source/core/access/acctextframe.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/docnode/node.cxx | 11 |
9 files changed, 134 insertions, 180 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 3c6a4ad10e49..125891a8cb50 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -79,7 +79,6 @@ typedef std::set< sal_Int32 > SwSoftPageBreakList; class SW_DLLPUBLIC SwTextNode : public SwContentNode , public ::sfx2::Metadatable - , public sw::BroadcasterMixin { friend class SwContentNode; /// For creating the first TextNode. diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 9ed3eb02579a..143213035881 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -349,7 +349,7 @@ private: // SwContentNode -class SW_DLLPUBLIC SwContentNode: public SwModify, public SwNode, public SwIndexReg +class SW_DLLPUBLIC SwContentNode: public sw::BroadcastingModify, public SwNode, public SwIndexReg { sw::WriterMultiListener m_aCondCollListener; diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx index 2040f0c76e11..fba6ca85fcc6 100644 --- a/sw/source/core/access/accframebase.cxx +++ b/sw/source/core/access/accframebase.cxx @@ -126,8 +126,9 @@ SwAccessibleFrameBase::SwAccessibleFrameBase( SwAccessibleContext( pInitMap, nInitRole, pFlyFrame ), m_bIsSelected( false ) { - const SwFrameFormat *pFrameFormat = pFlyFrame->GetFormat(); - const_cast< SwFrameFormat * >( pFrameFormat )->Add( this ); + const SwFrameFormat* pFrameFormat = pFlyFrame->GetFormat(); + if(pFrameFormat) + StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier()); SetName( pFrameFormat->GetName() ); @@ -206,54 +207,37 @@ SwAccessibleFrameBase::~SwAccessibleFrameBase() { } -void SwAccessibleFrameBase::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwAccessibleFrameBase::Notify(const SfxHint& rHint) { - sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; - switch( nWhich ) + if(rHint.GetId() == SfxHintId::Dying) + { + EndListeningAll(); + } + else if(auto pLegacyModifyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - case RES_NAME_CHANGED: + sal_uInt16 nWhich = pLegacyModifyHint->m_pOld ? pLegacyModifyHint->m_pOld->Which() : pLegacyModifyHint->m_pNew ? pLegacyModifyHint->m_pNew->Which() : 0; + const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); + if(nWhich == RES_NAME_CHANGED && pFlyFrame) { - const SwFlyFrame *pFlyFrame = static_cast< const SwFlyFrame * >( GetFrame() ); - if( pFlyFrame ) - { - const SwFrameFormat *pFrameFormat = pFlyFrame->GetFormat(); - assert(pFrameFormat == GetRegisteredIn() && "invalid frame"); + const SwFrameFormat* pFrameFormat = pFlyFrame->GetFormat(); - const OUString sOldName( GetName() ); - assert( !pOld || - static_cast<const SwStringMsgPoolItem *>(pOld)->GetString() == GetName()); + const OUString sOldName( GetName() ); + assert( !pLegacyModifyHint->m_pOld || + static_cast<const SwStringMsgPoolItem *>(pLegacyModifyHint->m_pOld)->GetString() == GetName()); - SetName( pFrameFormat->GetName() ); - assert( !pNew || - static_cast<const SwStringMsgPoolItem *>(pNew)->GetString() == GetName()); + SetName( pFrameFormat->GetName() ); + assert( !pLegacyModifyHint->m_pNew || + static_cast<const SwStringMsgPoolItem *>(pLegacyModifyHint->m_pNew)->GetString() == GetName()); - if( sOldName != GetName() ) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldName; - aEvent.NewValue <<= GetName(); - FireAccessibleEvent( aEvent ); - } + if( sOldName != GetName() ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= sOldName; + aEvent.NewValue <<= GetName(); + FireAccessibleEvent( aEvent ); } - break; } - case RES_OBJECTDYING: - // mba: it seems that this class intentionally does not call code in base class SwClient - if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) ) - EndListeningAll(); - break; - - case RES_FMT_CHG: - if( pOld && - static_cast< const SwFormatChg * >(pNew)->pChangedFormat == GetRegisteredIn() && - static_cast< const SwFormatChg * >(pOld)->pChangedFormat->IsFormatInDTOR() ) - EndListeningAll(); - break; - - default: - // mba: former call to base class method removed as it is meant to handle only RES_OBJECTDYING - break; } } diff --git a/sw/source/core/access/accframebase.hxx b/sw/source/core/access/accframebase.hxx index cc4fb0c0058f..c38424a3b413 100644 --- a/sw/source/core/access/accframebase.hxx +++ b/sw/source/core/access/accframebase.hxx @@ -21,13 +21,12 @@ #define INCLUDED_SW_SOURCE_CORE_ACCESS_ACCFRAMEBASE_HXX #include "acccontext.hxx" -#include <calbck.hxx> +#include <svl/listener.hxx> #include <ndtyp.hxx> class SwFlyFrame; -class SwAccessibleFrameBase : public SwAccessibleContext, - public SwClient +class SwAccessibleFrameBase : public SwAccessibleContext, public SvtListener { bool m_bIsSelected; // protected by base class mutex bool IsSelected(); @@ -45,7 +44,7 @@ protected: virtual void InvalidateFocus_() override; virtual ~SwAccessibleFrameBase() override; - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify(const SfxHint&) override; public: SwAccessibleFrameBase(std::shared_ptr<SwAccessibleMap> const& pInitMap, diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx index b35cf64a78b6..7aa34cffe2bf 100644 --- a/sw/source/core/access/accnotextframe.cxx +++ b/sw/source/core/access/accnotextframe.cxx @@ -59,12 +59,11 @@ SwAccessibleNoTextFrame::SwAccessibleNoTextFrame( sal_Int16 nInitRole, const SwFlyFrame* pFlyFrame ) : SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrame ), - m_aListener(*this), msTitle(), msDesc() { const SwNoTextNode* pNd = GetNoTextNode(); - m_aListener.StartListening(const_cast<SwNoTextNode*>(pNd)); + StartListening(const_cast<SwNoTextNode*>(pNd)->GetNotifier()); // #i73249# // consider new attributes Title and Description if( pNd ) @@ -84,86 +83,70 @@ SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame() { } -void SwAccessibleNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwAccessibleNoTextFrame::Notify(const SfxHint& rHint) { - const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; - // #i73249# - // suppress handling of RES_NAME_CHANGED in case that attribute Title is - // used as the accessible name. - if ( nWhich != RES_NAME_CHANGED || - msTitle.isEmpty() ) + if(rHint.GetId() == SfxHintId::Dying) + EndListeningAll(); + else if(auto pLegacyModifyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - SwAccessibleFrameBase::Modify( pOld, pNew ); - if (!GetRegisteredIn()) - return; // probably was deleted - avoid doing anything - } - - if (nWhich != RES_TITLE_CHANGED && nWhich != RES_DESCRIPTION_CHANGED) - return; - - const SwNoTextNode *pNd = GetNoTextNode(); - assert( m_aListener.IsListeningTo(pNd) && "invalid frame" ); - switch( nWhich ) - { - // #i73249# - case RES_TITLE_CHANGED: + const sal_uInt16 nWhich = pLegacyModifyHint->m_pOld ? pLegacyModifyHint->m_pOld->Which() : pLegacyModifyHint->m_pNew ? pLegacyModifyHint->m_pNew->Which() : 0; + if (nWhich != RES_TITLE_CHANGED && nWhich != RES_DESCRIPTION_CHANGED) + return; + const SwNoTextNode* pNd = GetNoTextNode(); + switch(nWhich) { - OUString sOldTitle, sNewTitle; - const SwStringMsgPoolItem* pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pOld); - if (pOldItem) - sOldTitle = pOldItem->GetString(); - const SwStringMsgPoolItem* pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pNew); - if (pNewItem) - sNewTitle = pNewItem->GetString(); - if ( sOldTitle == sNewTitle ) + // #i73249# + case RES_TITLE_CHANGED: { - break; + OUString sOldTitle, sNewTitle; + const SwStringMsgPoolItem* pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pOld); + if(pOldItem) + sOldTitle = pOldItem->GetString(); + const SwStringMsgPoolItem* pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pNew); + if(pNewItem) + sNewTitle = pNewItem->GetString(); + if(sOldTitle == sNewTitle) + break; + msTitle = sNewTitle; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= sOldTitle; + aEvent.NewValue <<= msTitle; + FireAccessibleEvent(aEvent); + + if(!pNd->GetDescription().isEmpty()) + break; + [[fallthrough]]; } - msTitle = sNewTitle; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldTitle; - aEvent.NewValue <<= msTitle; - FireAccessibleEvent( aEvent ); - - if ( !pNd->GetDescription().isEmpty() ) + case RES_DESCRIPTION_CHANGED: { - break; - } - [[fallthrough]]; - } - case RES_DESCRIPTION_CHANGED: - { - if ( pNd && GetFrame() ) - { - const OUString sOldDesc( msDesc ); - - const OUString& rDesc = pNd->GetDescription(); - msDesc = rDesc; - if ( msDesc.isEmpty() && - msTitle != GetName() ) - { - msDesc = msTitle; - } - - if ( msDesc != sOldDesc ) + if(pNd && GetFrame()) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= msDesc; - FireAccessibleEvent( aEvent ); + const OUString sOldDesc(msDesc); + + const OUString& rDesc = pNd->GetDescription(); + msDesc = rDesc; + if(msDesc.isEmpty() && msTitle != GetName()) + msDesc = msTitle; + + if(msDesc != sOldDesc) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent(aEvent); + } } } } - break; } } void SwAccessibleNoTextFrame::Dispose(bool bRecursive, bool bCanSkipInvisible) { SolarMutexGuard aGuard; - m_aListener.EndListeningAll(); + EndListeningAll(); SwAccessibleFrameBase::Dispose(bRecursive, bCanSkipInvisible); } diff --git a/sw/source/core/access/accnotextframe.hxx b/sw/source/core/access/accnotextframe.hxx index 6363bd9dcda4..38fdd480cc97 100644 --- a/sw/source/core/access/accnotextframe.hxx +++ b/sw/source/core/access/accnotextframe.hxx @@ -33,7 +33,6 @@ class SwAccessibleNoTextFrame : public SwAccessibleFrameBase, { friend class SwAccessibleNoTextHyperlink; css::uno::Reference< css::accessibility::XAccessibleHyperlink > m_xHyperlink; - sw::WriterMultiListener m_aListener; OUString msTitle; OUString msDesc; @@ -42,7 +41,7 @@ protected: const SwNoTextNode *GetNoTextNode() const; - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify(const SfxHint&) override; public: SwAccessibleNoTextFrame( std::shared_ptr<SwAccessibleMap> const& pInitMap, diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 44a5b37d7e05..928a68677283 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -63,74 +63,63 @@ SwAccessibleTextFrame::~SwAccessibleTextFrame() { } -void SwAccessibleTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwAccessibleTextFrame::Notify(const SfxHint& rHint) { - const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; - // #i73249# - suppress handling of RES_NAME_CHANGED - // in case that attribute Title is used as the accessible name. - if ( nWhich != RES_NAME_CHANGED || - msTitle.isEmpty() ) + if(rHint.GetId() == SfxHintId::Dying) + EndListeningAll(); + else if(auto pLegacyModifyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - SwAccessibleFrameBase::Modify( pOld, pNew ); - } - - const SwFlyFrame *pFlyFrame = static_cast< const SwFlyFrame * >( GetFrame() ); - switch( nWhich ) - { - // #i73249# - case RES_TITLE_CHANGED: - { - OUString sOldTitle, sNewTitle; - const SwStringMsgPoolItem *pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pOld); - if (pOldItem) - sOldTitle = pOldItem->GetString(); - const SwStringMsgPoolItem *pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pNew); - if (pNewItem) - sNewTitle = pNewItem->GetString(); - if (sOldTitle == sNewTitle) - { - break; - } - msTitle = sNewTitle; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldTitle; - aEvent.NewValue <<= msTitle; - FireAccessibleEvent( aEvent ); - - const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); - if (!pFlyFrameFormat || !pFlyFrameFormat->GetObjDescription().isEmpty()) - { - break; - } - [[fallthrough]]; - } - case RES_DESCRIPTION_CHANGED: + const sal_uInt16 nWhich = pLegacyModifyHint->m_pOld ? pLegacyModifyHint->m_pOld->Which() : pLegacyModifyHint->m_pNew ? pLegacyModifyHint->m_pNew->Which() : 0; + const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); + switch(nWhich) { - if ( pFlyFrame ) + // #i73249# + case RES_TITLE_CHANGED: { - const OUString sOldDesc( msDesc ); + OUString sOldTitle, sNewTitle; + const SwStringMsgPoolItem *pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pOld); + if(pOldItem) + sOldTitle = pOldItem->GetString(); + const SwStringMsgPoolItem *pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pNew); + if(pNewItem) + sNewTitle = pNewItem->GetString(); + if(sOldTitle == sNewTitle) + break; + msTitle = sNewTitle; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= sOldTitle; + aEvent.NewValue <<= msTitle; + FireAccessibleEvent( aEvent ); const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); - const OUString& rDesc = pFlyFrameFormat->GetObjDescription(); - msDesc = rDesc; - if ( msDesc.isEmpty() && - msTitle != GetName() ) - { - msDesc = msTitle; - } - - if ( msDesc != sOldDesc ) + if(!pFlyFrameFormat || !pFlyFrameFormat->GetObjDescription().isEmpty()) + break; + [[fallthrough]]; + } + case RES_DESCRIPTION_CHANGED: + { + if(pFlyFrame) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= msDesc; - FireAccessibleEvent( aEvent ); + const OUString sOldDesc(msDesc); + + const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); + const OUString& rDesc = pFlyFrameFormat->GetObjDescription(); + msDesc = rDesc; + if(msDesc.isEmpty() && msTitle != GetName()) + msDesc = msTitle; + + if(msDesc != sOldDesc) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent(aEvent); + } } } } - break; } } diff --git a/sw/source/core/access/acctextframe.hxx b/sw/source/core/access/acctextframe.hxx index a9d743d5e92f..a4ee77ad8500 100644 --- a/sw/source/core/access/acctextframe.hxx +++ b/sw/source/core/access/acctextframe.hxx @@ -36,7 +36,7 @@ private: protected: virtual ~SwAccessibleTextFrame() override; - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Notify(const SfxHint&) override; public: SwAccessibleTextFrame(std::shared_ptr<SwAccessibleMap> const& pInitMap, diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 8ab7544a9a13..3256f12c617a 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1023,12 +1023,13 @@ SwEndNode::SwEndNode( SwNodes& rNds, sal_uLong nPos, SwStartNode& rSttNd ) SwContentNode::SwContentNode( const SwNodeIndex &rWhere, const SwNodeType nNdType, SwFormatColl *pColl ) - : SwModify( pColl ), // CursorsShell, FrameFormat, - SwNode( rWhere, nNdType ), - m_aCondCollListener( *this ), - m_pCondColl( nullptr ), - mbSetModifyAtAttr( false ) + : SwNode( rWhere, nNdType ) + , m_aCondCollListener( *this ) + , m_pCondColl( nullptr ) + , mbSetModifyAtAttr( false ) { + if(pColl) + pColl->Add(this); } SwContentNode::~SwContentNode() |