diff options
Diffstat (limited to 'framework/inc/dispatch')
-rw-r--r-- | framework/inc/dispatch/basedispatcher.hxx | 391 | ||||
-rw-r--r-- | framework/inc/dispatch/blankdispatcher.hxx | 129 | ||||
-rw-r--r-- | framework/inc/dispatch/closedispatcher.hxx | 322 | ||||
-rw-r--r-- | framework/inc/dispatch/createdispatcher.hxx | 127 | ||||
-rw-r--r-- | framework/inc/dispatch/dispatchinformationprovider.hxx | 111 | ||||
-rw-r--r-- | framework/inc/dispatch/dispatchprovider.hxx | 173 | ||||
-rw-r--r-- | framework/inc/dispatch/helpagentdispatcher.hxx | 205 | ||||
-rw-r--r-- | framework/inc/dispatch/interaction.hxx | 325 | ||||
-rw-r--r-- | framework/inc/dispatch/interceptionhelper.hxx | 326 | ||||
-rw-r--r-- | framework/inc/dispatch/mailtodispatcher.hxx | 145 | ||||
-rw-r--r-- | framework/inc/dispatch/menudispatcher.hxx | 336 | ||||
-rw-r--r-- | framework/inc/dispatch/oxt_handler.hxx | 215 | ||||
-rw-r--r-- | framework/inc/dispatch/popupmenudispatcher.hxx | 199 | ||||
-rw-r--r-- | framework/inc/dispatch/selfdispatcher.hxx | 112 | ||||
-rw-r--r-- | framework/inc/dispatch/servicehandler.hxx | 149 | ||||
-rw-r--r-- | framework/inc/dispatch/startmoduledispatcher.hxx | 197 | ||||
-rw-r--r-- | framework/inc/dispatch/systemexec.hxx | 145 |
17 files changed, 3607 insertions, 0 deletions
diff --git a/framework/inc/dispatch/basedispatcher.hxx b/framework/inc/dispatch/basedispatcher.hxx new file mode 100644 index 000000000000..0b2f7d547b2e --- /dev/null +++ b/framework/inc/dispatch/basedispatcher.hxx @@ -0,0 +1,391 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_BASEDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_BASEDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <classes/taskcreator.hxx> +#include <threadhelp/resetableguard.hxx> +#include <threadhelp/threadhelpbase.hxx> + +#ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_ +#include <threadhelp/transactionbase.hxx> +#endif +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/debug.hxx> +#include <macros/generic.hxx> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/frame/XFrameLoader.hpp> +#include <com/sun/star/frame/XLoadEventListener.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/FeatureStateEvent.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/interfacecontainer.h> +/*DRAFT +#include <unotools/historyoptions.hxx> +*/ + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @descr We must support loading of different URLs with different handler or loader into different tasks simultaniously. + They call us back to return state of operation. We need some informations to distinguish + between these different "loading threads". + This is the reason to implement this dynamicly list. + + @attention I maked class LoaderThreads threadsafe! Using will be easier in a multithreaded environment. + struct DispatchBinding doesn't need that! +*//*-*************************************************************************************************************/ +struct LoadBinding +{ + //------------------------------------------------------------------------------------------------------------- + public: + + //--------------------------------------------------------------------------------------------------------- + inline LoadBinding() + { + free(); + } + + //--------------------------------------------------------------------------------------------------------- + // use to initialize struct for asynchronous dispatching by using handler + inline LoadBinding( const css::util::URL& aNewURL , + const css::uno::Sequence< css::beans::PropertyValue > lNewDescriptor , + const css::uno::Reference< css::frame::XDispatch >& xNewHandler , + const css::uno::Any& aNewAsyncInfo ) + { + free(); + xHandler = xNewHandler ; + aURL = aNewURL ; + lDescriptor = lNewDescriptor; + aAsyncInfo = aNewAsyncInfo ; + } + + //--------------------------------------------------------------------------------------------------------- + // use to initialize struct for asynchronous loading by using frame loader + inline LoadBinding( const css::util::URL& aNewURL , + const css::uno::Sequence< css::beans::PropertyValue > lNewDescriptor , + const css::uno::Reference< css::frame::XFrame >& xNewFrame , + const css::uno::Reference< css::frame::XFrameLoader >& xNewLoader , + const css::uno::Any& aNewAsyncInfo ) + { + free(); + xLoader = xNewLoader ; + xFrame = xNewFrame ; + aURL = aNewURL ; + lDescriptor = lNewDescriptor; + aAsyncInfo = aNewAsyncInfo ; + } + + //--------------------------------------------------------------------------------------------------------- + // dont forget toe release used references + inline ~LoadBinding() + { + free(); + } + + //--------------------------------------------------------------------------------------------------------- + inline void free() + { + xHandler = css::uno::Reference< css::frame::XDispatch >() ; + xLoader = css::uno::Reference< css::frame::XFrameLoader >(); + xFrame = css::uno::Reference< css::frame::XFrame >() ; + aURL = css::util::URL() ; + lDescriptor = css::uno::Sequence< css::beans::PropertyValue >(); + aAsyncInfo = css::uno::Any() ; + } + + //------------------------------------------------------------------------------------------------------------- + public: + css::uno::Reference< css::frame::XDispatch > xHandler ; // if handler was used, this reference will be valid + css::uno::Reference< css::frame::XFrameLoader > xLoader ; // if loader was used, this reference will be valid + css::uno::Reference< css::frame::XFrame > xFrame ; // Target of loading + css::util::URL aURL ; // dispatched URL - neccessary to find listener for status event! + css::uno::Sequence< css::beans::PropertyValue > lDescriptor ; // dispatched arguments - neccessary for "reactForLoadingState()"! + css::uno::Any aAsyncInfo ; // superclasses could use them to save her own user specific data for these asynchron call-info + css::uno::Reference< css::frame::XDispatchResultListener > xListener; +}; + +//***************************************************************************************************************** +class LoaderThreads : private ::std::vector< LoadBinding > + , private ThreadHelpBase +{ + //------------------------------------------------------------------------------------------------------------- + public: + + //--------------------------------------------------------------------------------------------------------- + inline LoaderThreads() + : ThreadHelpBase() + { + } + + //--------------------------------------------------------------------------------------------------------- + inline void append( const LoadBinding& aBinding ) + { + ResetableGuard aGuard( m_aLock ); + push_back( aBinding ); + } + + //--------------------------------------------------------------------------------------------------------- + /// search for handler thread in list wich match given parameter and delete it + inline sal_Bool searchAndForget( const css::uno::Reference < css::frame::XDispatchResultListener >& rListener, LoadBinding& aBinding ) + { + ResetableGuard aGuard( m_aLock ); + sal_Bool bFound = sal_False; + for( iterator pItem=begin(); pItem!=end(); ++pItem ) + { + if( pItem->xListener == rListener ) + { + aBinding = *pItem; + erase( pItem ); + bFound = sal_True; + break; + } + } + return bFound; + } + + //--------------------------------------------------------------------------------------------------------- + /// search for loader thread in list wich match given parameter and delete it + inline sal_Bool searchAndForget( const css::uno::Reference< css::frame::XFrameLoader > xLoader, LoadBinding& aBinding ) + { + ResetableGuard aGuard( m_aLock ); + sal_Bool bFound = sal_False; + for( iterator pItem=begin(); pItem!=end(); ++pItem ) + { + if( pItem->xLoader == xLoader ) + { + aBinding = *pItem; + erase( pItem ); + bFound = sal_True; + break; + } + } + return bFound; + } + + //--------------------------------------------------------------------------------------------------------- + // free ALL memory ... I hope it + inline void free() + { + ResetableGuard aGuard( m_aLock ); + LoaderThreads().swap( *this ); + } +}; + +/*-************************************************************************************************************//** + @short base class for dispatcher implementations + @descr Most of our dispatch implementations do everytime the same. They try to handle or load + somethinmg into a target ... normaly a frame/task/pluginframe! + They must do it synchron or sometimes asynchron. They must wait for callbacks and + notify registered listener with right status events. + All these things are implemented by this baseclass. You should override some methods + to change something. + + "dispatch()" => should be you dispatch algorithm + "reactForLoadingState()" => do something depending from loading state ... + + @implements XInterface + XDispatch + XLoadEventListener + XEventListener + + @base ThreadHelpBase + TransactionBase + OWeakObject + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class BaseDispatcher : // interfaces + public css::lang::XTypeProvider , + public css::frame::XNotifyingDispatch , + public css::frame::XLoadEventListener , // => XEventListener too! + // baseclasses + // Order is neccessary for right initialization! + protected ThreadHelpBase , + protected TransactionBase , + public ::cppu::OWeakObject +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + // constructor / destructor + BaseDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xOwnerFrame ); + + void dispatchFinished ( const css::frame::DispatchResultEvent& aEvent, const css::uno::Reference < css::frame::XDispatchResultListener >& rListener ); + + // XInterface + DECLARE_XINTERFACE + DECLARE_XTYPEPROVIDER + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification ( const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& aArgs, + const css::uno::Reference< css::frame::XDispatchResultListener >& Listener ) throw ( css::uno::RuntimeException); + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ) = 0; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + // XLoadEventListener + virtual void SAL_CALL loadFinished ( const css::uno::Reference< css::frame::XFrameLoader >& xLoader ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL loadCancelled ( const css::uno::Reference< css::frame::XFrameLoader >& xLoader ) throw( css::uno::RuntimeException ); + + // XEventListener + virtual void SAL_CALL disposing ( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + virtual ~BaseDispatcher(); + + /*-****************************************************************************************************//** + @short you should react for successfully or failed load/handle operations. + @descr These baseclass implement handling of dispatched URLs and synchronous/asynchronous loading + of it into a target frame. It implement the complete listener mechanism to get events from + used loader or handler and sending of status events to registered listener too! + But we couldn't react for this events in all cases. + May be - you wish to reactivate suspended controllers or wish to delete a new created + task if operation failed ...!? + By overwriting these pure virtual methods it's possible to do such things. + We call you with all available informations ... you should react for it. + BUT - don't send any status events to your listener! We will do it everytime. + (other listener could be informed as well!) + + You will called back in: a) "reactForLoadingState()" , if URL was loaded into a frame + b) "reactForHandlingState()", if URL was handled by a registered content handler + (without using a target frame!) + + @seealso method statusChanged() + @seealso method loadFinished() + @seealso method loadCancelled() + + @param "aURL" , original dispatched URL + @param "lDescriptor" , original dispatched arguments + @param "xTarget" , target of operation (could be NULL if URL was handled not loaded!) + @param "bState" , state of operation + @return - + + @onerror - + @threadsafe - + *//*-*****************************************************************************************************/ + virtual void SAL_CALL reactForLoadingState ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const css::uno::Reference< css::frame::XFrame >& xTarget , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ) = 0; + + virtual void SAL_CALL reactForHandlingState( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ) = 0; + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + ::rtl::OUString implts_detectType ( const css::util::URL& aURL , + css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + sal_Bool bDeep ); + sal_Bool implts_handleIt ( const css::util::URL& aURL , + css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const ::rtl::OUString& sTypeName , + const css::uno::Any& aAsyncInfo = css::uno::Any() ); + sal_Bool implts_loadIt ( const css::util::URL& aURL , + css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const ::rtl::OUString& sTypeName , + const css::uno::Reference< css::frame::XFrame >& xTarget , + const css::uno::Any& aAsyncInfo = css::uno::Any() ); + void implts_enableFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ); + void implts_disableFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame ); + sal_Bool implts_deactivateController ( const css::uno::Reference< css::frame::XController >& xController ); + sal_Bool implts_reactivateController ( const css::uno::Reference< css::frame::XController >& xController ); + void implts_sendResultEvent ( const css::uno::Reference< css::frame::XFrame >& xEventSource , + const ::rtl::OUString& sURL , + sal_Bool bLoadState ); + + //------------------------------------------------------------------------------------------------------------- + // variables + // - should be private normaly ... + // - but some super classes need access to some of them => protected! + //------------------------------------------------------------------------------------------------------------- + protected: + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// global uno service manager to create new services + css::uno::WeakReference< css::frame::XFrame > m_xOwner ; /// weakreference to owner (Don't use a hard reference. Owner can't delete us then!) + + private: + LoaderThreads m_aLoaderThreads ; /// list of bindings between handler/loader, tasks and loaded URLs + ListenerHash m_aListenerContainer ; /// hash table for listener at specified URLs + +}; // class BaseDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_BASEDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/blankdispatcher.hxx b/framework/inc/dispatch/blankdispatcher.hxx new file mode 100644 index 000000000000..bd0e5b1d34dd --- /dev/null +++ b/framework/inc/dispatch/blankdispatcher.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_BLANKDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_BLANKDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <dispatch/basedispatcher.hxx> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short helper for desktop only(!) to create new tasks on demand for dispatches + @descr Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! + + @implements XInterface + XDispatch + XStatusListener + XLoadEventListener + XEventListener + + @base BaseDispatcher + OWeakObject + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class BlankDispatcher : // -interfaces ... are supported by our BaseDispatcher! + // -baseclasses ... order is neccessary for right initialization! + public BaseDispatcher +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + // ctor + BlankDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xDesktop, + sal_Bool bIsDefaultDispatcher ); + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + virtual void SAL_CALL reactForLoadingState ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const css::uno::Reference< css::frame::XFrame >& xTarget , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ); + + virtual void SAL_CALL reactForHandlingState( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + private: + sal_Bool implts_findAndActivateAlreadyLoadedTask( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments , + const css::uno::Reference< css::frame::XFrame > xDesktop ); + + css::uno::Reference< css::frame::XFrame > implts_findAndLockRecycleTask( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments , + const css::uno::Reference< css::frame::XFrame > xDesktop ); + + //------------------------------------------------------------------------------------------------------------- + // variables + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + private: + sal_Bool m_bIsDefaultDispatcher; +}; // class BlankDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_BLANKDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/closedispatcher.hxx b/framework/inc/dispatch/closedispatcher.hxx new file mode 100644 index 000000000000..c9de9f311d9b --- /dev/null +++ b/framework/inc/dispatch/closedispatcher.hxx @@ -0,0 +1,322 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_ + +//_______________________________________________ +// my own includes + +#include <threadhelp/threadhelpbase.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/debug.hxx> +#include <macros/generic.hxx> +#include <stdtypes.h> +#include <general.h> + +//_______________________________________________ +// interface includes +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/DispatchResultState.hpp> + +//_______________________________________________ +// other includes +#include <cppuhelper/weak.hxx> +#include <vcl/evntpost.hxx> + +//_______________________________________________ +// namespace + +namespace framework{ + +//----------------------------------------------- +/** + @short helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" + to close a frame/document or the whole application implicitly in case it was the last frame + + @descr These URLs implements a special functionality to close a document or the whole frame ... + and handle the state, it was the last frame or document. Then we create the + default backing document which can be used to open new ones using the file open dialog + or some other menu entries. Or we terminate the whole application in case this backing mode shouldnt + be used. + */ +class CloseDispatcher : public css::lang::XTypeProvider + , public css::frame::XNotifyingDispatch // => XDispatch + , public css::frame::XDispatchInformationProvider + // baseclasses ... order is neccessary for right initialization! + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + //------------------------------------------- + // types + + private: + + //--------------------------------------- + /** @short describe, which request must be done here. + @descr The incoming URLs {.uno:CloseDoc/CloseWin and CloseFrame + can be classified so and checked later performant.}*/ + enum EOperation + { + E_CLOSE_DOC, + E_CLOSE_FRAME, + E_CLOSE_WIN + }; + + //------------------------------------------- + // member + + private: + + //--------------------------------------- + /** @short reference to an uno service manager, + which can be used to create own needed + uno resources. */ + css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + + //--------------------------------------- + /** @short reference to the target frame, which should be + closed by this dispatch. */ + css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame; + + //--------------------------------------- + /** @short used for asynchronous callbacks within the main thread. + @descr Internaly we work asynchronous. Because our callis + are not aware, that her request can kill its own environment ... */ + ::vcl::EventPoster m_aAsyncCallback; + + //--------------------------------------- + /** @short used inside asyncronous callback to decide, + which operation must be executed. */ + EOperation m_eOperation; + + //--------------------------------------- + /** @short for asynchronous operations we must hold us self alive! */ + css::uno::Reference< css::uno::XInterface > m_xSelfHold; + + //--------------------------------------- + /** @short list of registered status listener */ + ListenerHash m_lStatusListener; + + //--------------------------------------- + /** @short holded alive for internaly asynchronous operations! */ + css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener; + + //------------------------------------------- + // native interface + + public: + + //--------------------------------------- + /** @short connect a new CloseDispatcher instance to its frame. + @descr One CloseDispatcher instance is bound to onw frame only. + That makes an implementation (e.g. of listener support) + much more easier .-) + + @param xSMGR + an un oservice manager, which is needed to create uno resource + internaly. + + @param xFrame + the frame where the corresponding dispatch was started. + + @param sTarget + help us to find the right target for this close operation. + */ + CloseDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , + const css::uno::Reference< css::frame::XFrame >& xFrame , + const ::rtl::OUString& sTarget); + + //--------------------------------------- + /** @short does nothing real. */ + virtual ~CloseDispatcher(); + + //------------------------------------------- + // uno interface + + public: + + //--------------------------------------- + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + //--------------------------------------- + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException); + + //--------------------------------------- + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments) throw(css::uno::RuntimeException); + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw(css::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw(css::uno::RuntimeException); + + //--------------------------------------- + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) throw (css::uno::RuntimeException); + + //------------------------------------------- + // internal helper + + private: + + //--------------------------------------- + /** @short a callback for asynchronous started operations. + + @descr As already mentione, we make internaly all operations + asynchronous. Otherwhise our callis kill its own environment + during they call us ... + */ + DECL_LINK( impl_asyncCallback, void* ); + + //--------------------------------------- + /** @short prepare m_xCloseFrame so it should be closeable without problems. + + @descr Thats needed to be shure, that the document cant disagree + later with e.g. an office termination. + The problem: Closing of documents can show UI. If the user + ignores it and open/close other documents, we cant know + which state the office has after closing of this frame. + + @param bAllowSuspend + force calling of XController->suspend(). + + @param bCloseAllOtherViewsToo + if there are other top level frames, which + contains views to the same document then our m_xCloseFrame, + they are forced to be closed too. + We need it to implement the CLOSE_DOC semantic. + + @return [boolean] + TRUE if closing was successfully. + */ + sal_Bool implts_prepareFrameForClosing(const css::uno::Reference< css::frame::XFrame >& xFrame , + sal_Bool bAllowSuspend , + sal_Bool bCloseAllOtherViewsToo, + sal_Bool& bControllerSuspended ); + + //--------------------------------------- + /** @short close the member m_xCloseFrame. + + @descr This method does not look for any document + inside this frame. Such views must be cleared + before (e.g. by calling implts_closeView()! + + Otherwhise e.g. the XController->suspend() + call isnt made and no UI warn the user about + loosing document changes. Because the + frame is closed .... + + @return [bool] + TRUE if closing was successfully. + */ + sal_Bool implts_closeFrame(); + + //--------------------------------------- + /** @short set the special BackingComponent (now StartModule) + as new component of our m_xCloseFrame. + + @return [bool] + TRUE if operation was successfully. + */ + sal_Bool implts_establishBackingMode(); + + //--------------------------------------- + /** @short calls XDesktop->terminate(). + + @descr No office code has to be called + afterwards! Because the process is dieing ... + The only exception is a might be registered + listener at this instance here. + Because he should know, that such things will happen :-) + + @return [bool] + TRUE if termination of the application was started ... + */ + sal_Bool implts_terminateApplication(); + + //--------------------------------------- + /** @short notify a DispatchResultListener. + + @descr We check the listener reference before we use it. + So this method can be called everytimes! + + @parama xListener + the listener, which should be notified. + Can be null! + + @param nState + directly used as css::frame::DispatchResultState value. + + @param aResult + not used yet realy ... + */ + void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + sal_Int16 nState , + const css::uno::Any& aResult ); + + //--------------------------------------- + /** @short try to find the right target frame where this close request + must be realy done. + + @descr The problem behind: closing some resources depends sometimes from the + context where its dispatched. Sometimes the start frame of the dispatch + has to be closed itself (target=_self) ... sometimes it's parent frame + has to be closed - BUT(!) it means a parent frame containing a top level + window. _top cant be used then for dispatch - because it adress TopFrames + not frames containg top level windows. So normaly _magic (which btw does not + exists at the moment .-) ) should be used. So we interpret target=<empty> + as _magic ! + + @param xFrame + start point for search of right dispatch frame. + + @param sTarget + give us an idea how this target frame must be searched. + */ + + static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame , + const ::rtl::OUString& sTarget); + +}; // class CloseDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/createdispatcher.hxx b/framework/inc/dispatch/createdispatcher.hxx new file mode 100644 index 000000000000..41b448455b0e --- /dev/null +++ b/framework/inc/dispatch/createdispatcher.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_CREATEDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_CREATEDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <dispatch/basedispatcher.hxx> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short helper to create new frames by using non special target name and CREATE flag + @descr If user whish to find any frame by name or will create it, if it not already exist ... + these dispatch helper should be used. Because - a frame must be created at dispatch call ... + not on queryDispatch()! So we hold weakreferences to the possible parent frame, safe the name + of new frame. If user call dispatch at us - we check a weakreference to our last created frame + (he should have same name!) ... if he exist - we do nothing ... if not - we create it again. + But if possible parent for new created task doesn't exist - we couldn't do anything! + Then we wait for our own dispose and do nothing. + + @attention Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! + + @implements XInterface + XDispatch + XStatusListener + XLoadEventListener + XEventListener + + @base BaseDispatcher + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class CreateDispatcher : // -interfaces ... are supported by our BaseDispatcher! + // -baseclasses ... order is neccessary for right initialization! + public BaseDispatcher +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + // ctor + CreateDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xParent , + const rtl::OUString& sName ); + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + virtual void SAL_CALL reactForLoadingState ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const css::uno::Reference< css::frame::XFrame >& xTarget , + sal_Bool bState , + const css::uno::Any& aAsyncInfo = css::uno::Any() ); + + virtual void SAL_CALL reactForHandlingState( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + sal_Bool bState , + const css::uno::Any& aAsyncInfo = css::uno::Any() ) + { LOG_WARNING( "CreateDispatcher::reactForHandlingState()", "Who call this function! It's a non used pure virtual function overload ..." ) } + + //------------------------------------------------------------------------------------------------------------- + // variables + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + private: + css::uno::WeakReference< css::frame::XFrame > m_xTarget ; /// new created frame (Don't hold hard reference ... target frame couldn't die then!) + ::rtl::OUString m_sTargetName ; /// name of new created frame + +}; // class CreateDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_CREATEDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/dispatchinformationprovider.hxx b/framework/inc/dispatch/dispatchinformationprovider.hxx new file mode 100644 index 000000000000..124698145340 --- /dev/null +++ b/framework/inc/dispatch/dispatchinformationprovider.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX_ +#define __FRAMEWORK_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <threadhelp/threadhelpbase.hxx> +#include <macros/generic.hxx> +#include <macros/debug.hxx> +#include <macros/xinterface.hxx> +#include <general.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weakref.hxx> +#include <rtl/ustring.hxx> +#include <cppuhelper/weak.hxx> +#include <vcl/svapp.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short a helper to merge dispatch informations of different sources together. +*//*-*************************************************************************************************************/ +class DispatchInformationProvider : public css::frame::XDispatchInformationProvider + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + //_______________________ + // member + private: + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + //_______________________ + // interface + public: + + DispatchInformationProvider(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , + const css::uno::Reference< css::frame::XFrame >& xFrame); + + virtual ~DispatchInformationProvider(); + + FWK_DECLARE_XINTERFACE + + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups() + throw (css::uno::RuntimeException); + + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation(sal_Int16 nCommandGroup) + throw (css::uno::RuntimeException); + + //_______________________ + // helper + private: + + css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > implts_getAllSubProvider(); + +}; // class DispatchInformationProvider + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX_ diff --git a/framework/inc/dispatch/dispatchprovider.hxx b/framework/inc/dispatch/dispatchprovider.hxx new file mode 100644 index 000000000000..15e2a1df5987 --- /dev/null +++ b/framework/inc/dispatch/dispatchprovider.hxx @@ -0,0 +1,173 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ +#define __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <services/frame.hxx> + +#include <classes/protocolhandlercache.hxx> +#include <threadhelp/threadhelpbase.hxx> + +#ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_ +#include <threadhelp/transactionbase.hxx> +#endif +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/debug.hxx> +#include <macros/generic.hxx> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ + +/** + @descr We know some special dispatch objects with diffrent functionality. + The can be created internaly by the following DispatchProvider. + Here we define some identifier to force creation of the right one. +*/ +enum EDispatchHelper +{ + E_DEFAULTDISPATCHER , + E_MENUDISPATCHER , + E_HELPAGENTDISPATCHER , + E_CREATEDISPATCHER , + E_BLANKDISPATCHER , + E_SELFDISPATCHER , + E_CLOSEDISPATCHER , + E_STARTMODULEDISPATCHER +}; + +//_________________________________________________________________________________________________________________ + +/** + @short implement a helper for XDispatchProvider interface + @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class. + (frame, desktop) All of them must provides different functionality. + E.g: - task can be created by the desktop only + - a task can have a beamer as direct child + - a normal frame never can create a new one by himself + + @attention Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! + + @base ThreadHelpBase + supports threadsafe mechanism + @base OWeakObject + provides ref count and weak mechanism + + @devstatus ready to use + @threadsafe yes + @modified 17.05.2002 07:56, as96863 +*/ +class DispatchProvider : // interfaces + public css::lang::XTypeProvider , + public css::frame::XDispatchProvider , + // baseclasses + // Order is neccessary for right initialization! + private ThreadHelpBase , + private TransactionBase , + public ::cppu::OWeakObject +{ + /* member */ + private: + /// reference to global service manager to create new services + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!) + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.) + css::uno::Reference< css::frame::XDispatch > m_xMenuDispatcher ; + css::uno::Reference< css::frame::XDispatch > m_xHelpAgentDispatcher; +/* css::uno::Reference< css::frame::XDispatch > m_xBlankDispatcher ; + css::uno::Reference< css::frame::XDispatch > m_xSelfDispatcher ; + css::uno::Reference< css::frame::XDispatch > m_xDefaultDispatcher ;*/ + /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols + HandlerCache m_aProtocolHandlerCache; + + /* interface */ + public: + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + DispatchProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xFrame ); + + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const ::rtl::OUString& sTargetFrameName , + sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) throw( css::uno::RuntimeException ); + + /* helper */ + protected: + // Let him protected! So nobody can use us as base ... + virtual ~DispatchProvider(); + + private: + css::uno::Reference< css::frame::XDispatch > implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper , + const css::uno::Reference< css::frame::XFrame >& xOwner , + const ::rtl::OUString& sTarget = ::rtl::OUString() , + sal_Int32 nSearchFlags = 0 ); + sal_Bool implts_isLoadableContent ( const css::util::URL& aURL ); + css::uno::Reference< css::frame::XDispatch > implts_queryDesktopDispatch ( const css::uno::Reference< css::frame::XFrame > xDesktop , + const css::util::URL& aURL , + const ::rtl::OUString& sTargetFrameName , + sal_Int32 nSearchFlags ); + css::uno::Reference< css::frame::XDispatch > implts_queryFrameDispatch ( const css::uno::Reference< css::frame::XFrame > xFrame , + const css::util::URL& aURL , + const ::rtl::OUString& sTargetFrameName , + sal_Int32 nSearchFlags ); + css::uno::Reference< css::frame::XDispatch > implts_searchProtocolHandler ( const css::util::URL& aURL ); + +}; // class DispatchProvider + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ diff --git a/framework/inc/dispatch/helpagentdispatcher.hxx b/framework/inc/dispatch/helpagentdispatcher.hxx new file mode 100644 index 000000000000..1a8a0b2425d7 --- /dev/null +++ b/framework/inc/dispatch/helpagentdispatcher.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ + +#include <threadhelp/threadhelpbase.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <svtools/helpagentwindow.hxx> +#include <vcl/timer.hxx> +#include <vcl/evntpost.hxx> +#include <cppuhelper/weak.hxx> + +//........................................................................ +namespace framework +{ + +// define css alias ... and undefine it at the end of this file !!! +#ifdef css + #error "I tried to use css as namespace define inside non exported header ... but it was already defined by somwhere else. .-)" +#else + #define css ::com::sun::star +#endif + +//........................................................................ + +class HelpAgentDispatcher : public css::lang::XTypeProvider + , public css::frame::XDispatch + , public css::awt::XWindowListener // => css::lang::XEventListener + , public ::svt::IHelpAgentCallback + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + private: + + //--------------------------------------- + /// @short represent the current active help URL, which must be used to show the right help page + ::rtl::OUString m_sCurrentURL; + + //--------------------------------------- + /// @short parent of the agent window. + css::uno::Reference< css::awt::XWindow > m_xContainerWindow; + + //--------------------------------------- + /// @short the agent window itself (implemented in svtools) + css::uno::Reference< css::awt::XWindow > m_xAgentWindow; + + //--------------------------------------- + /// @short the timer for showing the agent window + Timer m_aTimer; + + //--------------------------------------- + /** @short hold this dispatcher alive till the timer was killed or expired! + @descr Because the vcl timer knows us by using a pointer ... and our instance is used + ref counted normaly it can happen that our reference goes down to 0 ... and the timer + runs into some trouble. So we hold us self alive till the timer could be stopped or expired. + */ + css::uno::Reference< css::uno::XInterface > m_xSelfHold; + + public: + + HelpAgentDispatcher(const css::uno::Reference< css::frame::XFrame >& xParentFrame); + + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + // css::frame::XDispatch + virtual void SAL_CALL dispatch(const css::util::URL& sURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArgs) + throw(css::uno::RuntimeException); + virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, + const css::util::URL& aURL ) + throw(css::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, + const css::util::URL& aURL ) + throw(css::uno::RuntimeException); + + // css::awt::XWindowListener + virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aSource) + throw(css::uno::RuntimeException); + virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aSource) + throw(css::uno::RuntimeException); + virtual void SAL_CALL windowShown(const css::lang::EventObject& aSource) + throw(css::uno::RuntimeException); + virtual void SAL_CALL windowHidden(const css::lang::EventObject& aSource) + throw(css::uno::RuntimeException); + + // css::lang::XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) + throw(css::uno::RuntimeException); + + protected: + + ~HelpAgentDispatcher(); + + protected: + + /// IHelpAgentCallback overridables + virtual void helpRequested(); + virtual void closeAgent(); + + private: + + //--------------------------------------- + /** @short mark the current set URL as "accepted by user" and show the right help window + */ + void implts_acceptCurrentURL(); + + //--------------------------------------- + /** @short mark the current set URL as "ignored by user" + */ + void implts_ignoreCurrentURL(); + + //--------------------------------------- + /** @short ensures that the agent's window exists + @descr We create the agent window on demand. But afterwards we hold it alive till + this helpagent dispatcher dies. The agent window will be made visible/hidden + in case a new dispatch occures or in case the timer expired. + + @return [sal_Bool] + TRUE in case the member m_xAgentWindow is a valid reference; + FALSE otherwise. + */ + css::uno::Reference< css::awt::XWindow > implts_ensureAgentWindow(); + + //--------------------------------------- + /** @short show the agent window. + @descr If the agent window does not exists, it will be created on demand. + (see implts_ensureAgentWindow). Further it's checked if the parent container + window is currently visible or not. Only if its visible the agent window will + be shown too. + */ + void implts_showAgentWindow(); + + //--------------------------------------- + /** @short hide the agent window. + */ + void implts_hideAgentWindow(); + + //--------------------------------------- + /** @short set the new position and size of the agent window. + @descr If the agent window does not exists, it will be created on demand. + (see implts_ensureAgentWindow). + If the agent window exists, its position and size will be calculated + and set. + */ + void implts_positionAgentWindow(); + + //--------------------------------------- + /** @short starts the timer for showing the agent window. + @descr The timer wont be started twice ... this method checks the current running state .-) + */ + void implts_startTimer(); + + //--------------------------------------- + /** @short stop the timer. + @descr The timer wont be stopped twice ... this method checks the current running state .-) + Further this method marks the current help URL (m_xCurrentURL) as "ignorable". + Cause the user ignored it ! + */ + void implts_stopTimer(); + + //--------------------------------------- + /** @short callback of our internal timer. + */ + DECL_LINK(implts_timerExpired, void*); +}; + +#undef css + +//........................................................................ +} // namespace framework +//........................................................................ + +#endif // _FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ + diff --git a/framework/inc/dispatch/interaction.hxx b/framework/inc/dispatch/interaction.hxx new file mode 100644 index 000000000000..28b5d817251b --- /dev/null +++ b/framework/inc/dispatch/interaction.hxx @@ -0,0 +1,325 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_INTERACTION_HXX_ +#define __FRAMEWORK_DISPATCH_INTERACTION_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +#include <com/sun/star/task/XInteractionRequest.hpp> +#include <com/sun/star/task/XInteractionContinuation.hpp> +#include <com/sun/star/task/XInteractionAbort.hpp> +#include <com/sun/star/task/XInteractionApprove.hpp> +#include <com/sun/star/task/XInteractionDisapprove.hpp> +#include <com/sun/star/task/XInteractionRetry.hpp> +#include <com/sun/star/document/XInteractionFilterSelect.hpp> +#include <com/sun/star/document/NoSuchFilterRequest.hpp> +#include <com/sun/star/document/AmbigousFilterRequest.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> + +//_________________________________________________________________________________________________________________ +// includes of other projects +//_________________________________________________________________________________________________________________ +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// non exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// non exported definitions +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// declarations +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short base for continuation classes + @descr An interaction continuation could be used on XInteractionHandler/XInteractionRequest + to abort or react for it. + Base functionality is everytime the same - handler mark right continuation by calling + interface method "select()". User of interaction can detect it by testing c++ method "isSelected()"! + Superclasses can add additional interfaces or methods to support additional features ... + but selection of it is supported here! + + @implements XInterface + XTypeProvider (supported by WeakImplHelper!) + XInteractionContinuation + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +template< class TContinuationType > +class ContinuationBase : public ::cppu::WeakImplHelper1< TContinuationType > +{ + // c++ interface + public: + + //--------------------------------------------------------------------------------------------------------- + // initialize continuation with right start values + //--------------------------------------------------------------------------------------------------------- + ContinuationBase() + : m_bSelected( sal_False ) + { + } + + //--------------------------------------------------------------------------------------------------------- + // was continuation selected by handler? + //--------------------------------------------------------------------------------------------------------- + sal_Bool isSelected() const + { + return m_bSelected; + } + + //--------------------------------------------------------------------------------------------------------- + // make using more then once possible + //--------------------------------------------------------------------------------------------------------- + void reset() + { + m_bSelected = sal_False; + } + + // uno interface + public: + + //--------------------------------------------------------------------------------------------------------- + // called by handler to mark continuation as the only possible solution for started interaction + //--------------------------------------------------------------------------------------------------------- + virtual void SAL_CALL select() throw( ::com::sun::star::uno::RuntimeException ) + { + m_bSelected = sal_True; + } + + // member + private: + + sal_Bool m_bSelected; + +}; // class ContinuationBase + +/*-************************************************************************************************************//** + @short declaration of some simple continuations + @descr These derived classes implements some simple continuations, which doesnt need and additional + interfaces or methods. Her selected state is the only neccessary feature. User of it can + distinguish by type between different functionality! + + @implements - + + @base ContinuationBase + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +typedef ContinuationBase< ::com::sun::star::task::XInteractionAbort > ContinuationAbort; +typedef ContinuationBase< ::com::sun::star::task::XInteractionApprove > ContinuationApprove; +typedef ContinuationBase< ::com::sun::star::task::XInteractionDisapprove > ContinuationDisapprove; +typedef ContinuationBase< ::com::sun::star::task::XInteractionRetry > ContinuationRetry; + +/*-************************************************************************************************************//** + @short declaration of special continuation for filter selection + @descr Sometimes filter detection during loading document failed. Then we need a possibility + to ask user for his decision. These continuation transport selected filter by user to + code user of interaction. + + @attention This implementation could be used one times only. We don't support a resetable continuation yet! + Why? Normaly interaction should show a filter selection dialog and ask user for his decision. + He can select any filter - then instances of these class will be called by handler ... or user + close dialog without any selection. Then another continuation should be slected by handler to + abort continuations ... Retrying isn't very usefull here ... I think. + + @implements XInteractionFilterSelect + + @base ImplInheritanceHelper1 + ContinuationBase + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class ContinuationFilterSelect : public ContinuationBase< ::com::sun::star::document::XInteractionFilterSelect > +{ + // c++ interface + public: + ContinuationFilterSelect(); + + // uno interface + public: + virtual void SAL_CALL setFilter( const ::rtl::OUString& sFilter ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getFilter( ) throw( ::com::sun::star::uno::RuntimeException ); + + // member + private: + ::rtl::OUString m_sFilter; + +}; // class ContinuationFilterSelect + +/*-************************************************************************************************************//** + @short special request for interaction to ask user for right filter + @descr These helper can be used to ask user for right filter, if filter detection failed. + It capsulate communication with any interaction handler and supports an easy + access on interaction results for user of these class. + Use it and forget complex mechanism of interaction ... + + @example RequestFilterSelect* pRequest = new RequestFilterSelect; + Reference< XInteractionRequest > xRequest ( pRequest ); + xInteractionHandler->handle( xRequest ); + if( ! pRequest.isAbort() ) + { + OUString sFilter = pRequest->getFilter(); + } + + @implements XInteractionRequest + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class RequestFilterSelect : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +{ + // c++ interface + public: + RequestFilterSelect( const ::rtl::OUString& sURL ); + sal_Bool isAbort () const; + ::rtl::OUString getFilter() const; + + // uno interface + public: + virtual ::com::sun::star::uno::Any SAL_CALL getRequest () throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException ); + + // member + private: + ::com::sun::star::uno::Any m_aRequest ; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations; + ContinuationAbort* m_pAbort ; + ContinuationFilterSelect* m_pFilter ; + +}; // class RequestFilterSelect + +/*-************************************************************************************************************//** + @short special request for interaction + @descr User must decide between a preselected and another detected filter. + It capsulate communication with any interaction handler and supports an easy + access on interaction results for user of these class. + + @implements XInteractionRequest + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class RequestAmbigousFilter : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +{ + // c++ interface + public: + RequestAmbigousFilter( const ::rtl::OUString& sURL , + const ::rtl::OUString& sSelectedFilter , + const ::rtl::OUString& sDetectedFilter ); + sal_Bool isAbort () const; + ::rtl::OUString getFilter() const; + + // uno interface + public: + virtual ::com::sun::star::uno::Any SAL_CALL getRequest () throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException ); + + // member + private: + ::com::sun::star::uno::Any m_aRequest ; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations; + ContinuationAbort* m_pAbort ; + ContinuationFilterSelect* m_pFilter ; + +}; // class RequestFilterSelect + +/*-************************************************************************************************************//** + @short special request for interaction + @descr User must decide between a preselected and another detected filter. + It capsulate communication with any interaction handler and supports an easy + access on interaction results for user of these class. + + @implements XInteractionRequest + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class InteractionRequest : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +{ + // c++ interface + public: + InteractionRequest( const ::com::sun::star::uno::Any& aRequest , + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations ) + { + m_aRequest = aRequest ; + m_lContinuations = lContinuations; + } + + // uno interface + public: + virtual ::com::sun::star::uno::Any SAL_CALL getRequest() + throw( ::com::sun::star::uno::RuntimeException ) + { + return m_aRequest; + } + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() + throw( ::com::sun::star::uno::RuntimeException ) + { + return m_lContinuations; + } + + // member + private: + ::com::sun::star::uno::Any m_aRequest ; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations; + +}; // class RequestFilterSelect + +} // namespace framework + +#endif // #define __FRAMEWORK_DISPATCH_INTERACTION_HXX_ diff --git a/framework/inc/dispatch/interceptionhelper.hxx b/framework/inc/dispatch/interceptionhelper.hxx new file mode 100644 index 000000000000..e811e9ddec7c --- /dev/null +++ b/framework/inc/dispatch/interceptionhelper.hxx @@ -0,0 +1,326 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_HELPER_INTERCEPTIONHELPER_HXX_ +#define __FRAMEWORK_HELPER_INTERCEPTIONHELPER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <services/frame.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <macros/xinterface.hxx> +#include <macros/generic.hxx> +#include <macros/debug.hxx> +#include <general.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <tools/wldcrd.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> + +#ifndef __SGI_STL_DEQUE +#include <deque> +#endif + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________ +// definitions +//_________________________________________________________ + +/** @short implements a helper to support interception with additional functionality. + + @descr This helper implements the complete XDispatchProviderInterception interface with + master/slave functionality AND using of optional features like registration of URL pattern! + + @attention Don't use this class as direct member - use it dynamicly. Do not derive from this class. + We hold a weakreference to ouer owner not to ouer superclass. + */ +class InterceptionHelper : public css::frame::XDispatchProvider + , public css::frame::XDispatchProviderInterception + , public css::lang::XEventListener + // order of base classes is important for right initialization of mutex member! + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + //_____________________________________________________ + // structs, helper + + /** @short bind an interceptor component to it's URL pattern registration. */ + struct InterceptorInfo + { + /** @short reference to the interceptor component. */ + css::uno::Reference< css::frame::XDispatchProvider > xInterceptor; + + /** @short it's registration for URL patterns. + + @descr If the interceptor component does not support the optional interface + XInterceptorInfo, it will be registered for one pattern "*" by default. + That would make it possible to handle it in the same manner then real + registered interceptor objects and we must not implement any special code. */ + css::uno::Sequence< ::rtl::OUString > lURLPattern; + }; + + //_____________________________________________________ + + /** @short implements a list of items of type InterceptorInfo, and provides some special + functions on it. + + @descr Because interceptor objects can be registered for URL patterns, + it supports a wildcard search on all list items. + */ + class InterceptorList : public ::std::deque< InterceptorInfo > + { + public: + + //_____________________________________________ + + /** @short search for an interceptor inside this list using it's reference. + + @param xInterceptor + points to the interceptor object, which should be located inside this list. + + @return An iterator object, which points directly to the located item inside this list. + In case no interceptor could be found, it points to the end of this list! + */ + iterator findByReference(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) + { + css::uno::Reference< css::frame::XDispatchProviderInterceptor > xProviderInterface(xInterceptor, css::uno::UNO_QUERY); + iterator pIt; + for (pIt=begin(); pIt!=end(); ++pIt) + { + if (pIt->xInterceptor == xProviderInterface) + return pIt; + } + return end(); + } + + //_____________________________________________ + + /** @short search for an interceptor inside this list using it's reference. + + @param xInterceptor + points to the interceptor object, which should be located inside this list. + + @return An iterator object, which points directly to the located item inside this list. + In case no interceptor could be found, it points to the end of this list! + */ + iterator findByPattern(const ::rtl::OUString& sURL) + { + iterator pIt; + for (pIt=begin(); pIt!=end(); ++pIt) + { + sal_Int32 c = pIt->lURLPattern.getLength(); + const ::rtl::OUString* pPattern = pIt->lURLPattern.getConstArray(); + + for (sal_Int32 i=0; i<c; ++i) + { + WildCard aPattern(pPattern[i]); + if (aPattern.Matches(sURL)) + return pIt; + } + } + return end(); + } + }; + + //_____________________________________________________ + // member + + private: + + /** @short reference to the frame, which uses this instance to implement it's own interception. + + @descr We hold a weak reference only, to make disposing operations easy. */ + css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak; + + /** @short this interception helper implements the top level master of an interceptor list ... + but this member is the lowest possible slave! */ + css::uno::Reference< css::frame::XDispatchProvider > m_xSlave; + + /** @short contains all registered interceptor objects. */ + InterceptorList m_lInterceptionRegs; + + /** @short it regulates, which interceptor is used first. + The last or the first registered one. */ + static sal_Bool m_bPreferrFirstInterceptor; + + //_____________________________________________________ + // native interface + + public: + + //_________________________________________________ + + /** @short creates a new interception helper instance. + + @param xOwner + points to the frame, which use this instances to support it's own interception interfaces. + + @param xSlave + an outside creates dispatch provider, which has to be used here as lowest slave "interceptor". + */ + InterceptionHelper(const css::uno::Reference< css::frame::XFrame >& xOwner, + const css::uno::Reference< css::frame::XDispatchProvider >& xSlave); + + protected: + + //_________________________________________________ + + /** @short standard destructor. + + @descr This method destruct an instance of this class and clear some member. + This method is protected, because its not allowed to use this class as a direct member! + You MUST use a dynamical instance (pointer). That's the reason for a protected dtor. + */ + virtual ~InterceptionHelper(); + + //_____________________________________________________ + // uno interface + + public: + + FWK_DECLARE_XINTERFACE + + //_________________________________________________ + // XDispatchProvider + + /** @short query for a dispatch, which implements the requested feature. + + @descr We search inside our list of interception registrations, to locate + any interested interceptor. In case no interceptor exists or nobody is + interested on this URL our lowest slave will be used. + + @param aURL + describes the requested dispatch functionality. + + @param sTargetFrameName + the name of the target frame or a special name like "_blank", "_top" ... + Won't be used here ... but may by one of our registered interceptor objects + or our slave. + + @param nSearchFlags + optional search parameter for targeting, if sTargetFrameName isn't a special one. + + @return A valid dispatch object, if any interceptor or at least our slave is interested on the given URL; + or NULL otherwhise. + */ + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL& aURL , + const ::rtl::OUString& sTargetFrameName, + sal_Int32 nSearchFlags ) + throw(css::uno::RuntimeException); + + //_________________________________________________ + // XDispatchProvider + + /** @short implements an optimized queryDispatch() for remote. + + @descr It capsulate more then one queryDispatch() requests and return a lits of dispatch objects + as result. Because both lists (in and out) coreespond together, it's not allowed to + pack it - means supress NULL references! + + @param lDescriptor + a list of queryDispatch() arguments. + + @return A list of dispatch objects. + */ + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor) + throw(css::uno::RuntimeException); + + //_________________________________________________ + // XDispatchProviderInterception + + /** @short register an interceptor. + + @descr Somebody can register himself to intercept all or some special dispatches. + It's depend from his supported interfaces. If he implement XInterceptorInfo + he his called for some special URLs only - otherwise we call it for every request! + + @attention We don't check for double registrations here! + + @param xInterceptor + reference to interceptor, which wish to be registered here. + + @throw A RuntimeException if the given reference is NULL! + */ + virtual void SAL_CALL registerDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) + throw(css::uno::RuntimeException); + + //_________________________________________________ + // XDispatchProviderInterception + + /** @short release an interceptor. + + @descr Remove the registered interceptor from our internal list + and delete all special informations about it. + + @param xInterceptor + reference to the interceptor, which wish to be deregistered. + + @throw A RuntimeException if the given reference is NULL! + */ + virtual void SAL_CALL releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) throw( css::uno::RuntimeException ); + + //_________________________________________________ + // XEventListener + + /** @short Is called from our owner frame, in case he will be disposed. + + @descr We have to relaease all references to him then. + Normaly we will die by ref count too ... + */ + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) + throw(css::uno::RuntimeException); + +}; // class InterceptionHelper + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_HELPER_INTERCEPTIONHELPER_HXX_ diff --git a/framework/inc/dispatch/mailtodispatcher.hxx b/framework/inc/dispatch/mailtodispatcher.hxx new file mode 100644 index 000000000000..f1c6dc34d194 --- /dev/null +++ b/framework/inc/dispatch/mailtodispatcher.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_MAILTODISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_MAILTODISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <macros/debug.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <general.h> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/** + @short protocol handler for "mailto:" URLs + @descr It's a special dispatch object which is used registered for "mailto:*" URLs and + will be automaticly used from the framework dispatch mechanism if such URL occured. + + @base ThreadHelpBase + exports a lock member to guarantee right initialize value of it + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use + + @modified 02.05.2002 08:12, as96863 +*/ +class MailToDispatcher : // interfaces + public css::lang::XTypeProvider , + public css::lang::XServiceInfo , + public css::frame::XDispatchProvider , + public css::frame::XNotifyingDispatch, // => XDispatch + // baseclasses + // Order is neccessary for right initialization! + private ThreadHelpBase , + public cppu::OWeakObject +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + /* interface */ + public: + + // ctor/dtor + MailToDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~MailToDispatcher( ); + + // XInterface, XTypeProvider, XServiceInfo + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException ); + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + /* internal */ + private: + + sal_Bool implts_dispatch( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + +}; // class MailToDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_MAILTODISPATCHER_HXX_ diff --git a/framework/inc/dispatch/menudispatcher.hxx b/framework/inc/dispatch/menudispatcher.hxx new file mode 100644 index 000000000000..30016a96f499 --- /dev/null +++ b/framework/inc/dispatch/menudispatcher.hxx @@ -0,0 +1,336 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <classes/taskcreator.hxx> +#include <services/frame.hxx> +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/debug.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <classes/menumanager.hxx> +#include <general.h> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrameLoader.hpp> +#include <com/sun/star/frame/XLoadEventListener.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/FeatureStateEvent.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/interfacecontainer.h> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + We must save informations about our listener and URL for listening. + We implement this as a hashtable for strings. +*//*-*************************************************************************************************************/ + +typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString , + OUStringHashCode , + std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer; + + +/*-************************************************************************************************************//** + @short helper for desktop only(!) to create new tasks on demand for dispatches + @descr Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakcss::uno::Reference to ouer OWNER - not to ouer SUPERCLASS! + + @implements XInterface + XDispatch + XLoadEventListener + XFrameActionListener + XEventListener + @base ThreadHelpBase + OWeakObject + + @devstatus ready to use +*//*-*************************************************************************************************************/ +class MenuDispatcher : // interfaces + public css::lang::XTypeProvider , + public css::frame::XDispatch , + public css::frame::XFrameActionListener , + // baseclasses + // Order is neccessary for right initialization! + public ThreadHelpBase , + public cppu::OWeakObject +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short standard ctor + @descr These initialize a new instance of ths class with needed informations for work. + + @seealso using at owner + + @param "xFactory" , css::uno::Reference to servicemanager for creation of new services + @param "xOwner" , css::uno::Reference to our owner, the Desktop!!! + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + MenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xOwner ); + + //--------------------------------------------------------------------------------------------------------- + // XInterface + //--------------------------------------------------------------------------------------------------------- + + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + //--------------------------------------------------------------------------------------------------------- + // XDispatch + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short dispatch URL with arguments + @descr Every dispatch create a new task. If load of URL failed task will deleted automaticly! + + @seealso - + + @param "aURL" , URL to dispatch. + @param "seqArguments" , list of optional arguments. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL dispatch( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException ); + + /*-****************************************************************************************************//** + @short add listener for state events + @descr You can add a listener to get information about status of dispatch: OK or Failed. + + @seealso method loadFinished() + @seealso method loadCancelled() + + @param "xControl" , css::uno::Reference to a valid listener for state events. + @param "aURL" , URL about listener will be informed, if something occured. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + /*-****************************************************************************************************//** + @short remove listener for state events + @descr You can remove a listener if information of dispatch isn't important for you any longer. + + @seealso method loadFinished() + @seealso method loadCancelled() + + @param "xControl" , css::uno::Reference to a valid listener. + @param "aURL" , URL on which listener has registered. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + + //--------------------------------------------------------------------------------------------------------- + // XFrameActionListener + //--------------------------------------------------------------------------------------------------------- + + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XEventListener + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short dispose current instance + @descr If service helper isn't required any longer call this method to release all used ressources. + + @seealso - + + @param "aEvent", information about source of this event. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + + protected: + + /*-****************************************************************************************************//** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + This method is protected, because its not allowed to use an instance of this class as a member! + You MUST use a pointer. + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual ~MenuDispatcher(); + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + DECL_LINK( Close_Impl, void* ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + sal_Bool impl_setMenuBar( MenuBar* pMenuBar, sal_Bool bMenuFromResource = sal_False ); + + /*-****************************************************************************************************//** + @short - + @descr - + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel ); + + //------------------------------------------------------------------------------------------------------------- + // debug methods + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short debug-method to check incoming parameter of some other mehods of this class + @descr The following methods are used to check parameters for other methods + of this class. The return value is used directly for an ASSERT(...). + + @seealso ASSERTs in implementation! + + @param css::uno::References to checking variables + @return sal_False on invalid parameter<BR> + sal_True otherway + + @onerror - + *//*-*****************************************************************************************************/ + + #ifdef ENABLE_ASSERTIONS + + private: + + static sal_Bool impldbg_checkParameter_MenuDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xOwner ); + static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , + const css::util::URL& aURL ); + static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , + const css::util::URL& aURL ); + #endif // #ifdef ENABLE_ASSERTIONS + + //------------------------------------------------------------------------------------------------------------- + // variables + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + + private: + + css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak ; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!) + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services! + IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs + sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. + sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation + MenuManager* m_pMenuManager ; /// menu manager controlling menu dispatches + +}; // class MenuDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/oxt_handler.hxx b/framework/inc/dispatch/oxt_handler.hxx new file mode 100644 index 000000000000..25bb1db58086 --- /dev/null +++ b/framework/inc/dispatch/oxt_handler.hxx @@ -0,0 +1,215 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_HANDLER_OXT_HANDLER_HXX_ +#define __FRAMEWORK_HANDLER_OXT_HANDLER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_ +#include <threadhelp/threadhelpbase.hxx> +#endif + +#ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_ +#include <threadhelp/resetableguard.hxx> +#endif + +#ifndef __FRAMEWORK_MACROS_XINTERFACE_HXX_ +#include <macros/xinterface.hxx> +#endif + +#ifndef __FRAMEWORK_MACROS_XTYPEPROVIDER_HXX_ +#include <macros/xtypeprovider.hxx> +#endif + +#ifndef __FRAMEWORK_MACROS_XSERVICEINFO_HXX_ +#include <macros/xserviceinfo.hxx> +#endif + +#ifndef __FRAMEWORK_MACROS_DEBUG_HXX_ +#include <macros/debug.hxx> +#endif + +#ifndef __FRAMEWORK_MACROS_GENERIC_HXX_ +#include <macros/generic.hxx> +#endif + +#ifndef __FRAMEWORK_GENERAL_H_ +#include <general.h> +#endif + +#ifndef __FRAMEWORK_STDTYPES_H_ +#include <stdtypes.h> +#endif + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_ +#include <com/sun/star/lang/XTypeProvider.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +#ifndef _COM_SUN_STAR_FRAME_XNOTIFYINGDISPATCH_HPP_ +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#endif + +#ifndef _COM_SUN_STAR_FRAME_XSTATUSLISTENER_HPP_ +#include <com/sun/star/frame/XStatusListener.hpp> +#endif + +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include <com/sun/star/frame/XFrame.hpp> +#endif + +#ifndef _COM_SUN_STAR_DOCUMENT_XEXTENDEDFILTERDETECTION_HPP_ +#include <com/sun/star/document/XExtendedFilterDetection.hpp> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#ifndef _COM_SUN_STAR_UTIL_URL_HPP_ +#include <com/sun/star/util/URL.hpp> +#endif + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short handler to detect and play sounds ("wav" and "au" only!) + @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds. + It doesn't depend from the target platform. But one instance of this class + can play one sound at the same time only. Means every new dispatch request will stop the + might still running one. So we support one operation/one URL/one listener at the same time + only. + + @devstatus ready + @threadsafe yes +*//*-*************************************************************************************************************/ +class Oxt_Handler : // interfaces + public css::lang::XTypeProvider + , public css::lang::XServiceInfo + , public css::frame::XNotifyingDispatch // => XDispatch + , public css::document::XExtendedFilterDetection + // baseclasses + // Order is neccessary for right initialization! + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + Oxt_Handler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~Oxt_Handler( ); + + //--------------------------------------------------------------------------------------------------------- + // XInterface, XTypeProvider, XServiceInfo + //--------------------------------------------------------------------------------------------------------- + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + //--------------------------------------------------------------------------------------------------------- + // XNotifyingDispatch + //--------------------------------------------------------------------------------------------------------- + virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException ); + + //--------------------------------------------------------------------------------------------------------- + // XDispatch + //--------------------------------------------------------------------------------------------------------- + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + // not supported ! + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , + const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {}; + virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , + const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {}; + + //--------------------------------------------------------------------------------------------------------- + // XExtendedFilterDetection + //--------------------------------------------------------------------------------------------------------- + virtual ::rtl::OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + private: + + //------------------------------------------------------------------------------------------------------------- + // variables + // (should be private everyway!) + //------------------------------------------------------------------------------------------------------------- + private: + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// global uno service factory to create new services + css::uno::Reference< css::uno::XInterface > m_xSelfHold ; /// we must protect us against dieing during async(!) dispatch() call! + css::uno::Reference< css::frame::XDispatchResultListener > m_xListener ; + +}; // class Oxt_Handler + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_HANDLER_OXT_HANDLER_HXX_ diff --git a/framework/inc/dispatch/popupmenudispatcher.hxx b/framework/inc/dispatch/popupmenudispatcher.hxx new file mode 100644 index 000000000000..e8002834dff9 --- /dev/null +++ b/framework/inc/dispatch/popupmenudispatcher.hxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <services/frame.hxx> +/* +#include <macros/generic.hxx> +*/ +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +/* +#include <macros/debug.hxx> +*/ +#include <threadhelp/threadhelpbase.hxx> +#include <general.h> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrameLoader.hpp> +#include <com/sun/star/frame/XLoadEventListener.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/FeatureStateEvent.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#ifndef _COM_SUN_STAR_URI_XURLREFERENCEFACTORY_HPP_ +#include <com/sun/star/uri/XUriReferenceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_URI_XURLREFERENCE_HPP_ +#include <com/sun/star/uri/XUriReference.hpp> +#endif + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/interfacecontainer.h> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + We must save informations about our listener and URL for listening. + We implement this as a hashtable for strings. +*//*-*************************************************************************************************************/ + +typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString , + OUStringHashCode , + std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer; + + +/*-************************************************************************************************************//** + @short helper for desktop only(!) to create new tasks on demand for dispatches + @descr Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakcss::uno::Reference to ouer OWNER - not to our SUPERCLASS! + + @implements XInterface + XDispatch + XLoadEventListener + XFrameActionListener + XEventListener + @base ThreadHelpBase + OWeakObject + + @devstatus ready to use +*//*-*************************************************************************************************************/ +class PopupMenuDispatcher : // interfaces + public css::lang::XTypeProvider , + public css::lang::XServiceInfo , + public css::frame::XDispatchProvider , + public css::frame::XDispatch , + public css::frame::XFrameActionListener , + public css::lang::XInitialization , + // baseclasses + // Order is neccessary for right initialization! + public ThreadHelpBase , + public cppu::OWeakObject +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + // constructor / destructor + PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + + // XInterface, XTypeProvider, XServiceInfo + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) throw( css::uno::Exception , + css::uno::RuntimeException); + // XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( + const ::com::sun::star::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) + throw( ::com::sun::star::uno::RuntimeException ); + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( + const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) + throw( css::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException ); + + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException ); + + // XEventListener + void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); + + // protected methods + protected: + virtual ~PopupMenuDispatcher(); + + void impl_RetrievePopupControllerQuery(); + void impl_CreateUriRefFactory(); + + // private methods + + // variables + private: + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame ; /// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!) + css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller + css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services! + IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs + sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. + sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation + +}; // class PopupMenuDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/selfdispatcher.hxx b/framework/inc/dispatch/selfdispatcher.hxx new file mode 100644 index 000000000000..1bbca4d20ed5 --- /dev/null +++ b/framework/inc/dispatch/selfdispatcher.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_SELFDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_SELFDISPATCHER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <dispatch/basedispatcher.hxx> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short helper to dispatch into an existing owner frame + @descr You should use it as dispatcher for "_self", flag::SELF ... cases, to load a document into an + owner frame without creation of a new one. + Use this class as member only! Never use it as baseclass. + XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS! + + @implements XInterface + XDispatch + XStatusListener + XLoadEventListener + XEventListener + + @base BaseDispatcher + OWeakObject + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class SelfDispatcher : // -interfaces ... are supported by our BaseDispatcher! + // -baseclasses ... order is neccessary for right initialization! + public BaseDispatcher +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + // ctor + SelfDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , + const css::uno::Reference< css::frame::XFrame >& xTarget ); + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + + //------------------------------------------------------------------------------------------------------------- + // protected methods + //------------------------------------------------------------------------------------------------------------- + protected: + virtual void SAL_CALL reactForLoadingState ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + const css::uno::Reference< css::frame::XFrame >& xTarget , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ); + + virtual void SAL_CALL reactForHandlingState( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lDescriptor , + sal_Bool bState , + const css::uno::Any& aAsyncInfo ); + +}; // class SelfDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_SELFDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/servicehandler.hxx b/framework/inc/dispatch/servicehandler.hxx new file mode 100644 index 000000000000..8b93b8734265 --- /dev/null +++ b/framework/inc/dispatch/servicehandler.hxx @@ -0,0 +1,149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_ +#define __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <macros/debug.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <general.h> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/** + @short protocol handler for "service:*" URLs + @descr It's a special dispatch/provider object which is registered for such URL pattern and will + be automaticly used by the framework dispatch mechanism if such URL occured. + His job is to create any registered uno components which must be coded inside + dispatched URL (may with some optional given parameters). After that such created + service must be hold his self alive. Such mechanism can be usefull for UI components + (e.g. Dialogs, Wizards) only. + + @base ThreadHelpBase + exports a lock member to guarantee right initialize value of it + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use + + @modified 02.05.2002 08:13, as96863 +*/ +class ServiceHandler : // interfaces + public css::lang::XTypeProvider , + public css::lang::XServiceInfo , + public css::frame::XDispatchProvider , + public css::frame::XNotifyingDispatch, // => XDispatch + // baseclasses + // Order is neccessary for right initialization! + private ThreadHelpBase , + public cppu::OWeakObject +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + /* interface */ + public: + + // ctor/dtor + ServiceHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~ServiceHandler( ); + + // XInterface, XTypeProvider, XServiceInfo + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException ); + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + /* internal */ + private: + + css::uno::Reference< css::uno::XInterface > implts_dispatch( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + +}; // class ServiceHandler + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_ diff --git a/framework/inc/dispatch/startmoduledispatcher.hxx b/framework/inc/dispatch/startmoduledispatcher.hxx new file mode 100644 index 000000000000..80ba78972f88 --- /dev/null +++ b/framework/inc/dispatch/startmoduledispatcher.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_ +#define __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_ + +//_______________________________________________ +// my own includes + +#include <threadhelp/threadhelpbase.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/debug.hxx> +#include <macros/generic.hxx> +#include <stdtypes.h> +#include <general.h> + +//_______________________________________________ +// interface includes +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/DispatchResultState.hpp> + +//_______________________________________________ +// other includes +#include <cppuhelper/weak.hxx> +#include <vcl/evntpost.hxx> + +//_______________________________________________ +// namespace + +namespace framework{ + +//----------------------------------------------- +/** + @short helper to handle all URLs related to the StartModule + */ +class StartModuleDispatcher : public css::lang::XTypeProvider + , public css::frame::XNotifyingDispatch // => XDispatch + , public css::frame::XDispatchInformationProvider + // baseclasses ... order is neccessary for right initialization! + , private ThreadHelpBase + , public ::cppu::OWeakObject +{ + //------------------------------------------- + // member + + private: + + //--------------------------------------- + /** @short reference to an uno service manager, + which can be used to create own needed + uno resources. */ + css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + + //--------------------------------------- + /** @short our "context" frame. */ + css::uno::WeakReference< css::frame::XFrame > m_xOwner; + + //--------------------------------------- + /** @short the original queryDispatch() target. */ + ::rtl::OUString m_sDispatchTarget; + + //--------------------------------------- + /** @short list of registered status listener */ + ListenerHash m_lStatusListener; + + //------------------------------------------- + // native interface + + public: + + //--------------------------------------- + /** @short connect a new StartModuleDispatcher instance to its "owner frame". + + @descr Such "owner frame" is used as context for all related operations. + + @param xSMGR + an uno service manager, which is needed to create uno resource + internaly. + + @param xFrame + the frame where the corresponding dispatch was started. + + @param sTarget + the original target information used for the related queryDispatch() call. + */ + StartModuleDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , + const css::uno::Reference< css::frame::XFrame >& xFrame , + const ::rtl::OUString& sTarget); + + //--------------------------------------- + /** @short does nothing real. */ + virtual ~StartModuleDispatcher(); + + //------------------------------------------- + // uno interface + + public: + + //--------------------------------------- + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + //--------------------------------------- + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException); + + //--------------------------------------- + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments) throw(css::uno::RuntimeException); + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw(css::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw(css::uno::RuntimeException); + + //--------------------------------------- + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) throw (css::uno::RuntimeException); + + //------------------------------------------- + // internal helper + + private: + + //--------------------------------------- + /** @short check if StartModule can be shown. + */ + ::sal_Bool implts_isBackingModePossible(); + + //--------------------------------------- + /** @short open the special BackingComponent (now StartModule) + + @return [bool] + TRUE if operation was successfully. + */ + ::sal_Bool implts_establishBackingMode(); + + //--------------------------------------- + /** @short notify a DispatchResultListener. + + @descr We check the listener reference before we use it. + So this method can be called everytimes! + + @parama xListener + the listener, which should be notified. + Can be null! + + @param nState + directly used as css::frame::DispatchResultState value. + + @param aResult + not used yet realy ... + */ + void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + sal_Int16 nState , + const css::uno::Any& aResult ); + +}; // class StartModuleDispatcher + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_ diff --git a/framework/inc/dispatch/systemexec.hxx b/framework/inc/dispatch/systemexec.hxx new file mode 100644 index 000000000000..b191ab3e31c5 --- /dev/null +++ b/framework/inc/dispatch/systemexec.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FRAMEWORK_DISPATCH_SYSTEMEXEC_HXX_ +#define __FRAMEWORK_DISPATCH_SYSTEMEXEC_HXX_ + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <macros/generic.hxx> +#include <macros/xinterface.hxx> +#include <macros/xtypeprovider.hxx> +#include <macros/xserviceinfo.hxx> +#include <macros/debug.hxx> +#include <threadhelp/threadhelpbase.hxx> +#include <general.h> +#include <stdtypes.h> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/weak.hxx> + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +namespace framework{ + +//_________________________________________________________________________________________________________________ +// exported const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// exported definitions +//_________________________________________________________________________________________________________________ + +/** + @short protocol handler for "systemexec:*" URLs + @descr It's a special dispatch/provider object which is registered for such URL pattern and will + be automaticly used by the framework dispatch mechanism if such URL occured. + It forwards all URL's to the underlying operating system. + So it would e.g. be possible to open HTML files outside the office within a web browser. + + @base ThreadHelpBase + exports a lock member to guarantee right initialize value of it + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use +*/ +class SystemExec : // interfaces + public css::lang::XTypeProvider , + public css::lang::XServiceInfo , + public css::frame::XDispatchProvider , + public css::frame::XNotifyingDispatch, // => XDispatch + // baseclasses + // Order is neccessary for right initialization! + private ThreadHelpBase , + public cppu::OWeakObject +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + /* interface */ + public: + + // ctor/dtor + SystemExec( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~SystemExec( ); + + // XInterface, XTypeProvider, XServiceInfo + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + DECLARE_XSERVICEINFO + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException ); + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + + /* internal */ + private: + + void impl_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + const sal_Int16 nState ); + +}; // class SystemExec + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_DISPATCH_SYSTEMEXEC_HXX_ |