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 @@
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <cppuhelper/implbase.hxx>
#include <svl/listener.hxx>
#include "flyenum.hxx"
#include "frmfmt.hxx"
......@@ -306,10 +307,10 @@ public:
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
};
class SwXOLEListener : public cppu::WeakImplHelper<css::util::XModifyListener>,
public SwClient
class SwXOLEListener : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
{
css::uno::Reference< css::frame::XModel > xOLEModel;
SwFormat* m_pOLEFormat;
css::uno::Reference<css::frame::XModel> m_xOLEModel;
public:
SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > const & xOLE);
......@@ -321,8 +322,7 @@ public:
// css::util::XModifyListener
virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
protected:
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
virtual void Notify( const SfxHint& ) override;
};
#endif
......
......@@ -3541,11 +3541,25 @@ uno::Reference<container::XNameReplace> SAL_CALL
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) :
SwClient(&rOLEFormat),
xOLEModel(xOLE)
SwXOLEListener::SwXOLEListener( SwFormat& rOLEFormat, uno::Reference< XModel > const & xOLE)
: m_pOLEFormat(&rOLEFormat)
, m_xOLEModel(xOLE)
{
StartListening(m_pOLEFormat->GetNotifier());
}
SwXOLEListener::~SwXOLEListener()
......@@ -3554,30 +3568,17 @@ SwXOLEListener::~SwXOLEListener()
void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
{
SolarMutexGuard aGuard;
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();
}
}
const auto pNd = lcl_GetOLENode(m_pOLEFormat);
if(!pNd)
throw uno::RuntimeException();
uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef();
if ( xIP.is() )
const auto xIP = pNd->GetOLEObj().GetOleRef();
if(xIP.is())
{
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;
}
// if the OLE-Node is UI-Active do nothing
pNd->SetOLESizeInvalid(true);
pNd->GetDoc()->SetOLEObjModified();
}
......@@ -3585,16 +3586,14 @@ void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ )
void SwXOLEListener::disposing( const lang::EventObject& rEvent )
{
SolarMutexGuard aGuard;
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<util::XModifyListener> xListener( this );
uno::Reference<frame::XModel> xModel(rEvent.Source, uno::UNO_QUERY);
uno::Reference<util::XModifyBroadcaster> xBrdcst(xModel, uno::UNO_QUERY);
if(!xBrdcst.is())
return;
try
{
if( xBrdcst.is() )
xBrdcst->removeModifyListener( xListener );
xBrdcst->removeModifyListener(xListener);
}
catch(uno::Exception const &)
{
......@@ -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(!GetRegisteredIn())
xOLEModel = nullptr;
if(rHint.GetId() == SfxHintId::Dying)
{
m_xOLEModel = nullptr;
m_pOLEFormat = nullptr;
}
}
/* 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