sw/source/core/doc/acmplwrd.cxx |   51 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 16 deletions(-)

New commits:
commit 0b44a7760dc2093564bbded0afce6c749dd307ae
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Thu Feb 16 08:18:50 2023 +0100
Commit:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Sun Feb 19 17:45:41 2023 +0000

    SwAutoCompleteClient: SwClient no more
    
    Change-Id: Id6e13fdf037bd1a910ecd127344b46393a190d55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147138
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index d566f188d7cc..38011750bd29 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -23,7 +23,7 @@
 #include <doc.hxx>
 #include <pagedesc.hxx>
 #include <poolfmt.hxx>
-#include <calbck.hxx>
+#include <svl/listener.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 #include <editeng/svxacorr.hxx>
 #include <osl/diagnose.h>
@@ -35,7 +35,7 @@
 #include <cassert>
 #include <vector>
 
-class SwAutoCompleteClient : public SwClient
+class SwAutoCompleteClient : public SvtListener
 {
     SwAutoCompleteWord* m_pAutoCompleteWord;
     SwDoc*              m_pDoc;
@@ -54,7 +54,9 @@ public:
     static sal_uLong GetElementCount() {return s_nSwAutoCompleteClientCount;}
 #endif
 protected:
-    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
+    virtual void Notify(const SfxHint&) override;
+private:
+    void DocumentDying();
 };
 
 class SwAutoCompleteWord_Impl
@@ -96,18 +98,18 @@ 
SwAutoCompleteClient::SwAutoCompleteClient(SwAutoCompleteWord& rToTell, SwDoc& r
         m_pAutoCompleteWord(&rToTell),
         m_pDoc(&rSwDoc)
 {
-    
m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
+    
StartListening(m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
 #if OSL_DEBUG_LEVEL > 0
     ++s_nSwAutoCompleteClientCount;
 #endif
 }
 
 SwAutoCompleteClient::SwAutoCompleteClient(const SwAutoCompleteClient& 
rClient) :
-    SwClient(),
+    SvtListener(),
     m_pAutoCompleteWord(rClient.m_pAutoCompleteWord),
     m_pDoc(rClient.m_pDoc)
 {
-    
m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
+    
StartListening(m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
 #if OSL_DEBUG_LEVEL > 0
     ++s_nSwAutoCompleteClientCount;
 #endif
@@ -126,21 +128,38 @@ SwAutoCompleteClient& 
SwAutoCompleteClient::operator=(const SwAutoCompleteClient
 {
     m_pAutoCompleteWord = rClient.m_pAutoCompleteWord;
     m_pDoc = rClient.m_pDoc;
-    StartListeningToSameModifyAs(rClient);
+    CopyAllBroadcasters(rClient);
     return *this;
 }
 
-void SwAutoCompleteClient::SwClientNotify(const SwModify&, const SfxHint& 
rHint)
+void SwAutoCompleteClient::DocumentDying()
 {
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
-        return;
-    auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
-    switch(pLegacy->GetWhich())
+    EndListeningAll();
+    m_pAutoCompleteWord->DocumentDying(*m_pDoc);
+}
+
+void SwAutoCompleteClient::Notify(const SfxHint& rHint)
+{
+    switch(rHint.GetId())
     {
-        case RES_REMOVE_UNO_OBJECT:
-        case RES_OBJECTDYING:
-            EndListeningAll();
-            m_pAutoCompleteWord->DocumentDying(*m_pDoc);
+        case SfxHintId::Dying:
+            DocumentDying();
+            return;
+        case SfxHintId::SwLegacyModify:
+        {
+            auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
+            switch(pLegacy->GetWhich())
+            {
+                case RES_REMOVE_UNO_OBJECT:
+                case RES_OBJECTDYING:
+                    DocumentDying();
+                    return;
+                default:
+                    return;
+            }
+        }
+        default:
+            return;
     }
 }
 

Reply via email to