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