update credits
[LibreOffice.git] / scripting / source / provider / ScriptImpl.cxx
blob5ca950916fe6852a6aabb1358e9faf2bca03993b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <stdio.h>
23 #include "ScriptImpl.hxx"
24 #include <util/util.hxx>
25 #include "sal/log.hxx"
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::script::framework;
31 namespace func_provider
34 //*************************************************************************
35 ScriptImpl::ScriptImpl(
36 const Reference< beans::XPropertySet > & scriptingContext,
37 const Reference< runtime::XScriptInvocation > & runtimeMgr,
38 const OUString& scriptURI )
39 throw ( RuntimeException ) :
40 m_XScriptingContext( scriptingContext, UNO_SET_THROW ),
41 m_RunTimeManager( runtimeMgr, UNO_SET_THROW ),
42 m_ScriptURI( scriptURI )
44 SAL_INFO("scripting.provider", "<!constucting a ScriptImpl>" );
47 //*************************************************************************
48 ScriptImpl::~ScriptImpl()
50 SAL_INFO("scripting.provider", "<Destructing a ScriptImpl>" );
53 //*************************************************************************
54 Any SAL_CALL
55 ScriptImpl::invoke( const Sequence< Any >& aParams,
56 Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
57 throw ( lang::IllegalArgumentException, script::CannotConvertException,
58 reflection::InvocationTargetException, RuntimeException )
60 SAL_INFO("scripting.provider", "<ScriptImpl::invoke>" );
61 Any result;
62 Any anyScriptingContext;
64 anyScriptingContext <<= m_XScriptingContext;
65 try
67 result = m_RunTimeManager->invoke( m_ScriptURI, anyScriptingContext, aParams,
68 aOutParamIndex, aOutParam );
70 catch ( const lang::IllegalArgumentException & iae )
72 OUString temp = "ScriptImpl::invoke IllegalArgumentException : ";
73 throw lang::IllegalArgumentException( temp.concat( iae.Message ),
74 Reference< XInterface > (),
75 iae.ArgumentPosition );
77 catch ( const script::CannotConvertException & cce )
79 OUString temp = "ScriptImpl::invoke CannotConvertException : ";
80 throw script::CannotConvertException( temp.concat( cce.Message ),
81 Reference< XInterface > (),
82 cce.DestinationTypeClass,
83 cce.Reason,
84 cce.ArgumentIndex );
86 catch ( const reflection::InvocationTargetException & ite )
88 OUString temp = "ScriptImpl::invoke InvocationTargetException : ";
89 throw reflection::InvocationTargetException( temp.concat( ite.Message ),
90 Reference< XInterface > (),
91 ite.TargetException );
93 catch ( const RuntimeException & re )
95 OUString temp = "ScriptImpl::invoke RuntimeException : ";
96 throw RuntimeException( temp.concat( re.Message ),
97 Reference< XInterface > () );
99 #ifdef _DEBUG
100 catch ( ... )
102 throw RuntimeException(
103 "ScriptImpl::invoke Unknown Exception caught - RuntimeException rethrown",
104 Reference< XInterface > () );
106 #endif
107 return result;
109 } // namespace func_provider
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */