Branch data 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 BASIC_NAMECONTAINER_HXX
21 : : #define BASIC_NAMECONTAINER_HXX
22 : :
23 : : #include <boost/unordered_map.hpp>
24 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
25 : : #include <com/sun/star/uno/XComponentContext.hpp>
26 : : #include <com/sun/star/lang/XInitialization.hpp>
27 : : #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
28 : : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
29 : : #include <com/sun/star/script/XLibraryContainerExport.hpp>
30 : : #include <com/sun/star/script/XLibraryQueryExecutable.hpp>
31 : : #include <com/sun/star/script/XLibraryContainer3.hpp>
32 : : #include <com/sun/star/container/XNameContainer.hpp>
33 : : #include <com/sun/star/container/XContainer.hpp>
34 : : #include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
35 : : #include <com/sun/star/io/XOutputStream.hpp>
36 : : #include <com/sun/star/io/XInputStream.hpp>
37 : : #include <com/sun/star/util/XMacroExpander.hpp>
38 : : #include <com/sun/star/util/XStringSubstitution.hpp>
39 : : #include <com/sun/star/document/XStorageBasedDocument.hpp>
40 : : #include <com/sun/star/lang/XServiceInfo.hpp>
41 : : #include <com/sun/star/frame/XModel.hpp>
42 : : #include <com/sun/star/deployment/XPackage.hpp>
43 : : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
44 : : #include <com/sun/star/script/vba/XVBAScriptListener.hpp>
45 : : #include <com/sun/star/util/XChangesNotifier.hpp>
46 : :
47 : : #include <osl/mutex.hxx>
48 : : #include <unotools/eventlisteneradapter.hxx>
49 : : #include <cppuhelper/implbase3.hxx>
50 : : #include <cppuhelper/compbase8.hxx>
51 : : #include <cppuhelper/interfacecontainer.hxx>
52 : : #include <cppuhelper/weakref.hxx>
53 : : #include <cppuhelper/component.hxx>
54 : : #include <cppuhelper/typeprovider.hxx>
55 : : #include <cppuhelper/basemutex.hxx>
56 : : #include <sot/storage.hxx>
57 : : #include <comphelper/listenernotification.hxx>
58 : : #include <xmlscript/xmllib_imexp.hxx>
59 : : #include <cppuhelper/compbase9.hxx>
60 : :
61 : : class BasicManager;
62 : :
63 : : namespace basic
64 : : {
65 : : typedef ::cppu::WeakImplHelper3<
66 : : ::com::sun::star::container::XNameContainer,
67 : : ::com::sun::star::container::XContainer,
68 : : ::com::sun::star::util::XChangesNotifier > NameContainer_BASE;
69 : :
70 : : //============================================================================
71 : :
72 [ + - ][ + - ]: 2832 : class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ]
73 : : {
74 : : typedef boost::unordered_map < ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap;
75 : :
76 : : NameContainerNameMap mHashMap;
77 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames;
78 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues;
79 : : sal_Int32 mnElementCount;
80 : :
81 : : ::com::sun::star::uno::Type mType;
82 : : ::com::sun::star::uno::XInterface* mpxEventSource;
83 : :
84 : : ::cppu::OInterfaceContainerHelper maContainerListeners;
85 : : ::cppu::OInterfaceContainerHelper maChangesListeners;
86 : :
87 : : public:
88 : 3044 : NameContainer( const ::com::sun::star::uno::Type& rType )
89 : : : mnElementCount( 0 )
90 : : , mType( rType )
91 : : , mpxEventSource( NULL )
92 : : , maContainerListeners( m_aMutex )
93 [ + - ][ + - ]: 3044 : , maChangesListeners( m_aMutex )
[ + - ][ + - ]
[ + - ][ + - ]
94 : 3044 : {}
95 : :
96 : 952 : void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
97 : 952 : { mpxEventSource = pxEventSource; }
98 : :
99 : : // Methods XElementAccess
100 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
101 : : throw(::com::sun::star::uno::RuntimeException);
102 : : virtual sal_Bool SAL_CALL hasElements( )
103 : : throw(::com::sun::star::uno::RuntimeException);
104 : :
105 : : // Methods XNameAccess
106 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
107 : : throw(::com::sun::star::container::NoSuchElementException,
108 : : ::com::sun::star::lang::WrappedTargetException,
109 : : ::com::sun::star::uno::RuntimeException);
110 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
111 : : throw(::com::sun::star::uno::RuntimeException);
112 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
113 : : throw(::com::sun::star::uno::RuntimeException);
114 : :
115 : : // Methods XNameReplace
116 : : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
117 : : throw(::com::sun::star::lang::IllegalArgumentException,
118 : : ::com::sun::star::container::NoSuchElementException,
119 : : ::com::sun::star::lang::WrappedTargetException,
120 : : ::com::sun::star::uno::RuntimeException);
121 : :
122 : : // Methods XNameContainer
123 : : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
124 : : throw(::com::sun::star::lang::IllegalArgumentException,
125 : : ::com::sun::star::container::ElementExistException,
126 : : ::com::sun::star::lang::WrappedTargetException,
127 : : ::com::sun::star::uno::RuntimeException);
128 : : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
129 : : throw(::com::sun::star::container::NoSuchElementException,
130 : : ::com::sun::star::lang::WrappedTargetException,
131 : : ::com::sun::star::uno::RuntimeException);
132 : :
133 : : // Methods XContainer
134 : : virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
135 : : ::com::sun::star::container::XContainerListener >& xListener )
136 : : throw (::com::sun::star::uno::RuntimeException);
137 : : virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
138 : : ::com::sun::star::container::XContainerListener >& xListener )
139 : : throw (::com::sun::star::uno::RuntimeException);
140 : :
141 : : // Methods XChangesNotifier
142 : : virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
143 : : ::com::sun::star::util::XChangesListener >& xListener )
144 : : throw (::com::sun::star::uno::RuntimeException);
145 : : virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
146 : : ::com::sun::star::util::XChangesListener >& xListener )
147 : : throw (::com::sun::star::uno::RuntimeException);
148 : : };
149 : :
150 : : //============================================================================
151 : :
152 : 1458 : class ModifiableHelper
153 : : {
154 : : private:
155 : : ::cppu::OInterfaceContainerHelper m_aModifyListeners;
156 : : ::cppu::OWeakObject& m_rEventSource;
157 : : sal_Bool mbModified;
158 : :
159 : : public:
160 : 1599 : ModifiableHelper( ::cppu::OWeakObject& _rEventSource, ::osl::Mutex& _rMutex )
161 : : :m_aModifyListeners( _rMutex )
162 : : ,m_rEventSource( _rEventSource )
163 : 1599 : ,mbModified( sal_False )
164 : : {
165 : 1599 : }
166 : :
167 : 180 : inline sal_Bool isModified() const { return mbModified; }
168 : : void setModified( sal_Bool _bModified );
169 : :
170 : 0 : inline void addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener )
171 : : {
172 : 0 : m_aModifyListeners.addInterface( _rxListener );
173 : 0 : }
174 : :
175 : 0 : inline void removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener )
176 : : {
177 : 0 : m_aModifyListeners.removeInterface( _rxListener );
178 : 0 : }
179 : : };
180 : :
181 : : //============================================================================
182 : :
183 : : typedef ::comphelper::OListenerContainerBase<
184 : : ::com::sun::star::script::vba::XVBAScriptListener,
185 : : ::com::sun::star::script::vba::VBAScriptEvent > VBAScriptListenerContainer_BASE;
186 : :
187 [ - + ]: 1458 : class VBAScriptListenerContainer : public VBAScriptListenerContainer_BASE
188 : : {
189 : : public:
190 : : explicit VBAScriptListenerContainer( ::osl::Mutex& rMutex );
191 : :
192 : : private:
193 : : virtual bool implTypedNotify(
194 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& rxListener,
195 : : const ::com::sun::star::script::vba::VBAScriptEvent& rEvent )
196 : : throw (::com::sun::star::uno::Exception);
197 : : };
198 : :
199 : : //============================================================================
200 : :
201 : : class SfxLibrary;
202 : :
203 : : typedef ::cppu::WeakComponentImplHelper9<
204 : : ::com::sun::star::lang::XInitialization,
205 : : ::com::sun::star::script::XStorageBasedLibraryContainer,
206 : : ::com::sun::star::script::XLibraryContainerPassword,
207 : : ::com::sun::star::script::XLibraryContainerExport,
208 : : ::com::sun::star::script::XLibraryContainer3,
209 : : ::com::sun::star::container::XContainer,
210 : : ::com::sun::star::script::XLibraryQueryExecutable,
211 : : ::com::sun::star::script::vba::XVBACompatibility,
212 : : ::com::sun::star::lang::XServiceInfo > SfxLibraryContainer_BASE;
213 : :
214 : : class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEventListenerAdapter
215 : : {
216 : : VBAScriptListenerContainer maVBAScriptListeners;
217 : : sal_Int32 mnRunningVBAScripts;
218 : : sal_Bool mbVBACompat;
219 : : rtl::OUString msProjectName;
220 : : protected:
221 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
222 : : ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > mxSFI;
223 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander > mxMacroExpander;
224 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XStringSubstitution > mxStringSubstitution;
225 : : ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > mxOwnerDocument;
226 : :
227 : : ::osl::Mutex maMutex;
228 : : ModifiableHelper maModifiable;
229 : :
230 : : NameContainer maNameContainer;
231 : : bool mbOldInfoFormat;
232 : : bool mbOasis2OOoFormat;
233 : :
234 : : ::rtl::OUString maInitialDocumentURL;
235 : : ::rtl::OUString maInfoFileName;
236 : : ::rtl::OUString maOldInfoFileName;
237 : : ::rtl::OUString maLibElementFileExtension;
238 : : ::rtl::OUString maLibraryPath;
239 : : ::rtl::OUString maLibrariesDir;
240 : :
241 : : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > mxStorage;
242 : : BasicManager* mpBasMgr;
243 : : bool mbOwnBasMgr;
244 : :
245 : : enum InitMode
246 : : {
247 : : DEFAULT,
248 : : CONTAINER_INIT_FILE,
249 : : LIBRARY_INIT_FILE,
250 : : OFFICE_DOCUMENT,
251 : : OLD_BASIC_STORAGE
252 : : } meInitMode;
253 : :
254 : : void implStoreLibrary( SfxLibrary* pLib,
255 : : const ::rtl::OUString& aName,
256 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
257 : :
258 : : // New variant for library export
259 : : void implStoreLibrary( SfxLibrary* pLib,
260 : : const ::rtl::OUString& aName,
261 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
262 : : const ::rtl::OUString& aTargetURL,
263 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > xToUseSFI,
264 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
265 : :
266 : : void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib,
267 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
268 : :
269 : : // New variant for library export
270 : : void implStoreLibraryIndexFile( SfxLibrary* pLib, const ::xmlscript::LibDescriptor& rLib,
271 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
272 : : const ::rtl::OUString& aTargetURL,
273 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > xToUseSFI );
274 : :
275 : : bool implLoadLibraryIndexFile( SfxLibrary* pLib,
276 : : ::xmlscript::LibDescriptor& rLib,
277 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
278 : : const ::rtl::OUString& aIndexFileName );
279 : :
280 : : void implImportLibDescriptor( SfxLibrary* pLib, ::xmlscript::LibDescriptor& rLib );
281 : :
282 : : // Methods to distinguish between deffirent library types
283 : : virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName ) = 0;
284 : : virtual SfxLibrary* SAL_CALL implCreateLibraryLink
285 : : ( const ::rtl::OUString& aName, const ::rtl::OUString& aLibInfoFileURL,
286 : : const ::rtl::OUString& StorageURL, sal_Bool ReadOnly ) = 0;
287 : : virtual ::com::sun::star::uno::Any SAL_CALL createEmptyLibraryElement( void ) = 0;
288 : : virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
289 : : virtual void SAL_CALL writeLibraryElement
290 : : (
291 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
292 : : const ::rtl::OUString& aElementName,
293 : : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
294 : : )
295 : : throw(::com::sun::star::uno::Exception) = 0;
296 : :
297 : : virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
298 : : (
299 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
300 : : const ::rtl::OUString& aElementName,
301 : : const ::rtl::OUString& aFile,
302 : : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) = 0;
303 : : virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ) = 0;
304 : :
305 : : // Password encryption
306 : : virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName,
307 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
308 : :
309 : : // New variant for library export
310 : : virtual sal_Bool implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName,
311 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
312 : : const ::rtl::OUString& aTargetURL,
313 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > xToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler );
314 : :
315 : : virtual sal_Bool implLoadPasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& Name,
316 : : sal_Bool bVerifyPasswordOnly=false )
317 : : throw(::com::sun::star::lang::WrappedTargetException,
318 : : ::com::sun::star::uno::RuntimeException);
319 : :
320 : : virtual void onNewRootStorage() = 0;
321 : :
322 : :
323 : : // #56666, Creates another library container
324 : : // instance of the same derived class
325 : : virtual SfxLibraryContainer* createInstanceImpl( void ) = 0;
326 : :
327 : :
328 : : // Interface to get the BasicManager (Hack for password implementation)
329 : : BasicManager* getBasicManager( void );
330 : : ::rtl::OUString createAppLibraryFolder( SfxLibrary* pLib, const ::rtl::OUString& aName );
331 : :
332 : : void init( const ::rtl::OUString& rInitialDocumentURL,
333 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage );
334 : :
335 : : virtual const sal_Char* SAL_CALL getInfoFileName() const = 0;
336 : : virtual const sal_Char* SAL_CALL getOldInfoFileName() const = 0;
337 : : virtual const sal_Char* SAL_CALL getLibElementFileExtension() const = 0;
338 : : virtual const sal_Char* SAL_CALL getLibrariesDir() const = 0;
339 : :
340 : : // Handle maLibInfoFileURL and maStorageURL correctly
341 : : void checkStorageURL
342 : : (
343 : : const ::rtl::OUString& aSourceURL,
344 : : ::rtl::OUString& aLibInfoFileURL,
345 : : ::rtl::OUString& aStorageURL,
346 : : ::rtl::OUString& aUnexpandedStorageURL
347 : : );
348 : : ::rtl::OUString expand_url( const ::rtl::OUString& url )
349 : : throw(::com::sun::star::uno::RuntimeException);
350 : :
351 : : SfxLibrary* getImplLib( const String& rLibraryName );
352 : :
353 : : void storeLibraries_Impl(
354 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
355 : : bool bComplete );
356 : :
357 : : void SAL_CALL initializeFromDocumentURL( const ::rtl::OUString& _rInitialDocumentURL );
358 : : void SAL_CALL initializeFromDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageBasedDocument >& _rxDocument );
359 : :
360 : : // OEventListenerAdapter
361 : : virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
362 : :
363 : : // OComponentHelper
364 : : virtual void SAL_CALL disposing();
365 : :
366 : : private:
367 : : void init_Impl( const ::rtl::OUString& rInitialDocumentURL,
368 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxInitialStorage );
369 : : void implScanExtensions( void );
370 : :
371 : : public:
372 : : SfxLibraryContainer( void );
373 : : ~SfxLibraryContainer();
374 : :
375 : :
376 : : // Interface to set the BasicManager (Hack for password implementation)
377 : 122 : void setBasicManager( BasicManager* pBasMgr )
378 : : {
379 : 122 : mpBasMgr = pBasMgr;
380 : 122 : }
381 : :
382 : : void enterMethod();
383 : : void leaveMethod();
384 [ + - ][ - + ]: 9096 : bool isDisposed() const { return rBHelper.bInDispose || rBHelper.bDisposed; }
385 : : void checkDisposed() const;
386 : :
387 : : // Methods XElementAccess
388 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
389 : : throw(::com::sun::star::uno::RuntimeException);
390 : : virtual sal_Bool SAL_CALL hasElements()
391 : : throw(::com::sun::star::uno::RuntimeException);
392 : :
393 : : // Methods XNameAccess
394 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
395 : : throw(::com::sun::star::container::NoSuchElementException,
396 : : ::com::sun::star::lang::WrappedTargetException,
397 : : ::com::sun::star::uno::RuntimeException);
398 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
399 : : throw(::com::sun::star::uno::RuntimeException);
400 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
401 : : throw(::com::sun::star::uno::RuntimeException);
402 : :
403 : : // Members XStorageBasedLibraryContainer
404 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getRootStorage() throw (::com::sun::star::uno::RuntimeException);
405 : : 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);
406 : : 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);
407 : :
408 : : // Methods XModifiable (base of XPersistentLibraryContainer)
409 : : virtual ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
410 : : virtual void SAL_CALL setModified( ::sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
411 : : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
412 : : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
413 : :
414 : : // Methods XPersistentLibraryContainer (base of XStorageBasedLibraryContainer)
415 : : virtual ::com::sun::star::uno::Any SAL_CALL getRootLocation() throw (::com::sun::star::uno::RuntimeException);
416 : : virtual ::rtl::OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException);
417 : : virtual void SAL_CALL storeLibraries( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
418 : :
419 : : //Methods XLibraryContainer3
420 : : virtual ::rtl::OUString SAL_CALL getOriginalLibraryLinkURL( const ::rtl::OUString& Name )
421 : : throw (::com::sun::star::lang::IllegalArgumentException,
422 : : ::com::sun::star::container::NoSuchElementException,
423 : : ::com::sun::star::uno::RuntimeException);
424 : :
425 : : // Methods XLibraryContainer2 (base of XPersistentLibraryContainer)
426 : : virtual sal_Bool SAL_CALL isLibraryLink( const ::rtl::OUString& Name )
427 : : throw (::com::sun::star::container::NoSuchElementException,
428 : : ::com::sun::star::uno::RuntimeException);
429 : : virtual ::rtl::OUString SAL_CALL getLibraryLinkURL( const ::rtl::OUString& Name )
430 : : throw (::com::sun::star::lang::IllegalArgumentException,
431 : : ::com::sun::star::container::NoSuchElementException,
432 : : ::com::sun::star::uno::RuntimeException);
433 : : virtual sal_Bool SAL_CALL isLibraryReadOnly( const ::rtl::OUString& Name )
434 : : throw (::com::sun::star::container::NoSuchElementException,
435 : : ::com::sun::star::uno::RuntimeException);
436 : : virtual void SAL_CALL setLibraryReadOnly( const ::rtl::OUString& Name, sal_Bool bReadOnly )
437 : : throw (::com::sun::star::container::NoSuchElementException,
438 : : ::com::sun::star::uno::RuntimeException);
439 : : virtual void SAL_CALL renameLibrary( const ::rtl::OUString& Name, const ::rtl::OUString& NewName )
440 : : throw (::com::sun::star::container::NoSuchElementException,
441 : : ::com::sun::star::container::ElementExistException,
442 : : ::com::sun::star::uno::RuntimeException);
443 : :
444 : : // Methods XLibraryContainer (base of XLibraryContainer2)
445 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL
446 : : createLibrary( const ::rtl::OUString& Name )
447 : : throw(::com::sun::star::lang::IllegalArgumentException,
448 : : ::com::sun::star::container::ElementExistException,
449 : : ::com::sun::star::uno::RuntimeException);
450 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL createLibraryLink
451 : : ( const ::rtl::OUString& Name, const ::rtl::OUString& StorageURL, sal_Bool ReadOnly )
452 : : throw(::com::sun::star::lang::IllegalArgumentException,
453 : : ::com::sun::star::container::ElementExistException,
454 : : ::com::sun::star::uno::RuntimeException);
455 : : virtual void SAL_CALL removeLibrary( const ::rtl::OUString& Name )
456 : : throw(::com::sun::star::container::NoSuchElementException,
457 : : ::com::sun::star::lang::WrappedTargetException,
458 : : ::com::sun::star::uno::RuntimeException);
459 : : virtual sal_Bool SAL_CALL isLibraryLoaded( const ::rtl::OUString& Name )
460 : : throw(::com::sun::star::container::NoSuchElementException,
461 : : ::com::sun::star::uno::RuntimeException);
462 : : virtual void SAL_CALL loadLibrary( const ::rtl::OUString& Name )
463 : : throw(::com::sun::star::container::NoSuchElementException,
464 : : ::com::sun::star::lang::WrappedTargetException,
465 : : ::com::sun::star::uno::RuntimeException);
466 : :
467 : : // Methods XInitialization
468 : : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence<
469 : : ::com::sun::star::uno::Any >& aArguments )
470 : : throw (::com::sun::star::uno::Exception,
471 : : ::com::sun::star::uno::RuntimeException);
472 : :
473 : : // Methods XLibraryContainerPassword
474 : : virtual sal_Bool SAL_CALL isLibraryPasswordProtected( const ::rtl::OUString& Name )
475 : : throw (::com::sun::star::container::NoSuchElementException,
476 : : ::com::sun::star::uno::RuntimeException);
477 : : virtual sal_Bool SAL_CALL isLibraryPasswordVerified( const ::rtl::OUString& Name )
478 : : throw (::com::sun::star::lang::IllegalArgumentException,
479 : : ::com::sun::star::container::NoSuchElementException,
480 : : ::com::sun::star::uno::RuntimeException);
481 : : virtual sal_Bool SAL_CALL verifyLibraryPassword( const ::rtl::OUString& Name, const ::rtl::OUString& Password )
482 : : throw (::com::sun::star::lang::IllegalArgumentException,
483 : : ::com::sun::star::container::NoSuchElementException,
484 : : ::com::sun::star::uno::RuntimeException);
485 : : virtual void SAL_CALL changeLibraryPassword( const ::rtl::OUString& Name,
486 : : const ::rtl::OUString& OldPassword, const ::rtl::OUString& NewPassword )
487 : : throw (::com::sun::star::lang::IllegalArgumentException,
488 : : ::com::sun::star::container::NoSuchElementException,
489 : : ::com::sun::star::uno::RuntimeException);
490 : :
491 : : // Methods XContainer
492 : : virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
493 : : ::com::sun::star::container::XContainerListener >& xListener )
494 : : throw (::com::sun::star::uno::RuntimeException);
495 : : virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
496 : : ::com::sun::star::container::XContainerListener >& xListener )
497 : : throw (::com::sun::star::uno::RuntimeException);
498 : :
499 : : // Methods XLibraryContainerExport
500 : : virtual void SAL_CALL exportLibrary( const ::rtl::OUString& Name, const ::rtl::OUString& URL,
501 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler )
502 : : throw (::com::sun::star::uno::Exception,
503 : : ::com::sun::star::container::NoSuchElementException,
504 : : ::com::sun::star::uno::RuntimeException);
505 : :
506 : : // Methods XServiceInfo
507 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
508 : : throw (::com::sun::star::uno::RuntimeException) = 0;
509 : : virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
510 : : throw (::com::sun::star::uno::RuntimeException);
511 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
512 : : throw (::com::sun::star::uno::RuntimeException) = 0;
513 : : // Methods XVBACompatibility
514 : : virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException);
515 : : virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException);
516 : 17 : virtual ::rtl::OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException) { return msProjectName; }
517 : : virtual void SAL_CALL setProjectName( const ::rtl::OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException);
518 : : virtual sal_Int32 SAL_CALL getRunningVBAScripts()
519 : : throw (::com::sun::star::uno::RuntimeException);
520 : : virtual void SAL_CALL addVBAScriptListener(
521 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
522 : : throw (::com::sun::star::uno::RuntimeException);
523 : : virtual void SAL_CALL removeVBAScriptListener(
524 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::vba::XVBAScriptListener >& Listener )
525 : : throw (::com::sun::star::uno::RuntimeException);
526 : : virtual void SAL_CALL broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName )
527 : : throw (::com::sun::star::uno::RuntimeException);
528 : : };
529 : :
530 : : //============================================================================
531 : :
532 : : class LibraryContainerMethodGuard
533 : : {
534 : : private:
535 : : SfxLibraryContainer& m_rContainer;
536 : : public:
537 : 9088 : LibraryContainerMethodGuard( SfxLibraryContainer& _rContainer )
538 : 9088 : :m_rContainer( _rContainer )
539 : : {
540 : 9088 : m_rContainer.enterMethod();
541 : 9088 : }
542 : :
543 : 9088 : ~LibraryContainerMethodGuard()
544 : : {
545 : 9088 : m_rContainer.leaveMethod();
546 : 9088 : }
547 : : };
548 : :
549 : : //============================================================================
550 : :
551 [ + - ][ + - ]: 1374 : class SfxLibrary
[ + - ][ - + ]
552 : : : public ::com::sun::star::container::XNameContainer
553 : : , public ::com::sun::star::container::XContainer
554 : : , public ::com::sun::star::util::XChangesNotifier
555 : : , public ::cppu::BaseMutex
556 : : , public ::cppu::OComponentHelper
557 : : {
558 : : friend class SfxLibraryContainer;
559 : : friend class SfxDialogLibraryContainer;
560 : : friend class SfxScriptLibraryContainer;
561 : :
562 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
563 : : ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > mxSFI;
564 : :
565 : : ModifiableHelper& mrModifiable;
566 : : NameContainer maNameContainer;
567 : :
568 : : sal_Bool mbLoaded;
569 : : sal_Bool mbIsModified;
570 : : bool mbInitialised;
571 : :
572 : : private:
573 : :
574 : : ::rtl::OUString maLibElementFileExtension;
575 : : ::rtl::OUString maLibInfoFileURL;
576 : : ::rtl::OUString maStorageURL;
577 : : ::rtl::OUString maUnexpandedStorageURL;
578 : : ::rtl::OUString maOriginalStorageURL;
579 : :
580 : : sal_Bool mbLink;
581 : : sal_Bool mbReadOnly;
582 : : sal_Bool mbReadOnlyLink;
583 : : sal_Bool mbPreload;
584 : :
585 : : sal_Bool mbPasswordProtected;
586 : : sal_Bool mbPasswordVerified;
587 : : bool mbDoc50Password;
588 : : ::rtl::OUString maPassword;
589 : :
590 : : bool mbSharedIndexFile;
591 : : bool mbExtension;
592 : :
593 : : // Additional functionality for localisation
594 : : // Provide modify state including resources
595 : : virtual sal_Bool isModified( void ) = 0;
596 : : virtual void storeResources( void ) = 0;
597 : : virtual void storeResourcesAsURL( const ::rtl::OUString& URL, const ::rtl::OUString& NewName ) = 0;
598 : : virtual void storeResourcesToURL( const ::rtl::OUString& URL,
599 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) = 0;
600 : : virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
601 : : < ::com::sun::star::embed::XStorage >& xStorage ) = 0;
602 : :
603 : : protected:
604 : 304 : inline sal_Bool implIsModified() const { return mbIsModified; }
605 : : void implSetModified( sal_Bool _bIsModified );
606 : :
607 : : private:
608 : : /** checks whether the lib is readonly, or a readonly link, throws an IllegalArgumentException if so
609 : : */
610 : : void impl_checkReadOnly();
611 : : /** checks whether the library is loaded, throws a LibraryNotLoadedException (wrapped in a WrappedTargetException),
612 : : if not.
613 : : */
614 : : void impl_checkLoaded();
615 : :
616 : : private:
617 : : void impl_removeWithoutChecks( const ::rtl::OUString& _rElementName );
618 : :
619 : : public:
620 : : SfxLibrary(
621 : : ModifiableHelper& _rModifiable,
622 : : const ::com::sun::star::uno::Type& aType,
623 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
624 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 >& xSFI
625 : : );
626 : : SfxLibrary(
627 : : ModifiableHelper& _rModifiable,
628 : : const ::com::sun::star::uno::Type& aType,
629 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
630 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 >& xSFI,
631 : : const ::rtl::OUString& aLibInfoFileURL,
632 : : const ::rtl::OUString&
633 : : aStorageURL,
634 : : sal_Bool ReadOnly
635 : : );
636 : :
637 : : // Methods XInterface
638 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException );
639 : 33054 : virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
640 : 32983 : virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
641 : :
642 : : // Methods XElementAccess
643 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
644 : : throw(::com::sun::star::uno::RuntimeException);
645 : : virtual sal_Bool SAL_CALL hasElements( )
646 : : throw(::com::sun::star::uno::RuntimeException);
647 : :
648 : : // Methods XNameAccess
649 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
650 : : throw(::com::sun::star::container::NoSuchElementException,
651 : : ::com::sun::star::lang::WrappedTargetException,
652 : : ::com::sun::star::uno::RuntimeException);
653 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
654 : : throw(::com::sun::star::uno::RuntimeException);
655 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
656 : : throw(::com::sun::star::uno::RuntimeException);
657 : :
658 : : // Methods XNameReplace
659 : : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
660 : : throw(::com::sun::star::lang::IllegalArgumentException,
661 : : ::com::sun::star::container::NoSuchElementException,
662 : : ::com::sun::star::lang::WrappedTargetException,
663 : : ::com::sun::star::uno::RuntimeException);
664 : :
665 : : // Methods XNameContainer
666 : : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
667 : : throw(::com::sun::star::lang::IllegalArgumentException,
668 : : ::com::sun::star::container::ElementExistException,
669 : : ::com::sun::star::lang::WrappedTargetException,
670 : : ::com::sun::star::uno::RuntimeException);
671 : : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
672 : : throw(::com::sun::star::container::NoSuchElementException,
673 : : ::com::sun::star::lang::WrappedTargetException,
674 : : ::com::sun::star::uno::RuntimeException);
675 : :
676 : : // XTypeProvider
677 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
678 : : throw( ::com::sun::star::uno::RuntimeException );
679 : : ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( )
680 : : throw( ::com::sun::star::uno::RuntimeException );
681 : :
682 : : // Methods XContainer
683 : : virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference<
684 : : ::com::sun::star::container::XContainerListener >& xListener )
685 : : throw (::com::sun::star::uno::RuntimeException);
686 : : virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference<
687 : : ::com::sun::star::container::XContainerListener >& xListener )
688 : : throw (::com::sun::star::uno::RuntimeException);
689 : :
690 : : // Methods XChangesNotifier
691 : : virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference<
692 : : ::com::sun::star::util::XChangesListener >& xListener )
693 : : throw (::com::sun::star::uno::RuntimeException);
694 : : virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
695 : : ::com::sun::star::util::XChangesListener >& xListener )
696 : : throw (::com::sun::star::uno::RuntimeException);
697 : :
698 : : public:
699 : 0 : struct LibraryContainerAccess { friend class SfxLibraryContainer; private: LibraryContainerAccess() { } };
700 : 0 : void removeElementWithoutChecks( const ::rtl::OUString& _rElementName, LibraryContainerAccess )
701 : : {
702 : 0 : impl_removeWithoutChecks( _rElementName );
703 : 0 : }
704 : :
705 : : protected:
706 : : virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
707 : : };
708 : :
709 : : //============================================================================
710 : :
711 [ + - ]: 992 : class ScriptSubPackageIterator
712 : : {
713 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > m_xMainPackage;
714 : :
715 : : bool m_bIsValid;
716 : : bool m_bIsBundle;
717 : :
718 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
719 : : < com::sun::star::deployment::XPackage > > m_aSubPkgSeq;
720 : : sal_Int32 m_nSubPkgCount;
721 : : sal_Int32 m_iNextSubPkg;
722 : :
723 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
724 : : implDetectScriptPackage( const com::sun::star::uno::Reference
725 : : < com::sun::star::deployment::XPackage > xPackage, bool& rbPureDialogLib );
726 : :
727 : : public:
728 : : ScriptSubPackageIterator( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xMainPackage );
729 : :
730 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > getNextScriptSubPackage( bool& rbPureDialogLib );
731 : : };
732 : :
733 : : //============================================================================
734 : :
735 [ + - ][ + - ]: 226 : class ScriptExtensionIterator
[ + - ]
736 : : {
737 : : public:
738 : : ScriptExtensionIterator( void );
739 : : rtl::OUString nextBasicOrDialogLibrary( bool& rbPureDialogLib );
740 : :
741 : : protected:
742 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
743 : : implGetNextUserScriptPackage( bool& rbPureDialogLib );
744 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
745 : : implGetNextSharedScriptPackage( bool& rbPureDialogLib );
746 : : com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >
747 : : implGetNextBundledScriptPackage( bool& rbPureDialogLib );
748 : :
749 : : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
750 : :
751 : : enum IteratorState
752 : : {
753 : : USER_EXTENSIONS,
754 : : SHARED_EXTENSIONS,
755 : : BUNDLED_EXTENSIONS,
756 : : END_REACHED
757 : : } m_eState;
758 : :
759 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
760 : : < com::sun::star::deployment::XPackage > > m_aUserPackagesSeq;
761 : : bool m_bUserPackagesLoaded;
762 : :
763 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
764 : : < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
765 : : bool m_bSharedPackagesLoaded;
766 : :
767 : : com::sun::star::uno::Sequence< com::sun::star::uno::Reference
768 : : < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
769 : : bool m_bBundledPackagesLoaded;
770 : :
771 : : int m_iUserPackage;
772 : : int m_iSharedPackage;
773 : : int m_iBundledPackage;
774 : :
775 : : ScriptSubPackageIterator* m_pScriptSubPackageIterator;
776 : :
777 : : }; // end class ScriptExtensionIterator
778 : :
779 : : //============================================================================
780 : :
781 : : } // namespace basic
782 : :
783 : : #endif
784 : :
785 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|