From 484e87678986f4922582f3cdaf1a9e1b45bf8b17 Mon Sep 17 00:00:00 2001 From: Andreas Schlüns Date: Fri, 3 May 2002 07:01:46 +0000 Subject: #99021# support XDispatchProvider interface --- framework/inc/dispatch/mailtodispatcher.hxx | 15 +++- framework/inc/dispatch/servicehandler.hxx | 17 +++- framework/source/dispatch/mailtodispatcher.cxx | 105 +++++++++++++++++-------- framework/source/dispatch/servicehandler.cxx | 88 +++++++++++++++------ 4 files changed, 167 insertions(+), 58 deletions(-) (limited to 'framework') diff --git a/framework/inc/dispatch/mailtodispatcher.hxx b/framework/inc/dispatch/mailtodispatcher.hxx index 1f4d2ee67e40..97a81fab0dfc 100644 --- a/framework/inc/dispatch/mailtodispatcher.hxx +++ b/framework/inc/dispatch/mailtodispatcher.hxx @@ -2,9 +2,9 @@ * * $RCSfile: mailtodispatcher.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: as $ $Date: 2002-05-02 11:40:15 $ + * last change: $Author: as $ $Date: 2002-05-03 08:01:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,10 @@ #include #endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include +#endif + #ifndef _COM_SUN_STAR_UTIL_URL_HPP_ #include #endif @@ -165,6 +169,7 @@ namespace framework{ 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! @@ -189,6 +194,12 @@ class MailToDispatcher : // interfaces 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, diff --git a/framework/inc/dispatch/servicehandler.hxx b/framework/inc/dispatch/servicehandler.hxx index 07b2cbdd5f18..654bfeddf3ad 100644 --- a/framework/inc/dispatch/servicehandler.hxx +++ b/framework/inc/dispatch/servicehandler.hxx @@ -2,9 +2,9 @@ * * $RCSfile: servicehandler.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: as $ $Date: 2002-05-02 11:36:04 $ + * last change: $Author: as $ $Date: 2002-05-03 08:01:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,10 @@ #include #endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include +#endif + #ifndef _COM_SUN_STAR_UTIL_URL_HPP_ #include #endif @@ -150,7 +154,7 @@ namespace framework{ /** @short protocol handler for "service:*" URLs - @descr It's a special dispatch object which is registered for such URL pattern and will + @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 @@ -169,6 +173,7 @@ namespace framework{ 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! @@ -193,6 +198,12 @@ class ServiceHandler : // interfaces 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, diff --git a/framework/source/dispatch/mailtodispatcher.cxx b/framework/source/dispatch/mailtodispatcher.cxx index 2cab8838b7ac..9617a248ec36 100644 --- a/framework/source/dispatch/mailtodispatcher.cxx +++ b/framework/source/dispatch/mailtodispatcher.cxx @@ -2,9 +2,9 @@ * * $RCSfile: mailtodispatcher.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: as $ $Date: 2002-05-02 11:40:25 $ + * last change: $Author: as $ $Date: 2002-05-03 08:01:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,6 +111,9 @@ namespace framework{ // non exported const //_________________________________________________________________________________________________________________ +#define PROTOCOL_VALUE "mailto:" +#define PROTOCOL_LENGTH 7 + //_________________________________________________________________________________________________________________ // non exported definitions //_________________________________________________________________________________________________________________ @@ -122,16 +125,18 @@ namespace framework{ //_________________________________________________________________________________________________________________ // XInterface, XTypeProvider, XServiceInfo -DEFINE_XINTERFACE_4(MailToDispatcher , +DEFINE_XINTERFACE_5(MailToDispatcher , OWeakObject , DIRECT_INTERFACE(css::lang::XTypeProvider ), DIRECT_INTERFACE(css::lang::XServiceInfo ), + DIRECT_INTERFACE(css::frame::XDispatchProvider ), DIRECT_INTERFACE(css::frame::XNotifyingDispatch), DIRECT_INTERFACE(css::frame::XDispatch )) -DEFINE_XTYPEPROVIDER_4(MailToDispatcher , +DEFINE_XTYPEPROVIDER_5(MailToDispatcher , css::lang::XTypeProvider , css::lang::XServiceInfo , + css::frame::XDispatchProvider , css::frame::XNotifyingDispatch, css::frame::XDispatch ) @@ -185,6 +190,51 @@ MailToDispatcher::~MailToDispatcher() //_________________________________________________________________________________________________________________ +/** + @short decide if this dispatch implementation can be used for requested URL or not + @descr A protocol handler is registerd for an URL pattern inside configuration and will + be asked by the generic dispatch mechanism inside framework, if he can handle this + special URL wich match his registration. He can agree by returning of a valid dispatch + instance or disagree by returning . + We don't create new dispatch instances here realy - we return THIS as result to handle it + at the same implementation. + + @modified 02.05.2002 15:25, as96863 +*/ +css::uno::Reference< css::frame::XDispatch > SAL_CALL MailToDispatcher::queryDispatch( const css::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) throw( css::uno::RuntimeException ) +{ + css::uno::Reference< css::frame::XDispatch > xDispatcher; + if (aURL.Complete.compareToAscii(PROTOCOL_VALUE,PROTOCOL_LENGTH)==0) + xDispatcher = this; + return xDispatcher; +} + +//_________________________________________________________________________________________________________________ + +/** + @short do the same like dispatch() but for multiple requests at the same time + @descr - + + @modified 02.05.2002 15:27, as96863 +*/ +css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL MailToDispatcher::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException ) +{ + sal_Int32 nCount = lDescriptor.getLength(); + css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount ); + for( sal_Int32 i=0; iqueryDispatch( + lDescriptor[i].FeatureURL, + lDescriptor[i].FrameName, + lDescriptor[i].SearchFlags); + } + return lDispatcher; +} + +//_________________________________________________________________________________________________________________ + /** @short dispatch URL with arguments @descr We use threadsafe internal method to do so. It returns a state value - but we ignore it. @@ -272,35 +322,28 @@ sal_Bool MailToDispatcher::implts_dispatch( const css::util::URL& { sal_Bool bSuccess = sal_False; - // don't accept other protocols - // Normaly we shouldn't be used for other URLs then "mailto" ... - // but ... - if (aURL.Protocol.compareToAscii("mailto:",7)==0) + css::uno::Reference< css::lang::XMultiServiceFactory > xFactory; + /* SAFE */{ + ReadGuard aReadLock( m_aLock ); + xFactory = m_xFactory; + /* SAFE */} + + css::uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute( xFactory->createInstance(SERVICENAME_SYSTEMSHELLEXECUTE), css::uno::UNO_QUERY ); + if (xSystemShellExecute.is()) { - css::uno::Reference< css::lang::XMultiServiceFactory > xFactory; - /* SAFE */{ - ReadGuard aReadLock( m_aLock ); - xFactory = m_xFactory; - /* SAFE */} - - css::uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute( xFactory->createInstance(SERVICENAME_SYSTEMSHELLEXECUTE), css::uno::UNO_QUERY ); - if (xSystemShellExecute.is()) + try + { + // start mail client + // Because there is no notofocation about success - we use case of + // no detected exception as SUCCESS - FAILED otherwhise. + xSystemShellExecute->execute( aURL.Complete, ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS ); + bSuccess = sal_True; + } + catch (css::lang::IllegalArgumentException&) + { + } + catch (css::system::SystemShellExecuteException&) { - try - { - // start mail client - // Because there is no notofocation about success - we use case of - // no detected exception as SUCCESS - FAILED otherwhise. - ::rtl::OUString sURL( aURL.Complete ); - xSystemShellExecute->execute( sURL, ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS ); - bSuccess = sal_True; - } - catch (css::lang::IllegalArgumentException&) - { - } - catch (css::system::SystemShellExecuteException&) - { - } } } diff --git a/framework/source/dispatch/servicehandler.cxx b/framework/source/dispatch/servicehandler.cxx index c810176a34b6..7425aee71cbf 100644 --- a/framework/source/dispatch/servicehandler.cxx +++ b/framework/source/dispatch/servicehandler.cxx @@ -2,9 +2,9 @@ * * $RCSfile: servicehandler.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: as $ $Date: 2002-05-02 11:36:24 $ + * last change: $Author: as $ $Date: 2002-05-03 08:01:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,6 +103,9 @@ namespace framework{ // non exported const //_________________________________________________________________________________________________________________ +#define PROTOCOL_VALUE "service:" +#define PROTOCOL_LENGTH 8 + //_________________________________________________________________________________________________________________ // non exported definitions //_________________________________________________________________________________________________________________ @@ -114,16 +117,18 @@ namespace framework{ //_________________________________________________________________________________________________________________ // XInterface, XTypeProvider, XServiceInfo -DEFINE_XINTERFACE_4(ServiceHandler , +DEFINE_XINTERFACE_5(ServiceHandler , OWeakObject , DIRECT_INTERFACE(css::lang::XTypeProvider ), DIRECT_INTERFACE(css::lang::XServiceInfo ), + DIRECT_INTERFACE(css::frame::XDispatchProvider ), DIRECT_INTERFACE(css::frame::XNotifyingDispatch), DIRECT_INTERFACE(css::frame::XDispatch )) -DEFINE_XTYPEPROVIDER_4(ServiceHandler , +DEFINE_XTYPEPROVIDER_5(ServiceHandler , css::lang::XTypeProvider , css::lang::XServiceInfo , + css::frame::XDispatchProvider , css::frame::XNotifyingDispatch, css::frame::XDispatch ) @@ -177,6 +182,51 @@ ServiceHandler::~ServiceHandler() //_________________________________________________________________________________________________________________ +/** + @short decide if this dispatch implementation can be used for requested URL or not + @descr A protocol handler is registerd for an URL pattern inside configuration and will + be asked by the generic dispatch mechanism inside framework, if he can handle this + special URL wich match his registration. He can agree by returning of a valid dispatch + instance or disagree by returning . + We don't create new dispatch instances here realy - we return THIS as result to handle it + at the same implementation. + + @modified 02.05.2002 15:25, as96863 +*/ +css::uno::Reference< css::frame::XDispatch > SAL_CALL ServiceHandler::queryDispatch( const css::util::URL& aURL , + const ::rtl::OUString& sTarget , + sal_Int32 nFlags ) throw( css::uno::RuntimeException ) +{ + css::uno::Reference< css::frame::XDispatch > xDispatcher; + if (aURL.Complete.compareToAscii(PROTOCOL_VALUE,PROTOCOL_LENGTH)==0) + xDispatcher = this; + return xDispatcher; +} + +//_________________________________________________________________________________________________________________ + +/** + @short do the same like dispatch() but for multiple requests at the same time + @descr - + + @modified 02.05.2002 15:27, as96863 +*/ +css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL ServiceHandler::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException ) +{ + sal_Int32 nCount = lDescriptor.getLength(); + css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount ); + for( sal_Int32 i=0; iqueryDispatch( + lDescriptor[i].FeatureURL, + lDescriptor[i].FrameName, + lDescriptor[i].SearchFlags); + } + return lDispatcher; +} + +//_________________________________________________________________________________________________________________ + /** @short dispatch URL with arguments @descr We use threadsafe internal method to do so. It returns a state value - but we ignore it. @@ -263,25 +313,19 @@ css::uno::Reference< css::uno::XInterface > ServiceHandler::implts_dispatch( con { css::uno::Reference< css::uno::XInterface > xService; - // don't accept other protocols - // Normaly we shouldn't be used for other URLs then "service:" ... - // but ... - if (aURL.Complete.compareToAscii("service:",8)==0) + css::uno::Reference< css::lang::XMultiServiceFactory > xFactory; + /* SAFE */{ + ReadGuard aReadLock( m_aLock ); + xFactory = m_xFactory; + /* SAFE */} + + if (xFactory.is()) { - css::uno::Reference< css::lang::XMultiServiceFactory > xFactory; - /* SAFE */{ - ReadGuard aReadLock( m_aLock ); - xFactory = m_xFactory; - /* SAFE */} - - if (xFactory.is()) - { - // extract service name from given URL and use it to create the component - // Arguments are not supported yet. - ::rtl::OUString sServiceName = aURL.Complete.copy(8); - if (sServiceName.getLength()>0) - xService = xFactory->createInstance(sServiceName); - } + // extract service name from given URL and use it to create the component + // Arguments are not supported yet. + ::rtl::OUString sServiceName = aURL.Complete.copy(PROTOCOL_LENGTH); + if (sServiceName.getLength()>0) + xService = xFactory->createInstance(sServiceName); } return xService; -- cgit