1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX 29 #define _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX 30 31 #include <com/sun/star/uno/RuntimeException.hpp> 32 #include <com/sun/star/frame/XDispatchProvider.hpp> 33 #include <com/sun/star/frame/XNotifyingDispatch.hpp> 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 #include <com/sun/star/lang/XInitialization.hpp> 36 #include <cppuhelper/implbase4.hxx> 37 #include <com/sun/star/script/provider/XScriptProvider.hpp> 38 39 namespace rtl 40 { 41 class OUString; 42 } 43 44 namespace com { namespace sun { namespace star { 45 46 namespace document { 47 class XScriptInvocationContext; 48 } 49 namespace uno { 50 class Any; 51 } 52 namespace lang { 53 class XMultiServiceFactory; 54 class XSingleServiceFactory; 55 } 56 namespace frame { 57 class XFrame; 58 class XModel; 59 class XDispatch; 60 class XNotifyingDispatch; 61 class XDispatchResultListener; 62 struct DispatchDescriptor; 63 } 64 namespace beans { 65 struct PropertyValue; 66 } 67 namespace util { 68 struct URL; 69 } 70 } } } 71 72 namespace scripting_protocolhandler 73 { 74 75 namespace css = ::com::sun::star; 76 77 class ScriptProtocolHandler : 78 public ::cppu::WeakImplHelper4< css::frame::XDispatchProvider, 79 css::frame::XNotifyingDispatch, css::lang::XServiceInfo, css::lang::XInitialization > 80 { 81 private: 82 bool m_bInitialised; 83 css::uno::Reference < css::lang::XMultiServiceFactory > m_xFactory; 84 css::uno::Reference < css::frame::XFrame > m_xFrame; 85 css::uno::Reference < css::script::provider::XScriptProvider > m_xScriptProvider; 86 css::uno::Reference< css::document::XScriptInvocationContext > m_xScriptInvocation; 87 88 void createScriptProvider(); 89 bool getScriptInvocation(); 90 91 public: 92 ScriptProtocolHandler( const css::uno::Reference < 93 css::lang::XMultiServiceFactory >& xFactory ); 94 virtual ~ScriptProtocolHandler(); 95 96 /* XServiceInfo */ 97 virtual ::rtl::OUString SAL_CALL getImplementationName() 98 throw( css::uno::RuntimeException ); 99 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) 100 throw( css::uno::RuntimeException ); 101 virtual css::uno::Sequence < ::rtl::OUString > SAL_CALL getSupportedServiceNames() 102 throw( css::uno::RuntimeException ); 103 104 /* Helper for XServiceInfo */ 105 static css::uno::Sequence < ::rtl::OUString > impl_getStaticSupportedServiceNames(); 106 static ::rtl::OUString impl_getStaticImplementationName(); 107 108 /* Helper for registry */ 109 static css::uno::Reference < css::uno::XInterface > SAL_CALL 110 impl_createInstance( 111 const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) 112 throw( css::uno::RuntimeException ); 113 static css::uno::Reference < css::lang::XSingleServiceFactory > impl_createFactory( 114 const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); 115 116 /* Implementation for XDispatchProvider */ 117 virtual css::uno::Reference < css::frame::XDispatch > SAL_CALL 118 queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& sTargetFrameName, 119 sal_Int32 eSearchFlags ) throw( css::uno::RuntimeException ) ; 120 virtual css::uno::Sequence< css::uno::Reference < css::frame::XDispatch > > SAL_CALL 121 queryDispatches( 122 const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescriptor ) 123 throw( css::uno::RuntimeException ); 124 125 /* Implementation for X(Notifying)Dispatch */ 126 virtual void SAL_CALL dispatchWithNotification( 127 const css::util::URL& aURL, 128 const css::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs, 129 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& Listener ) 130 throw ( css::uno::RuntimeException ); 131 virtual void SAL_CALL dispatch( 132 const css::util::URL& aURL, 133 const css::uno::Sequence< css::beans::PropertyValue >& lArgs ) 134 throw ( css::uno::RuntimeException ); 135 virtual void SAL_CALL addStatusListener( 136 const css::uno::Reference< css::frame::XStatusListener >& xControl, 137 const css::util::URL& aURL ) 138 throw ( css::uno::RuntimeException ); 139 virtual void SAL_CALL removeStatusListener( 140 const css::uno::Reference< css::frame::XStatusListener >& xControl, 141 const css::util::URL& aURL ) 142 throw ( css::uno::RuntimeException ); 143 144 /* Implementation for XInitialization */ 145 virtual void SAL_CALL initialize( 146 const css::uno::Sequence < css::uno::Any >& aArguments ) 147 throw ( css::uno::Exception ); 148 }; 149 150 } 151 #endif 152