#102213# notice if the viewshell is closed (switching to preview)

This commit is contained in:
Niklas Nebel 2002-08-16 08:27:33 +00:00
parent 943e3aaa8e
commit 0f32a0915a
2 changed files with 43 additions and 8 deletions

View file

@ -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 <cppuhelper/implbase2.hxx>
#endif
#ifndef _SFXLSTNER_HXX //autogen
#include <svtools/lstner.hxx>
#endif
#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#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<

View file

@ -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 <sfx2/viewfrm.hxx>
#include <comphelper/uno3.hxx>
#include <svx/dataaccessdescriptor.hxx>
#include <svtools/smplhint.hxx>
#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
@ -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<frame::XDispatch> SAL_CALL ScDispatchProviderInterceptor::queryDi
uno::Reference<frame::XDispatch> 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<view::XSelectionSupplier> 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,