1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_scripting.hxx" 30 31 #include <stdio.h> 32 33 #include "ScriptImpl.hxx" 34 #include <util/util.hxx> 35 36 using namespace ::com::sun::star; 37 using namespace ::com::sun::star::uno; 38 using namespace ::com::sun::star::script::framework; 39 40 namespace func_provider 41 { 42 43 //************************************************************************* 44 ScriptImpl::ScriptImpl( 45 const Reference< beans::XPropertySet > & scriptingContext, 46 const Reference< runtime::XScriptInvocation > & runtimeMgr, 47 const ::rtl::OUString& scriptURI ) 48 throw ( RuntimeException ) : 49 m_XScriptingContext( scriptingContext, UNO_SET_THROW ), 50 m_RunTimeManager( runtimeMgr, UNO_SET_THROW ), 51 m_ScriptURI( scriptURI ) 52 { 53 OSL_TRACE( "<!constucting a ScriptImpl>\n" ); 54 } 55 56 //************************************************************************* 57 ScriptImpl::~ScriptImpl() 58 { 59 OSL_TRACE( "<Destructing a ScriptImpl>\n" ); 60 } 61 62 //************************************************************************* 63 Any SAL_CALL 64 ScriptImpl::invoke( const Sequence< Any >& aParams, 65 Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) 66 throw ( lang::IllegalArgumentException, script::CannotConvertException, 67 reflection::InvocationTargetException, RuntimeException ) 68 { 69 OSL_TRACE( "<ScriptImpl::invoke>" ); 70 Any result; 71 Any anyScriptingContext; 72 73 anyScriptingContext <<= m_XScriptingContext; 74 try 75 { 76 result = m_RunTimeManager->invoke( m_ScriptURI, anyScriptingContext, aParams, 77 aOutParamIndex, aOutParam ); 78 } 79 catch ( lang::IllegalArgumentException & iae ) 80 { 81 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke IllegalArgumentException : " ); 82 throw lang::IllegalArgumentException( temp.concat( iae.Message ), 83 Reference< XInterface > (), 84 iae.ArgumentPosition ); 85 } 86 catch ( script::CannotConvertException & cce ) 87 { 88 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke CannotConvertException : " ); 89 throw script::CannotConvertException( temp.concat( cce.Message ), 90 Reference< XInterface > (), 91 cce.DestinationTypeClass, 92 cce.Reason, 93 cce.ArgumentIndex ); 94 } 95 catch ( reflection::InvocationTargetException & ite ) 96 { 97 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke InvocationTargetException : " ); 98 throw reflection::InvocationTargetException( temp.concat( ite.Message ), 99 Reference< XInterface > (), 100 ite.TargetException ); 101 } 102 catch ( RuntimeException & re ) 103 { 104 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke RuntimeException : " ); 105 throw RuntimeException( temp.concat( re.Message ), 106 Reference< XInterface > () ); 107 } 108 #ifdef _DEBUG 109 catch ( ... ) 110 { 111 throw RuntimeException( 112 OUSTR( "ScriptImpl::invoke Unknown Exception caught - RuntimeException rethrown" ), 113 Reference< XInterface > () ); 114 } 115 #endif 116 return result; 117 } 118 } // namespace func_provider 119