1*6998d047SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6998d047SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6998d047SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6998d047SAndrew Rist  * distributed with this work for additional information
6*6998d047SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6998d047SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6998d047SAndrew Rist  * "License"); you may not use this file except in compliance
9*6998d047SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6998d047SAndrew Rist  *
11*6998d047SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6998d047SAndrew Rist  *
13*6998d047SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6998d047SAndrew Rist  * software distributed under the License is distributed on an
15*6998d047SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6998d047SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6998d047SAndrew Rist  * specific language governing permissions and limitations
18*6998d047SAndrew Rist  * under the License.
19*6998d047SAndrew Rist  *
20*6998d047SAndrew Rist  *************************************************************/
21*6998d047SAndrew Rist 
22*6998d047SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
25cdf0e10cSrcweir #define  _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> // helper for XInterface, XTypeProvider etc.
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
31cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/script/CannotConvertException.hpp>
33cdf0e10cSrcweir #include <com/sun/star/reflection/InvocationTargetException.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <drafts/com/sun/star/script/framework/runtime/XScriptNameResolver.hpp>
36cdf0e10cSrcweir #include <drafts/com/sun/star/script/framework/storage/XScriptInfoAccess.hpp>
37cdf0e10cSrcweir #include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace scripting_runtimemgr
40cdf0e10cSrcweir {
41cdf0e10cSrcweir // for simplification
42cdf0e10cSrcweir #define css ::com::sun::star
43cdf0e10cSrcweir #define dcsssf ::drafts::com::sun::star::script::framework
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class ScriptNameResolverImpl : public
46cdf0e10cSrcweir     ::cppu::WeakImplHelper1 < dcsssf::runtime::XScriptNameResolver >
47cdf0e10cSrcweir {
48cdf0e10cSrcweir public:
49cdf0e10cSrcweir     /**********************************************
50cdf0e10cSrcweir      ScriptNameResolverImpl Constructor
51cdf0e10cSrcweir      @param  the current context
52cdf0e10cSrcweir     */
53cdf0e10cSrcweir     ScriptNameResolverImpl(
54cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext > & xContext );
55cdf0e10cSrcweir     ~ScriptNameResolverImpl();
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     // XServiceInfo implementation
58cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName()
59cdf0e10cSrcweir         throw( css::uno::RuntimeException );
60cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
61cdf0e10cSrcweir         throw( css::uno::RuntimeException );
62cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
63cdf0e10cSrcweir         throw( css::uno::RuntimeException );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     /**********************************************
66cdf0e10cSrcweir      resolve method
67cdf0e10cSrcweir      @param  scriptURI this is the given ScriptURI
68cdf0e10cSrcweir      @param invocationCtx  the invocation context contains the
69cdf0e10cSrcweir       documentStorageID and document reference for use in script name
70cdf0e10cSrcweir       resolving. On full name resolution it sets the resolvedScriptStorageID to
71cdf0e10cSrcweir       the actual storage location of the fully resolved script. May or may not * be the
72cdf0e10cSrcweir       same as the documentStorageID.
73cdf0e10cSrcweir      @exception CannotResolveScriptNameException
74cdf0e10cSrcweir      @exception IllegalArgumentException
75cdf0e10cSrcweir      @exception NullPointerException
76cdf0e10cSrcweir      @return  the resolved XScriptURI
77cdf0e10cSrcweir     */
78cdf0e10cSrcweir     css::uno::Reference < dcsssf::storage::XScriptInfo > SAL_CALL resolve(
79cdf0e10cSrcweir         const ::rtl::OUString & scriptURI,
80cdf0e10cSrcweir         css::uno::Any& invocationCtx )
81cdf0e10cSrcweir         throw( css::script::CannotConvertException, css::lang::IllegalArgumentException,
82cdf0e10cSrcweir            css::uno::RuntimeException );
83cdf0e10cSrcweir private:
84cdf0e10cSrcweir     css::uno::Reference < dcsssf::storage::XScriptInfo >
85cdf0e10cSrcweir     resolveURIFromStorageID( sal_Int32 sid, const rtl::OUString & docURI,
86cdf0e10cSrcweir         const ::rtl::OUString & nameToResolve )
87cdf0e10cSrcweir         SAL_THROW ( ( css::lang::IllegalArgumentException, css::uno::RuntimeException ) );
88cdf0e10cSrcweir     css::uno::Reference< dcsssf::storage::XScriptInfoAccess >
89cdf0e10cSrcweir     getStorageInstance( sal_Int32 sid, const rtl::OUString & permissionURI)
90cdf0e10cSrcweir         SAL_THROW ( ( css::uno::RuntimeException ) );
91cdf0e10cSrcweir     ::rtl::OUString
92cdf0e10cSrcweir     ScriptNameResolverImpl::getFilesysURL( const ::rtl::OUString & scriptURI )
93cdf0e10cSrcweir         throw( css::lang::IllegalArgumentException );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     /**********************************************
96cdf0e10cSrcweir      Reference< XComponentContext > m_xContext
97cdf0e10cSrcweir         to obtain other services if needed
98cdf0e10cSrcweir     */
99cdf0e10cSrcweir     css::uno::Reference< css::uno::XComponentContext > m_xContext;
100cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiComponentFactory > m_xMultiComFac;
101cdf0e10cSrcweir     ::osl::Mutex m_mutex;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir };
104cdf0e10cSrcweir } // scripting_runtimemgr
105cdf0e10cSrcweir 
106cdf0e10cSrcweir #endif //_FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
107