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