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 throw ( css::uno::RuntimeException ); 61 62 /************************************************************* 63 ScriptImpl Destructor 64 */ 65 ~ScriptImpl(); 66 67 /************************************************************* 68 Invoke 69 @param aParams all parameters; pure, out params are undefined in sequence, 70 i.e., the value has to be ignored by the callee 71 @param aOutParamIndex out indices 72 @param aOutParam out parameters 73 74 @returns 75 the value returned from the function being invoked 76 77 @throws IllegalArgumentException 78 if there is no matching script name 79 80 @throws CannotConvertException 81 if args do not match or cannot be converted the those 82 of the invokee 83 84 @throws InvocationTargetException 85 if the running script throws an exception this information is captured and 86 rethrown as this exception type. 87 88 */ 89 virtual css::uno::Any SAL_CALL invoke( 90 const css::uno::Sequence< css::uno::Any > & aParams, 91 css::uno::Sequence< sal_Int16 > & aOutParamIndex, 92 css::uno::Sequence< css::uno::Any > & aOutParam ) 93 throw ( css::lang::IllegalArgumentException, 94 css::script::CannotConvertException, 95 css::reflection::InvocationTargetException, 96 css::uno::RuntimeException ); 97 98 private: 99 css::uno::Reference< css::beans::XPropertySet > m_XScriptingContext; 100 css::uno::Reference < dcsssf::runtime::XScriptInvocation > m_RunTimeManager; 101 ::rtl::OUString m_ScriptURI; 102 103 /* copy ctor disabled, i.e. not defined */ 104 ScriptImpl( const ScriptImpl& ); 105 /* assignment disabled, i.e. not defined */ 106 ScriptImpl& operator = ( const ScriptImpl& ); 107 }; 108 } // namespace func_provider 109 #endif //_FRAMEWORK_SCRIPT_PROVIDER_FUNCTIONIMPL_HXX_ 110