Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _TREEVIEW_TVREAD_HXX_
30 : : #define _TREEVIEW_TVREAD_HXX_
31 : :
32 : : #include <vector>
33 : : #include <rtl/ref.hxx>
34 : : #include <rtl/ustring.hxx>
35 : : #include <ucbhelper/macros.hxx>
36 : : #include <com/sun/star/uno/Type.hxx>
37 : : #include <cppuhelper/weak.hxx>
38 : : #include <com/sun/star/uno/XInterface.hpp>
39 : : #include <com/sun/star/lang/XTypeProvider.hpp>
40 : : #include <com/sun/star/container/XNameAccess.hpp>
41 : : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
42 : : #include <com/sun/star/util/XChangesNotifier.hpp>
43 : : #include <com/sun/star/lang/XComponent.hpp>
44 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 : : #include <com/sun/star/deployment/XPackage.hpp>
46 : : #include "com/sun/star/ucb/XSimpleFileAccess2.hpp"
47 : :
48 : : namespace treeview {
49 : :
50 : :
51 : 0 : class ConfigData
52 : : {
53 : : public:
54 : : enum {
55 : : PRODUCTNAME, PRODUCTVERSION, VENDORNAME, VENDORVERSION,
56 : : VENDORSHORT };
57 : : ConfigData();
58 : : int m_vAdd[5];
59 : : rtl::OUString m_vReplacement[5];
60 : : rtl::OUString prodName,prodVersion,vendName,vendVersion,vendShort;
61 : :
62 : : std::vector< sal_uInt64 > vFileLen;
63 : : std::vector< rtl::OUString > vFileURL;
64 : : rtl::OUString locale,system;
65 : : rtl::OUString appendix;
66 : :
67 : : void SAL_CALL replaceName( rtl::OUString& oustring ) const;
68 : : };
69 : :
70 : :
71 : : class TVDom;
72 : : class TVChildTarget;
73 : :
74 : 0 : class TVBase
75 : : : public cppu::OWeakObject,
76 : : public com::sun::star::lang::XTypeProvider,
77 : : public com::sun::star::container::XNameAccess,
78 : : public com::sun::star::container::XHierarchicalNameAccess,
79 : : public com::sun::star::util::XChangesNotifier,
80 : : public com::sun::star::lang::XComponent
81 : : {
82 : : friend class TVChildTarget;
83 : :
84 : : public:
85 : :
86 : 0 : virtual ~TVBase() { }
87 : :
88 : : // XInterface
89 : : virtual com::sun::star::uno::Any SAL_CALL
90 : : queryInterface(
91 : : const com::sun::star::uno::Type& aType )
92 : : throw( com::sun::star::uno::RuntimeException);
93 : :
94 : : virtual void SAL_CALL
95 : : acquire(
96 : : void )
97 : : throw();
98 : :
99 : : virtual void SAL_CALL
100 : : release(
101 : : void )
102 : : throw();
103 : :
104 : :
105 : : // XTypeProvider
106 : :
107 : : XTYPEPROVIDER_DECL()
108 : :
109 : :
110 : : // XNameAccess
111 : :
112 : : virtual com::sun::star::uno::Type SAL_CALL
113 : 0 : getElementType( )
114 : : throw( com::sun::star::uno::RuntimeException )
115 : : {
116 : 0 : return getCppuVoidType();
117 : : }
118 : :
119 : :
120 : 0 : virtual sal_Bool SAL_CALL hasElements()
121 : : throw( com::sun::star::uno::RuntimeException )
122 : : {
123 : 0 : return true;
124 : : }
125 : :
126 : : // XChangesNotifier
127 : :
128 : : virtual void SAL_CALL
129 : 0 : addChangesListener(
130 : : const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
131 : : throw( com::sun::star::uno::RuntimeException )
132 : : {
133 : : // read only
134 : : (void)aListener;
135 : 0 : }
136 : :
137 : : virtual void SAL_CALL
138 : 0 : removeChangesListener(
139 : : const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
140 : : throw( com::sun::star::uno::RuntimeException )
141 : : {
142 : : // read only
143 : : (void)aListener;
144 : 0 : }
145 : :
146 : :
147 : : // XComponent
148 : :
149 : 0 : virtual void SAL_CALL dispose( )
150 : : throw( com::sun::star::uno::RuntimeException )
151 : : {
152 : 0 : }
153 : :
154 : 0 : virtual void SAL_CALL addEventListener(
155 : : const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
156 : : throw( com::sun::star::uno::RuntimeException )
157 : : {
158 : : (void)xListener;
159 : 0 : }
160 : :
161 : : virtual void SAL_CALL
162 : 0 : removeEventListener(
163 : : const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
164 : : throw( com::sun::star::uno::RuntimeException )
165 : : {
166 : : (void)aListener;
167 : 0 : }
168 : :
169 : :
170 : : // Abstract functions
171 : : // XNameAccess
172 : :
173 : : virtual com::sun::star::uno::Any SAL_CALL
174 : : getByName( const rtl::OUString& aName )
175 : : throw( com::sun::star::container::NoSuchElementException,
176 : : com::sun::star::lang::WrappedTargetException,
177 : : com::sun::star::uno::RuntimeException) = 0;
178 : :
179 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
180 : : getElementNames( )
181 : : throw( com::sun::star::uno::RuntimeException ) = 0;
182 : :
183 : : virtual sal_Bool SAL_CALL
184 : : hasByName( const rtl::OUString& aName )
185 : : throw( com::sun::star::uno::RuntimeException ) = 0;
186 : :
187 : :
188 : : // XHierarchicalNameAccess
189 : :
190 : : virtual com::sun::star::uno::Any SAL_CALL
191 : : getByHierarchicalName( const rtl::OUString& aName )
192 : : throw( com::sun::star::container::NoSuchElementException,
193 : : com::sun::star::uno::RuntimeException ) = 0;
194 : :
195 : : virtual sal_Bool SAL_CALL
196 : : hasByHierarchicalName( const rtl::OUString& aName )
197 : : throw( com::sun::star::uno::RuntimeException ) = 0;
198 : :
199 : : }; // end class TVBase
200 : :
201 : :
202 : :
203 : :
204 : :
205 : : class TVRead
206 : : : public TVBase
207 : : {
208 : : friend class TVChildTarget;
209 : :
210 : : public:
211 : : TVRead( const ConfigData& configData,TVDom* tvDom = 0 );
212 : :
213 : : ~TVRead();
214 : :
215 : : // XNameAccess
216 : :
217 : : virtual com::sun::star::uno::Any SAL_CALL
218 : : getByName( const rtl::OUString& aName )
219 : : throw( com::sun::star::container::NoSuchElementException,
220 : : com::sun::star::lang::WrappedTargetException,
221 : : com::sun::star::uno::RuntimeException);
222 : :
223 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
224 : : getElementNames( )
225 : : throw( com::sun::star::uno::RuntimeException );
226 : :
227 : : virtual sal_Bool SAL_CALL
228 : : hasByName( const rtl::OUString& aName )
229 : : throw( com::sun::star::uno::RuntimeException );
230 : :
231 : :
232 : : // XHierarchicalNameAccess
233 : :
234 : : virtual com::sun::star::uno::Any SAL_CALL
235 : : getByHierarchicalName( const rtl::OUString& aName )
236 : : throw( com::sun::star::container::NoSuchElementException,
237 : : com::sun::star::uno::RuntimeException );
238 : :
239 : : virtual sal_Bool SAL_CALL
240 : : hasByHierarchicalName( const rtl::OUString& aName )
241 : : throw( com::sun::star::uno::RuntimeException );
242 : :
243 : :
244 : : private:
245 : :
246 : : rtl::OUString Title;
247 : : rtl::OUString TargetURL;
248 : : rtl::Reference< TVChildTarget > Children;
249 : :
250 : : }; // end class TVRead
251 : :
252 : :
253 : :
254 : :
255 : :
256 : :
257 : : class TVChildTarget
258 : : : public TVBase
259 : : {
260 : : public:
261 : :
262 : : TVChildTarget( const ConfigData& configData,TVDom* tvDom );
263 : :
264 : : TVChildTarget( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
265 : :
266 : : ~TVChildTarget();
267 : :
268 : : virtual com::sun::star::uno::Any SAL_CALL
269 : : getByName( const rtl::OUString& aName )
270 : : throw( com::sun::star::container::NoSuchElementException,
271 : : com::sun::star::lang::WrappedTargetException,
272 : : com::sun::star::uno::RuntimeException);
273 : :
274 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
275 : : getElementNames( )
276 : : throw( com::sun::star::uno::RuntimeException );
277 : :
278 : : virtual sal_Bool SAL_CALL
279 : : hasByName( const rtl::OUString& aName )
280 : : throw( com::sun::star::uno::RuntimeException );
281 : :
282 : :
283 : : // XHierarchicalNameAccess
284 : :
285 : : virtual com::sun::star::uno::Any SAL_CALL
286 : : getByHierarchicalName( const rtl::OUString& aName )
287 : : throw( com::sun::star::container::NoSuchElementException,
288 : : com::sun::star::uno::RuntimeException );
289 : :
290 : : virtual sal_Bool SAL_CALL
291 : : hasByHierarchicalName( const rtl::OUString& aName )
292 : : throw( com::sun::star::uno::RuntimeException );
293 : :
294 : :
295 : : private:
296 : : std::vector< rtl::Reference< TVRead > > Elements;
297 : :
298 : : ConfigData init(
299 : : const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
300 : :
301 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
302 : : getConfiguration(
303 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr ) const;
304 : :
305 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >
306 : : getHierAccess( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& sProvider,
307 : : const char* file ) const;
308 : :
309 : : ::rtl::OUString
310 : : getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
311 : : const char* key ) const;
312 : :
313 : : sal_Bool
314 : : getBooleanKey(
315 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
316 : : const char* key) const;
317 : :
318 : : void subst(
319 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
320 : : rtl::OUString& instpath ) const;
321 : :
322 : : bool SearchAndInsert(TVDom* p, TVDom* tvDom);
323 : :
324 : : void Check(TVDom* tvDom);
325 : :
326 : : }; // end class TVChildTarget
327 : :
328 : :
329 : : enum IteratorState
330 : : {
331 : : USER_EXTENSIONS,
332 : : SHARED_EXTENSIONS,
333 : : BUNDLED_EXTENSIONS,
334 : : END_REACHED
335 : : };
336 : :
337 : 0 : class ExtensionIteratorBase
338 : : {
339 : : public:
340 : : ExtensionIteratorBase( const rtl::OUString& aLanguage );
341 : : void init( void );
342 : :
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 );
347 : :
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 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage
354 : : ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
355 : :
356 : : void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv,
357 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
358 : :
359 : : osl::Mutex m_aMutex;
360 : : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
361 : : com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess2 > m_xSFA;
362 : :
363 : : IteratorState m_eState;
364 : : rtl::OUString m_aLanguage;
365 : :
366 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
367 : : < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
368 : : bool m_bUserPackagesLoaded;
369 : :
370 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
371 : : < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
372 : : bool m_bSharedPackagesLoaded;
373 : :
374 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
375 : : < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
376 : : bool m_bBundledPackagesLoaded;
377 : :
378 : : int m_iUserPackage;
379 : : int m_iSharedPackage;
380 : : int m_iBundledPackage;
381 : :
382 : : }; // end class ExtensionIteratorBase
383 : :
384 : :
385 : : //===================================================================
386 : 0 : class TreeFileIterator : public ExtensionIteratorBase
387 : : {
388 : : public:
389 : 0 : TreeFileIterator( const rtl::OUString& aLanguage )
390 : 0 : : ExtensionIteratorBase( aLanguage )
391 : 0 : {}
392 : :
393 : : rtl::OUString nextTreeFile( sal_Int32& rnFileSize );
394 : :
395 : : private:
396 : : rtl::OUString expandURL( const rtl::OUString& aURL );
397 : : rtl::OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
398 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
399 : :
400 : : }; // end class TreeFileIterator
401 : :
402 : :
403 : : }
404 : :
405 : :
406 : : #endif
407 : :
408 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|