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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_scripting.hxx" 26 27 #include <stdio.h> 28 29 #include "ScriptImpl.hxx" 30 #include <util/util.hxx> 31 32 using namespace ::com::sun::star; 33 using namespace ::com::sun::star::uno; 34 using namespace ::com::sun::star::script::framework; 35 36 namespace func_provider 37 { 38 39 //************************************************************************* 40 ScriptImpl::ScriptImpl( 41 const Reference< beans::XPropertySet > & scriptingContext, 42 const Reference< runtime::XScriptInvocation > & runtimeMgr, 43 const ::rtl::OUString& scriptURI ) : 44 m_XScriptingContext( scriptingContext, UNO_SET_THROW ), 45 m_RunTimeManager( runtimeMgr, UNO_SET_THROW ), 46 m_ScriptURI( scriptURI ) 47 { 48 OSL_TRACE( "<!constucting a ScriptImpl>\n" ); 49 } 50 51 //************************************************************************* 52 ScriptImpl::~ScriptImpl() 53 { 54 OSL_TRACE( "<Destructing a ScriptImpl>\n" ); 55 } 56 57 //************************************************************************* 58 Any SAL_CALL 59 ScriptImpl::invoke( const Sequence< Any >& aParams, 60 Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) 61 { 62 OSL_TRACE( "<ScriptImpl::invoke>" ); 63 Any result; 64 Any anyScriptingContext; 65 66 anyScriptingContext <<= m_XScriptingContext; 67 try 68 { 69 result = m_RunTimeManager->invoke( m_ScriptURI, anyScriptingContext, aParams, 70 aOutParamIndex, aOutParam ); 71 } 72 catch ( lang::IllegalArgumentException & iae ) 73 { 74 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke IllegalArgumentException : " ); 75 throw lang::IllegalArgumentException( temp.concat( iae.Message ), 76 Reference< XInterface > (), 77 iae.ArgumentPosition ); 78 } 79 catch ( script::CannotConvertException & cce ) 80 { 81 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke CannotConvertException : " ); 82 throw script::CannotConvertException( temp.concat( cce.Message ), 83 Reference< XInterface > (), 84 cce.DestinationTypeClass, 85 cce.Reason, 86 cce.ArgumentIndex ); 87 } 88 catch ( reflection::InvocationTargetException & ite ) 89 { 90 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke InvocationTargetException : " ); 91 throw reflection::InvocationTargetException( temp.concat( ite.Message ), 92 Reference< XInterface > (), 93 ite.TargetException ); 94 } 95 catch ( RuntimeException & re ) 96 { 97 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke RuntimeException : " ); 98 throw RuntimeException( temp.concat( re.Message ), 99 Reference< XInterface > () ); 100 } 101 #ifdef _DEBUG 102 catch ( ... ) 103 { 104 throw RuntimeException( 105 OUSTR( "ScriptImpl::invoke Unknown Exception caught - RuntimeException rethrown" ), 106 Reference< XInterface > () ); 107 } 108 #endif 109 return result; 110 } 111 } // namespace func_provider 112