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: namecont.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 BASIC_NAMECONTAINER_HXX
32 #define BASIC_NAMECONTAINER_HXX
35 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
39 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
40 #include <com/sun/star/script/XLibraryContainerExport.hpp>
41 #include <com/sun/star/script/XLibraryQueryExecutable.hpp>
42 #include <com/sun/star/container/XNameContainer.hpp>
43 #include <com/sun/star/container/XContainer.hpp>
44 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
45 #include <com/sun/star/io/XOutputStream.hpp>
46 #include <com/sun/star/io/XInputStream.hpp>
47 #include <com/sun/star/util/XMacroExpander.hpp>
48 #include <com/sun/star/util/XStringSubstitution.hpp>
49 #include <com/sun/star/document/XStorageBasedDocument.hpp>
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #include <com/sun/star/frame/XModel.hpp>
52 #include <osl/mutex.hxx>
53 #include <unotools/eventlisteneradapter.hxx>
54 #include <cppuhelper/weakref.hxx>
55 #include <cppuhelper/component.hxx>
56 #include <cppuhelper/typeprovider.hxx>
57 #include <cppuhelper/interfacecontainer.hxx>
58 #include <cppuhelper/basemutex.hxx>
59 #include <sot/storage.hxx>
60 #include <xmlscript/xmllib_imexp.hxx>
61 #include <com/sun/star/deployment/XPackage.hpp>
63 #include <cppuhelper/implbase2.hxx>
64 #include <cppuhelper/compbase6.hxx>
65 #include <cppuhelper/compbase7.hxx>
66 #include <cppuhelper/compbase8.hxx>
67 #include <cppuhelper/interfacecontainer.hxx>
68 #include <com/sun/star/script/XVBACompat.hpp>
75 typedef ::cppu::WeakComponentImplHelper8
<
76 ::com::sun::star::lang::XInitialization
,
77 ::com::sun::star::script::XStorageBasedLibraryContainer
,
78 ::com::sun::star::script::XLibraryContainerPassword
,
79 ::com::sun::star::script::XLibraryContainerExport
,
80 ::com::sun::star::container::XContainer
,
81 ::com::sun::star::script::XLibraryQueryExecutable
,
82 ::com::sun::star::script::XVBACompat
,
83 ::com::sun::star::lang::XServiceInfo
> LibraryContainerHelper
;
85 typedef ::cppu::WeakImplHelper2
< ::com::sun::star::container::XNameContainer
,
86 ::com::sun::star::container::XContainer
> NameContainerHelper
;
91 size_t operator()(const ::rtl::OUString Str
) const
93 return (size_t)Str
.hashCode();
99 sal_Bool
operator()(const ::rtl::OUString Str1
, const ::rtl::OUString Str2
) const
101 return ( Str1
== Str2
);
105 typedef std::hash_map
112 NameContainerNameMap
;
115 //============================================================================
117 class NameContainer
: public ::cppu::BaseMutex
, public NameContainerHelper
119 NameContainerNameMap mHashMap
;
120 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> mNames
;
121 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> mValues
;
122 sal_Int32 mnElementCount
;
124 ::com::sun::star::uno::Type mType
;
125 ::com::sun::star::uno::XInterface
* mpxEventSource
;
127 ::cppu::OInterfaceContainerHelper maListenerContainer
;
130 NameContainer( const ::com::sun::star::uno::Type
& rType
)
131 : mnElementCount( 0 )
133 , mpxEventSource( NULL
)
134 , maListenerContainer( m_aMutex
)
137 void setEventSource( ::com::sun::star::uno::XInterface
* pxEventSource
)
138 { mpxEventSource
= pxEventSource
; }
140 // Methods XElementAccess
141 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
142 throw(::com::sun::star::uno::RuntimeException
);
143 virtual sal_Bool SAL_CALL
hasElements( )
144 throw(::com::sun::star::uno::RuntimeException
);
146 // Methods XNameAccess
147 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
148 throw(::com::sun::star::container::NoSuchElementException
,
149 ::com::sun::star::lang::WrappedTargetException
,
150 ::com::sun::star::uno::RuntimeException
);
151 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( )
152 throw(::com::sun::star::uno::RuntimeException
);
153 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
154 throw(::com::sun::star::uno::RuntimeException
);
156 // Methods XNameReplace
157 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
158 throw(::com::sun::star::lang::IllegalArgumentException
,
159 ::com::sun::star::container::NoSuchElementException
,
160 ::com::sun::star::lang::WrappedTargetException
,
161 ::com::sun::star::uno::RuntimeException
);
163 // Methods XNameContainer
164 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
165 throw(::com::sun::star::lang::IllegalArgumentException
,
166 ::com::sun::star::container::ElementExistException
,
167 ::com::sun::star::lang::WrappedTargetException
,
168 ::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& Name
)
170 throw(::com::sun::star::container::NoSuchElementException
,
171 ::com::sun::star::lang::WrappedTargetException
,
172 ::com::sun::star::uno::RuntimeException
);
174 // Methods XContainer
175 virtual void SAL_CALL
addContainerListener( const ::com::sun::star::uno::Reference
<
176 ::com::sun::star::container::XContainerListener
>& xListener
)
177 throw (::com::sun::star::uno::RuntimeException
);
178 virtual void SAL_CALL
removeContainerListener( const ::com::sun::star::uno::Reference
<
179 ::com::sun::star::container::XContainerListener
>& xListener
)
180 throw (::com::sun::star::uno::RuntimeException
);
183 //============================================================================
196 class ModifiableHelper
199 ::cppu::OInterfaceContainerHelper m_aModifyListeners
;
200 ::cppu::OWeakObject
& m_rEventSource
;
204 ModifiableHelper( ::cppu::OWeakObject
& _rEventSource
, ::osl::Mutex
& _rMutex
)
205 :m_aModifyListeners( _rMutex
)
206 ,m_rEventSource( _rEventSource
)
207 ,mbModified( sal_False
)
211 inline sal_Bool
isModified() const { return mbModified
; }
212 void setModified( sal_Bool _bModified
);
214 inline void addModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& _rxListener
)
216 m_aModifyListeners
.addInterface( _rxListener
);
219 inline void removeModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& _rxListener
)
221 m_aModifyListeners
.removeInterface( _rxListener
);
225 class SfxLibraryContainer
:public LibraryContainerHelper
226 ,public ::utl::OEventListenerAdapter
229 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
230 ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> mxSFI
;
231 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XMacroExpander
> mxMacroExpander
;
232 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XStringSubstitution
> mxStringSubstitution
;
233 ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XModel
> mxOwnerDocument
;
235 ::osl::Mutex maMutex
;
236 ModifiableHelper maModifiable
;
238 NameContainer maNameContainer
;
239 sal_Bool mbOldInfoFormat
;
240 sal_Bool mbOasis2OOoFormat
;
242 ::rtl::OUString maInitialDocumentURL
;
243 ::rtl::OUString maInfoFileName
;
244 ::rtl::OUString maOldInfoFileName
;
245 ::rtl::OUString maLibElementFileExtension
;
246 ::rtl::OUString maLibraryPath
;
247 ::rtl::OUString maLibrariesDir
;
249 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
> mxStorage
;
250 BasicManager
* mpBasMgr
;
251 sal_Bool mbOwnBasMgr
;
255 void implStoreLibrary( SfxLibrary
* pLib
,
256 const ::rtl::OUString
& aName
,
257 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
);
259 // New variant for library export
260 void implStoreLibrary( SfxLibrary
* pLib
,
261 const ::rtl::OUString
& aName
,
262 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
263 const ::rtl::OUString
& aTargetURL
,
264 const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> xToUseSFI
,
265 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& xHandler
);
267 void implStoreLibraryIndexFile( SfxLibrary
* pLib
, const ::xmlscript::LibDescriptor
& rLib
,
268 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
);
270 // New variant for library export
271 void implStoreLibraryIndexFile( SfxLibrary
* pLib
, const ::xmlscript::LibDescriptor
& rLib
,
272 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
273 const ::rtl::OUString
& aTargetURL
,
274 const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> xToUseSFI
);
276 sal_Bool
implLoadLibraryIndexFile( SfxLibrary
* pLib
,
277 ::xmlscript::LibDescriptor
& rLib
,
278 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
279 const ::rtl::OUString
& aIndexFileName
);
281 void implImportLibDescriptor( SfxLibrary
* pLib
, ::xmlscript::LibDescriptor
& rLib
);
283 // Methods to distinguish between deffirent library types
284 virtual SfxLibrary
* SAL_CALL
implCreateLibrary( const ::rtl::OUString
& aName
) = 0;
285 virtual SfxLibrary
* SAL_CALL implCreateLibraryLink
286 ( const ::rtl::OUString
& aName
, const ::rtl::OUString
& aLibInfoFileURL
,
287 const ::rtl::OUString
& StorageURL
, sal_Bool ReadOnly
) = 0;
288 virtual ::com::sun::star::uno::Any SAL_CALL
createEmptyLibraryElement( void ) = 0;
289 virtual bool SAL_CALL
isLibraryElementValid( ::com::sun::star::uno::Any aElement
) const = 0;
290 virtual void SAL_CALL writeLibraryElement
292 ::com::sun::star::uno::Any aElement
,
293 const ::rtl::OUString
& aElementName
,
294 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
> xOutput
296 throw(::com::sun::star::uno::Exception
) = 0;
298 virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
299 ( const ::rtl::OUString
& aFile
,
300 const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
>& xElementStream
) = 0;
301 virtual void SAL_CALL
importFromOldStorage( const ::rtl::OUString
& aFile
) = 0;
303 // Password encryption
304 virtual sal_Bool
implStorePasswordLibrary( SfxLibrary
* pLib
, const ::rtl::OUString
& aName
,
305 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
, const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& Handler
);
307 // New variant for library export
308 virtual sal_Bool
implStorePasswordLibrary( SfxLibrary
* pLib
, const ::rtl::OUString
& aName
,
309 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
310 const ::rtl::OUString
& aTargetURL
,
311 const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> xToUseSFI
, const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& Handler
);
313 virtual sal_Bool
implLoadPasswordLibrary( SfxLibrary
* pLib
, const ::rtl::OUString
& Name
,
314 sal_Bool bVerifyPasswordOnly
=false )
315 throw(::com::sun::star::lang::WrappedTargetException
,
316 ::com::sun::star::uno::RuntimeException
);
318 virtual void onNewRootStorage() = 0;
321 // #56666, Creates another library container
322 // instance of the same derived class
323 virtual SfxLibraryContainer
* createInstanceImpl( void ) = 0;
326 // Interface to get the BasicManager (Hack for password implementation)
327 BasicManager
* getBasicManager( void );
328 ::rtl::OUString
createAppLibraryFolder( SfxLibrary
* pLib
, const ::rtl::OUString
& aName
);
330 sal_Bool
init( const ::rtl::OUString
& rInitialDocumentURL
,
331 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rxInitialStorage
);
333 virtual const sal_Char
* SAL_CALL
getInfoFileName() const = 0;
334 virtual const sal_Char
* SAL_CALL
getOldInfoFileName() const = 0;
335 virtual const sal_Char
* SAL_CALL
getLibElementFileExtension() const = 0;
336 virtual const sal_Char
* SAL_CALL
getLibrariesDir() const = 0;
338 // Handle maLibInfoFileURL and maStorageURL correctly
341 const ::rtl::OUString
& aSourceURL
,
342 ::rtl::OUString
& aLibInfoFileURL
,
343 ::rtl::OUString
& aStorageURL
,
344 ::rtl::OUString
& aUnexpandedStorageURL
346 ::rtl::OUString
expand_url( const ::rtl::OUString
& url
)
347 throw(::com::sun::star::uno::RuntimeException
);
349 SfxLibrary
* getImplLib( const String
& rLibraryName
);
351 void storeLibraries_Impl(
352 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
353 sal_Bool bComplete
);
355 void SAL_CALL
initializeFromDocumentURL( const ::rtl::OUString
& _rInitialDocumentURL
);
356 void SAL_CALL
initializeFromDocument( const ::com::sun::star::uno::Reference
< ::com::sun::star::document::XStorageBasedDocument
>& _rxDocument
);
358 // OEventListenerAdapter
359 virtual void _disposing( const ::com::sun::star::lang::EventObject
& _rSource
);
362 virtual void SAL_CALL
disposing();
365 sal_Bool
init_Impl( const ::rtl::OUString
& rInitialDocumentURL
,
366 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rxInitialStorage
);
367 void implScanExtensions( void );
370 SfxLibraryContainer( void );
371 ~SfxLibraryContainer();
374 // Interface to set the BasicManager (Hack for password implementation)
375 void setBasicManager( BasicManager
* pBasMgr
)
382 bool isDisposed() const { return rBHelper
.bInDispose
|| rBHelper
.bDisposed
; }
383 void checkDisposed() const;
385 // Methods XElementAccess
386 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
387 throw(::com::sun::star::uno::RuntimeException
);
388 virtual sal_Bool SAL_CALL
hasElements()
389 throw(::com::sun::star::uno::RuntimeException
);
391 // Methods XNameAccess
392 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
393 throw(::com::sun::star::container::NoSuchElementException
,
394 ::com::sun::star::lang::WrappedTargetException
,
395 ::com::sun::star::uno::RuntimeException
);
396 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames()
397 throw(::com::sun::star::uno::RuntimeException
);
398 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
399 throw(::com::sun::star::uno::RuntimeException
);
401 // Members XStorageBasedLibraryContainer
402 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
> SAL_CALL
getRootStorage() throw (::com::sun::star::uno::RuntimeException
);
403 virtual void SAL_CALL
setRootStorage( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& _rootstorage
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
404 virtual void SAL_CALL
storeLibrariesToStorage( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& RootStorage
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
406 // Methods XModifiable (base of XPersistentLibraryContainer)
407 virtual ::sal_Bool SAL_CALL
isModified( ) throw (::com::sun::star::uno::RuntimeException
);
408 virtual void SAL_CALL
setModified( ::sal_Bool bModified
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::uno::RuntimeException
);
409 virtual void SAL_CALL
addModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
410 virtual void SAL_CALL
removeModifyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
412 // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer)
413 virtual ::com::sun::star::uno::Any SAL_CALL
getRootLocation() throw (::com::sun::star::uno::RuntimeException
);
414 virtual ::rtl::OUString SAL_CALL
getContainerLocationName() throw (::com::sun::star::uno::RuntimeException
);
415 virtual void SAL_CALL
storeLibraries( ) throw (::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
417 // Methods XLibraryContainer2 (base of XPersistentLibraryContainer)
418 virtual sal_Bool SAL_CALL
isLibraryLink( const ::rtl::OUString
& Name
)
419 throw (::com::sun::star::container::NoSuchElementException
,
420 ::com::sun::star::uno::RuntimeException
);
421 virtual ::rtl::OUString SAL_CALL
getLibraryLinkURL( const ::rtl::OUString
& Name
)
422 throw (::com::sun::star::lang::IllegalArgumentException
,
423 ::com::sun::star::container::NoSuchElementException
,
424 ::com::sun::star::uno::RuntimeException
);
425 virtual sal_Bool SAL_CALL
isLibraryReadOnly( const ::rtl::OUString
& Name
)
426 throw (::com::sun::star::container::NoSuchElementException
,
427 ::com::sun::star::uno::RuntimeException
);
428 virtual void SAL_CALL
setLibraryReadOnly( const ::rtl::OUString
& Name
, sal_Bool bReadOnly
)
429 throw (::com::sun::star::container::NoSuchElementException
,
430 ::com::sun::star::uno::RuntimeException
);
431 virtual void SAL_CALL
renameLibrary( const ::rtl::OUString
& Name
, const ::rtl::OUString
& NewName
)
432 throw (::com::sun::star::container::NoSuchElementException
,
433 ::com::sun::star::container::ElementExistException
,
434 ::com::sun::star::uno::RuntimeException
);
436 // Methods XLibraryContainer (base of XLibraryContainer2)
437 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
> SAL_CALL
438 createLibrary( const ::rtl::OUString
& Name
)
439 throw(::com::sun::star::lang::IllegalArgumentException
,
440 ::com::sun::star::container::ElementExistException
,
441 ::com::sun::star::uno::RuntimeException
);
442 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL createLibraryLink
443 ( const ::rtl::OUString
& Name
, const ::rtl::OUString
& StorageURL
, sal_Bool ReadOnly
)
444 throw(::com::sun::star::lang::IllegalArgumentException
,
445 ::com::sun::star::container::ElementExistException
,
446 ::com::sun::star::uno::RuntimeException
);
447 virtual void SAL_CALL
removeLibrary( const ::rtl::OUString
& Name
)
448 throw(::com::sun::star::container::NoSuchElementException
,
449 ::com::sun::star::lang::WrappedTargetException
,
450 ::com::sun::star::uno::RuntimeException
);
451 virtual sal_Bool SAL_CALL
isLibraryLoaded( const ::rtl::OUString
& Name
)
452 throw(::com::sun::star::container::NoSuchElementException
,
453 ::com::sun::star::uno::RuntimeException
);
454 virtual void SAL_CALL
loadLibrary( const ::rtl::OUString
& Name
)
455 throw(::com::sun::star::container::NoSuchElementException
,
456 ::com::sun::star::lang::WrappedTargetException
,
457 ::com::sun::star::uno::RuntimeException
);
459 // Methods XInitialization
460 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
<
461 ::com::sun::star::uno::Any
>& aArguments
)
462 throw (::com::sun::star::uno::Exception
,
463 ::com::sun::star::uno::RuntimeException
);
465 // Methods XLibraryContainerPassword
466 virtual sal_Bool SAL_CALL
isLibraryPasswordProtected( const ::rtl::OUString
& Name
)
467 throw (::com::sun::star::container::NoSuchElementException
,
468 ::com::sun::star::uno::RuntimeException
);
469 virtual sal_Bool SAL_CALL
isLibraryPasswordVerified( const ::rtl::OUString
& Name
)
470 throw (::com::sun::star::lang::IllegalArgumentException
,
471 ::com::sun::star::container::NoSuchElementException
,
472 ::com::sun::star::uno::RuntimeException
);
473 virtual sal_Bool SAL_CALL
verifyLibraryPassword( const ::rtl::OUString
& Name
, const ::rtl::OUString
& Password
)
474 throw (::com::sun::star::lang::IllegalArgumentException
,
475 ::com::sun::star::container::NoSuchElementException
,
476 ::com::sun::star::uno::RuntimeException
);
477 virtual void SAL_CALL
changeLibraryPassword( const ::rtl::OUString
& Name
,
478 const ::rtl::OUString
& OldPassword
, const ::rtl::OUString
& NewPassword
)
479 throw (::com::sun::star::lang::IllegalArgumentException
,
480 ::com::sun::star::container::NoSuchElementException
,
481 ::com::sun::star::uno::RuntimeException
);
483 // Methods XContainer
484 virtual void SAL_CALL
addContainerListener( const ::com::sun::star::uno::Reference
<
485 ::com::sun::star::container::XContainerListener
>& xListener
)
486 throw (::com::sun::star::uno::RuntimeException
);
487 virtual void SAL_CALL
removeContainerListener( const ::com::sun::star::uno::Reference
<
488 ::com::sun::star::container::XContainerListener
>& xListener
)
489 throw (::com::sun::star::uno::RuntimeException
);
491 // Methods XLibraryContainerExport
492 virtual void SAL_CALL
exportLibrary( const ::rtl::OUString
& Name
, const ::rtl::OUString
& URL
,
493 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& Handler
)
494 throw (::com::sun::star::uno::Exception
,
495 ::com::sun::star::container::NoSuchElementException
,
496 ::com::sun::star::uno::RuntimeException
);
498 // Methods XServiceInfo
499 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
500 throw (::com::sun::star::uno::RuntimeException
) = 0;
501 virtual ::sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
502 throw (::com::sun::star::uno::RuntimeException
);
503 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
504 throw (::com::sun::star::uno::RuntimeException
) = 0;
506 // Methods XVBACompat
507 virtual ::sal_Bool SAL_CALL
getVBACompatModeOn() throw (::com::sun::star::uno::RuntimeException
);
508 virtual void SAL_CALL
setVBACompatModeOn( ::sal_Bool _vbacompatmodeon
) throw (::com::sun::star::uno::RuntimeException
);
511 class LibraryContainerMethodGuard
514 SfxLibraryContainer
& m_rContainer
;
516 LibraryContainerMethodGuard( SfxLibraryContainer
& _rContainer
)
517 :m_rContainer( _rContainer
)
519 m_rContainer
.enterMethod();
522 ~LibraryContainerMethodGuard()
524 m_rContainer
.leaveMethod();
529 //============================================================================
532 : public ::com::sun::star::container::XNameContainer
533 , public ::com::sun::star::container::XContainer
534 , public ::cppu::BaseMutex
535 , public ::cppu::OComponentHelper
537 friend class SfxLibraryContainer
;
538 friend class SfxDialogLibraryContainer
;
539 friend class SfxScriptLibraryContainer
;
541 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
542 ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
> mxSFI
;
544 ModifiableHelper
& mrModifiable
;
545 NameContainer maNameContainer
;
548 sal_Bool mbIsModified
;
549 sal_Bool mbInitialised
;
553 ::rtl::OUString maLibElementFileExtension
;
554 ::rtl::OUString maLibInfoFileURL
;
555 ::rtl::OUString maStorageURL
;
556 ::rtl::OUString maUnexpandedStorageURL
;
559 sal_Bool mbReadOnlyLink
;
562 sal_Bool mbPasswordProtected
;
563 sal_Bool mbPasswordVerified
;
564 sal_Bool mbDoc50Password
;
565 ::rtl::OUString maPassword
;
567 sal_Bool mbSharedIndexFile
;
568 sal_Bool mbExtension
;
570 // Additional functionality for localisation
571 // Provide modify state including resources
572 virtual sal_Bool
isModified( void ) = 0;
573 virtual void storeResources( void ) = 0;
574 virtual void storeResourcesAsURL( const ::rtl::OUString
& URL
, const ::rtl::OUString
& NewName
) = 0;
575 virtual void storeResourcesToURL( const ::rtl::OUString
& URL
,
576 const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& xHandler
) = 0;
577 virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
578 < ::com::sun::star::embed::XStorage
>& xStorage
) = 0;
581 inline sal_Bool
implIsModified() const { return mbIsModified
; }
582 void implSetModified( sal_Bool _bIsModified
);
585 /** checks whether the lib is readonly, or a readonly link, throws an IllegalArgumentException if so
587 void impl_checkReadOnly();
588 /** checks whether the library is loaded, throws a LibraryNotLoadedException (wrapped in a WrappedTargetException),
591 void impl_checkLoaded();
594 void impl_removeWithoutChecks( const ::rtl::OUString
& _rElementName
);
598 ModifiableHelper
& _rModifiable
,
599 const ::com::sun::star::uno::Type
& aType
,
600 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xMSF
,
601 const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
>& xSFI
604 ModifiableHelper
& _rModifiable
,
605 const ::com::sun::star::uno::Type
& aType
,
606 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xMSF
,
607 const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XSimpleFileAccess
>& xSFI
,
608 const ::rtl::OUString
& aLibInfoFileURL
,
609 const ::rtl::OUString
&
614 // Methods XInterface
615 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw( ::com::sun::star::uno::RuntimeException
);
616 virtual void SAL_CALL
acquire() throw() { OComponentHelper::acquire(); }
617 virtual void SAL_CALL
release() throw() { OComponentHelper::release(); }
619 // Methods XElementAccess
620 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
621 throw(::com::sun::star::uno::RuntimeException
);
622 virtual sal_Bool SAL_CALL
hasElements( )
623 throw(::com::sun::star::uno::RuntimeException
);
625 // Methods XNameAccess
626 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
627 throw(::com::sun::star::container::NoSuchElementException
,
628 ::com::sun::star::lang::WrappedTargetException
,
629 ::com::sun::star::uno::RuntimeException
);
630 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( )
631 throw(::com::sun::star::uno::RuntimeException
);
632 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
633 throw(::com::sun::star::uno::RuntimeException
);
635 // Methods XNameReplace
636 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
637 throw(::com::sun::star::lang::IllegalArgumentException
,
638 ::com::sun::star::container::NoSuchElementException
,
639 ::com::sun::star::lang::WrappedTargetException
,
640 ::com::sun::star::uno::RuntimeException
);
642 // Methods XNameContainer
643 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
644 throw(::com::sun::star::lang::IllegalArgumentException
,
645 ::com::sun::star::container::ElementExistException
,
646 ::com::sun::star::lang::WrappedTargetException
,
647 ::com::sun::star::uno::RuntimeException
);
648 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& Name
)
649 throw(::com::sun::star::container::NoSuchElementException
,
650 ::com::sun::star::lang::WrappedTargetException
,
651 ::com::sun::star::uno::RuntimeException
);
654 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( )
655 throw( ::com::sun::star::uno::RuntimeException
);
656 ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId( )
657 throw( ::com::sun::star::uno::RuntimeException
);
659 // Methods XContainer
660 virtual void SAL_CALL
addContainerListener( const ::com::sun::star::uno::Reference
<
661 ::com::sun::star::container::XContainerListener
>& xListener
)
662 throw (::com::sun::star::uno::RuntimeException
);
663 virtual void SAL_CALL
removeContainerListener( const ::com::sun::star::uno::Reference
<
664 ::com::sun::star::container::XContainerListener
>& xListener
)
665 throw (::com::sun::star::uno::RuntimeException
);
668 struct LibraryContainerAccess
{ friend class SfxLibraryContainer
; private: LibraryContainerAccess() { } };
669 void removeElementWithoutChecks( const ::rtl::OUString
& _rElementName
, LibraryContainerAccess
)
671 impl_removeWithoutChecks( _rElementName
);
675 virtual bool SAL_CALL
isLibraryElementValid( ::com::sun::star::uno::Any aElement
) const = 0;
678 //===================================================================
679 class ScriptSubPackageIterator
681 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
> m_xMainPackage
;
686 com::sun::star::uno::Sequence
< com::sun::star::uno::Reference
687 < com::sun::star::deployment::XPackage
> > m_aSubPkgSeq
;
688 sal_Int32 m_nSubPkgCount
;
689 sal_Int32 m_iNextSubPkg
;
691 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
>
692 implDetectScriptPackage( const com::sun::star::uno::Reference
693 < com::sun::star::deployment::XPackage
> xPackage
, bool& rbPureDialogLib
);
696 ScriptSubPackageIterator( com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
> xMainPackage
);
698 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
> getNextScriptSubPackage( bool& rbPureDialogLib
);
708 class ScriptExtensionIterator
711 ScriptExtensionIterator( void );
712 rtl::OUString
nextBasicOrDialogLibrary( bool& rbPureDialogLib
);
715 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
> implGetScriptPackageFromPackage
716 ( const com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
> xPackage
,
717 bool& rbPureDialogLib
);
720 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
>
721 implGetNextUserScriptPackage( bool& rbPureDialogLib
);
722 com::sun::star::uno::Reference
< com::sun::star::deployment::XPackage
>
723 implGetNextSharedScriptPackage( bool& rbPureDialogLib
);
725 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> m_xContext
;
727 IteratorState m_eState
;
729 com::sun::star::uno::Sequence
< com::sun::star::uno::Reference
730 < com::sun::star::deployment::XPackage
> > m_aUserPackagesSeq
;
731 bool m_bUserPackagesLoaded
;
733 com::sun::star::uno::Sequence
< com::sun::star::uno::Reference
734 < com::sun::star::deployment::XPackage
> > m_aSharedPackagesSeq
;
735 bool m_bSharedPackagesLoaded
;
738 int m_iSharedPackage
;
740 ScriptSubPackageIterator
* m_pScriptSubPackageIterator
;
742 }; // end class ScriptExtensionIterator