[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 26 10:48:25 UTC 2019


 sw/inc/ndtxt.hxx                         |    1 
 sw/inc/node.hxx                          |    2 
 sw/source/core/access/accframebase.cxx   |   68 +++++++-----------
 sw/source/core/access/accframebase.hxx   |    7 -
 sw/source/core/access/accnotextframe.cxx |  115 +++++++++++++------------------
 sw/source/core/access/accnotextframe.hxx |    3 
 sw/source/core/access/acctable.cxx       |   39 ++++------
 sw/source/core/access/acctable.hxx       |    9 +-
 sw/source/core/access/acctextframe.cxx   |  105 ++++++++++++----------------
 sw/source/core/access/acctextframe.hxx   |    2 
 sw/source/core/docnode/node.cxx          |   11 +-
 11 files changed, 154 insertions(+), 208 deletions(-)

New commits:
commit e412401edcf0a979f9f19c051990c0fb08987048
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Wed Sep 25 11:35:10 2019 +0200
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Thu Sep 26 12:47:29 2019 +0200

    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 at libreoffice.org>

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()
commit 7258c47364a8a9b7cd108cc076243c96f1c1c0f2
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Wed Sep 25 09:15:59 2019 +0200
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Thu Sep 26 12:47:12 2019 +0200

    SwAccessibleTable/SwAccessibleTableColHeaders: SwClient no more
    
    Change-Id: I0ca9f9d38f9f990fe4a41319d8dbd9b204544f49
    Reviewed-on: https://gerrit.libreoffice.org/79506
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 64f7fed7bd01..7094aeecbb01 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -671,8 +671,9 @@ SwAccessibleTable::SwAccessibleTable(
         const SwTabFrame* pTabFrame  ) :
     SwAccessibleContext( pInitMap, AccessibleRole::TABLE, pTabFrame )
 {
-    const SwFrameFormat *pFrameFormat = pTabFrame->GetFormat();
-    const_cast< SwFrameFormat * >( pFrameFormat )->Add( this );
+    const SwFrameFormat* pFrameFormat = pTabFrame->GetFormat();
+    if(pFrameFormat)
+        StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier());
 
     SetName( pFrameFormat->GetName() + "-" + OUString::number( pTabFrame->GetPhyPageNum() ) );
 
@@ -690,17 +691,19 @@ SwAccessibleTable::~SwAccessibleTable()
     mpTableData.reset();
 }
 
-void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwAccessibleTable::Notify(const SfxHint& rHint)
 {
-    sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
-    const SwTabFrame *pTabFrame = static_cast< const SwTabFrame * >( GetFrame() );
-    switch( nWhich )
+    if(rHint.GetId() == SfxHintId::Dying)
     {
-    case RES_NAME_CHANGED:
-        if( pTabFrame )
+        EndListeningAll();
+    }
+    else if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
+    {
+        sal_uInt16 nWhich = pLegacyHint->m_pOld ? pLegacyHint->m_pOld->Which() : pLegacyHint->m_pNew ? pLegacyHint->m_pNew->Which() : 0;
+        const SwTabFrame* pTabFrame = static_cast<const SwTabFrame*>(GetFrame());
+        if(nWhich == RES_NAME_CHANGED && pTabFrame)
         {
             const SwFrameFormat *pFrameFormat = pTabFrame->GetFormat();
-            OSL_ENSURE( pFrameFormat == GetRegisteredIn(), "invalid frame" );
 
             const OUString sOldName( GetName() );
             const OUString sNewTabName = pFrameFormat->GetName();
@@ -729,17 +732,6 @@ void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew
                 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;
-
-    default:
-        // mba: former call to base class method removed as it is meant to handle only RES_OBJECTDYING
-        break;
     }
 }
 
@@ -1703,8 +1695,9 @@ SwAccessibleTableColHeaders::SwAccessibleTableColHeaders(
 {
     SolarMutexGuard aGuard;
 
-    const SwFrameFormat *pFrameFormat = pTabFrame->GetFormat();
-    const_cast< SwFrameFormat * >( pFrameFormat )->Add( this );
+    const SwFrameFormat* pFrameFormat = pTabFrame->GetFormat();
+    if(pFrameFormat)
+        StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier());
     const OUString aName = pFrameFormat->GetName() + "-ColumnHeaders";
 
     SetName( aName + "-" + OUString::number( pTabFrame->GetPhyPageNum() ) );
@@ -1722,7 +1715,7 @@ std::unique_ptr<SwAccessibleTableData_Impl> SwAccessibleTableColHeaders::CreateN
     return std::unique_ptr<SwAccessibleTableData_Impl>(new SwAccessibleTableData_Impl( *(GetMap()), pTabFrame, IsInPagePreview(), true ));
 }
 
-void SwAccessibleTableColHeaders::Modify( const SfxPoolItem * /*pOld*/, const SfxPoolItem * /*pNew*/ )
+void SwAccessibleTableColHeaders::Notify(const SfxHint& )
 {
 }
 
diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx
index 39a21f024aa7..4da4944ba2c2 100644
--- a/sw/source/core/access/acctable.hxx
+++ b/sw/source/core/access/acctable.hxx
@@ -26,8 +26,7 @@
 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
 
 #include <svl/poolitem.hxx>
-
-#include <calbck.hxx>
+#include <svl/listener.hxx>
 
 #include "acccontext.hxx"
 
@@ -45,7 +44,7 @@ class SwAccessibleTable :
         public css::accessibility::XAccessibleTable,
         public css::accessibility::XAccessibleSelection,
         public css::accessibility::XAccessibleTableSelection,
-        public SwClient
+        public SvtListener
 {
     std::unique_ptr<SwAccessibleTableData_Impl> mpTableData;    // the table's data, protected by SolarMutex
     OUString m_sDesc;
@@ -87,7 +86,7 @@ protected:
     // Is table data evailable?
     bool HasTableData() const { return (mpTableData != nullptr); }
 
-    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
+    virtual void Notify(const SfxHint&) override;
 
 public:
     SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
@@ -239,7 +238,7 @@ protected:
     {}
 
     virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
-    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
+    virtual void Notify(const SfxHint&) override;
 
 public:
     SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,


More information about the Libreoffice-commits mailing list