diff options
author | Andreas Schlüns <as@openoffice.org> | 2002-05-23 11:54:59 +0000 |
---|---|---|
committer | Andreas Schlüns <as@openoffice.org> | 2002-05-23 11:54:59 +0000 |
commit | 62df05fdb1ff991447349c1cc38118d19c7efe2d (patch) | |
tree | 151ce5e4e894cd18050ac3002338fd91489b8a86 /framework/source/dispatch | |
parent | db80f11d26551393cfe8060857cb302956b2c6fa (diff) |
#91939# supports XClosable; remove deprecated task; ...
Diffstat (limited to 'framework/source/dispatch')
-rw-r--r-- | framework/source/dispatch/dispatchprovider.cxx | 1195 | ||||
-rw-r--r-- | framework/source/dispatch/helpagentdispatcher.cxx | 11 | ||||
-rw-r--r-- | framework/source/dispatch/menudispatcher.cxx | 8 |
3 files changed, 656 insertions, 558 deletions
diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index e6855c2b7bbf..d1076b307605 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dispatchprovider.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: as $ $Date: 2002-05-03 08:00:14 $ + * last change: $Author: as $ $Date: 2002-05-23 12:52:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -131,10 +131,6 @@ #include <com/sun/star/document/XTypeDetection.hpp> #endif -#ifndef _COM_SUN_STAR_MOZILLA_XPLUGININSTANCE_HPP_ -#include <com/sun/star/mozilla/XPluginInstance.hpp> -#endif - //_________________________________________________________________________________________________________________ // includes of other projects //_________________________________________________________________________________________________________________ @@ -179,20 +175,20 @@ namespace framework{ //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** -DEFINE_XINTERFACE_3 ( DispatchProvider , - OWeakObject , - DIRECT_INTERFACE(css::lang::XTypeProvider ), - DIRECT_INTERFACE(css::frame::XDispatchProvider ), - DIRECT_INTERFACE(css::lang::XEventListener ) - ) - -DEFINE_XTYPEPROVIDER_3 ( DispatchProvider , - css::lang::XTypeProvider , - css::frame::XDispatchProvider , - css::lang::XEventListener - ) - -/*-************************************************************************************************************//** +DEFINE_XINTERFACE_2( DispatchProvider , + OWeakObject , + DIRECT_INTERFACE(css::lang::XTypeProvider ), + DIRECT_INTERFACE(css::frame::XDispatchProvider) + ) + +DEFINE_XTYPEPROVIDER_2( DispatchProvider , + css::lang::XTypeProvider , + css::frame::XDispatchProvider + ) + +//_________________________________________________________________________________________________________________ + +/** @short standard ctor/dtor @descr These initialize a new instance of tihs class with needed informations for work. We hold a weakreference to our owner frame which start dispatches at us. @@ -201,248 +197,89 @@ DEFINE_XTYPEPROVIDER_3 ( DispatchProvider , @seealso using at owner - @param "xFactory", reference to servicemanager to create new services. - @param "xFrame" , reference to our owner frame. - @return - + @param xFactory + reference to servicemanager to create new services. + @param xFrame + reference to our owner frame. - @onerror - -*//*-*************************************************************************************************************/ + @modified 17.05.2002 10:07, as96863 +*/ DispatchProvider::DispatchProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , const css::uno::Reference< css::frame::XFrame >& xFrame ) // Init baseclasses first - : ThreadHelpBase ( &Application::GetSolarMutex() ) - , TransactionBase ( ) - , OWeakObject ( ) + : ThreadHelpBase( &Application::GetSolarMutex() ) + , OWeakObject ( ) // Init member - , m_xFrame ( xFrame ) - , m_xFactory ( xFactory ) - // Don't initialize dispatch helper ... - // because we create it on demand! + , m_xFrame ( xFrame ) + , m_xFactory ( xFactory ) { - // Safe impossible cases - // We need valid informations about ouer owner for working. - LOG_ASSERT2( implcp_ctor( xFactory, xFrame ), "DispatchProvider::DispatchProvider()", "Invalid parameter detected!\n" ) - - // Open object for working! - m_aTransactionManager.setWorkingMode( E_WORK ); } -//***************************************************************************************************************** +css::uno::WeakReference< css::mozilla::XPluginInstance > DispatchProvider::m_xPluginInterceptor=NULL; + +//_________________________________________________________________________________________________________________ + +/** + @short protected(!) dtor for deinitializing + @descr We made it protected to prevent using of us as base class instead as a member. + + @modified 17.05.2002 10:05, as96863 + */ DispatchProvider::~DispatchProvider() { - // A dtor isn't a good place to make anything ... - // Do it in dispose/ing()! - // We are listener on our owner frame ... } -/*-************************************************************************************************************//** +//_________________________________________________________________________________________________________________ + +/** @interface XDispatchProvider @short search a dispatcher for given URL @descr If no interceptor is set on owner, we search for right frame and dispatch URL to it. If no frame was found, we do nothing. + But we doesn't do it directly here. We detect the type of our owner frame and calls + specialized queryDispatch() helper dependen from that. Because a Desktop handle some + requests in another way then a plugin or normal frame. + + @param aURL + URL to dispatch. + @param sTargetFrameName + name of searched frame. + @param nSearchFlags + flags for searching. + @return A reference to a dispatch object for this URL (if someone was found!). - @seealso - - - @param "aURL" , URL to dispatch. - @param "sTargetFrameName" , name of searched frame. - @param "nSearchFlags" , flags for searching. - @return A reference a dispatcher for these URL (if someone was found!). - - @onerror We return a NULL-reference. @threadsafe yes -*//*-*************************************************************************************************************/ + @modified 17.05.2002 10:59, as96863 +*/ css::uno::Reference< css::frame::XDispatch > SAL_CALL DispatchProvider::queryDispatch( const css::util::URL& aURL , const ::rtl::OUString& sTargetFrameName , sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ) { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Check incoming parameter ... - LOG_ASSERT2( implcp_queryDispatch( aURL, sTargetFrameName, nSearchFlags ), "DispatchProvider::queryDispatch()", "Invalid Parameter detected!" ) - // Register operation as transaction and reject wrong calls! - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); + css::uno::Reference< css::frame::XDispatch > xDispatcher; - // Set default return value if query failed. - css::uno::Reference< css::frame::XDispatch > xReturn; - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + /* SAFE { */ ReadGuard aReadLock( m_aLock ); - - // Make snapshot of neccessary member by using a read lock. - // Resolve weakreference to owner and hold a normal reference till the end of this method. - // So he couldn't die .-) - css::uno::Reference< css::frame::XFrame > xOwner ( m_xFrame.get(), css::uno::UNO_QUERY ); - css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory; - + css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY ); aReadLock.unlock(); - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ + /* } SAFE */ - if (xOwner.is()) - { - // Classify target of this dispatch call to find right dispatch helper! - // Try to get neccessary informations from tree environment. - TargetInfo aInfo ( xOwner, sTargetFrameName, nSearchFlags ); - ETargetClass eResult= TargetFinder::classifyQueryDispatch( aInfo ); - switch( eResult ) - { - //----------------------------------------------------------------------------------------------------- - case E_SELF : { - // Ask our controller for his agreement for these dispatched URL ... - // because some URLs are internal and can be handled faster by SFX - which most is the current controller! - // Attention: Desktop has no controller - don't ask him! - if( aInfo.eFrameType != E_DESKTOP ) - { - css::uno::Reference< css::frame::XDispatchProvider > xController( xOwner->getController(), css::uno::UNO_QUERY ); - if( xController.is() == sal_True ) - { - xReturn = xController->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); - } - } - // If controller has no fun to dispatch these URL - we must search another right dispatcher. - // Search for any registered protocol handler first. - // Note: member "m_aProtocolHandlerCache" use singleton mechanism to implement an internal threadsafe data container - // and use a ref count member too. On the other side he lives till we die. So we can use it without a lock. - if (!xReturn.is()) - { - ProtocolHandler aHandler; - if (m_aProtocolHandlerCache.search(aURL,&aHandler)) - { - css::uno::Reference< css::frame::XDispatchProvider > xHandler( - xFactory->createInstance(aHandler.m_sUNOName), - css::uno::UNO_QUERY); - if (xHandler.is()) - xReturn = xHandler->queryDispatch(aURL,SPECIALTARGET_SELF,0); - } - // Not for controller - not for protocol handler - // It should be a loadable content - may be a file. Check it ... - // This check is neccessary to found out, that - // support for some protocols isn't installed by user. May be - // "ftp" isn't available. So we suppress creation of our self dispatcher. - // The result will be clear. He can't handle it - but he would try it. - if (!xReturn.is() && implts_isLoadableContent(aURL)) - { - xReturn = implts_getOrCreateDispatchHelper( E_SELFDISPATCHER ); - } - } - } - break; - //----------------------------------------------------------------------------------------------------- - case E_CREATETASK : { - // Check ucb support before you create dispatch helper. - // He could do nothing then ... but it doesnt perform, if we try it! - if( implts_isLoadableContent( aURL ) == sal_True ) - { - css::uno::Reference < css::frame::XFramesSupplier > xDesktop( xOwner, css::uno::UNO_QUERY ); - css::uno::Reference < css::frame::XFrame > xTask = xDesktop->getActiveFrame(); - css::uno::Reference < css::mozilla::XPluginInstance > xPlug( xTask, css::uno::UNO_QUERY ); - if ( xPlug.is() ) - { - css::uno::Reference < css::frame::XDispatchProvider > xProv( xTask, css::uno::UNO_QUERY ); - xReturn = xProv->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); - } - else - xReturn = implts_getOrCreateDispatchHelper( E_BLANKDISPATCHER ); - } - } - break; - //----------------------------------------------------------------------------------------------------- - case E_DEFAULT : { - // Check ucb support before you create dispatch helper. - // He could do nothing then ... but it doesnt perform, if we try it! - if( implts_isLoadableContent( aURL ) == sal_True ) - { - css::uno::Reference < css::frame::XFramesSupplier > xDesktop( xOwner, css::uno::UNO_QUERY ); - css::uno::Reference < css::frame::XFrame > xTask = xDesktop->getActiveFrame(); - css::uno::Reference < css::mozilla::XPluginInstance > xPlug( xTask, css::uno::UNO_QUERY ); - if ( xPlug.is() ) - { - css::uno::Reference < css::frame::XDispatchProvider > xProv( xTask, css::uno::UNO_QUERY ); - xReturn = xProv->queryDispatch( aURL, SPECIALTARGET_SELF, 0 ); - } - else - xReturn = implts_getOrCreateDispatchHelper( E_DEFAULTDISPATCHER ); - } - } - break; - //----------------------------------------------------------------------------------------------------- - case E_PARENT : - case E_FORWARD_UP : { - css::uno::Reference< css::frame::XDispatchProvider > xParent( xOwner->getCreator(), css::uno::UNO_QUERY ); - if( xParent.is() == sal_True ) - { - xReturn = xParent->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); - } - } - break; - //----------------------------------------------------------------------------------------------------- - case E_BEAMER : { - css::uno::Reference< css::frame::XDispatchProvider > xBeamer( xOwner->findFrame( SPECIALTARGET_BEAMER, css::frame::FrameSearchFlag::CHILDREN || css::frame::FrameSearchFlag::SELF ), css::uno::UNO_QUERY ); - if( xBeamer.is() == sal_True ) - { - xReturn = xBeamer->queryDispatch( aURL, SPECIALTARGET_SELF, 0 ); - } - else - { - css::uno::Reference< css::frame::XDispatchProvider > xController( xOwner->getController(), css::uno::UNO_QUERY ); - if( xController.is() == sal_True ) - { - xReturn = xController->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); - } - } - } - break; - //----------------------------------------------------------------------------------------------------- - case E_MENUBAR : { - xReturn = implts_getOrCreateDispatchHelper( E_MENUDISPATCHER ); - } - break; - //----------------------------------------------------------------------------------------------------- - case E_HELPAGENT : { - xReturn = implts_getOrCreateDispatchHelper( E_HELPAGENTDISPATCHER ); - } - break; - //----------------------------------------------------------------------------------------------------- - case E_TASKS : - case E_DEEP_DOWN : - case E_FLAT_DOWN : - case E_DEEP_BOTH : - case E_FLAT_BOTH : { - sal_Int32 nNewFlags = nSearchFlags ; - nNewFlags &= ~css::frame::FrameSearchFlag::CREATE; - css::uno::Reference< css::frame::XFrame > xFrame = xOwner->findFrame( sTargetFrameName, nNewFlags ); - if( xFrame.is() == sal_True ) - { - xReturn = css::uno::Reference< css::frame::XDispatchProvider >( xFrame, css::uno::UNO_QUERY )->queryDispatch( aURL, SPECIALTARGET_SELF, 0 ); - } - else - if( - ( aInfo.bCreationAllowed == sal_True ) && - ( implts_isLoadableContent( aURL ) == sal_True ) - ) - { - css::uno::Any aParameter; - aParameter <<= sTargetFrameName; - xReturn = implts_getOrCreateDispatchHelper( E_CREATEDISPATCHER, aParameter ); - } - } - break; - //----------------------------------------------------------------------------------------------------- - #ifdef ENABLE_WARNINGS - default : { - if( eResult != E_UNKNOWN ) - { - LOG_WARNING( "DispatchProvider::queryDispatch()", "No valid result found ... could it be an algorithm error?!" ) - } - } - break; - #endif - } - } + css::uno::Reference< css::frame::XDesktop > xDesktopCheck( xOwner, css::uno::UNO_QUERY ); + css::uno::Reference< css::mozilla::XPluginInstance > xPluginCheck ( xOwner, css::uno::UNO_QUERY ); + + if (xDesktopCheck.is()) + xDispatcher = implts_queryDesktopDispatch(xOwner, aURL, sTargetFrameName, nSearchFlags); + else + if (xPluginCheck.is()) + xDispatcher = implts_queryPluginDispatch(xOwner, aURL, sTargetFrameName, nSearchFlags); + else + xDispatcher = implts_queryFrameDispatch(xOwner, aURL, sTargetFrameName, nSearchFlags); - // Return result of this operation. - return xReturn; + return xDispatcher; } -/*-************************************************************************************************************//** +//_________________________________________________________________________________________________________________ + +/** @interface XDispatchProvider @short do the same like queryDispatch() ... but handle multiple dispatches at the same time @descr It's an optimism. User give us a list of queries ... and we return a list of dispatcher. @@ -451,292 +288,642 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL DispatchProvider::queryDis @seealso method queryDispatch() - @param "aURL" , URL to dispatch. - @param "sTargetFrameName" , name of searched frame. - @param "nSearchFlags" , flags for searching. - @return A reference a dispatcher for these URL (if someone was found!). + @param lDescriptions + a list of all dispatch parameters for multiple requests + @return A reference a list of dispatch objects for these URLs - may with some <NULL/> values inside. - @onerror We return a NULL-reference. @threadsafe yes -*//*-*************************************************************************************************************/ + @modified 17.05.2002 09:55, as96863 +*/ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL DispatchProvider::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) throw( css::uno::RuntimeException ) { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Check incoming parameter ... - LOG_ASSERT2( implcp_queryDispatches( lDescriptions ), "DispatchProvider::queryDispatches()", "Invalid Parameter detected!" ) - // Register operation as transaction and reject wrong calls! - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); + // Create return list - which must have same size then the given descriptor + // It's not allowed to pack it! + sal_Int32 nCount = lDescriptions.getLength(); + css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount ); - // Set default return value if query failed. - css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher; + // Step over all descriptors and try to get any dispatcher for it. + for( sal_Int32 i=0; i<nCount; ++i ) + { + lDispatcher[i] = queryDispatch( lDescriptions[i].FeatureURL , + lDescriptions[i].FrameName , + lDescriptions[i].SearchFlags ); + } - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - ReadGuard aReadLock( m_aLock ); + return lDispatcher; +} - // Make snapshot of neccessary member by using a read lock. - // Resolve weakreference to owner and hold a normal reference till the end of this method. - // So he couldn't die .-) - css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY ); +//_________________________________________________________________________________________________________________ - aReadLock.unlock(); - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ +/** + @short set a new plugin frame for intercepting special queryDispatch() requests directly + @descr Some requests (e.g. creation of new tasks) must be done by forwarding it to the + used browser. Normaly we can start a search for any existing plugin instance on our + desktop container to detect (a) if we run in plugin mode and (b) to use one of such + plugins to send the request to the browser. It can be very expensive. So + we optimize this process. If the desktop gets a new child frame which represent a plugin + he set it as a static member on this class. So all dispatch objects inside the frame tree + knows them and can can use it. But we hold a weak reference only. So we the plugin mustn't + be deregistered again. We can try to get the real reference and if it failed we don't use it. + + @threadsafe yes + @modified 17.05.2002 08:25, as96863 + */ +void DispatchProvider::setPluginInterceptor( const css::uno::Reference< css::mozilla::XPluginInstance >& xPlugin ) +{ + /* STATIC SAFE { */ + WriteGuard aExclusivLock( LockHelper::getGlobalLock() ); + m_xPluginInterceptor = xPlugin; + aExclusivLock.unlock(); + /* } STATIC SAFE */ +} - if( xOwner.is() == sal_True ) +//_________________________________________________________________________________________________________________ + +/** + @short helper for queryDispatch() + @descr Every member of the frame tree (frame, task, plugin, desktop) must handle such request + in another way. So we implement different specialized metods for every one. + + @threadsafe yes + @modified 17.05.2002 08:38, as96863 + */ +css::uno::Reference< css::frame::XDispatch > DispatchProvider::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 > xDispatcher; + + // ignore wrong requests which are not supported + if ( + (sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for frame dispatches - not for desktop + (sTargetFrameName==SPECIALTARGET_HELPAGENT) || // valid for frame dispatches - not for desktop + (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition + (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - + // and they exist more then ones. We have no idea which our sub tasks is the right one + ) { - // Get count of all given discriptors ... - sal_Int32 nCount = lDescriptions.getLength(); - if( nCount > 0 ) + return NULL; + } + + // If we must load such URL we should check if ucb support it. + // Otherwhise we create some dispatch objects which can't handle them. + sal_Bool bIsLoadable = implts_isLoadableContent(aURL); + + /* TODO: In special plugin mode we must use the already found plugin frame to forward the request + to the browser. Thats the only solution till we get the functionality to create + an emtpy browser task synchronously. + */ + + /* STATIC SAFE { */ + ReadGuard aGlobalReadLock( LockHelper::getGlobalLock() ); + css::uno::Reference< css::frame::XDispatchProvider > xPlugin( m_xPluginInterceptor.get(), css::uno::UNO_QUERY ); + aGlobalReadLock.unlock(); + /* } STATIC SAFE */ + + //----------------------------------------------------------------------------------------------------- + // I) handle special cases which not right for using findFrame() first + //----------------------------------------------------------------------------------------------------- + + //----------------------------------------------------------------------------------------------------- + // I.I) "_blank" + // It's not the right place to create a new task here - because we are queried for a dispatch object + // only, which can handle such request. Such dispatcher should create the required task on demand. + // Normaly the functionality for "_blank" is provided by findFrame() - but that would create it directly + // here. Thats why we must "intercept" here. + //----------------------------------------------------------------------------------------------------- + if (sTargetFrameName==SPECIALTARGET_BLANK) + { + if (bIsLoadable) { - // ... to get enough memory for expected dispatcher list - // We can't get more dispatcher as descriptors exist! - lDispatcher.realloc( nCount ); - // Step over all descriptors and try to get any dispatcher for it. - for( sal_Int32 nPosition=0; nPosition<nCount; ++nPosition ) + if (xPlugin.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xPlugin, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_BLANK,0); // ask him for _blank ... not for _self! + } + else { - lDispatcher[nPosition] = queryDispatch( lDescriptions[nPosition].FeatureURL , - lDescriptions[nPosition].FrameName , - lDescriptions[nPosition].SearchFlags ); + xDispatcher = implts_getOrCreateDispatchHelper( E_BLANKDISPATCHER, xDesktop ); } } } - return lDispatcher; + //----------------------------------------------------------------------------------------------------- + // I.II) "_default" + // This is a combination of search an empty task for recycling - or create a new one. + // Normaly we can use a specialized dispatch object for that ... but not for plugin mode. + // Such search isn't provided there. + //----------------------------------------------------------------------------------------------------- + else + if (sTargetFrameName==SPECIALTARGET_DEFAULT) + { + if (bIsLoadable) + { + if (xPlugin.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xPlugin, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_BLANK,0); // ask him for _blank ... not for _default! + } + else + { + xDispatcher = implts_getOrCreateDispatchHelper( E_DEFAULTDISPATCHER, xDesktop ); + } + } + } + + //----------------------------------------------------------------------------------------------------- + // I.III) "_self", "", "_top" + // The desktop can't load any document - but he can handle some special protocols like "uno", "slot" ... + // Why is "top" here handled too? Because the desktop is the topest frame. Normaly it's superflous + // to use this target - but we can handle it in the same manner then "_self". + //----------------------------------------------------------------------------------------------------- + else + if ( + (sTargetFrameName==SPECIALTARGET_SELF) || + (sTargetFrameName==SPECIALTARGET_TOP ) || + (sTargetFrameName.getLength()<1 ) + ) + { + if (!bIsLoadable) + xDispatcher = implts_searchProtocolHandler(aURL); + } + + //----------------------------------------------------------------------------------------------------- + // I.IV) no further special targets exist + // Now we have to search for the right target frame by calling findFrame() - but should provide our code + // against creation of a new task if no frame could be found. + // I said it b efore - it's allowed for dispatch() only. + //----------------------------------------------------------------------------------------------------- + else + { + sal_Int32 nRightFlags = nSearchFlags; + nRightFlags &= ~css::frame::FrameSearchFlag::CREATE; + + // try to find any existing target and ask him for his dispatcher + css::uno::Reference< css::frame::XFrame > xFoundFrame = xDesktop->findFrame(sTargetFrameName, nRightFlags); + if (xFoundFrame.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xFoundFrame, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_SELF,0); + } + else + // if it couldn't be found - but creation was allowed + // use special dispatcher for creatio or froward it to the browser + if (nSearchFlags & css::frame::FrameSearchFlag::CREATE) + { + if (xPlugin.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xPlugin, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_BLANK,0); + } + else + { + css::uno::Any aParameter; + aParameter <<= sTargetFrameName; + xDispatcher = implts_getOrCreateDispatchHelper( E_CREATEDISPATCHER, xDesktop, aParameter ); + } + } + } + + return xDispatcher; } -/*-****************************************************************************************************//** - @interface XEventListener - @short release this object - @descr This implementation is used as a helper of a Task, PlugInFrame or Frame. - These services could get a dispose() call from his owner. - We should die at the same time - disposed by our owner frame! - That's why we are a listener for disposing events ... +//_________________________________________________________________________________________________________________ + +css::uno::Reference< css::frame::XDispatch > DispatchProvider::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 > xDispatcher; + + // If we must load such URL we should check if ucb support it. + // Otherwhise we create some dispatch objects which can't handle them. + sal_Bool bIsLoadable = implts_isLoadableContent(aURL); + + /* TODO: In special plugin mode we must use the already found plugin frame to forward the request + to the browser. Thats the only solution till we get the functionality to create + an emtpy browser task synchronously. + */ + + /* STATIC SAFE { */ + ReadGuard aGlobalReadLock( LockHelper::getGlobalLock() ); + css::uno::Reference< css::frame::XDispatchProvider > xPlugin( m_xPluginInterceptor.get(), css::uno::UNO_QUERY ); + aGlobalReadLock.unlock(); + /* } STATIC SAFE */ + + //----------------------------------------------------------------------------------------------------- + // I) handle special cases which not right for using findFrame() first + //----------------------------------------------------------------------------------------------------- + + //----------------------------------------------------------------------------------------------------- + // I.I) "_blank", "_default" + // It's not the right place to create a new task here. Only the desktop can do that. + // Normaly the functionality for "_blank" is provided by findFrame() - but that would create it directly + // here. Thats why we must "intercept" here. + // Another eason is a possible plugin mode! + //----------------------------------------------------------------------------------------------------- + if ( + (sTargetFrameName==SPECIALTARGET_BLANK ) || + (sTargetFrameName==SPECIALTARGET_DEFAULT) + ) + { + if (xPlugin.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xPlugin, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_BLANK,0); // ask him for _blank ... not for _default! + } + else + { + css::uno::Reference< css::frame::XDispatchProvider > xParent( xFrame->getCreator(), css::uno::UNO_QUERY ); + if (xParent.is()) + xDispatcher = xParent->queryDispatch(aURL, sTargetFrameName, 0); // its a special target - ignore search flags + } + } - @attention We accept disposing events of our owner frame only! + //----------------------------------------------------------------------------------------------------- + // I.II) "_menubar" + // Special mode on frame or task to receive the local menu. Not supported by findFrame() + //----------------------------------------------------------------------------------------------------- + else + if (sTargetFrameName==SPECIALTARGET_MENUBAR) + { + xDispatcher = implts_getOrCreateDispatchHelper( E_MENUDISPATCHER, xFrame ); + } - @seealso method Frame::dispose() + //----------------------------------------------------------------------------------------------------- + // I.III) "_helpagent" + // Special mode on frame or task to start the help agent inside this frame. Not supported by findFrame() + //----------------------------------------------------------------------------------------------------- + else + if (sTargetFrameName==SPECIALTARGET_HELPAGENT) + { + xDispatcher = implts_getOrCreateDispatchHelper( E_HELPAGENTDISPATCHER, xFrame ); + } - @param "aEvent", describe the source of this event and should be the owner of this object. - @return - + //----------------------------------------------------------------------------------------------------- + // I.IV) "_helpagent" + // Special sub frame of a top frame only. Search or create it. ... OK it's currently a little bit HACKI. + // Only the sfx (means the controller) can create it it. + //----------------------------------------------------------------------------------------------------- + else + if (sTargetFrameName==SPECIALTARGET_BEAMER) + { + css::uno::Reference< css::frame::XDispatchProvider > xBeamer( xFrame->findFrame( SPECIALTARGET_BEAMER, css::frame::FrameSearchFlag::CHILDREN | css::frame::FrameSearchFlag::SELF ), css::uno::UNO_QUERY ); + if (xBeamer.is()) + { + xDispatcher = xBeamer->queryDispatch(aURL, SPECIALTARGET_SELF, 0); + } + else + { + css::uno::Reference< css::frame::XDispatchProvider > xController( xFrame->getController(), css::uno::UNO_QUERY ); + if (xController.is()) + // force using of special target - but use original search flags + // May the caller used the CREATE flag or not! + xDispatcher = xController->queryDispatch(aURL, SPECIALTARGET_BEAMER, nSearchFlags); + } + } - @onerror We do nothing. - @threadsafe yes -*//*-*****************************************************************************************************/ -void SAL_CALL DispatchProvider::disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ) + //----------------------------------------------------------------------------------------------------- + // I.V) "_self", "" + // Our owner frame should handle this URL. But we can't do it for all of them. + // So we ask the internal setted controller first. If he disagree we try to find a registered + // protocol handler. If this failed too - we check for a loadable content and in case of true + // we load it into the frame by returning specilized dispatch object. + //----------------------------------------------------------------------------------------------------- + else + if ( + (sTargetFrameName==SPECIALTARGET_SELF) || + (sTargetFrameName.getLength()<1 ) + ) + { + // Ask our controller for his agreement for these dispatched URL ... + // because some URLs are internal and can be handled faster by SFX - which most is the current controller! + // But in case of e.g. the bibliography not all queries will be handled successfully here. + css::uno::Reference< css::frame::XDispatchProvider > xController( xFrame->getController(), css::uno::UNO_QUERY ); + if (xController.is()) + xDispatcher = xController->queryDispatch(aURL, SPECIALTARGET_SELF, 0); + // If controller has no fun to dispatch these URL - we must search another right dispatcher. + // Search for any registered protocol handler first. + // Note: member "m_aProtocolHandlerCache" use singleton mechanism to implement an internal threadsafe data container + // and use a ref count member too. On the other side he lives till we die. So we can use it without a lock. + if ( ! xDispatcher.is() ) + { + ProtocolHandler aHandler; + if (m_aProtocolHandlerCache.search(aURL,&aHandler)) + { + /* SAFE { */ + ReadGuard aReadLock( m_aLock ); + css::uno::Reference< css::frame::XDispatchProvider > xHandler( m_xFactory->createInstance(aHandler.m_sUNOName), css::uno::UNO_QUERY); + aReadLock.unlock(); + /* } SAFE */ + if (xHandler.is()) + xDispatcher = xHandler->queryDispatch(aURL,SPECIALTARGET_SELF,0); + } + } + // Not for controller - not for protocol handler + // It should be a loadable content - may be a file. Check it ... + // This check is neccessary to found out, that + // support for some protocols isn't installed by user. May be + // "ftp" isn't available. So we suppress creation of our self dispatcher. + // The result will be clear. He can't handle it - but he would try it. + if ( + ( ! xDispatcher.is() ) && + ( bIsLoadable ) + ) + { + xDispatcher = implts_getOrCreateDispatchHelper( E_SELFDISPATCHER, xFrame ); + } + } + + //----------------------------------------------------------------------------------------------------- + // I.VI) no further special handlings exist + // Now we have to search for the right target frame by calling findFrame() - but should provide our code + // against creation of a new task if no frame could be found. + // I said it before - it's allowed for dispatch() only. + //----------------------------------------------------------------------------------------------------- + else + { + sal_Int32 nRightFlags = nSearchFlags; + nRightFlags &= ~css::frame::FrameSearchFlag::CREATE; + + // try to find any existing target and ask him for his dispatcher + css::uno::Reference< css::frame::XFrame > xFoundFrame = xFrame->findFrame(sTargetFrameName, nRightFlags); + if (xFoundFrame.is()) + { + // Attention: Found target is our own owner frame! + // Don't ask him for his dispatcher. We know it already - it's our self dispatch helper. + // Otherwhise we can start a never ending recursiv call. Why? + // Somewere called our owner frame - he called some interceptor objects - and may by this dispatch provider + // is called. If wa use queryDispatch() on our owner frame again - we start this call stack again ... and again. + if (xFoundFrame==xFrame) + xDispatcher = implts_getOrCreateDispatchHelper( E_SELFDISPATCHER, xFrame ); + else + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xFoundFrame, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_SELF,0); + } + } + else + // if it couldn't be found - but creation was allowed + // forward request to the browser (for plugin mode) or to the desktop + // (for nomal mode). + // Note: The given target name must be used to set the name on new created task! + // Don't forward request by changing it to a special one e.g _blank. + // Use the CREATE flag only to prevent call against further searches. + // We already know it - the target must be created new. + if (nSearchFlags & css::frame::FrameSearchFlag::CREATE) + { + if (xPlugin.is()) + { + css::uno::Reference< css::frame::XDispatchProvider > xProvider( xPlugin, css::uno::UNO_QUERY ); + xDispatcher = xProvider->queryDispatch(aURL, sTargetFrameName, css::frame::FrameSearchFlag::CREATE); + } + else + { + css::uno::Reference< css::frame::XDispatchProvider > xParent( xFrame->getCreator(), css::uno::UNO_QUERY ); + if (xParent.is()) + xDispatcher = xParent->queryDispatch(aURL, sTargetFrameName, css::frame::FrameSearchFlag::CREATE); + } + } + } + + return xDispatcher; +} + +//_________________________________________________________________________________________________________________ + +css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryPluginDispatch( const css::uno::Reference< css::frame::XFrame > xPlugin , + const css::util::URL& aURL , + const ::rtl::OUString& sTargetFrameName , + sal_Int32 nSearchFlags ) { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Safe impossible cases - // This method is not defined for all incoming parameter. - LOG_ASSERT2( implcp_disposing( aEvent ), "DispatchProvider::disposing()", "Invalid parameter detected!" ) - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - WriteGuard aWriteLock( m_aLock ); - // Try to get access on our owner frame. If he already died ... we will get some trouble. - // But normaly HE sended this event ... if we should handle it. - css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY ); - // Ignore event, if source isn't our owner frame! - // Nobody should dispose us ... if he isn't our real owner. - sal_Bool bIgnore = sal_True; - if( - ( xOwner.is() == sal_True ) && - ( aEvent.Source == xOwner ) - ) + css::uno::Reference< css::frame::XDispatch > xDispatcher; + + // If we must load such URL we should check if ucb support it. + // Otherwhise we create some dispatch objects which can't handle them. + sal_Bool bIsLoadable = implts_isLoadableContent(aURL); + + //----------------------------------------------------------------------------------------------------- + // I.I) "_blank", "_default", "_self", "" + // Such requests must be forwarded to the browser! + // Normaly the _default mode search for any target which can be recycled or try to find out + // if requested ressource was already loaded. But currently we can't support that for plugin mode. + //----------------------------------------------------------------------------------------------------- + if ( + (sTargetFrameName==SPECIALTARGET_BLANK ) || + (sTargetFrameName==SPECIALTARGET_DEFAULT) || + (sTargetFrameName==SPECIALTARGET_SELF ) || + (sTargetFrameName.getLength()<1 ) + ) + { + if (bIsLoadable) + xDispatcher = implts_getOrCreateDispatchHelper( E_PLUGINDISPATCHER, xPlugin ); + } + + //----------------------------------------------------------------------------------------------------- + // I.II) Most other targets or flags can be handled by the base class functionality + // of a PlugInFrame - the Frame. But look for case of not found target in combination with + // the CREATE flag. Such request must be forwarded to the browser too! + //----------------------------------------------------------------------------------------------------- + else { - bIgnore = sal_False; + sal_Int32 nRightFlags = nSearchFlags; + nRightFlags &= ~css::frame::FrameSearchFlag::CREATE; + + xDispatcher = implts_queryFrameDispatch(xPlugin, aURL, sTargetFrameName, nRightFlags); + if ( + ( ! xDispatcher.is() ) && + ( nSearchFlags & css::frame::FrameSearchFlag::CREATE ) + ) + { + if (bIsLoadable) + xDispatcher = implts_getOrCreateDispatchHelper( E_PLUGINDISPATCHER, xPlugin ); + } } - aWriteLock.unlock(); - if( bIgnore == sal_False ) + return xDispatcher; +} + +//_________________________________________________________________________________________________________________ + +/** + @short search for a registered protocol handler and ask him for a dispatch object + @descr Such protocol handler doesn't need any target frame. They handle special URL protocols. + + @param aURL + the dispatch URL for which may a handler is registered + @return A dispatch object if a handler was found or <NULL/> if not. + + @threadsafe yes + @modified 16.05.2002 15:52, as96863 +*/ +css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProtocolHandler( const css::util::URL& aURL ) +{ + css::uno::Reference< css::frame::XDispatch > xDispatcher; + ProtocolHandler aHandler ; + if (m_aProtocolHandlerCache.search(aURL,&aHandler)) // This member is threadsafe by himself and lives if we live - we doesn't need any mutex here. { - // Follow lines are safe too - because our transaction helper are threadsafe by herself ... - // and after "setWorkingMode() we are alone! - - /* Disposing of a service is a special procedure. - We have registered all interface operations as non breakable ones. - So we must disable this object for working - further requests will be rejected then. - After that we can release our internal structures ... and die :_( - */ - - // It's a good idea to hold usself alive ... Because we should prevent us against dieing during tis operation. - // Other people could release there references to use ... and then our dtor is called automaticly! - css::uno::Reference< css::uno::XInterface > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); - - // Register operation as transaction and reject wrong calls! - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - - // Now we should disable object for real working. - // Don't forget to disable current running transaction of THIS method. - // setWorkingMode() will wait for all current registered transactions ... - // and will wait for ever then! - aTransaction.stop(); - m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); - - // Now we are allone. Further calls are rejected by E_HARDEXCEPTIONS ... see before. - // We can work on our member without any lock! - - /* Attention - If you call some internal impl methods during follow lines ... you should - think about it again. Because: These internal methods could se E_SOFTEXCEPTIONS to work - during this disposing call ... and use some internal member too. - So you must synchronize it! - */ - - // Release our internal dispatch helper ... BUT DON'T dispose it! - // They are listener on our owner frame too. So they will get same event from it and die herself. - // But we should release our references and stop working on it. - 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_xDefaultDispatcher = css::uno::Reference< css::frame::XDispatch >(); - m_xSelfDispatcher = css::uno::Reference< css::frame::XDispatch >(); - - // Forget all other references too. - m_xFactory = css::uno::Reference< css::lang::XMultiServiceFactory >(); - m_xFrame = css::uno::WeakReference< css::frame::XFrame >() ; - - // Disable object for working ... Do it for ever .-) - m_aTransactionManager.setWorkingMode( E_CLOSE ); + /* SAFE { */ + css::uno::Reference< css::frame::XDispatchProvider > xHandler( m_xFactory->createInstance(aHandler.m_sUNOName), css::uno::UNO_QUERY ); + /* } SAFE */ + if (xHandler.is()) + xDispatcher = xHandler->queryDispatch(aURL,SPECIALTARGET_SELF,0); } + + return xDispatcher; } -/*-************************************************************************************************************//** +//_________________________________________________________________________________________________________________ + +/** @short get or create new dispatch helper @descr Sometimes we need some helper implementations to support dispatching of special URLs or commands. But it's not a good idea to hold these services for the whole life time of this provider instance. We should create it on demand ... - Thats why we implement this methods. They return an already existing helper or create a new one otherwise. - - @seealso - - - @param "eHelper", specify type of helper + Thats why we implement this method. It return an already existing helper or create a new one otherwise. + + @param eHelper + specify the requested dispatch helper + @param xOwner + the target of possible dispatch() call on created dispatch helper + @param aParameters + some of such helpers need special (optional) parameters @return A reference to a dispatch helper. - @onerror We return a NULL-reference. @threadsafe yes -*//*-*************************************************************************************************************/ -css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreateDispatchHelper( EDispatchHelper eHelper, const css::uno::Any& aParameters ) + @modified 17.05.2002 10:14, as96863 +*/ +css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreateDispatchHelper( EDispatchHelper eHelper , + const css::uno::Reference< css::frame::XFrame >& xOwner , + const css::uno::Any& aParameters ) { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Register operation as transaction and reject wrong calls! - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - WriteGuard aWriteLock( m_aLock ); - css::uno::Reference< css::frame::XDispatch > xDispatchHelper; - css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY ); - if( xOwner.is() == sal_True ) + /* SAFE { */ + ReadGuard aReadLock( m_aLock ); + css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory; + aReadLock.unlock(); + /* } SAFE */ + + switch (eHelper) { - switch( eHelper ) - { - //----------------------------------------------------------------------------------------------------- - case E_MENUDISPATCHER : { - if( m_xMenuDispatcher.is() == sal_False ) - { - MenuDispatcher* pDispatcher = new MenuDispatcher( m_xFactory, xOwner ); - m_xMenuDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xMenuDispatcher; - } - break; - //----------------------------------------------------------------------------------------------------- - case E_HELPAGENTDISPATCHER : { - if( m_xHelpAgentDispatcher.is() == sal_False ) - { - HelpAgentDispatcher* pDispatcher = new HelpAgentDispatcher( xOwner ); - m_xHelpAgentDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xHelpAgentDispatcher; - } - break; - //----------------------------------------------------------------------------------------------------- - case E_CREATEDISPATCHER : { - // Don't hold these dispatch helper! Create it on demand for every given target name. - // He could handle one target frame at one time only! - ::rtl::OUString sTargetName; - aParameters >>= sTargetName; - CreateDispatcher* pDispatcher = new CreateDispatcher( m_xFactory, xOwner, sTargetName ); - xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - break; - //----------------------------------------------------------------------------------------------------- - case E_BLANKDISPATCHER : { - if( m_xBlankDispatcher.is() == sal_False ) - { - css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY ); - BlankDispatcher* pDispatcher = new BlankDispatcher( m_xFactory, xDesktop, sal_False ); - m_xBlankDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xBlankDispatcher; - } - break; - //----------------------------------------------------------------------------------------------------- - case E_DEFAULTDISPATCHER : { - if( m_xDefaultDispatcher.is() == sal_False ) - { - css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY ); - BlankDispatcher* pDispatcher = new BlankDispatcher( m_xFactory, xDesktop, sal_True ); - m_xDefaultDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xDefaultDispatcher; - } - break; - //----------------------------------------------------------------------------------------------------- - case E_SELFDISPATCHER : { - if( m_xSelfDispatcher.is() == sal_False ) - { - SelfDispatcher* pDispatcher = new SelfDispatcher( m_xFactory, xOwner ); - m_xSelfDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xSelfDispatcher; - } - break; - //----------------------------------------------------------------------------------------------------- - case E_PLUGINDISPATCHER : { - LOG_WARNING( "DispatchProvider::implts_getOrCreateDispatchHelper( E_PLUGINDISPATCHER )", "Not implemented yet!" ) - } - break; - } + case E_MENUDISPATCHER : + { + // Attention: Such menue dispatcher must be a singleton for this frame - means our owner frame. + // Otherwhise he can make some trouble. + /* SAFE { */ + WriteGuard aWriteLock( m_aLock ); + if ( ! m_xMenuDispatcher.is() ) + { + MenuDispatcher* pDispatcher = new MenuDispatcher( xFactory, xOwner ); + m_xMenuDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + xDispatchHelper = m_xMenuDispatcher; + aWriteLock.unlock(); + /* } SAFE */ + } + break; + + case E_HELPAGENTDISPATCHER : + { + // Attention: It's not a good idea to create this help agent twice for the same frame (window) + // May it will be shown twice too - and user activate the first one. Then he get the corresponding + // help window ... but there exist another help agent window on bottom side of the frame window. + // It's superflous. Create it on demand - but hold it alive till this provider dies. + /* SAFE { */ + WriteGuard aWriteLock( m_aLock ); + if ( ! m_xHelpAgentDispatcher.is() ) + { + HelpAgentDispatcher* pDispatcher = new HelpAgentDispatcher( xOwner ); + m_xHelpAgentDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + xDispatchHelper = m_xHelpAgentDispatcher; + aWriteLock.unlock(); + /* } SAFE */ + } + break; + + case E_CREATEDISPATCHER : + { + ::rtl::OUString sTargetName; + aParameters >>= sTargetName; + CreateDispatcher* pDispatcher = new CreateDispatcher( xFactory, xOwner, sTargetName ); + xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + break; + + case E_BLANKDISPATCHER : + { + css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY ); + if (xDesktop.is()) + { + BlankDispatcher* pDispatcher = new BlankDispatcher( xFactory, xDesktop, sal_False ); + xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + } + break; + + case E_DEFAULTDISPATCHER : + { + css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY ); + if (xDesktop.is()) + { + BlankDispatcher* pDispatcher = new BlankDispatcher( xFactory, xDesktop, sal_True ); + xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + } + break; + + case E_SELFDISPATCHER : + { + SelfDispatcher* pDispatcher = new SelfDispatcher( xFactory, xOwner ); + xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); + } + break; + + case E_PLUGINDISPATCHER : + { + LOG_WARNING( "DispatchProvider::implts_getOrCreateDispatchHelper( E_PLUGINDISPATCHER )", "Not implemented yet!" ) + } + break; } return xDispatchHelper; } -/*-************************************************************************************************************//** +//_________________________________________________________________________________________________________________ + +/** @short check URL for support by our used loader or handler @descr If we must return our own dispatch helper implementations (self, blank, create dispatcher!) we should be shure, that URL describe any loadable content. Otherwise slot/uno URLs - will be detected ... but there exist nothing to detect! + will be detected ... but there exist nothing for ral loading into a target frame! - @seealso method queryDispatch() - - @param "aURL", URL which should be "detected" - @return True , if somewhere could handle that - False , otherwise + @param aURL + URL which should be "detected" + @return <TRUE/> if somewhere could handle that - <FALSE/> otherwise. - @onerror We return False. @threadsafe yes -*//*-*************************************************************************************************************/ + @modified 17.05.2002 09:47, as96863 +*/ sal_Bool DispatchProvider::implts_isLoadableContent( const css::util::URL& aURL ) { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Register operation as transaction and reject wrong calls! - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + /* SAFE { */ ReadGuard aReadLock( m_aLock ); css::uno::Reference< css::document::XTypeDetection > xDetection( m_xFactory->createInstance( SERVICENAME_TYPEDETECTION ), css::uno::UNO_QUERY ); css::uno::Reference< css::ucb::XContentProviderManager > xUCB ( m_xFactory->createInstance( SERVICENAME_UCBCONTENTBROKER ), css::uno::UNO_QUERY ); aReadLock.unlock(); - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ + /* } SAFE */ sal_Bool bLoadable = sal_False; - if( xUCB.is() == sal_True ) - { + // (a) a UCB provide loadable contents only + if (xUCB.is()) bLoadable = xUCB->queryContentProvider( aURL.Complete ).is(); - } // no else here! + // (b) if we can detect a type for given URL - it must be loadable too if( ( bLoadable == sal_False ) && ( xDetection.is() == sal_True ) @@ -746,6 +933,7 @@ sal_Bool DispatchProvider::implts_isLoadableContent( const css::util::URL& aURL bLoadable = (sTypeName.getLength()>0); } // no else here! + // (c) such special URL indicates a given input stream - it should be loadable too if( ( bLoadable == sal_False ) && ( aURL.Complete.compareToAscii( "private:stream/", 15 ) == 0 ) @@ -757,97 +945,4 @@ sal_Bool DispatchProvider::implts_isLoadableContent( const css::util::URL& aURL return bLoadable; } -/*-************************************************************************************************************//** - @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(...). - - @attention These methods are threadsafe ... - because they don't work on internal member... - they are static functions! - - @seealso ASSERTs in implementation! - - @param references to checking variables - @return sal_True on invalid parameter<BR> - sal_False otherway - - @onerror - - @threadsafe yes -*//*-*************************************************************************************************************/ - -#ifdef ENABLE_ASSERTIONS - -//***************************************************************************************************************** -sal_Bool DispatchProvider::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , - const css::uno::Reference< css::frame::XFrame >& xFrame ) -{ - return( - ( &xFactory == NULL ) || - ( &xFrame == NULL ) || - ( xFactory.is() == sal_False ) || - ( xFrame.is() == sal_False ) - ); -} - -//***************************************************************************************************************** -// Please don't check for empty strings on URL or target name. They are allowed! -sal_Bool DispatchProvider::implcp_queryDispatch( const css::util::URL& aURL , - const ::rtl::OUString& sTargetFrameName, - sal_Int32 nSearchFlags ) -{ - return( - ( &aURL == NULL ) || - ( &sTargetFrameName == NULL ) || - ( - ( nSearchFlags != css::frame::FrameSearchFlag::AUTO ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::PARENT ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::SELF ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::CHILDREN ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::CREATE ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::SIBLINGS ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::TASKS ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::ALL ) ) && - ( !( nSearchFlags & css::frame::FrameSearchFlag::GLOBAL ) ) - ) - ); -} - -//***************************************************************************************************************** -// Use implcp_queryDispatch() for every descriptor item to check parameter! -sal_Bool DispatchProvider::implcp_queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) -{ - sal_Bool bFail = sal_False; - if( &lDescriptions == NULL ) - { - bFail = sal_True; - } - else - { - sal_Int32 nCount = lDescriptions.getLength(); - for( sal_Int32 nPosition=0; nPosition<nCount; ++nPosition ) - { - if( implcp_queryDispatch( lDescriptions[nPosition].FeatureURL , - lDescriptions[nPosition].FrameName , - lDescriptions[nPosition].SearchFlags ) == sal_False ) - { - bFail = sal_True; - break; - } - } - } - return bFail; -} - -//***************************************************************************************************************** -sal_Bool DispatchProvider::implcp_disposing( const css::lang::EventObject& aEvent ) -{ - return( - ( &aEvent == NULL ) || - ( aEvent.Source.is() == sal_False ) - ); -} - -#endif // #ifdef ENABLE_ASSERTIONS - -} // namespace framework +} // namespace framework diff --git a/framework/source/dispatch/helpagentdispatcher.cxx b/framework/source/dispatch/helpagentdispatcher.cxx index c2ed20570c0f..85acb693b8da 100644 --- a/framework/source/dispatch/helpagentdispatcher.cxx +++ b/framework/source/dispatch/helpagentdispatcher.cxx @@ -2,9 +2,9 @@ * * $RCSfile: helpagentdispatcher.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-11-05 10:06:23 $ + * last change: $Author: as $ $Date: 2002-05-23 12:52:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -213,6 +213,8 @@ namespace framework //-------------------------------------------------------------------- void SAL_CALL HelpAgentDispatcher::disposing( const EventObject& _rSource ) throw (RuntimeException) { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xSelfHold( static_cast< ::com::sun::star::frame::XDispatch* >(this), ::com::sun::star::uno::UNO_QUERY ); + // not interested in case the container window is closed (this should be handled by our owner) // interested in case our agent window is closed (we're the only instance allowed to close it) @@ -334,6 +336,8 @@ namespace framework //-------------------------------------------------------------------- void HelpAgentDispatcher::closeAgentWindow() { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xSelfHold( static_cast< ::com::sun::star::frame::XDispatch* >(this), ::com::sun::star::uno::UNO_QUERY ); + // now acquire the SolarMutex ... ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); // ... and our own mutex @@ -425,6 +429,9 @@ namespace framework /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.4 2001/11/05 10:06:23 oj + * #94279# set Listener to NULL in dtor + * * Revision 1.3 2001/10/11 09:21:51 pb * fix: #93014# dont show tooltip * diff --git a/framework/source/dispatch/menudispatcher.cxx b/framework/source/dispatch/menudispatcher.cxx index a9c54cf00621..cec5e243ae6b 100644 --- a/framework/source/dispatch/menudispatcher.cxx +++ b/framework/source/dispatch/menudispatcher.cxx @@ -2,9 +2,9 @@ * * $RCSfile: menudispatcher.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: as $ $Date: 2001-07-02 13:26:10 $ + * last change: $Author: as $ $Date: 2002-05-23 12:52:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -123,10 +123,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #endif -#ifndef _COM_SUN_STAR_FRAME_XTASKSSUPPLIER_HPP_ -#include <com/sun/star/frame/XTasksSupplier.hpp> -#endif - #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATION_HPP_ #include <com/sun/star/container/XEnumeration.hpp> #endif |