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