Kaydet (Commit) 0c02f3c5 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

dont use SwClient/SwModify in unocore: RefMark

Change-Id: I021f410793c9debfe5e984d591144636d6793fd6
Reviewed-on: https://gerrit.libreoffice.org/54610Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 4da8aef2
...@@ -36,6 +36,7 @@ class SwTextRefMark; ...@@ -36,6 +36,7 @@ class SwTextRefMark;
class SwFormatRefMark class SwFormatRefMark
: public SfxPoolItem : public SfxPoolItem
, public SwModify , public SwModify
, public sw::BroadcasterMixin
{ {
friend class SwTextRefMark; friend class SwTextRefMark;
SwTextRefMark* m_pTextAttr; SwTextRefMark* m_pTextAttr;
......
...@@ -18,13 +18,16 @@ ...@@ -18,13 +18,16 @@
*/ */
#include <memory> #include <memory>
#include <sal/config.h>
#include <utility> #include <utility>
#include <osl/mutex.hxx>
#include <comphelper/interfacecontainer2.hxx> #include <comphelper/interfacecontainer2.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
#include <osl/mutex.hxx>
#include <sal/config.h>
#include <svl/listener.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <unomid.h> #include <unomid.h>
...@@ -39,7 +42,13 @@ ...@@ -39,7 +42,13 @@
#include <fmtrfmrk.hxx> #include <fmtrfmrk.hxx>
#include <txtrfmrk.hxx> #include <txtrfmrk.hxx>
#include <hints.hxx> #include <hints.hxx>
#include <comphelper/servicehelper.hxx> #include <unometa.hxx>
#include <unotext.hxx>
#include <unoport.hxx>
#include <txtatr.hxx>
#include <fmtmeta.hxx>
#include <docsh.hxx>
#include <com/sun/star/lang/NoSupportException.hpp> #include <com/sun/star/lang/NoSupportException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/rdf/Statement.hpp> #include <com/sun/star/rdf/Statement.hpp>
...@@ -47,21 +56,12 @@ ...@@ -47,21 +56,12 @@
#include <com/sun/star/rdf/URIs.hpp> #include <com/sun/star/rdf/URIs.hpp>
#include <com/sun/star/rdf/XLiteral.hpp> #include <com/sun/star/rdf/XLiteral.hpp>
#include <com/sun/star/rdf/XRepositorySupplier.hpp> #include <com/sun/star/rdf/XRepositorySupplier.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
#include <unometa.hxx>
#include <unotext.hxx>
#include <unoport.hxx>
#include <txtatr.hxx>
#include <fmtmeta.hxx>
#include <docsh.hxx>
#include <cppuhelper/weak.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
class SwXReferenceMark::Impl class SwXReferenceMark::Impl
: public SwClient : public SvtListener
{ {
private: private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2 ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
...@@ -69,30 +69,29 @@ private: ...@@ -69,30 +69,29 @@ private:
public: public:
uno::WeakReference<uno::XInterface> m_wThis; uno::WeakReference<uno::XInterface> m_wThis;
::comphelper::OInterfaceContainerHelper2 m_EventListeners; ::comphelper::OInterfaceContainerHelper2 m_EventListeners;
bool m_bIsDescriptor; bool m_bIsDescriptor;
SwDoc * m_pDoc; SwDoc* m_pDoc;
const SwFormatRefMark * m_pMarkFormat; const SwFormatRefMark* m_pMarkFormat;
OUString m_sMarkName; OUString m_sMarkName;
Impl( SwDoc *const pDoc, SwFormatRefMark *const pRefMark) Impl(SwDoc* const pDoc, SwFormatRefMark* const pRefMark)
: SwClient(pRefMark) : m_EventListeners(m_Mutex)
, m_EventListeners(m_Mutex)
, m_bIsDescriptor(nullptr == pRefMark) , m_bIsDescriptor(nullptr == pRefMark)
, m_pDoc(pDoc) , m_pDoc(pDoc)
, m_pMarkFormat(pRefMark) , m_pMarkFormat(pRefMark)
{ {
if (pRefMark) if (pRefMark)
{ {
StartListening(pRefMark->GetNotifier());
m_sMarkName = pRefMark->GetRefName(); m_sMarkName = pRefMark->GetRefName();
} }
} }
bool IsValid() const { return nullptr != GetRegisteredIn(); } bool IsValid() const { return m_pMarkFormat; }
void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor ); void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor );
void Invalidate(); void Invalidate();
protected: protected:
// SwClient virtual void Notify(const SfxHint&) override;
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
}; };
...@@ -110,14 +109,10 @@ void SwXReferenceMark::Impl::Invalidate() ...@@ -110,14 +109,10 @@ void SwXReferenceMark::Impl::Invalidate()
m_EventListeners.disposeAndClear(ev); m_EventListeners.disposeAndClear(ev);
} }
void SwXReferenceMark::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXReferenceMark::Impl::Notify(const SfxHint& rHint)
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if (!IsValid()) // removed => dispose
{
Invalidate(); Invalidate();
}
} }
SwXReferenceMark::SwXReferenceMark( SwXReferenceMark::SwXReferenceMark(
...@@ -272,8 +267,8 @@ void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam, ...@@ -272,8 +267,8 @@ void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam,
} }
m_pMarkFormat = &pTextAttr->GetRefMark(); m_pMarkFormat = &pTextAttr->GetRefMark();
EndListeningAll();
const_cast<SwFormatRefMark*>(m_pMarkFormat)->Add(this); StartListening(const_cast<SwFormatRefMark*>(m_pMarkFormat)->GetNotifier());
} }
void SAL_CALL void SAL_CALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment