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