1*2c696243SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2c696243SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2c696243SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2c696243SAndrew Rist * distributed with this work for additional information 6*2c696243SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2c696243SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2c696243SAndrew Rist * "License"); you may not use this file except in compliance 9*2c696243SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2c696243SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2c696243SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2c696243SAndrew Rist * software distributed under the License is distributed on an 15*2c696243SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2c696243SAndrew Rist * KIND, either express or implied. See the License for the 17*2c696243SAndrew Rist * specific language governing permissions and limitations 18*2c696243SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2c696243SAndrew Rist *************************************************************/ 21*2c696243SAndrew Rist 22*2c696243SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_scripting.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <stdio.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "ScriptImpl.hxx" 30cdf0e10cSrcweir #include <util/util.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir using namespace ::com::sun::star; 33cdf0e10cSrcweir using namespace ::com::sun::star::uno; 34cdf0e10cSrcweir using namespace ::com::sun::star::script::framework; 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace func_provider 37cdf0e10cSrcweir { 38cdf0e10cSrcweir 39cdf0e10cSrcweir //************************************************************************* 40cdf0e10cSrcweir ScriptImpl::ScriptImpl( 41cdf0e10cSrcweir const Reference< beans::XPropertySet > & scriptingContext, 42cdf0e10cSrcweir const Reference< runtime::XScriptInvocation > & runtimeMgr, 43cdf0e10cSrcweir const ::rtl::OUString& scriptURI ) 44cdf0e10cSrcweir throw ( RuntimeException ) : 45cdf0e10cSrcweir m_XScriptingContext( scriptingContext, UNO_SET_THROW ), 46cdf0e10cSrcweir m_RunTimeManager( runtimeMgr, UNO_SET_THROW ), 47cdf0e10cSrcweir m_ScriptURI( scriptURI ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir OSL_TRACE( "<!constucting a ScriptImpl>\n" ); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir //************************************************************************* 53cdf0e10cSrcweir ScriptImpl::~ScriptImpl() 54cdf0e10cSrcweir { 55cdf0e10cSrcweir OSL_TRACE( "<Destructing a ScriptImpl>\n" ); 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir //************************************************************************* 59cdf0e10cSrcweir Any SAL_CALL 60cdf0e10cSrcweir ScriptImpl::invoke( const Sequence< Any >& aParams, 61cdf0e10cSrcweir Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) 62cdf0e10cSrcweir throw ( lang::IllegalArgumentException, script::CannotConvertException, 63cdf0e10cSrcweir reflection::InvocationTargetException, RuntimeException ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir OSL_TRACE( "<ScriptImpl::invoke>" ); 66cdf0e10cSrcweir Any result; 67cdf0e10cSrcweir Any anyScriptingContext; 68cdf0e10cSrcweir 69cdf0e10cSrcweir anyScriptingContext <<= m_XScriptingContext; 70cdf0e10cSrcweir try 71cdf0e10cSrcweir { 72cdf0e10cSrcweir result = m_RunTimeManager->invoke( m_ScriptURI, anyScriptingContext, aParams, 73cdf0e10cSrcweir aOutParamIndex, aOutParam ); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir catch ( lang::IllegalArgumentException & iae ) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke IllegalArgumentException : " ); 78cdf0e10cSrcweir throw lang::IllegalArgumentException( temp.concat( iae.Message ), 79cdf0e10cSrcweir Reference< XInterface > (), 80cdf0e10cSrcweir iae.ArgumentPosition ); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir catch ( script::CannotConvertException & cce ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke CannotConvertException : " ); 85cdf0e10cSrcweir throw script::CannotConvertException( temp.concat( cce.Message ), 86cdf0e10cSrcweir Reference< XInterface > (), 87cdf0e10cSrcweir cce.DestinationTypeClass, 88cdf0e10cSrcweir cce.Reason, 89cdf0e10cSrcweir cce.ArgumentIndex ); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir catch ( reflection::InvocationTargetException & ite ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke InvocationTargetException : " ); 94cdf0e10cSrcweir throw reflection::InvocationTargetException( temp.concat( ite.Message ), 95cdf0e10cSrcweir Reference< XInterface > (), 96cdf0e10cSrcweir ite.TargetException ); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir catch ( RuntimeException & re ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke RuntimeException : " ); 101cdf0e10cSrcweir throw RuntimeException( temp.concat( re.Message ), 102cdf0e10cSrcweir Reference< XInterface > () ); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir #ifdef _DEBUG 105cdf0e10cSrcweir catch ( ... ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir throw RuntimeException( 108cdf0e10cSrcweir OUSTR( "ScriptImpl::invoke Unknown Exception caught - RuntimeException rethrown" ), 109cdf0e10cSrcweir Reference< XInterface > () ); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir #endif 112cdf0e10cSrcweir return result; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir } // namespace func_provider 115