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

dont use SwClient/SwModify in unocore: Bookmark

Change-Id: Iea03642c6b1de1160b98e3b61e831588bb6207b7
Reviewed-on: https://gerrit.libreoffice.org/54609Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 1e9304e2
...@@ -18,10 +18,16 @@ ...@@ -18,10 +18,16 @@
*/ */
#include <unobookmark.hxx> #include <unobookmark.hxx>
#include <osl/mutex.hxx>
#include <comphelper/interfacecontainer2.hxx> #include <comphelper/interfacecontainer2.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
#include <svl/itemprop.hxx>
#include <svl/listener.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <xmloff/odffields.hxx>
#include <TextCursorHelper.hxx> #include <TextCursorHelper.hxx>
#include <unotextrange.hxx> #include <unotextrange.hxx>
...@@ -34,30 +40,25 @@ ...@@ -34,30 +40,25 @@
#include <docary.hxx> #include <docary.hxx>
#include <swundo.hxx> #include <swundo.hxx>
#include <docsh.hxx> #include <docsh.hxx>
#include <xmloff/odffields.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/sequence.hxx>
#include <svl/itemprop.hxx>
using namespace ::sw::mark; using namespace ::sw::mark;
using namespace ::com::sun::star; using namespace ::com::sun::star;
class SwXBookmark::Impl class SwXBookmark::Impl
: public SwClient : public SvtListener
{ {
private: private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2 ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
public: public:
uno::WeakReference<uno::XInterface> m_wThis; uno::WeakReference<uno::XInterface> m_wThis;
::comphelper::OInterfaceContainerHelper2 m_EventListeners; ::comphelper::OInterfaceContainerHelper2 m_EventListeners;
SwDoc * m_pDoc; SwDoc* m_pDoc;
::sw::mark::IMark * m_pRegisteredBookmark; ::sw::mark::IMark* m_pRegisteredBookmark;
OUString m_sMarkName; OUString m_sMarkName;
Impl( SwDoc *const pDoc ) Impl( SwDoc *const pDoc )
: SwClient() : m_EventListeners(m_Mutex)
, m_EventListeners(m_Mutex)
, m_pDoc(pDoc) , m_pDoc(pDoc)
, m_pRegisteredBookmark(nullptr) , m_pRegisteredBookmark(nullptr)
{ {
...@@ -66,37 +67,34 @@ public: ...@@ -66,37 +67,34 @@ public:
void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk); void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk);
protected: protected:
// SwClient virtual void Notify(const SfxHint&) override;
virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
}; };
void SwXBookmark::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) void SwXBookmark::Impl::Notify(const SfxHint& rHint)
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if (GetRegisteredIn())
{ {
return; // core object still alive m_pRegisteredBookmark = nullptr;
} m_pDoc = nullptr;
uno::Reference<uno::XInterface> const xThis(m_wThis);
m_pRegisteredBookmark = nullptr; if (!xThis.is())
m_pDoc = nullptr; { // fdo#72695: if UNO object is already dead, don't revive it with event
uno::Reference<uno::XInterface> const xThis(m_wThis); return;
if (!xThis.is()) }
{ // fdo#72695: if UNO object is already dead, don't revive it with event lang::EventObject const ev(xThis);
return; m_EventListeners.disposeAndClear(ev);
} }
lang::EventObject const ev(xThis);
m_EventListeners.disposeAndClear(ev);
} }
void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis, void SwXBookmark::Impl::registerInMark(SwXBookmark& rThis,
::sw::mark::IMark *const pBkmk) ::sw::mark::IMark* const pBkmk)
{ {
const uno::Reference<text::XTextContent> xBookmark(& rThis); const uno::Reference<text::XTextContent> xBookmark(&rThis);
if (pBkmk) if (pBkmk)
{ {
pBkmk->Add(this); EndListeningAll();
StartListening(pBkmk->GetNotifier());
::sw::mark::MarkBase *const pMarkBase(dynamic_cast< ::sw::mark::MarkBase * >(pBkmk)); ::sw::mark::MarkBase *const pMarkBase(dynamic_cast< ::sw::mark::MarkBase * >(pBkmk));
OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?"); OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?");
if (pMarkBase) if (pMarkBase)
......
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