merge the formfield patch from ooo-build
[ooovba.git] / scripting / source / provider / ScriptImpl.cxx
blobba6e0f2047d749b458dd5dd0bae5c0a7b5c91678
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScriptImpl.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_scripting.hxx"
34 #include <stdio.h>
36 #include "ScriptImpl.hxx"
37 #include <util/util.hxx>
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::script::framework;
43 namespace func_provider
46 //*************************************************************************
47 ScriptImpl::ScriptImpl(
48 const Reference< beans::XPropertySet > & scriptingContext,
49 const Reference< runtime::XScriptInvocation > & runtimeMgr,
50 const ::rtl::OUString& scriptURI )
51 throw ( RuntimeException ) :
52 m_XScriptingContext( scriptingContext ),
53 m_RunTimeManager( runtimeMgr ),
54 m_ScriptURI( scriptURI )
56 OSL_TRACE( "<!constucting a ScriptImpl>\n" );
57 validateXRef( m_XScriptingContext,
58 "ScriptImpl::ScriptImpl: No XScriptingContext\n" );
59 validateXRef( m_RunTimeManager,
60 "ScriptImpl::ScriptImpl: No XScriptInvocation\n" );
63 //*************************************************************************
64 ScriptImpl::~ScriptImpl()
66 OSL_TRACE( "<Destructing a ScriptImpl>\n" );
69 //*************************************************************************
70 Any SAL_CALL
71 ScriptImpl::invoke( const Sequence< Any >& aParams,
72 Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
73 throw ( lang::IllegalArgumentException, script::CannotConvertException,
74 reflection::InvocationTargetException, RuntimeException )
76 OSL_TRACE( "<ScriptImpl::invoke>" );
77 Any result;
78 Any anyScriptingContext;
80 anyScriptingContext <<= m_XScriptingContext;
81 try
83 result = m_RunTimeManager->invoke( m_ScriptURI, anyScriptingContext, aParams,
84 aOutParamIndex, aOutParam );
86 catch ( lang::IllegalArgumentException & iae )
88 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke IllegalArgumentException : " );
89 throw lang::IllegalArgumentException( temp.concat( iae.Message ),
90 Reference< XInterface > (),
91 iae.ArgumentPosition );
93 catch ( script::CannotConvertException & cce )
95 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke CannotConvertException : " );
96 throw script::CannotConvertException( temp.concat( cce.Message ),
97 Reference< XInterface > (),
98 cce.DestinationTypeClass,
99 cce.Reason,
100 cce.ArgumentIndex );
102 catch ( reflection::InvocationTargetException & ite )
104 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke InvocationTargetException : " );
105 throw reflection::InvocationTargetException( temp.concat( ite.Message ),
106 Reference< XInterface > (),
107 ite.TargetException );
109 catch ( RuntimeException & re )
111 ::rtl::OUString temp = OUSTR( "ScriptImpl::invoke RuntimeException : " );
112 throw RuntimeException( temp.concat( re.Message ),
113 Reference< XInterface > () );
115 #ifdef _DEBUG
116 catch ( ... )
118 throw RuntimeException(
119 OUSTR( "ScriptImpl::invoke Unknown Exception caught - RuntimeException rethrown" ),
120 Reference< XInterface > () );
122 #endif
123 return result;
125 } // namespace func_provider