Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _TREEVIEW_TVREAD_HXX_
21 : #define _TREEVIEW_TVREAD_HXX_
22 :
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 :
39 : namespace treeview {
40 :
41 :
42 0 : class ConfigData
43 : {
44 : public:
45 : enum {
46 : PRODUCTNAME, PRODUCTVERSION, VENDORNAME, VENDORVERSION,
47 : VENDORSHORT };
48 : ConfigData();
49 : int m_vAdd[5];
50 : rtl::OUString m_vReplacement[5];
51 : rtl::OUString prodName,prodVersion,vendName,vendVersion,vendShort;
52 :
53 : std::vector< sal_uInt64 > vFileLen;
54 : std::vector< rtl::OUString > vFileURL;
55 : rtl::OUString locale,system;
56 : rtl::OUString appendix;
57 :
58 : void SAL_CALL replaceName( rtl::OUString& oustring ) const;
59 : };
60 :
61 :
62 : class TVDom;
63 : class TVChildTarget;
64 :
65 0 : 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
72 : {
73 : friend class TVChildTarget;
74 :
75 : public:
76 :
77 0 : virtual ~TVBase() { }
78 :
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);
84 :
85 : virtual void SAL_CALL
86 : acquire(
87 : void )
88 : throw();
89 :
90 : virtual void SAL_CALL
91 : release(
92 : void )
93 : throw();
94 :
95 :
96 : // XTypeProvider
97 :
98 : XTYPEPROVIDER_DECL()
99 :
100 :
101 : // XNameAccess
102 :
103 : virtual com::sun::star::uno::Type SAL_CALL
104 0 : getElementType( )
105 : throw( com::sun::star::uno::RuntimeException )
106 : {
107 0 : return getCppuVoidType();
108 : }
109 :
110 :
111 0 : virtual sal_Bool SAL_CALL hasElements()
112 : throw( com::sun::star::uno::RuntimeException )
113 : {
114 0 : return true;
115 : }
116 :
117 : // XChangesNotifier
118 :
119 : virtual void SAL_CALL
120 0 : addChangesListener(
121 : const com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >& aListener )
122 : throw( com::sun::star::uno::RuntimeException )
123 : {
124 : // read only
125 : (void)aListener;
126 0 : }
127 :
128 : virtual void SAL_CALL
129 0 : removeChangesListener(
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 :
138 : // XComponent
139 :
140 0 : virtual void SAL_CALL dispose( )
141 : throw( com::sun::star::uno::RuntimeException )
142 : {
143 0 : }
144 :
145 0 : 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 )
148 : {
149 : (void)xListener;
150 0 : }
151 :
152 : virtual void SAL_CALL
153 0 : removeEventListener(
154 : const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
155 : throw( com::sun::star::uno::RuntimeException )
156 : {
157 : (void)aListener;
158 0 : }
159 :
160 :
161 : // Abstract functions
162 : // XNameAccess
163 :
164 : virtual com::sun::star::uno::Any SAL_CALL
165 : getByName( const rtl::OUString& aName )
166 : throw( com::sun::star::container::NoSuchElementException,
167 : com::sun::star::lang::WrappedTargetException,
168 : com::sun::star::uno::RuntimeException) = 0;
169 :
170 : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
171 : getElementNames( )
172 : throw( com::sun::star::uno::RuntimeException ) = 0;
173 :
174 : virtual sal_Bool SAL_CALL
175 : hasByName( const rtl::OUString& aName )
176 : throw( com::sun::star::uno::RuntimeException ) = 0;
177 :
178 :
179 : // XHierarchicalNameAccess
180 :
181 : virtual com::sun::star::uno::Any SAL_CALL
182 : getByHierarchicalName( const rtl::OUString& aName )
183 : throw( com::sun::star::container::NoSuchElementException,
184 : com::sun::star::uno::RuntimeException ) = 0;
185 :
186 : virtual sal_Bool SAL_CALL
187 : hasByHierarchicalName( const rtl::OUString& aName )
188 : throw( com::sun::star::uno::RuntimeException ) = 0;
189 :
190 : }; // end class TVBase
191 :
192 :
193 :
194 :
195 :
196 : class TVRead
197 : : public TVBase
198 : {
199 : friend class TVChildTarget;
200 :
201 : public:
202 : TVRead( const ConfigData& configData,TVDom* tvDom = 0 );
203 :
204 : ~TVRead();
205 :
206 : // XNameAccess
207 :
208 : virtual com::sun::star::uno::Any SAL_CALL
209 : getByName( const rtl::OUString& aName )
210 : throw( com::sun::star::container::NoSuchElementException,
211 : com::sun::star::lang::WrappedTargetException,
212 : com::sun::star::uno::RuntimeException);
213 :
214 : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
215 : getElementNames( )
216 : throw( com::sun::star::uno::RuntimeException );
217 :
218 : virtual sal_Bool SAL_CALL
219 : hasByName( const rtl::OUString& aName )
220 : throw( com::sun::star::uno::RuntimeException );
221 :
222 :
223 : // XHierarchicalNameAccess
224 :
225 : virtual com::sun::star::uno::Any SAL_CALL
226 : getByHierarchicalName( const rtl::OUString& aName )
227 : throw( com::sun::star::container::NoSuchElementException,
228 : com::sun::star::uno::RuntimeException );
229 :
230 : virtual sal_Bool SAL_CALL
231 : hasByHierarchicalName( const rtl::OUString& aName )
232 : throw( com::sun::star::uno::RuntimeException );
233 :
234 :
235 : private:
236 :
237 : rtl::OUString Title;
238 : rtl::OUString TargetURL;
239 : rtl::Reference< TVChildTarget > Children;
240 :
241 : }; // end class TVRead
242 :
243 :
244 :
245 :
246 :
247 :
248 : class TVChildTarget
249 : : public TVBase
250 : {
251 : public:
252 :
253 : TVChildTarget( const ConfigData& configData,TVDom* tvDom );
254 :
255 : TVChildTarget( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
256 :
257 : ~TVChildTarget();
258 :
259 : virtual com::sun::star::uno::Any SAL_CALL
260 : getByName( const rtl::OUString& aName )
261 : throw( com::sun::star::container::NoSuchElementException,
262 : com::sun::star::lang::WrappedTargetException,
263 : com::sun::star::uno::RuntimeException);
264 :
265 : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
266 : getElementNames( )
267 : throw( com::sun::star::uno::RuntimeException );
268 :
269 : virtual sal_Bool SAL_CALL
270 : hasByName( const rtl::OUString& aName )
271 : throw( com::sun::star::uno::RuntimeException );
272 :
273 :
274 : // XHierarchicalNameAccess
275 :
276 : virtual com::sun::star::uno::Any SAL_CALL
277 : getByHierarchicalName( const rtl::OUString& aName )
278 : throw( com::sun::star::container::NoSuchElementException,
279 : com::sun::star::uno::RuntimeException );
280 :
281 : virtual sal_Bool SAL_CALL
282 : hasByHierarchicalName( const rtl::OUString& aName )
283 : throw( com::sun::star::uno::RuntimeException );
284 :
285 :
286 : private:
287 : std::vector< rtl::Reference< TVRead > > Elements;
288 :
289 : ConfigData init(
290 : const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
291 :
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;
295 :
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;
299 :
300 : ::rtl::OUString
301 : getKey( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
302 : const char* key ) const;
303 :
304 : sal_Bool
305 : getBooleanKey(
306 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& xHierAccess,
307 : const char* key) const;
308 :
309 : void subst(
310 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSgr,
311 : rtl::OUString& instpath ) const;
312 :
313 : bool SearchAndInsert(TVDom* p, TVDom* tvDom);
314 :
315 : void Check(TVDom* tvDom);
316 :
317 : }; // end class TVChildTarget
318 :
319 :
320 : enum IteratorState
321 : {
322 : USER_EXTENSIONS,
323 : SHARED_EXTENSIONS,
324 : BUNDLED_EXTENSIONS,
325 : END_REACHED
326 : };
327 :
328 0 : class ExtensionIteratorBase
329 : {
330 : public:
331 : ExtensionIteratorBase( const rtl::OUString& aLanguage );
332 : void init( void );
333 :
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 );
338 :
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 );
346 :
347 : void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv,
348 : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
349 :
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;
353 :
354 : IteratorState m_eState;
355 : rtl::OUString m_aLanguage;
356 :
357 : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
358 : < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
359 : bool m_bUserPackagesLoaded;
360 :
361 : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
362 : < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
363 : bool m_bSharedPackagesLoaded;
364 :
365 : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
366 : < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
367 : bool m_bBundledPackagesLoaded;
368 :
369 : int m_iUserPackage;
370 : int m_iSharedPackage;
371 : int m_iBundledPackage;
372 :
373 : }; // end class ExtensionIteratorBase
374 :
375 :
376 : //===================================================================
377 0 : class TreeFileIterator : public ExtensionIteratorBase
378 : {
379 : public:
380 0 : TreeFileIterator( const rtl::OUString& aLanguage )
381 0 : : ExtensionIteratorBase( aLanguage )
382 0 : {}
383 :
384 : rtl::OUString nextTreeFile( sal_Int32& rnFileSize );
385 :
386 : private:
387 : rtl::OUString expandURL( const rtl::OUString& aURL );
388 : rtl::OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
389 : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
390 :
391 : }; // end class TreeFileIterator
392 :
393 :
394 : }
395 :
396 :
397 : #endif
398 :
399 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|