merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / scripting / source / runtimemgr / ScriptRuntimeManager.hxx
blob0358ce7659ab9545126e7de3dee7a558e4c2088e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #ifndef _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
31 #define _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
33 #include <osl/mutex.hxx>
35 #include <cppuhelper/implbase3.hxx>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/IllegalArgumentException.hpp>
39 #include <com/sun/star/uno/RuntimeException.hpp>
40 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
41 #include <com/sun/star/script/CannotConvertException.hpp>
42 #include <com/sun/star/reflection/InvocationTargetException.hpp>
44 #include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp>
45 #include <drafts/com/sun/star/script/framework/runtime/XScriptNameResolver.hpp>
47 namespace scripting_runtimemgr
49 // for simplification
50 #define css ::com::sun::star
51 #define dcsssf ::drafts::com::sun::star::script::framework
53 /**
54 * Class responsible for managing the various ScriptRuntime implementations.
56 class ScriptRuntimeManager : public
57 ::cppu::WeakImplHelper3< dcsssf::runtime::XScriptInvocation, css::lang::XServiceInfo,
58 dcsssf::runtime::XScriptNameResolver >
60 public:
61 explicit ScriptRuntimeManager(
62 const css::uno::Reference< css::uno::XComponentContext > & xContext );
63 ~ScriptRuntimeManager();
66 // XServiceInfo implementation
67 virtual ::rtl::OUString SAL_CALL getImplementationName()
68 throw( css::uno::RuntimeException );
69 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
70 throw( css::uno::RuntimeException );
71 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
72 throw( css::uno::RuntimeException );
74 /**
75 * implements XScriptInvocation, invokes the script named in scriptURI
76 * (resolving it first, if necessary), with the args passed.
78 * @param scriptURI the URI, which may not be fully qualified, for the
79 * script to be invoked
81 *************************************************************
82 Invoke
83 @param scriptUri script uri describing the script
84 @param invocationCtx
85 the invocation context contains the documentStorageID and document reference
86 for use in script name resolving
88 @param aParams all parameters; pure, out params are undefined in sequence,
89 i.e., the value has to be ignored by the callee
90 @param aOutParamIndex out indices
91 @param aOutParam out parameters
93 @returns
94 the value returned from the function being invoked
96 @throws IllegalArgumentException
97 if there is no matching script name
99 @throws CannotConvertException
100 if args do not match or cannot be converted the those
101 of the invokee
103 @throws InvocationTargetException
104 if the running script throws an exception this information is captured and
105 rethrown as this exception type.
108 virtual css::uno::Any SAL_CALL invoke(
109 const ::rtl::OUString & scriptUri,
110 const css::uno::Any& invocationCtx,
111 const css::uno::Sequence< css::uno::Any >& aParams,
112 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
113 css::uno::Sequence< css::uno::Any >& aOutParam )
114 throw ( css::lang::IllegalArgumentException,
115 css::script::CannotConvertException,
116 css::reflection::InvocationTargetException,
117 css::uno::RuntimeException );
120 * implements XScriptNameResolver, attempts to resolve the script URI
121 * passed in
123 * @param scriptURI the URI to be resolved
124 * @param invocationCtx the invocation context contains the
125 * documentStorageID and document reference for use in script name
126 * resolving. On full name resolution it sets the resolvedScriptStorageID to
127 * the actual storage location of the fully resolved script. May or may not * be the
128 same as the documentStorageID.
129 * @return the resolved URI
131 virtual css::uno::Reference< dcsssf::storage::XScriptInfo > SAL_CALL resolve(
132 const ::rtl::OUString& scriptUri,
133 css::uno::Any& invocationCtx )
134 throw( css::lang::IllegalArgumentException, css::script::CannotConvertException,
135 css::uno::RuntimeException );
137 private:
138 css::uno::Reference< dcsssf::runtime::XScriptInvocation > SAL_CALL getScriptRuntime(
139 const css::uno::Reference< css::uno::XInterface > & scriptInfo )
140 throw( css::uno::RuntimeException );
141 css::uno::Reference< dcsssf::runtime::XScriptNameResolver > SAL_CALL getScriptNameResolver()
142 throw( css::uno::RuntimeException );
144 css::uno::Reference< css::uno::XComponentContext > m_xContext;
145 css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
146 ::osl::Mutex m_mutex;
148 } // scripting_runtimemgr
150 #endif //_FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */