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_PROVIDER_XSCRIPTURIHELPER_HXX_
25 #define _FRAMEWORK_SCRIPT_PROVIDER_XSCRIPTURIHELPER_HXX_
26 
27 #include <com/sun/star/script/provider/XScriptURIHelper.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <com/sun/star/uno/RuntimeException.hpp>
32 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
33 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
34 
35 #include <rtl/ustring.hxx>
36 #include <cppuhelper/implbase3.hxx>
37 
38 namespace func_provider
39 {
40 
41 #define css ::com::sun::star
42 
43 class ScriptingFrameworkURIHelper :
44     public ::cppu::WeakImplHelper3<
45         css::script::provider::XScriptURIHelper,
46         css::lang::XServiceInfo,
47         css::lang::XInitialization >
48 {
49 private:
50 
51     css::uno::Reference< css::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
52     css::uno::Reference<css::uri::XUriReferenceFactory> m_xUriReferenceFactory;
53 
54     ::rtl::OUString m_sLanguage;
55     ::rtl::OUString m_sLocation;
56     ::rtl::OUString m_sBaseURI;
57 
58     ::rtl::OUString SCRIPTS_PART;
59 
60     bool initBaseURI();
61     ::rtl::OUString getLanguagePart(const ::rtl::OUString& rStorageURI);
62     ::rtl::OUString getLanguagePath(const ::rtl::OUString& rLanguagePart);
63 
64 public:
65 
66     ScriptingFrameworkURIHelper(
67         const css::uno::Reference< css::uno::XComponentContext >& xContext )
68             throw( css::uno::RuntimeException );
69 
70     ~ScriptingFrameworkURIHelper();
71 
72     virtual void SAL_CALL
73         initialize( const css::uno::Sequence < css::uno::Any > & args )
74             throw ( css::uno::Exception, css::uno::RuntimeException);
75 
76     virtual ::rtl::OUString SAL_CALL
77         getRootStorageURI()
78             throw ( ::com::sun::star::uno::RuntimeException );
79 
80     virtual ::rtl::OUString SAL_CALL
81         getScriptURI( const ::rtl::OUString& rStorageURI )
82             throw( css::lang::IllegalArgumentException,
83                    css::uno::RuntimeException );
84 
85     virtual ::rtl::OUString SAL_CALL
86         getStorageURI( const ::rtl::OUString& rScriptURI )
87             throw( css::lang::IllegalArgumentException,
88                    css::uno::RuntimeException );
89 
90     virtual ::rtl::OUString SAL_CALL
91         getImplementationName()
92             throw( css::uno::RuntimeException );
93 
94     virtual sal_Bool SAL_CALL
95         supportsService( const ::rtl::OUString& ServiceName )
96             throw( css::uno::RuntimeException );
97 
98     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL
99         getSupportedServiceNames()
100             throw( css::uno::RuntimeException );
101 };
102 
103 } // namespace func_provider
104 #endif //_FRAMEWORK_SCRIPT_PROVIDER_XSCRIPTURIHELPER_HXX_
105