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

dont use SwClient/SwModify in unocore: Meta

Change-Id: Icde1f5b9af599ca8b1ef52863c2772670659a39b
Reviewed-on: https://gerrit.libreoffice.org/54648Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 74aeeb9a
......@@ -127,6 +127,7 @@ namespace sw {
class Meta
: public ::sfx2::Metadatable
, public SwModify
, public sw::BroadcasterMixin
{
protected:
friend class ::SwFormatMeta; ///< SetFormatMeta, NotifyChangeTextNode
......
......@@ -664,9 +664,7 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode)
}
if (!pTextNode) // text node gone? invalidate UNO object!
{
SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
&static_cast<SwModify&>(*this) ); // cast to base class!
Modify(&aMsgHint, &aMsgHint);
GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
}
}
......@@ -674,9 +672,11 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode)
void Meta::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
{
NotifyClients(pOld, pNew);
GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged));
if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
{ // invalidate cached uno object
SetXMeta(uno::Reference<rdf::XMetadatable>(nullptr));
GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing));
}
}
......
......@@ -607,8 +607,7 @@ SwXMetaText::createTextCursorByRange(
// the Meta has a cached list of text portions for its contents
// this list is created by SwXTextPortionEnumeration
// the Meta listens at the SwTextNode and throws away the cache when it changes
class SwXMeta::Impl
: public SwClient
class SwXMeta::Impl : public SvtListener
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
......@@ -622,56 +621,53 @@ public:
bool m_bIsDescriptor;
uno::Reference<text::XText> m_xParentText;
rtl::Reference<SwXMetaText> m_xText;
sw::Meta* m_pMeta;
Impl( SwXMeta & rThis, SwDoc & rDoc,
::sw::Meta * const pMeta,
Impl(SwXMeta& rThis, SwDoc& rDoc,
::sw::Meta* const pMeta,
uno::Reference<text::XText> const& xParentText,
TextRangeList_t const * const pPortions)
: SwClient(pMeta)
, m_EventListeners(m_Mutex)
, m_pTextPortions( pPortions )
, m_bIsDisposed( false )
: m_EventListeners(m_Mutex)
, m_pTextPortions(pPortions)
, m_bIsDisposed(false)
, m_bIsDescriptor(nullptr == pMeta)
, m_xParentText(xParentText)
, m_xText(new SwXMetaText(rDoc, rThis))
, m_pMeta(pMeta)
{
!m_bIsDescriptor && StartListening(m_pMeta->GetNotifier());
}
inline const ::sw::Meta * GetMeta() const;
inline const ::sw::Meta* GetMeta() const;
// only for SwXMetaField!
inline const ::sw::MetaField * GetMetaField() const;
inline const ::sw::MetaField* GetMetaField() const;
protected:
// SwClient
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
virtual void Notify(const SfxHint& rHint) override;
};
inline const ::sw::Meta * SwXMeta::Impl::GetMeta() const
inline const ::sw::Meta* SwXMeta::Impl::GetMeta() const
{
return static_cast< const ::sw::Meta * >(GetRegisteredIn());
return m_pMeta;
}
// SwModify
void SwXMeta::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
void SwXMeta::Impl::Notify(const SfxHint& rHint)
{
m_pTextPortions.reset(); // throw away cache (SwTextNode changed)
ClientModify(this, pOld, pNew);
if (GetRegisteredIn())
if(rHint.GetId() == SfxHintId::Dying || rHint.GetId() == SfxHintId::Deinitializing)
{
return; // core object still alive
}
m_bIsDisposed = true;
m_xText->Invalidate();
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_bIsDisposed = true;
m_pMeta = nullptr;
m_xText->Invalidate();
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);
}
uno::Reference<text::XText> const & SwXMeta::GetParentText() const
......@@ -1020,7 +1016,9 @@ SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange,
static_cast< ::cppu::OWeakObject* >(this));
}
pMeta->Add(m_pImpl.get());
m_pImpl->EndListeningAll();
m_pImpl->m_pMeta = pMeta.get();
m_pImpl->StartListening(pMeta->GetNotifier());
pMeta->SetXMeta(uno::Reference<rdf::XMetadatable>(this));
m_pImpl->m_xParentText = ::sw::CreateParentXText(*pDoc, *aPam.GetPoint());
......@@ -1186,12 +1184,10 @@ SwXMeta::getElementType()
return cppu::UnoType<text::XTextRange>::get();
}
sal_Bool SAL_CALL
SwXMeta::hasElements()
sal_Bool SAL_CALL SwXMeta::hasElements()
{
SolarMutexGuard g;
return m_pImpl->GetRegisteredIn() != nullptr;
return m_pImpl->m_pMeta != nullptr;
}
// XEnumerationAccess
......@@ -1253,9 +1249,9 @@ uno::Reference<frame::XModel> SwXMeta::GetModel()
return nullptr;
}
inline const ::sw::MetaField * SwXMeta::Impl::GetMetaField() const
inline const ::sw::MetaField* SwXMeta::Impl::GetMetaField() const
{
return static_cast< const ::sw::MetaField * >(GetRegisteredIn());
return dynamic_cast<sw::MetaField*>(m_pMeta);
}
SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta,
......
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