bump product version to 5.0.4.1
[LibreOffice.git] / xmlhelp / source / cxxhelp / inc / tvread.hxx
blob757571064b0f1281909fd4be26edd65d2e9ea31e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLHELP_SOURCE_CXXHELP_INC_TVREAD_HXX
21 #define INCLUDED_XMLHELP_SOURCE_CXXHELP_INC_TVREAD_HXX
23 #include <vector>
24 #include <rtl/ref.hxx>
25 #include <rtl/ustring.hxx>
26 #include <ucbhelper/macros.hxx>
27 #include <com/sun/star/uno/Type.hxx>
28 #include <cppuhelper/weak.hxx>
29 #include <com/sun/star/uno/XInterface.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
33 #include <com/sun/star/util/XChangesNotifier.hpp>
34 #include <com/sun/star/lang/XComponent.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/deployment/XPackage.hpp>
37 #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
38 #include <cppuhelper/implbase4.hxx>
40 namespace treeview {
42 class ConfigData
44 public:
45 enum {
46 PRODUCTNAME, PRODUCTVERSION, VENDORNAME, VENDORVERSION,
47 VENDORSHORT };
48 ConfigData();
49 int m_vAdd[5];
50 OUString m_vReplacement[5];
51 OUString prodName,prodVersion,vendName,vendVersion,vendShort;
53 std::vector< sal_uInt64 > vFileLen;
54 std::vector< OUString > vFileURL;
55 OUString locale,system;
56 OUString appendix;
58 void SAL_CALL replaceName( OUString& oustring ) const;
61 class TVDom;
62 class TVChildTarget;
64 class TVBase : public cppu::WeakImplHelper4 <
65 css::container::XNameAccess,
66 css::container::XHierarchicalNameAccess,
67 css::util::XChangesNotifier,
68 css::lang::XComponent >
70 friend class TVChildTarget;
72 public:
74 virtual ~TVBase() { }
76 // XNameAccess
78 virtual com::sun::star::uno::Type SAL_CALL
79 getElementType( )
80 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
82 return cppu::UnoType<void>::get();
85 virtual sal_Bool SAL_CALL hasElements()
86 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
88 return true;
91 // XChangesNotifier
93 virtual void SAL_CALL
94 addChangesListener(
95 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
96 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
98 // read only
99 (void)aListener;
102 virtual void SAL_CALL
103 removeChangesListener(
104 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
105 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
107 // read only
108 (void)aListener;
111 // XComponent
113 virtual void SAL_CALL dispose( )
114 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
118 virtual void SAL_CALL addEventListener(
119 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
120 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
122 (void)xListener;
125 virtual void SAL_CALL
126 removeEventListener(
127 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
128 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
130 (void)aListener;
133 // Abstract functions
134 // XNameAccess
136 virtual com::sun::star::uno::Any SAL_CALL
137 getByName( const OUString& aName )
138 throw( com::sun::star::container::NoSuchElementException,
139 com::sun::star::lang::WrappedTargetException,
140 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
142 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
143 getElementNames( )
144 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE = 0;
146 virtual sal_Bool SAL_CALL
147 hasByName( const OUString& aName )
148 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE = 0;
150 // XHierarchicalNameAccess
152 virtual com::sun::star::uno::Any SAL_CALL
153 getByHierarchicalName( const OUString& aName )
154 throw( com::sun::star::container::NoSuchElementException,
155 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE = 0;
157 virtual sal_Bool SAL_CALL
158 hasByHierarchicalName( const OUString& aName )
159 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE = 0;
161 }; // end class TVBase
163 class TVRead
164 : public TVBase
166 friend class TVChildTarget;
168 public:
169 TVRead( const ConfigData& configData,TVDom* tvDom = 0 );
171 virtual ~TVRead();
173 // XNameAccess
175 virtual com::sun::star::uno::Any SAL_CALL
176 getByName( const OUString& aName )
177 throw( com::sun::star::container::NoSuchElementException,
178 com::sun::star::lang::WrappedTargetException,
179 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
182 getElementNames( )
183 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
185 virtual sal_Bool SAL_CALL
186 hasByName( const OUString& aName )
187 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
189 // XHierarchicalNameAccess
191 virtual com::sun::star::uno::Any SAL_CALL
192 getByHierarchicalName( const OUString& aName )
193 throw( com::sun::star::container::NoSuchElementException,
194 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
196 virtual sal_Bool SAL_CALL
197 hasByHierarchicalName( const OUString& aName )
198 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
200 private:
202 OUString Title;
203 OUString TargetURL;
204 rtl::Reference< TVChildTarget > Children;
206 }; // end class TVRead
208 class TVChildTarget
209 : public TVBase
211 public:
213 TVChildTarget( const ConfigData& configData,TVDom* tvDom );
215 TVChildTarget( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
217 virtual ~TVChildTarget();
219 virtual com::sun::star::uno::Any SAL_CALL
220 getByName( const OUString& aName )
221 throw( com::sun::star::container::NoSuchElementException,
222 com::sun::star::lang::WrappedTargetException,
223 com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
226 getElementNames( )
227 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
229 virtual sal_Bool SAL_CALL
230 hasByName( const OUString& aName )
231 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
233 // XHierarchicalNameAccess
235 virtual com::sun::star::uno::Any SAL_CALL
236 getByHierarchicalName( const OUString& aName )
237 throw( com::sun::star::container::NoSuchElementException,
238 com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
240 virtual sal_Bool SAL_CALL
241 hasByHierarchicalName( const OUString& aName )
242 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
244 private:
245 std::vector< rtl::Reference< TVRead > > Elements;
247 static ConfigData init(
248 const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
250 static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
251 getConfiguration(
252 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
254 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
255 getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxProvider,
256 const char* file );
258 static OUString
259 getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
260 const char* key );
262 static bool
263 getBooleanKey(
264 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
265 const char* key);
267 static void subst( OUString& instpath );
269 bool SearchAndInsert(TVDom* p, TVDom* tvDom);
271 void Check(TVDom* tvDom);
273 }; // end class TVChildTarget
275 enum IteratorState
277 USER_EXTENSIONS,
278 SHARED_EXTENSIONS,
279 BUNDLED_EXTENSIONS,
280 END_REACHED
283 class ExtensionIteratorBase
285 public:
286 ExtensionIteratorBase( const OUString& aLanguage );
287 void init();
289 private:
290 static com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetHelpPackageFromPackage
291 ( const com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
292 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
294 protected:
295 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextUserHelpPackage
296 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
297 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage
298 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
299 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage
300 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
302 void implGetLanguageVectorFromPackage( ::std::vector< OUString > &rv,
303 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
305 osl::Mutex m_aMutex;
306 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
307 com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 > m_xSFA;
309 IteratorState m_eState;
310 OUString m_aLanguage;
312 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
313 < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
314 bool m_bUserPackagesLoaded;
316 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
317 < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
318 bool m_bSharedPackagesLoaded;
320 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
321 < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
322 bool m_bBundledPackagesLoaded;
324 int m_iUserPackage;
325 int m_iSharedPackage;
326 int m_iBundledPackage;
328 }; // end class ExtensionIteratorBase
330 class TreeFileIterator : public ExtensionIteratorBase
332 public:
333 TreeFileIterator( const OUString& aLanguage )
334 : ExtensionIteratorBase( aLanguage )
337 OUString nextTreeFile( sal_Int32& rnFileSize );
339 private:
340 OUString expandURL( const OUString& aURL );
341 OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
342 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
344 }; // end class TreeFileIterator
348 #endif
350 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */