dont use SwClient/SwModify in unocore: RefMark

Change-Id: I021f410793c9debfe5e984d591144636d6793fd6
Reviewed-on: https://gerrit.libreoffice.org/54610
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
This commit is contained in:
Bjoern Michaelsen
2018-05-10 10:51:42 +02:00
committed by Björn Michaelsen
parent 4da8aef204
commit 0c02f3c5d6
2 changed files with 30 additions and 34 deletions

View File

@@ -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;

View File

@@ -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 @@
#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 @@
#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
@@ -75,24 +75,23 @@ public:
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,15 +109,11 @@ 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 (!IsValid()) // removed => dispose
{ {
if(rHint.GetId() == SfxHintId::Dying)
Invalidate(); Invalidate();
} }
}
SwXReferenceMark::SwXReferenceMark( SwXReferenceMark::SwXReferenceMark(
SwDoc *const pDoc, SwFormatRefMark *const pRefMark) SwDoc *const pDoc, SwFormatRefMark *const pRefMark)
@@ -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