update dev300-m58
[ooovba.git] / xmlhelp / source / treeview / tvread.hxx
blobf04538a7b6e69d21dccd8dd5c9de043d20cf0519
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tvread.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _TREEVIEW_TVREAD_HXX_
32 #define _TREEVIEW_TVREAD_HXX_
34 #ifndef INCLUDED_STL_VECTOR
35 #include <vector>
36 #define INCLUDED_STL_VECTOR
37 #endif
38 #include <rtl/ref.hxx>
39 #include <rtl/ustring.hxx>
40 #include <ucbhelper/macros.hxx>
41 #include <com/sun/star/uno/Type.hxx>
42 #include <cppuhelper/weak.hxx>
43 #include <com/sun/star/uno/XInterface.hpp>
44 #include <com/sun/star/lang/XTypeProvider.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
47 #include <com/sun/star/util/XChangesNotifier.hpp>
48 #include <com/sun/star/lang/XComponent.hpp>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/deployment/XPackage.hpp>
51 #include "com/sun/star/ucb/XSimpleFileAccess.hpp"
53 namespace treeview {
56 class ConfigData
58 public:
59 enum {
60 PRODUCTNAME, PRODUCTVERSION, VENDORNAME, VENDORVERSION,
61 VENDORSHORT };
62 ConfigData();
63 int m_vAdd[5];
64 rtl::OUString m_vReplacement[5];
65 rtl::OUString prodName,prodVersion,vendName,vendVersion,vendShort;
67 std::vector< sal_uInt64 > vFileLen;
68 std::vector< rtl::OUString > vFileURL;
69 rtl::OUString locale,system;
70 rtl::OUString appendix;
72 void SAL_CALL replaceName( rtl::OUString& oustring ) const;
76 class TVDom;
77 class TVChildTarget;
79 class TVBase
80 : public cppu::OWeakObject,
81 public com::sun::star::lang::XTypeProvider,
82 public com::sun::star::container::XNameAccess,
83 public com::sun::star::container::XHierarchicalNameAccess,
84 public com::sun::star::util::XChangesNotifier,
85 public com::sun::star::lang::XComponent
87 friend class TVChildTarget;
89 public:
91 virtual ~TVBase() { }
93 // XInterface
94 virtual com::sun::star::uno::Any SAL_CALL
95 queryInterface(
96 const com::sun::star::uno::Type& aType )
97 throw( com::sun::star::uno::RuntimeException);
99 virtual void SAL_CALL
100 acquire(
101 void )
102 throw();
104 virtual void SAL_CALL
105 release(
106 void )
107 throw();
110 // XTypeProvider
112 XTYPEPROVIDER_DECL()
115 // XNameAccess
117 virtual com::sun::star::uno::Type SAL_CALL
118 getElementType( )
119 throw( com::sun::star::uno::RuntimeException )
121 return getCppuVoidType();
125 virtual sal_Bool SAL_CALL hasElements()
126 throw( com::sun::star::uno::RuntimeException )
128 return true;
131 // XChangesNotifier
133 virtual void SAL_CALL
134 addChangesListener(
135 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
136 throw( com::sun::star::uno::RuntimeException )
138 // read only
139 (void)aListener;
142 virtual void SAL_CALL
143 removeChangesListener(
144 const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
145 throw( com::sun::star::uno::RuntimeException )
147 // read only
148 (void)aListener;
152 // XComponent
154 virtual void SAL_CALL dispose( )
155 throw( com::sun::star::uno::RuntimeException )
159 virtual void SAL_CALL addEventListener(
160 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
161 throw( com::sun::star::uno::RuntimeException )
163 (void)xListener;
166 virtual void SAL_CALL
167 removeEventListener(
168 const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
169 throw( com::sun::star::uno::RuntimeException )
171 (void)aListener;
175 // Abstract functions
176 // XNameAccess
178 virtual com::sun::star::uno::Any SAL_CALL
179 getByName( const rtl::OUString& aName )
180 throw( com::sun::star::container::NoSuchElementException,
181 com::sun::star::lang::WrappedTargetException,
182 com::sun::star::uno::RuntimeException) = 0;
184 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
185 getElementNames( )
186 throw( com::sun::star::uno::RuntimeException ) = 0;
188 virtual sal_Bool SAL_CALL
189 hasByName( const rtl::OUString& aName )
190 throw( com::sun::star::uno::RuntimeException ) = 0;
193 // XHierarchicalNameAccess
195 virtual com::sun::star::uno::Any SAL_CALL
196 getByHierarchicalName( const rtl::OUString& aName )
197 throw( com::sun::star::container::NoSuchElementException,
198 com::sun::star::uno::RuntimeException ) = 0;
200 virtual sal_Bool SAL_CALL
201 hasByHierarchicalName( const rtl::OUString& aName )
202 throw( com::sun::star::uno::RuntimeException ) = 0;
204 }; // end class TVBase
210 class TVRead
211 : public TVBase
213 friend class TVChildTarget;
215 public:
216 TVRead( const ConfigData& configData,TVDom* tvDom = 0 );
218 ~TVRead();
220 // XNameAccess
222 virtual com::sun::star::uno::Any SAL_CALL
223 getByName( const rtl::OUString& aName )
224 throw( com::sun::star::container::NoSuchElementException,
225 com::sun::star::lang::WrappedTargetException,
226 com::sun::star::uno::RuntimeException);
228 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
229 getElementNames( )
230 throw( com::sun::star::uno::RuntimeException );
232 virtual sal_Bool SAL_CALL
233 hasByName( const rtl::OUString& aName )
234 throw( com::sun::star::uno::RuntimeException );
237 // XHierarchicalNameAccess
239 virtual com::sun::star::uno::Any SAL_CALL
240 getByHierarchicalName( const rtl::OUString& aName )
241 throw( com::sun::star::container::NoSuchElementException,
242 com::sun::star::uno::RuntimeException );
244 virtual sal_Bool SAL_CALL
245 hasByHierarchicalName( const rtl::OUString& aName )
246 throw( com::sun::star::uno::RuntimeException );
249 private:
251 rtl::OUString Title;
252 rtl::OUString TargetURL;
253 rtl::Reference< TVChildTarget > Children;
255 }; // end class TVRead
262 class TVChildTarget
263 : public TVBase
265 public:
267 TVChildTarget( const ConfigData& configData,TVDom* tvDom );
269 TVChildTarget( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
271 ~TVChildTarget();
273 virtual com::sun::star::uno::Any SAL_CALL
274 getByName( const rtl::OUString& aName )
275 throw( com::sun::star::container::NoSuchElementException,
276 com::sun::star::lang::WrappedTargetException,
277 com::sun::star::uno::RuntimeException);
279 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
280 getElementNames( )
281 throw( com::sun::star::uno::RuntimeException );
283 virtual sal_Bool SAL_CALL
284 hasByName( const rtl::OUString& aName )
285 throw( com::sun::star::uno::RuntimeException );
288 // XHierarchicalNameAccess
290 virtual com::sun::star::uno::Any SAL_CALL
291 getByHierarchicalName( const rtl::OUString& aName )
292 throw( com::sun::star::container::NoSuchElementException,
293 com::sun::star::uno::RuntimeException );
295 virtual sal_Bool SAL_CALL
296 hasByHierarchicalName( const rtl::OUString& aName )
297 throw( com::sun::star::uno::RuntimeException );
300 private:
301 std::vector< rtl::Reference< TVRead > > Elements;
303 ConfigData init(
304 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
306 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
307 getConfiguration(
308 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr ) const;
310 ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
311 getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& sProvider,
312 const char* file ) const;
314 ::rtl::OUString
315 getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
316 const char* key ) const;
318 sal_Bool
319 getBooleanKey(
320 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
321 const char* key) const;
323 void subst(
324 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
325 rtl::OUString& instpath ) const;
327 }; // end class TVChildTarget
330 enum IteratorState
332 USER_EXTENSIONS,
333 SHARED_EXTENSIONS,
334 END_REACHED
337 class ExtensionIteratorBase
339 public:
340 ExtensionIteratorBase( const rtl::OUString& aLanguage );
341 void init( void );
343 private:
344 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetHelpPackageFromPackage
345 ( const com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
346 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
348 protected:
349 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextUserHelpPackage
350 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
351 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage
352 ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
353 void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv,
354 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
356 osl::Mutex m_aMutex;
357 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
358 com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess > m_xSFA;
360 IteratorState m_eState;
361 rtl::OUString m_aLanguage;
363 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
364 < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
365 bool m_bUserPackagesLoaded;
367 com::sun::star::uno::Sequence< com::sun::star::uno::Reference
368 < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
369 bool m_bSharedPackagesLoaded;
371 int m_iUserPackage;
372 int m_iSharedPackage;
374 }; // end class ExtensionIteratorBase
377 //===================================================================
378 class TreeFileIterator : public ExtensionIteratorBase
380 public:
381 TreeFileIterator( const rtl::OUString& aLanguage )
382 : ExtensionIteratorBase( aLanguage )
385 rtl::OUString nextTreeFile( sal_Int32& rnFileSize );
387 private:
388 rtl::OUString expandURL( const rtl::OUString& aURL );
389 rtl::OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
390 com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
392 }; // end class TreeFileIterator
398 #endif