1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _FRAMEWORK_SCRIPT_PROVIDER_FUNCTIONIMPL_HXX_ 25 #define _FRAMEWORK_SCRIPT_PROVIDER_FUNCTIONIMPL_HXX_ 26 27 #include <cppuhelper/implbase1.hxx> // helper for XInterface, XTypeProvider etc. 28 #include <osl/mutex.hxx> 29 30 #include <com/sun/star/lang/IllegalArgumentException.hpp> 31 #include <com/sun/star/uno/RuntimeException.hpp> 32 #include <com/sun/star/script/CannotConvertException.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/reflection/InvocationTargetException.hpp> 35 36 #include <drafts/com/sun/star/script/framework/provider/XScript.hpp> 37 #include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp> 38 39 namespace func_provider 40 { 41 // for simplification 42 #define css ::com::sun::star 43 #define dcsssf ::drafts::com::sun::star::script::framework 44 45 46 class ScriptImpl : 47 public ::cppu::WeakImplHelper1 < dcsssf::provider::XScript > 48 { 49 50 public: 51 /************************************************************* 52 ScriptImpl Constructor 53 @param runtimeMgr which is a service that implement a XScriptInvocation 54 @param scriptURI the received ScriptURI that needs to be resolve and invoked 55 */ 56 ScriptImpl( 57 const css::uno::Reference< css::beans::XPropertySet > & scriptingContext, 58 const css::uno::Reference< dcsssf::runtime::XScriptInvocation > & runtimeMgr, 59 const ::rtl::OUString& scriptURI ); 60 61 /************************************************************* 62 ScriptImpl Destructor 63 */ 64 ~ScriptImpl(); 65 66 /************************************************************* 67 Invoke 68 @param aParams all parameters; pure, out params are undefined in sequence, 69 i.e., the value has to be ignored by the callee 70 @param aOutParamIndex out indices 71 @param aOutParam out parameters 72 73 @returns 74 the value returned from the function being invoked 75 76 @throws IllegalArgumentException 77 if there is no matching script name 78 79 @throws CannotConvertException 80 if args do not match or cannot be converted the those 81 of the invokee 82 83 @throws InvocationTargetException 84 if the running script throws an exception this information is captured and 85 rethrown as this exception type. 86 87 */ 88 virtual css::uno::Any SAL_CALL invoke( 89 const css::uno::Sequence< css::uno::Any > & aParams, 90 css::uno::Sequence< sal_Int16 > & aOutParamIndex, 91 css::uno::Sequence< css::uno::Any > & aOutParam ); 92 93 private: 94 css::uno::Reference< css::beans::XPropertySet > m_XScriptingContext; 95 css::uno::Reference < dcsssf::runtime::XScriptInvocation > m_RunTimeManager; 96 ::rtl::OUString m_ScriptURI; 97 98 /* copy ctor disabled, i.e. not defined */ 99 ScriptImpl( const ScriptImpl& ); 100 /* assignment disabled, i.e. not defined */ 101 ScriptImpl& operator = ( const ScriptImpl& ); 102 }; 103 } // namespace func_provider 104 #endif //_FRAMEWORK_SCRIPT_PROVIDER_FUNCTIONIMPL_HXX_ 105