diff --git a/sc/inc/dispuno.hxx b/sc/inc/dispuno.hxx index 39d2e358003f..d585b7161b59 100644 --- a/sc/inc/dispuno.hxx +++ b/sc/inc/dispuno.hxx @@ -2,9 +2,9 @@ * * $RCSfile: dispuno.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: nn $ $Date: 2001-07-18 10:17:27 $ + * last change: $Author: nn $ $Date: 2002-08-16 09:27:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,10 @@ #include #endif +#ifndef _SFXLSTNER_HXX //autogen +#include +#endif + #ifndef _SVARRAY_HXX #include #endif @@ -96,7 +100,8 @@ SV_DECL_PTRARR_DEL( XStatusListenerArr_Impl, XStatusListenerPtr, 4, 4 ); class ScDispatchProviderInterceptor : public cppu::WeakImplHelper2< com::sun::star::frame::XDispatchProviderInterceptor, - com::sun::star::lang::XEventListener> + com::sun::star::lang::XEventListener>, + public SfxListener { ScTabViewShell* pViewShell; @@ -119,6 +124,8 @@ public: ScDispatchProviderInterceptor(ScTabViewShell* pViewSh); virtual ~ScDispatchProviderInterceptor(); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + // XDispatchProvider virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, @@ -151,7 +158,8 @@ public: class ScDispatch : public cppu::WeakImplHelper2< com::sun::star::frame::XDispatch, - com::sun::star::view::XSelectionChangeListener > + com::sun::star::view::XSelectionChangeListener >, + public SfxListener { ScTabViewShell* pViewShell; XStatusListenerArr_Impl aDataSourceListeners; @@ -163,6 +171,8 @@ public: ScDispatch(ScTabViewShell* pViewSh); virtual ~ScDispatch(); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + // XDispatch virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx index 43dcf6f1b695..c255c11676b8 100644 --- a/sc/source/ui/unoobj/dispuno.cxx +++ b/sc/source/ui/unoobj/dispuno.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dispuno.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: nn $ $Date: 2001-07-18 10:18:09 $ + * last change: $Author: nn $ $Date: 2002-08-16 09:27:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -132,11 +133,22 @@ ScDispatchProviderInterceptor::ScDispatchProviderInterceptor(ScTabViewShell* pVi comphelper::decrement( m_refCount ); } + + StartListening(*pViewShell); } } ScDispatchProviderInterceptor::~ScDispatchProviderInterceptor() { + if (pViewShell) + EndListening(*pViewShell); +} + +void ScDispatchProviderInterceptor::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + if ( rHint.ISA( SfxSimpleHint ) && + ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) + pViewShell = NULL; } // XDispatchProvider @@ -150,8 +162,9 @@ uno::Reference SAL_CALL ScDispatchProviderInterceptor::queryDi uno::Reference xResult; // create some dispatch ... - if( !aURL.Complete.compareToAscii(cURLInsertColumns) || - !aURL.Complete.compareToAscii(cURLDocDataSource) ) + if ( pViewShell && ( + !aURL.Complete.compareToAscii(cURLInsertColumns) || + !aURL.Complete.compareToAscii(cURLDocDataSource) ) ) { if (!m_xMyDispatch.is()) m_xMyDispatch = new ScDispatch( pViewShell ); @@ -243,10 +256,15 @@ ScDispatch::ScDispatch(ScTabViewShell* pViewSh) : pViewShell( pViewSh ), bListeningToView( FALSE ) { + if (pViewShell) + StartListening(*pViewShell); } ScDispatch::~ScDispatch() { + if (pViewShell) + EndListening(*pViewShell); + if (bListeningToView && pViewShell) { uno::Reference xSupplier = lcl_GetSelectionSupplier( pViewShell ); @@ -258,6 +276,13 @@ ScDispatch::~ScDispatch() } } +void ScDispatch::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + if ( rHint.ISA( SfxSimpleHint ) && + ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) + pViewShell = NULL; +} + // XDispatch void SAL_CALL ScDispatch::dispatch( const util::URL& aURL,