Update ooo320-m1
[ooovba.git] / scripting / source / runtimemgr / ScriptRuntimeManager.hxx
bloba628b267f3bf37ed18aaf9c2c3fd670327df0d76
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScriptRuntimeManager.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
33 #define _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
35 #include <osl/mutex.hxx>
37 #include <cppuhelper/implbase3.hxx>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 #include <com/sun/star/uno/RuntimeException.hpp>
42 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
43 #include <com/sun/star/script/CannotConvertException.hpp>
44 #include <com/sun/star/reflection/InvocationTargetException.hpp>
46 #include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp>
47 #include <drafts/com/sun/star/script/framework/runtime/XScriptNameResolver.hpp>
49 namespace scripting_runtimemgr
51 // for simplification
52 #define css ::com::sun::star
53 #define dcsssf ::drafts::com::sun::star::script::framework
55 /**
56 * Class responsible for managing the various ScriptRuntime implementations.
58 class ScriptRuntimeManager : public
59 ::cppu::WeakImplHelper3< dcsssf::runtime::XScriptInvocation, css::lang::XServiceInfo,
60 dcsssf::runtime::XScriptNameResolver >
62 public:
63 explicit ScriptRuntimeManager(
64 const css::uno::Reference< css::uno::XComponentContext > & xContext );
65 ~ScriptRuntimeManager();
68 // XServiceInfo implementation
69 virtual ::rtl::OUString SAL_CALL getImplementationName()
70 throw( css::uno::RuntimeException );
71 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
72 throw( css::uno::RuntimeException );
73 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
74 throw( css::uno::RuntimeException );
76 /**
77 * implements XScriptInvocation, invokes the script named in scriptURI
78 * (resolving it first, if necessary), with the args passed.
80 * @param scriptURI the URI, which may not be fully qualified, for the
81 * script to be invoked
83 *************************************************************
84 Invoke
85 @param scriptUri script uri describing the script
86 @param invocationCtx
87 the invocation context contains the documentStorageID and document reference
88 for use in script name resolving
90 @param aParams all parameters; pure, out params are undefined in sequence,
91 i.e., the value has to be ignored by the callee
92 @param aOutParamIndex out indices
93 @param aOutParam out parameters
95 @returns
96 the value returned from the function being invoked
98 @throws IllegalArgumentException
99 if there is no matching script name
101 @throws CannotConvertException
102 if args do not match or cannot be converted the those
103 of the invokee
105 @throws InvocationTargetException
106 if the running script throws an exception this information is captured and
107 rethrown as this exception type.
110 virtual css::uno::Any SAL_CALL invoke(
111 const ::rtl::OUString & scriptUri,
112 const css::uno::Any& invocationCtx,
113 const css::uno::Sequence< css::uno::Any >& aParams,
114 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
115 css::uno::Sequence< css::uno::Any >& aOutParam )
116 throw ( css::lang::IllegalArgumentException,
117 css::script::CannotConvertException,
118 css::reflection::InvocationTargetException,
119 css::uno::RuntimeException );
122 * implements XScriptNameResolver, attempts to resolve the script URI
123 * passed in
125 * @param scriptURI the URI to be resolved
126 * @param invocationCtx the invocation context contains the
127 * documentStorageID and document reference for use in script name
128 * resolving. On full name resolution it sets the resolvedScriptStorageID to
129 * the actual storage location of the fully resolved script. May or may not * be the
130 same as the documentStorageID.
131 * @return the resolved URI
133 virtual css::uno::Reference< dcsssf::storage::XScriptInfo > SAL_CALL resolve(
134 const ::rtl::OUString& scriptUri,
135 css::uno::Any& invocationCtx )
136 throw( css::lang::IllegalArgumentException, css::script::CannotConvertException,
137 css::uno::RuntimeException );
139 private:
140 css::uno::Reference< dcsssf::runtime::XScriptInvocation > SAL_CALL getScriptRuntime(
141 const css::uno::Reference< css::uno::XInterface > & scriptInfo )
142 throw( css::uno::RuntimeException );
143 css::uno::Reference< dcsssf::runtime::XScriptNameResolver > SAL_CALL getScriptNameResolver()
144 throw( css::uno::RuntimeException );
146 css::uno::Reference< css::uno::XComponentContext > m_xContext;
147 css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
148 ::osl::Mutex m_mutex;
150 } // scripting_runtimemgr
152 #endif //_FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_