sw/inc/unoframe.hxx | 10 ++--- sw/source/core/unocore/unoframe.cxx | 67 ++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 38 deletions(-)
New commits: commit 9bc56a8b61c276a4fa08db3e45b78122273feb2b Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Tue Jan 15 22:23:37 2019 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Wed Jan 16 21:02:59 2019 +0100 SwXOLEListener: not SwClient/Modify Change-Id: Ie27432549e835622ab8480acfb3ed613aef623ab Reviewed-on: https://gerrit.libreoffice.org/66411 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 43876e94a580..8751e7806480 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -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 diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 07c37323d917..7d748b8984e3 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits