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

Bjoern Michaelsen bjoern.michaelsen at libreoffice.org
Sun May 20 21:16:07 UTC 2018


 sw/inc/IMark.hxx                   |    1 
 sw/source/core/unocore/unoobj2.cxx |   76 ++++++++++++++++++-------------------
 2 files changed, 38 insertions(+), 39 deletions(-)

New commits:
commit db608e8e5e27cce8eeda26918bcab71222d342df
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date:   Thu May 10 10:51:42 2018 +0200

    dont use SwClient/SwModify in unocore: TextRange
    
    Change-Id: Ib87647671776e9c6ef5a9c5a7b75a638452b4555
    Reviewed-on: https://gerrit.libreoffice.org/54605
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/inc/IMark.hxx b/sw/inc/IMark.hxx
index dfb73b8f9e0c..39ff1d7108eb 100644
--- a/sw/inc/IMark.hxx
+++ b/sw/inc/IMark.hxx
@@ -38,6 +38,7 @@ namespace sw { namespace mark
     class SW_DLLPUBLIC IMark
         : virtual public SwModify // inherited as interface
         , public ::boost::totally_ordered<IMark>
+        , virtual public sw::BroadcasterMixin
     {
         protected:
             IMark() = default;
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 05854b1faf0f..193b400cb0e2 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -21,7 +21,20 @@
 
 #include <utility>
 
+#include <comphelper/servicehelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/unolingu.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <svl/listener.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svtools/ctrltool.hxx>
+#include <vcl/svapp.hxx>
+
 #include <swtypes.hxx>
 #include <hintids.hxx>
 #include <cmdid.h>
@@ -41,7 +54,6 @@
 #include <rootfrm.hxx>
 #include <flyfrm.hxx>
 #include <ftnidx.hxx>
-#include <sfx2/linkmgr.hxx>
 #include <docary.hxx>
 #include <paratr.hxx>
 #include <pam.hxx>
@@ -61,9 +73,6 @@
 #include <cntfrm.hxx>
 #include <pagefrm.hxx>
 #include <doctxm.hxx>
-#include <sfx2/docfilt.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/fcontnr.hxx>
 #include <fmtrfmrk.hxx>
 #include <txtrfmrk.hxx>
 #include <unoparaframeenum.hxx>
@@ -81,9 +90,6 @@
 #include <unocoll.hxx>
 #include <unostyle.hxx>
 #include <fmtanchr.hxx>
-#include <editeng/flstitem.hxx>
-#include <editeng/unolingu.hxx>
-#include <svtools/ctrltool.hxx>
 #include <flypos.hxx>
 #include <txtftn.hxx>
 #include <fmtftn.hxx>
@@ -97,9 +103,7 @@
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <unoframe.hxx>
 #include <fmthdft.hxx>
-#include <vcl/svapp.hxx>
 #include <fmtflcnt.hxx>
-#include <editeng/brushitem.hxx>
 #include <fmtclds.hxx>
 #include <dcontact.hxx>
 #include <dflyobj.hxx>
@@ -109,8 +113,6 @@
 #include <algorithm>
 #include <iterator>
 #include <calbck.hxx>
-#include <comphelper/servicehelper.hxx>
-#include <cppuhelper/supportsservice.hxx>
 
 using namespace ::com::sun::star;
 
@@ -679,30 +681,27 @@ uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
 }
 
 class SwXTextRange::Impl
-    : public SwClient
+    : public SvtListener
 {
 public:
     const SfxItemPropertySet& m_rPropSet;
     const enum RangePosition m_eRangePosition;
     SwDoc& m_rDoc;
     uno::Reference<text::XText> m_xParentText;
-    sw::WriterMultiListener m_aMultiListener;
-    const ::sw::mark::IMark* m_pMark;
     const SwFrameFormat* m_pTableFormat;
+    const ::sw::mark::IMark* m_pMark;
 
-    Impl(SwDoc & rDoc, const enum RangePosition eRange,
+    Impl(SwDoc& rDoc, const enum RangePosition eRange,
             SwFrameFormat* const pTableFormat,
             const uno::Reference<text::XText>& xParent = nullptr)
-        : SwClient()
-        , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
+        : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
         , m_eRangePosition(eRange)
         , m_rDoc(rDoc)
         , m_xParentText(xParent)
-        , m_aMultiListener(*this)
-        , m_pMark(nullptr)
         , m_pTableFormat(pTableFormat)
+        , m_pMark(nullptr)
     {
-        m_aMultiListener.StartListening(pTableFormat);
+        m_pTableFormat && StartListening(pTableFormat->GetNotifier());
     }
 
     virtual ~Impl() override
@@ -718,30 +717,30 @@ public:
             m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
             m_pMark = nullptr;
         }
+        m_pTableFormat = nullptr;
+        EndListeningAll();
     }
 
-    const ::sw::mark::IMark * GetBookmark() const { return m_pMark; }
+    const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
+    void SetMark(::sw::mark::IMark& rMark)
+    {
+        EndListeningAll();
+        m_pTableFormat = nullptr;
+        m_pMark = &rMark;
+        StartListening(rMark.GetNotifier());
+    }
 
 protected:
-    // SwClient
-    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
+    virtual void Notify(const SfxHint&) override;
 };
 
-void SwXTextRange::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+void SwXTextRange::Impl::Notify(const SfxHint& rHint)
 {
-    assert(!GetRegisteredIn()); // we should only listen with the WriterMultiListener from now on
-    if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
+    if(rHint.GetId() == SfxHintId::Dying)
     {
-        if(pModifyChangedHint->m_pNew == nullptr)
-        {
-            m_aMultiListener.EndListeningAll();
-            m_pMark = nullptr;
-            m_pTableFormat = nullptr;
-        }
-        else if(&rModify == m_pMark)
-            m_pMark = dynamic_cast<const ::sw::mark::IMark*>(pModifyChangedHint->m_pNew);
-        else if(&rModify == m_pTableFormat)
-            m_pTableFormat = dynamic_cast<const SwFrameFormat*>(pModifyChangedHint->m_pNew);
+        EndListeningAll();
+        m_pTableFormat = nullptr;
+        m_pMark = nullptr;
     }
 }
 
@@ -788,9 +787,8 @@ void SwXTextRange::SetPositions(const SwPaM& rPam)
 {
     m_pImpl->Invalidate();
     IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
-    m_pImpl->m_pMark = pMA->makeMark(rPam, OUString(),
-        IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
-    m_pImpl->m_aMultiListener.StartListening(const_cast<::sw::mark::IMark*>(m_pImpl->m_pMark));
+    auto pMark = pMA->makeMark(rPam, OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
+    m_pImpl->SetMark(*pMark);
 }
 
 void SwXTextRange::DeleteAndInsert(


More information about the Libreoffice-commits mailing list