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 INCLUDED_OFFICEINSTALLATIONDIRECTORIES_HXX
25 #define INCLUDED_OFFICEINSTALLATIONDIRECTORIES_HXX
26 
27 #include "osl/mutex.hxx"
28 #include "cppuhelper/implbase2.hxx"
29 
30 #include "com/sun/star/lang/XServiceInfo.hpp"
31 #include "com/sun/star/uno/XComponentContext.hpp"
32 #include "com/sun/star/util/XOfficeInstallationDirectories.hpp"
33 
34 namespace comphelper {
35 
36 //=========================================================================
37 
38 typedef cppu::WeakImplHelper2<
39             com::sun::star::util::XOfficeInstallationDirectories,
40             com::sun::star::lang::XServiceInfo > UnoImplBase;
41 
42 struct mutex_holder
43 {
44     osl::Mutex m_aMutex;
45 };
46 
47 class OfficeInstallationDirectories : public mutex_holder, public UnoImplBase
48 {
49 public:
50     OfficeInstallationDirectories(
51         const com::sun::star::uno::Reference<
52             com::sun::star::uno::XComponentContext > & xCtx );
53     virtual ~OfficeInstallationDirectories();
54 
55     // XOfficeInstallationDirectories
56     virtual ::rtl::OUString SAL_CALL
57     getOfficeInstallationDirectoryURL()
58         throw (::com::sun::star::uno::RuntimeException);
59     virtual ::rtl::OUString SAL_CALL
60     getOfficeUserDataDirectoryURL()
61         throw (::com::sun::star::uno::RuntimeException);
62     virtual ::rtl::OUString SAL_CALL
63     makeRelocatableURL( const ::rtl::OUString& URL )
64         throw (::com::sun::star::uno::RuntimeException);
65     virtual ::rtl::OUString SAL_CALL
66     makeAbsoluteURL( const ::rtl::OUString& URL )
67         throw (::com::sun::star::uno::RuntimeException);
68 
69     // XServiceInfo
70     virtual ::rtl::OUString SAL_CALL
71     getImplementationName()
72         throw (::com::sun::star::uno::RuntimeException);
73     virtual sal_Bool SAL_CALL
74     supportsService( const ::rtl::OUString& ServiceName )
75         throw (::com::sun::star::uno::RuntimeException);
76     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
77     getSupportedServiceNames()
78         throw (::com::sun::star::uno::RuntimeException);
79 
80     // XServiceInfo - static versions (used for component registration)
81     static ::rtl::OUString SAL_CALL
82         getImplementationName_static();
83     static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
84         getSupportedServiceNames_static();
85     static ::rtl::OUString SAL_CALL
86         getSingletonName_static();
87     static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
88         Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
89 
90 private:
91     void initDirs();
92 
93     rtl::OUString                                   m_aOfficeBrandDirMacro;
94     rtl::OUString                                   m_aOfficeBaseDirMacro;
95     rtl::OUString                                   m_aUserDirMacro;
96     com::sun::star::uno::Reference<
97         com::sun::star::uno::XComponentContext >    m_xCtx;
98     rtl::OUString *                                 m_pOfficeBrandDir;
99     rtl::OUString *                                 m_pOfficeBaseDir;
100     rtl::OUString *                                 m_pUserDir;
101 };
102 
103 } // namespace comphelper
104 
105 #endif /* !INCLUDED_OFFICEINSTALLATIONDIRECTORIES_HXX */
106