diff options
author | Mathias Bauer <mba@openoffice.org> | 2001-12-07 13:48:45 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2001-12-07 13:48:45 +0000 |
commit | 1cf0e949f721c8211bf035643729eb6bf5fa51ad (patch) | |
tree | d1ddf0af19f82223204a0031dfac7a9a9131a3ba /sfx2/source | |
parent | 181fe793faeb9b133cdb282890cbfbe40755fc44 (diff) |
#93782#: intercept context menues
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/view/viewimp.hxx | 15 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 74 |
3 files changed, 89 insertions, 8 deletions
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 6e5679c10e1f..865d37c6025b 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sfxbasecontroller.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: mba $ $Date: 2001-12-07 14:48:17 $ + * last change: $Author: mba $ $Date: 2001-12-07 14:48:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -417,7 +417,7 @@ ANY SAL_CALL SfxBaseController::queryInterface( const UNOTYPE& rType ) throw( RU static_cast< XCONTROLLER* > ( this ) , static_cast< XSTATUSINDICATORSUPPLIER* > ( this ) , static_cast< XDISPATCHINFORMATIONPROVIDER* > ( this ) , - // static_cast< XCONTEXTMENUINTERCEPTION* > ( this ) , + static_cast< XCONTEXTMENUINTERCEPTION* > ( this ) , static_cast< XDISPATCHPROVIDER* > ( this ) ) ) ; // If searched interface supported by this class ... @@ -482,7 +482,7 @@ SEQUENCE< UNOTYPE > SAL_CALL SfxBaseController::getTypes() throw( RUNTIMEEXCEPTI static OTYPECOLLECTION aTypeCollection( ::getCppuType(( const REFERENCE< XTYPEPROVIDER >*)NULL ) , ::getCppuType(( const REFERENCE< XSTATUSINDICATORSUPPLIER >*)NULL ) , ::getCppuType(( const REFERENCE< XCONTROLLER >*)NULL ) , -// ::getCppuType(( const REFERENCE< XCONTEXTMENUINTERCEPTION >*)NULL ) , + ::getCppuType(( const REFERENCE< XCONTEXTMENUINTERCEPTION >*)NULL ) , ::getCppuType(( const REFERENCE< XDISPATCHINFORMATIONPROVIDER >*)NULL ) , ::getCppuType(( const REFERENCE< XDISPATCHPROVIDER >*)NULL ) ) ; // ... and set his address to static pointer! diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 154d0b124b01..fea3324403c3 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: viewimp.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mba $ $Date: 2001-03-30 15:59:24 $ + * last change: $Author: mba $ $Date: 2001-12-07 14:48:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,11 @@ #endif #include "viewsh.hxx" +#include <osl/mutex.hxx> +#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#include <cppuhelper/interfacecontainer.hxx> +#endif + // forward --------------------------------------------------------------- class SfxFrameSetDescriptor; @@ -96,6 +101,8 @@ SV_DECL_PTRARR( SfxOffDispArr_Impl, SfxOffDispPtr_Impl, 4, 4 ); struct SfxViewShell_Impl { + ::osl::Mutex aMutex; + ::cppu::OInterfaceContainerHelper aInterceptorContainer; BOOL bControllerSet; SfxShellArr_Impl aArr; ModelessDialogPtrArr_Impl aDialogArr; @@ -119,6 +126,10 @@ struct SfxViewShell_Impl SfxAcceleratorManager* pAccel; USHORT nFamily; SfxBaseController* pController; + + SfxViewShell_Impl() + : aInterceptorContainer( aMutex ) + {} }; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index e307d5bb88ff..a04dbe5f5c3d 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2,9 +2,9 @@ * * $RCSfile: viewsh.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: mba $ $Date: 2001-11-01 11:14:16 $ + * last change: $Author: mba $ $Date: 2001-12-07 14:48:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,6 +100,7 @@ #include <svtools/javaoptions.hxx> #include <basic/basmgr.hxx> #include <basic/sbuno.hxx> +#include <framework/actiontriggerhelper.hxx> #pragma hdrstop @@ -1839,3 +1840,72 @@ void SfxViewShell::RemoveModelessDialog( USHORT nSlotId ) } } +void SfxViewShell::AddContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) +{ + pImp->aInterceptorContainer.addInterface( xInterceptor ); +} + +void SfxViewShell::RemoveContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) +{ + pImp->aInterceptorContainer.removeInterface( xInterceptor ); +} + +::cppu::OInterfaceContainerHelper& SfxViewShell::GetContextMenuInterceptors() const +{ + return pImp->aInterceptorContainer; +} + +BOOL SfxViewShell::TryContextMenuInterception( Menu& rIn, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent ) +{ + rpOut = NULL; + BOOL bModified = FALSE; + + // create container from menu + aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu( &rIn ); + + // get selection from controller + aEvent.Selection = ::com::sun::star::uno::Reference < ::com::sun::star::view::XSelectionSupplier > ( GetController(), ::com::sun::star::uno::UNO_QUERY ); + + // call interceptors + ::cppu::OInterfaceIteratorHelper aIt( pImp->aInterceptorContainer ); + while( aIt.hasMoreElements() ) + { + ::com::sun::star::ui::ContextMenuInterceptorAction eAction = + ((::com::sun::star::ui::XContextMenuInterceptor*)aIt.next())->notifyContextMenuExecute( aEvent ); + switch ( eAction ) + { + case ::com::sun::star::ui::ContextMenuInterceptorAction_CANCELLED : + // interceptor does not want execution + return FALSE; + break; + case ::com::sun::star::ui::ContextMenuInterceptorAction_EXECUTE_MODIFIED : + // interceptor wants his modified menu to be executed + bModified = TRUE; + break; + case ::com::sun::star::ui::ContextMenuInterceptorAction_CONTINUE_MODIFIED : + // interceptor has modified menu, but allows for calling other interceptors + bModified = TRUE; + continue; + break; + case ::com::sun::star::ui::ContextMenuInterceptorAction_IGNORED : + // interceptor is indifferent + continue; + break; + default: + DBG_ERROR("Wrong return value of ContextMenuInterceptor!"); + continue; + break; + } + + break; + } + + if ( bModified ) + { + // container was modified, create a new window out of it + rpOut = new PopupMenu; + ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer( rpOut, aEvent.ActionTriggerContainer ); + } + + return TRUE; +} |