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