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 #ifndef _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
29 #define  _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
30 
31 #include <cppuhelper/implbase1.hxx> // helper for XInterface, XTypeProvider etc.
32 
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/lang/IllegalArgumentException.hpp>
35 #include <com/sun/star/uno/RuntimeException.hpp>
36 #include <com/sun/star/script/CannotConvertException.hpp>
37 #include <com/sun/star/reflection/InvocationTargetException.hpp>
38 
39 #include <drafts/com/sun/star/script/framework/runtime/XScriptNameResolver.hpp>
40 #include <drafts/com/sun/star/script/framework/storage/XScriptInfoAccess.hpp>
41 #include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
42 
43 namespace scripting_runtimemgr
44 {
45 // for simplification
46 #define css ::com::sun::star
47 #define dcsssf ::drafts::com::sun::star::script::framework
48 
49 class ScriptNameResolverImpl : public
50     ::cppu::WeakImplHelper1 < dcsssf::runtime::XScriptNameResolver >
51 {
52 public:
53     /**********************************************
54      ScriptNameResolverImpl Constructor
55      @param  the current context
56     */
57     ScriptNameResolverImpl(
58         const css::uno::Reference< css::uno::XComponentContext > & xContext );
59     ~ScriptNameResolverImpl();
60 
61     // XServiceInfo implementation
62     virtual ::rtl::OUString SAL_CALL getImplementationName()
63         throw( css::uno::RuntimeException );
64     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
65         throw( css::uno::RuntimeException );
66     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
67         throw( css::uno::RuntimeException );
68 
69     /**********************************************
70      resolve method
71      @param  scriptURI this is the given ScriptURI
72      @param invocationCtx  the invocation context contains the
73       documentStorageID and document reference for use in script name
74       resolving. On full name resolution it sets the resolvedScriptStorageID to
75       the actual storage location of the fully resolved script. May or may not * be the
76       same as the documentStorageID.
77      @exception CannotResolveScriptNameException
78      @exception IllegalArgumentException
79      @exception NullPointerException
80      @return  the resolved XScriptURI
81     */
82     css::uno::Reference < dcsssf::storage::XScriptInfo > SAL_CALL resolve(
83         const ::rtl::OUString & scriptURI,
84         css::uno::Any& invocationCtx )
85         throw( css::script::CannotConvertException, css::lang::IllegalArgumentException,
86            css::uno::RuntimeException );
87 private:
88     css::uno::Reference < dcsssf::storage::XScriptInfo >
89     resolveURIFromStorageID( sal_Int32 sid, const rtl::OUString & docURI,
90         const ::rtl::OUString & nameToResolve )
91         SAL_THROW ( ( css::lang::IllegalArgumentException, css::uno::RuntimeException ) );
92     css::uno::Reference< dcsssf::storage::XScriptInfoAccess >
93     getStorageInstance( sal_Int32 sid, const rtl::OUString & permissionURI)
94         SAL_THROW ( ( css::uno::RuntimeException ) );
95     ::rtl::OUString
96     ScriptNameResolverImpl::getFilesysURL( const ::rtl::OUString & scriptURI )
97         throw( css::lang::IllegalArgumentException );
98 
99     /**********************************************
100      Reference< XComponentContext > m_xContext
101         to obtain other services if needed
102     */
103     css::uno::Reference< css::uno::XComponentContext > m_xContext;
104     css::uno::Reference< css::lang::XMultiComponentFactory > m_xMultiComFac;
105     ::osl::Mutex m_mutex;
106 
107 };
108 } // scripting_runtimemgr
109 
110 #endif //_FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
111