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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 12 19:23:13 UTC 2019


 sw/source/core/docnode/ndtbl.cxx  |    5 ---
 sw/source/core/docnode/nodes.cxx  |    4 --
 sw/source/core/unocore/unotbl.cxx |   61 +++++++++++++++++++-------------------
 3 files changed, 33 insertions(+), 37 deletions(-)

New commits:
commit da195d75a951265234c764aff7784f0bb888ccc9
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Wed Feb 27 21:34:00 2019 +0100
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Tue Mar 12 20:22:48 2019 +0100

    UNO SwTextTable: uso SvtListener instead of SwClient
    
    Change-Id: I672ea969efccf660d9a23847b26535031144e3da
    Reviewed-on: https://gerrit.libreoffice.org/68473
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 81994cd4bae0..61749c7d77e9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2323,10 +2323,7 @@ SwTableNode::SwTableNode( const SwNodeIndex& rIdx )
 SwTableNode::~SwTableNode()
 {
     // Notify UNO wrappers
-    SwFrameFormat* pTableFormat = GetTable().GetFrameFormat();
-    SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
-                                pTableFormat );
-    pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
+    GetTable().GetFrameFormat()->GetNotifier().Broadcast(SfxHint(SfxHintId::Dying));
     DelFrames();
     m_pTable->SetTableNode(this); // set this so that ~SwDDETable can read it!
     m_pTable.reset();
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 405d9c19d4ce..cce08f13204b 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -577,9 +577,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
                                     rNodes))
                         {
                             SwFrameFormat* pTableFormat = pTableNd->GetTable().GetFrameFormat();
-                            SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
-                                                        pTableFormat );
-                            pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
+                            pTableFormat->GetNotifier().Broadcast(SfxHint(SfxHintId::Dying));
                         }
                     }
                     if( bNewFrames )
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 76c7597bbcd2..2db210758520 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1916,9 +1916,10 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
 }
 
 class SwXTextTable::Impl
-    : public SwClient
+    : public SvtListener
 {
 private:
+    SwFrameFormat* m_pFrameFormat;
     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
 
 public:
@@ -1939,8 +1940,8 @@ public:
     unsigned short m_nRows;
     unsigned short m_nColumns;
 
-    explicit Impl(SwFrameFormat *const pFrameFormat)
-        : SwClient(pFrameFormat)
+    explicit Impl(SwFrameFormat* const pFrameFormat)
+        : m_pFrameFormat(pFrameFormat)
         , m_Listeners(m_Mutex)
         , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE))
         , m_bFirstRowAsLabel(false)
@@ -1949,17 +1950,19 @@ public:
         , m_nRows(pFrameFormat ? 0 : 2)
         , m_nColumns(pFrameFormat ? 0 : 2)
     {
+        if(m_pFrameFormat)
+            StartListening(m_pFrameFormat->GetNotifier());
     }
 
-    SwFrameFormat * GetFrameFormat()
+    SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
+    void SetFrameFormat(SwFrameFormat& rFrameFormat)
     {
-        return static_cast<SwFrameFormat*>(GetRegisteredIn());
+        EndListeningAll();
+        m_pFrameFormat = &rFrameFormat;
+        StartListening(m_pFrameFormat->GetNotifier());
     }
 
-    bool IsDescriptor()
-    {
-        return m_pTableProps != nullptr;
-    }
+    bool IsDescriptor() { return m_pTableProps != nullptr; }
 
     // note: lock mutex before calling this to avoid concurrent update
     static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
@@ -1977,8 +1980,7 @@ public:
     sal_uInt16 GetRowCount();
     sal_uInt16 GetColumnCount();
 
-    // SwClient
-    virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+    virtual void Notify(const SfxHint&) override;
 
 };
 
@@ -2158,7 +2160,8 @@ SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
             SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
             lcl_FormatTable(pTableFormat);
 
-            pTableFormat->Add(m_pImpl.get());
+            m_pImpl->SetFrameFormat(*pTableFormat);
+
             if (!m_pImpl->m_sTableName.isEmpty())
             {
                 sal_uInt16 nIndex = 1;
@@ -3094,27 +3097,25 @@ sal_uInt16 SwXTextTable::Impl::GetColumnCount()
     return nRet;
 }
 
-void SwXTextTable::Impl::Modify(
-        SfxPoolItem const*const pOld, SfxPoolItem const*const pNew)
+void SwXTextTable::Impl::Notify(const SfxHint& rHint)
 {
-    if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
-        static_cast<void*>(GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject )
-            EndListeningAll();
-    else
-        ClientModify(this, pOld, pNew);
-    uno::Reference<uno::XInterface> const xThis(m_wThis);
-    if (!xThis.is())
-    {   // fdo#72695: if UNO object is already dead, don't revive it with event
-        return;
-    }
-    if (!GetRegisteredIn())
+    if(rHint.GetId() == SfxHintId::Dying)
     {
-        lang::EventObject const ev(xThis);
-        m_Listeners.disposeAndClear(ev);
+        m_pFrameFormat = nullptr;
+        EndListeningAll();
     }
-    else
-    {
-        lcl_SendChartEvent(xThis.get(), m_Listeners);
+    uno::Reference<uno::XInterface> const xThis(m_wThis);
+    if (xThis.is())
+    {   // fdo#72695: if UNO object is already dead, don't revive it with event
+        if(!m_pFrameFormat)
+        {
+            lang::EventObject const ev(xThis);
+            m_Listeners.disposeAndClear(ev);
+        }
+        else
+        {
+            lcl_SendChartEvent(xThis.get(), m_Listeners);
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list