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

Bjoern Michaelsen bjoern.michaelsen at libreoffice.org
Sun May 20 00:03:22 UTC 2018


 sw/source/core/unocore/unoparagraph.cxx |   73 +++++++++++++++-----------------
 1 file changed, 36 insertions(+), 37 deletions(-)

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

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

diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index f8a0983432e0..f7a76e902013 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -37,6 +37,7 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 #include <docsh.hxx>
+#include <swunohelper.hxx>
 
 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
@@ -44,14 +45,14 @@
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
-#include <comphelper/servicehelper.hxx>
 
-#include <swunohelper.hxx>
-#include <svx/unobrushitemhelper.hxx>
+#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <comphelper/servicehelper.hxx>
 #include <editeng/unoipset.hxx>
-#include <svx/xflbstit.hxx>
+#include <svl/listener.hxx>
+#include <svx/unobrushitemhelper.hxx>
 #include <svx/xflbmtit.hxx>
-#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <svx/xflbstit.hxx>
 
 using namespace ::com::sun::star;
 
@@ -102,47 +103,47 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState(
                             bool &rAttrSetFetched );
 
 class SwXParagraph::Impl
-    : public SwClient
+    : public SvtListener
 {
 private:
     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
 
 public:
-    SwXParagraph &              m_rThis;
+    SwXParagraph& m_rThis;
     uno::WeakReference<uno::XInterface> m_wThis;
     ::comphelper::OInterfaceContainerHelper2 m_EventListeners;
-    SfxItemPropertySet const&   m_rPropSet;
-    bool                        m_bIsDescriptor;
-    sal_Int32                   m_nSelectionStartPos;
-    sal_Int32                   m_nSelectionEndPos;
-    OUString             m_sText;
+    SfxItemPropertySet const& m_rPropSet;
+    bool m_bIsDescriptor;
+    sal_Int32 m_nSelectionStartPos;
+    sal_Int32 m_nSelectionEndPos;
+    OUString m_sText;
     uno::Reference<text::XText> m_xParentText;
+    SwTextNode* m_pTextNode;
 
-    Impl(   SwXParagraph & rThis,
-            SwTextNode *const pTextNode = nullptr,
-            uno::Reference< text::XText > const & xParent = nullptr,
+    Impl(SwXParagraph& rThis,
+            SwTextNode* const pTextNode = nullptr, uno::Reference<text::XText> const& xParent = nullptr,
             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
-        : SwClient(pTextNode)
-        , m_rThis(rThis)
+        : m_rThis(rThis)
         , m_EventListeners(m_Mutex)
         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
         , m_bIsDescriptor(nullptr == pTextNode)
         , m_nSelectionStartPos(nSelStart)
         , m_nSelectionEndPos(nSelEnd)
         , m_xParentText(xParent)
+        , m_pTextNode(pTextNode)
     {
+        m_pTextNode && StartListening(m_pTextNode->GetNotifier());
     }
 
     SwTextNode* GetTextNode() {
-        return static_cast<SwTextNode*>(GetRegisteredInNonConst());
+        return m_pTextNode;
     }
 
-    SwTextNode & GetTextNodeOrThrow() {
-        SwTextNode *const pTextNode( GetTextNode() );
-        if (!pTextNode) {
+    SwTextNode& GetTextNodeOrThrow() {
+        if (!m_pTextNode) {
             throw uno::RuntimeException("SwXParagraph: disposed or invalid", nullptr);
         }
-        return *pTextNode;
+        return *m_pTextNode;
     }
 
     bool IsDescriptor() const { return m_bIsDescriptor; }
@@ -175,26 +176,23 @@ public:
             const uno::Sequence< OUString >& rPropertyNames,
             bool bDirectValuesOnly);
 protected:
-    // SwClient
-    virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+    virtual void Notify(const SfxHint& rHint) override;
 
 };
 
-void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
+void SwXParagraph::Impl::Notify(const SfxHint& rHint)
 {
-    ClientModify(this, pOld, pNew);
-    if (GetRegisteredIn())
+    if(rHint.GetId() == SfxHintId::Dying)
     {
-        return; // core object still alive
-    }
-
-    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;
+        m_pTextNode = nullptr;
+        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;
+        }
+        lang::EventObject const ev(xThis);
+        m_EventListeners.disposeAndClear(ev);
     }
-    lang::EventObject const ev(xThis);
-    m_EventListeners.disposeAndClear(ev);
 }
 
 SwXParagraph::SwXParagraph()
@@ -336,7 +334,8 @@ SwXParagraph::attachToText(SwXText & rParent, SwTextNode & rTextNode)
     if (m_pImpl->m_bIsDescriptor)
     {
         m_pImpl->m_bIsDescriptor = false;
-        rTextNode.Add(m_pImpl.get());
+        m_pImpl->EndListeningAll();
+        m_pImpl->StartListening(rTextNode.GetNotifier());
         rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
         m_pImpl->m_xParentText = &rParent;
         if (!m_pImpl->m_sText.isEmpty())


More information about the Libreoffice-commits mailing list