1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tvread.hxx,v $
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
36 #define INCLUDED_STL_VECTOR
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"
60 PRODUCTNAME
, PRODUCTVERSION
, VENDORNAME
, VENDORVERSION
,
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;
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
;
94 virtual com::sun::star::uno::Any SAL_CALL
96 const com::sun::star::uno::Type
& aType
)
97 throw( com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
117 virtual com::sun::star::uno::Type SAL_CALL
119 throw( com::sun::star::uno::RuntimeException
)
121 return getCppuVoidType();
125 virtual sal_Bool SAL_CALL
hasElements()
126 throw( com::sun::star::uno::RuntimeException
)
133 virtual void SAL_CALL
135 const com::sun::star::uno::Reference
< com::sun::star::util::XChangesListener
>& aListener
)
136 throw( com::sun::star::uno::RuntimeException
)
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
)
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
)
166 virtual void SAL_CALL
168 const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& aListener
)
169 throw( com::sun::star::uno::RuntimeException
)
175 // Abstract functions
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
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
213 friend class TVChildTarget
;
216 TVRead( const ConfigData
& configData
,TVDom
* tvDom
= 0 );
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
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
);
252 rtl::OUString TargetURL
;
253 rtl::Reference
< TVChildTarget
> Children
;
255 }; // end class TVRead
267 TVChildTarget( const ConfigData
& configData
,TVDom
* tvDom
);
269 TVChildTarget( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xMSF
);
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
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
);
301 std::vector
< rtl::Reference
< TVRead
> > Elements
;
304 const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xMSF
);
306 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
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;
315 getKey( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& xHierAccess
,
316 const char* key
) const;
320 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XHierarchicalNameAccess
>& xHierAccess
,
321 const char* key
) const;
324 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xMSgr
,
325 rtl::OUString
& instpath
) const;
327 }; // end class TVChildTarget
337 class ExtensionIteratorBase
340 ExtensionIteratorBase( const rtl::OUString
& aLanguage
);
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
);
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
);
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
;
372 int m_iSharedPackage
;
374 }; // end class ExtensionIteratorBase
377 //===================================================================
378 class TreeFileIterator
: public ExtensionIteratorBase
381 TreeFileIterator( const rtl::OUString
& aLanguage
)
382 : ExtensionIteratorBase( aLanguage
)
385 rtl::OUString
nextTreeFile( sal_Int32
& rnFileSize
);
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