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

SwXOLEListener: not SwClient/Modify

Change-Id: Ie27432549e835622ab8480acfb3ed613aef623ab
Reviewed-on: https://gerrit.libreoffice.org/66411
Tested-by: Jenkins
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst d807d6a6
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <svl/listener.hxx>
#include "flyenum.hxx" #include "flyenum.hxx"
#include "frmfmt.hxx" #include "frmfmt.hxx"
...@@ -306,10 +307,10 @@ public: ...@@ -306,10 +307,10 @@ public:
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override; virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
}; };
class SwXOLEListener : public cppu::WeakImplHelper<css::util::XModifyListener>, class SwXOLEListener : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
public SwClient
{ {
css::uno::Reference< css::frame::XModel > xOLEModel; SwFormat* m_pOLEFormat;
css::uno::Reference<css::frame::XModel> m_xOLEModel;
public: public:
SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > const & xOLE); SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > const & xOLE);
...@@ -321,8 +322,7 @@ public: ...@@ -321,8 +322,7 @@ public:
// css::util::XModifyListener // css::util::XModifyListener
virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
protected: virtual void Notify( const SfxHint& ) override;
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
}; };
#endif #endif
......
...@@ -3541,11 +3541,25 @@ uno::Reference<container::XNameReplace> SAL_CALL ...@@ -3541,11 +3541,25 @@ uno::Reference<container::XNameReplace> SAL_CALL
return new SwFrameEventDescriptor( *this ); return new SwFrameEventDescriptor( *this );
} }
namespace
{
SwOLENode* lcl_GetOLENode(const SwFormat* pFormat)
{
if(!pFormat)
return nullptr;
const SwNodeIndex* pIdx(pFormat->GetContent().GetContentIdx());
if(!pIdx)
return nullptr;
const SwNodeIndex aIdx(*pIdx, 1);
return aIdx.GetNode().GetNoTextNode()->GetOLENode();
}
}
SwXOLEListener::SwXOLEListener( SwFormat& rOLEFormat, uno::Reference< XModel > const & xOLE) : SwXOLEListener::SwXOLEListener( SwFormat& rOLEFormat, uno::Reference< XModel > const & xOLE)
SwClient(&rOLEFormat), : m_pOLEFormat(&rOLEFormat)
xOLEModel(xOLE) , m_xOLEModel(xOLE)
{ {
StartListening(m_pOLEFormat->GetNotifier());
} }
SwXOLEListener::~SwXOLEListener() SwXOLEListener::~SwXOLEListener()
...@@ -3554,30 +3568,17 @@ SwXOLEListener::~SwXOLEListener() ...@@ -3554,30 +3568,17 @@ SwXOLEListener::~SwXOLEListener()
void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ ) void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
const auto pNd = lcl_GetOLENode(m_pOLEFormat);
SwOLENode* pNd = nullptr;
SwFormat* pFormat = static_cast<SwFormat*>(GetRegisteredIn());
if(pFormat)
{const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
if(pIdx)
{
SwNodeIndex aIdx(*pIdx, 1);
SwNoTextNode* pNoText = aIdx.GetNode().GetNoTextNode();
pNd = pNoText->GetOLENode();
}
}
if(!pNd) if(!pNd)
throw uno::RuntimeException(); throw uno::RuntimeException();
const auto xIP = pNd->GetOLEObj().GetOleRef();
uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef(); if(xIP.is())
if ( xIP.is() )
{ {
sal_Int32 nState = xIP->getCurrentState(); sal_Int32 nState = xIP->getCurrentState();
if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE ) if(nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE)
// if the OLE-Node is UI-Active do nothing
return; return;
} }
// if the OLE-Node is UI-Active do nothing
pNd->SetOLESizeInvalid(true); pNd->SetOLESizeInvalid(true);
pNd->GetDoc()->SetOLEObjModified(); pNd->GetDoc()->SetOLEObjModified();
} }
...@@ -3585,16 +3586,14 @@ void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ ) ...@@ -3585,16 +3586,14 @@ void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
void SwXOLEListener::disposing( const lang::EventObject& rEvent ) void SwXOLEListener::disposing( const lang::EventObject& rEvent )
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
uno::Reference<util::XModifyListener> xListener( this );
uno::Reference< util::XModifyListener > xListener( this ); uno::Reference<frame::XModel> xModel(rEvent.Source, uno::UNO_QUERY);
uno::Reference<util::XModifyBroadcaster> xBrdcst(xModel, uno::UNO_QUERY);
uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY ); if(!xBrdcst.is())
uno::Reference< util::XModifyBroadcaster > xBrdcst(xModel, uno::UNO_QUERY); return;
try try
{ {
if( xBrdcst.is() ) xBrdcst->removeModifyListener(xListener);
xBrdcst->removeModifyListener( xListener );
} }
catch(uno::Exception const &) catch(uno::Exception const &)
{ {
...@@ -3602,11 +3601,13 @@ void SwXOLEListener::disposing( const lang::EventObject& rEvent ) ...@@ -3602,11 +3601,13 @@ void SwXOLEListener::disposing( const lang::EventObject& rEvent )
} }
} }
void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) void SwXOLEListener::Notify( const SfxHint& rHint )
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if(!GetRegisteredIn()) {
xOLEModel = nullptr; m_xOLEModel = nullptr;
m_pOLEFormat = nullptr;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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