bump product version to 4.1.6.2
[LibreOffice.git] / xmlhelp / source / treeview / tvread.hxx
blob1a9649b8edb0257e1f1e3ffb01cf4406bdeb566b
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 _TREEVIEW_TVREAD_HXX_
21 #define _TREEVIEW_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"
39 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;
62 class TVDom;
63 class TVChildTarget;
65 class TVBase
66 : public cppu::OWeakObject,
67 public com::sun::star::lang::XTypeProvider,
68 public com::sun::star::container::XNameAccess,
69 public com::sun::star::container::XHierarchicalNameAccess,
70 public com::sun::star::util::XChangesNotifier,
71 public com::sun::star::lang::XComponent
73 friend class TVChildTarget;
75 public:
77 virtual ~TVBase() { }
79 // XInterface
80 virtual com::sun::star::uno::Any SAL_CALL
81 queryInterface(
82 const com::sun::star::uno::Type& aType )
83 throw( com::sun::star::uno::RuntimeException);
85 virtual void SAL_CALL
86 acquire(
87 void )
88 throw();
90 virtual void SAL_CALL
91 release(
92 void )
93 throw();
96 // XTypeProvider
98 XTYPEPROVIDER_DECL()
101 // XNameAccess
103 virtual com::sun::star::uno::Type SAL_CALL
104 getElementType( )
105 throw( com::sun::star::uno::RuntimeException )
107 return getCppuVoidType();
111 virtual sal_Bool SAL_CALL hasElements()
112 throw( com::sun::star::uno::RuntimeException )
114 return true;
117 // XChangesNotifier
119 virtual void SAL_CALL
120 addChangesListener(
121 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
122 throw( com::sun::star::uno::RuntimeException )
124 // read only
125 (void)aListener;
128 virtual void SAL_CALL
129 removeChangesListener(
130 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
131 throw( com::sun::star::uno::RuntimeException )
133 // read only
134 (void)aListener;
138 // XComponent
140 virtual void SAL_CALL dispose( )
141 throw( com::sun::star::uno::RuntimeException )
145 virtual void SAL_CALL addEventListener(
146 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
147 throw( com::sun::star::uno::RuntimeException )
149 (void)xListener;
152 virtual void SAL_CALL
153 removeEventListener(
154 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
155 throw( com::sun::star::uno::RuntimeException )
157 (void)aListener;
161 // Abstract functions
162 // XNameAccess
164 virtual com::sun::star::uno::Any SAL_CALL
165 getByName( const OUString& aName )
166 throw( com::sun::star::container::NoSuchElementException,
167 com::sun::star::lang::WrappedTargetException,
168 com::sun::star::uno::RuntimeException) = 0;
170 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
171 getElementNames( )
172 throw( com::sun::star::uno::RuntimeException ) = 0;
174 virtual sal_Bool SAL_CALL
175 hasByName( const OUString& aName )
176 throw( com::sun::star::uno::RuntimeException ) = 0;
179 // XHierarchicalNameAccess
181 virtual com::sun::star::uno::Any SAL_CALL
182 getByHierarchicalName( const OUString& aName )
183 throw( com::sun::star::container::NoSuchElementException,
184 com::sun::star::uno::RuntimeException ) = 0;
186 virtual sal_Bool SAL_CALL
187 hasByHierarchicalName( const OUString& aName )
188 throw( com::sun::star::uno::RuntimeException ) = 0;
190 }; // end class TVBase
196 class TVRead
197 : public TVBase
199 friend class TVChildTarget;
201 public:
202 TVRead( const ConfigData& configData,TVDom* tvDom = 0 );
204 ~TVRead();
206 // XNameAccess
208 virtual com::sun::star::uno::Any SAL_CALL
209 getByName( const OUString& aName )
210 throw( com::sun::star::container::NoSuchElementException,
211 com::sun::star::lang::WrappedTargetException,
212 com::sun::star::uno::RuntimeException);
214 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
215 getElementNames( )
216 throw( com::sun::star::uno::RuntimeException );
218 virtual sal_Bool SAL_CALL
219 hasByName( const OUString& aName )
220 throw( com::sun::star::uno::RuntimeException );
223 // XHierarchicalNameAccess
225 virtual com::sun::star::uno::Any SAL_CALL
226 getByHierarchicalName( const OUString& aName )
227 throw( com::sun::star::container::NoSuchElementException,
228 com::sun::star::uno::RuntimeException );
230 virtual sal_Bool SAL_CALL
231 hasByHierarchicalName( const OUString& aName )
232 throw( com::sun::star::uno::RuntimeException );
235 private:
237 OUString Title;
238 OUString TargetURL;
239 rtl::Reference< TVChildTarget > Children;
241 }; // end class TVRead
248 class TVChildTarget
249 : public TVBase
251 public:
253 TVChildTarget( const ConfigData& configData,TVDom* tvDom );
255 TVChildTarget( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
257 ~TVChildTarget();
259 virtual com::sun::star::uno::Any SAL_CALL
260 getByName( const OUString& aName )
261 throw( com::sun::star::container::NoSuchElementException,
262 com::sun::star::lang::WrappedTargetException,
263 com::sun::star::uno::RuntimeException);
265 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
266 getElementNames( )
267 throw( com::sun::star::uno::RuntimeException );
269 virtual sal_Bool SAL_CALL
270 hasByName( const OUString& aName )
271 throw( com::sun::star::uno::RuntimeException );
274 // XHierarchicalNameAccess
276 virtual com::sun::star::uno::Any SAL_CALL
277 getByHierarchicalName( const OUString& aName )
278 throw( com::sun::star::container::NoSuchElementException,
279 com::sun::star::uno::RuntimeException );
281 virtual sal_Bool SAL_CALL
282 hasByHierarchicalName( const OUString& aName )
283 throw( com::sun::star::uno::RuntimeException );
286 private:
287 std::vector< rtl::Reference< TVRead > > Elements;
289 ConfigData init(
290 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
292 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
293 getConfiguration(
294 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ) const;
296 ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
297 getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxProvider,
298 const char* file ) const;
300 OUString
301 getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
302 const char* key ) const;
304 sal_Bool
305 getBooleanKey(
306 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
307 const char* key) const;
309 void subst(
310 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
311 OUString& instpath ) const;
313 bool SearchAndInsert(TVDom* p, TVDom* tvDom);
315 void Check(TVDom* tvDom);
317 }; // end class TVChildTarget
320 enum IteratorState
322 USER_EXTENSIONS,
323 SHARED_EXTENSIONS,
324 BUNDLED_EXTENSIONS,
325 END_REACHED
328 class ExtensionIteratorBase
330 public:
331 ExtensionIteratorBase( const OUString& aLanguage );
332 void init( void );
334 private:
335 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetHelpPackageFromPackage
336 ( const com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
337 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
339 protected:
340 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextUserHelpPackage
341 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
342 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage
343 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
344 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage
345 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
347 void implGetLanguageVectorFromPackage( ::std::vector< OUString > &rv,
348 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
350 osl::Mutex m_aMutex;
351 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
352 com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 > m_xSFA;
354 IteratorState m_eState;
355 OUString m_aLanguage;
357 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
358 < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
359 bool m_bUserPackagesLoaded;
361 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
362 < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
363 bool m_bSharedPackagesLoaded;
365 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
366 < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
367 bool m_bBundledPackagesLoaded;
369 int m_iUserPackage;
370 int m_iSharedPackage;
371 int m_iBundledPackage;
373 }; // end class ExtensionIteratorBase
376 //===================================================================
377 class TreeFileIterator : public ExtensionIteratorBase
379 public:
380 TreeFileIterator( const OUString& aLanguage )
381 : ExtensionIteratorBase( aLanguage )
384 OUString nextTreeFile( sal_Int32& rnFileSize );
386 private:
387 OUString expandURL( const OUString& aURL );
388 OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
389 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
391 }; // end class TreeFileIterator
397 #endif
399 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */