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

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 20 00:23:49 UTC 2019


 sw/inc/node.hxx                       |    2 +-
 sw/source/filter/inc/msfilter.hxx     |   11 +++++++----
 sw/source/filter/ww8/writerhelper.cxx |   25 ++++++++++++++-----------
 3 files changed, 22 insertions(+), 16 deletions(-)

New commits:
commit 11feca7a98e21062a2284e7d4dbb21030598cb65
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Fri Sep 20 00:43:42 2019 +0200
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Fri Sep 20 02:22:46 2019 +0200

    no more SwClient in sw/source/filter/ww8
    
    - prevent apparently leaking ~all InsertedTableClient by using a
      unique_ptr
    - rename InsertedTableClient to InsertedTableListener
    
    Change-Id: I60407113bf0ba28f5944ff9241a2d8a80a03d399
    Reviewed-on: https://gerrit.libreoffice.org/79262
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index e3e469c5ff9d..9ed3eb02579a 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -484,7 +484,7 @@ private:
 
 // SwTableNode
 
-class SW_DLLPUBLIC SwTableNode : public SwStartNode, public SwModify
+class SW_DLLPUBLIC SwTableNode : public SwStartNode, public sw::BroadcastingModify
 {
     friend class SwNodes;
     std::unique_ptr<SwTable> m_pTable;
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index e46769c02216..b5fbfdb2e737 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -32,6 +32,7 @@
 #include "fltshell.hxx"
 #include <shellio.hxx>
 #include <svl/zforlist.hxx>
+#include <svl/listener.hxx>
 
 class SwDoc;
 class SwPaM;
@@ -250,11 +251,13 @@ namespace sw
             explicit FontMapExport(const OUString &rFontDescription);
         };
 
-        class InsertedTableClient : public SwClient
+        class InsertedTableListener: public SvtListener
         {
+            SwTableNode* m_pTableNode;
         public:
-            explicit InsertedTableClient(SwTableNode & rNode);
-            SwTableNode * GetTableNode();
+            explicit InsertedTableListener(SwTableNode& rNode);
+            SwTableNode* GetTableNode();
+            virtual void Notify(const SfxHint&) override;
         };
 
         /** Handle requirements for table formatting in insert->file mode.
@@ -276,7 +279,7 @@ namespace sw
         class InsertedTablesManager
         {
         public:
-            typedef std::map<InsertedTableClient *, SwNodeIndex *> TableMap;
+            typedef std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> TableMap;
             void DelAndMakeTableFrames();
             void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
             explicit InsertedTablesManager(const SwDoc &rDoc);
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 792f492fa069..4c45fc48abb9 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -839,20 +839,24 @@ namespace sw
 
     namespace util
     {
-        InsertedTableClient::InsertedTableClient(SwTableNode & rNode)
+        InsertedTableListener::InsertedTableListener(SwTableNode& rNode)
+            : m_pTableNode(&rNode)
         {
-            rNode.Add(this);
+            StartListening(rNode.GetNotifier());
         }
 
-        SwTableNode * InsertedTableClient::GetTableNode()
+        SwTableNode* InsertedTableListener::GetTableNode()
+            { return m_pTableNode; }
+
+        void  InsertedTableListener::Notify(const SfxHint& rHint)
         {
-            return dynamic_cast<SwTableNode *> (GetRegisteredInNonConst());
+            if(rHint.GetId() == SfxHintId::Dying)
+                m_pTableNode = nullptr;
         }
 
         InsertedTablesManager::InsertedTablesManager(const SwDoc &rDoc)
             : mbHasRoot(rDoc.getIDocumentLayoutAccess().GetCurrentLayout())
-        {
-        }
+        { }
 
         void InsertedTablesManager::DelAndMakeTableFrames()
         {
@@ -877,16 +881,15 @@ namespace sw
             }
         }
 
-        void InsertedTablesManager::InsertTable(SwTableNode &rTableNode, SwPaM &rPaM)
+        void InsertedTablesManager::InsertTable(SwTableNode& rTableNode, SwPaM& rPaM)
         {
             if (!mbHasRoot)
                 return;
             //Associate this tablenode with this after position, replace an //old
             //node association if necessary
-
-            InsertedTableClient * pClient = new InsertedTableClient(rTableNode);
-
-            maTables.emplace(pClient, &(rPaM.GetPoint()->nNode));
+            maTables.emplace(
+                    std::unique_ptr<InsertedTableListener>(new InsertedTableListener(rTableNode)),
+                    &(rPaM.GetPoint()->nNode));
         }
     }
 


More information about the Libreoffice-commits mailing list