xref: /aoo42x/main/svl/source/fsstor/fsstorage.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __XSTORAGE_HXX_
29 #define __XSTORAGE_HXX_
30 
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/embed/XStorage.hpp>
33 #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/io/XStream.hpp>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 #include <com/sun/star/lang/XTypeProvider.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
41 #include <com/sun/star/packages/NoEncryptionException.hpp>
42 #include <cppuhelper/weak.hxx>
43 #include <cppuhelper/interfacecontainer.h>
44 
45 #include <ucbhelper/content.hxx>
46 
47 struct FSStorage_Impl;
48 class FSStorage	: public ::com::sun::star::lang::XTypeProvider
49 				, public ::com::sun::star::embed::XStorage
50 				, public ::com::sun::star::embed::XHierarchicalStorageAccess
51 				, public ::com::sun::star::beans::XPropertySet
52 				, public ::cppu::OWeakObject
53 {
54 	::osl::Mutex m_aMutex;
55 	FSStorage_Impl* m_pImpl;
56 
57 protected:
58 
59 public:
60 
61 	FSStorage(	const ::ucbhelper::Content& aContent,
62 				sal_Int32 nMode,
63 				::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > xProperties,
64 				::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory );
65 
66 	virtual ~FSStorage();
67 
68 	::ucbhelper::Content* GetContent();
69 
70 	void CopyStreamToSubStream( const ::rtl::OUString& aSourceURL,
71 								const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
72 								const ::rtl::OUString& aNewEntryName );
73 
74 	void CopyContentToStorage_Impl( ::ucbhelper::Content* pContent,
75 									const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest );
76 
77 	static sal_Bool MakeFolderNoUI( const String& rFolder, sal_Bool bNewOnly );
78 
79 	//____________________________________________________________________________________________________
80 	//	XInterface
81 	//____________________________________________________________________________________________________
82 
83 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
84 		throw( ::com::sun::star::uno::RuntimeException );
85 
86     virtual void SAL_CALL acquire() throw();
87 
88     virtual void SAL_CALL release() throw();
89 
90 	//____________________________________________________________________________________________________
91 	//	XTypeProvider
92 	//____________________________________________________________________________________________________
93 
94 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
95 		throw( ::com::sun::star::uno::RuntimeException );
96 
97 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
98 		throw( ::com::sun::star::uno::RuntimeException );
99 
100 	//____________________________________________________________________________________________________
101 	//	XStorage
102 	//____________________________________________________________________________________________________
103 
104     virtual void SAL_CALL copyToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest )
105 		throw ( ::com::sun::star::embed::InvalidStorageException,
106 				::com::sun::star::lang::IllegalArgumentException,
107 				::com::sun::star::io::IOException,
108 				::com::sun::star::embed::StorageWrappedTargetException,
109 				::com::sun::star::uno::RuntimeException );
110 
111     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openStreamElement(
112 			const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode )
113 		throw ( ::com::sun::star::embed::InvalidStorageException,
114 				::com::sun::star::lang::IllegalArgumentException,
115 				::com::sun::star::packages::WrongPasswordException,
116 				::com::sun::star::io::IOException,
117 				::com::sun::star::embed::StorageWrappedTargetException,
118 				::com::sun::star::uno::RuntimeException );
119 
120     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openEncryptedStreamElement(
121 			const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, const ::rtl::OUString& aPass )
122 		throw ( ::com::sun::star::embed::InvalidStorageException,
123 				::com::sun::star::lang::IllegalArgumentException,
124 				::com::sun::star::packages::NoEncryptionException,
125 				::com::sun::star::packages::WrongPasswordException,
126 				::com::sun::star::io::IOException,
127 				::com::sun::star::embed::StorageWrappedTargetException,
128 				::com::sun::star::uno::RuntimeException );
129 
130     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL openStorageElement(
131 			const ::rtl::OUString& aStorName, sal_Int32 nStorageMode )
132 		throw ( ::com::sun::star::embed::InvalidStorageException,
133 				::com::sun::star::lang::IllegalArgumentException,
134 				::com::sun::star::io::IOException,
135 				::com::sun::star::embed::StorageWrappedTargetException,
136 				::com::sun::star::uno::RuntimeException );
137 
138     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL cloneStreamElement(
139 			const ::rtl::OUString& aStreamName )
140 		throw ( ::com::sun::star::embed::InvalidStorageException,
141 				::com::sun::star::lang::IllegalArgumentException,
142 				::com::sun::star::packages::WrongPasswordException,
143 				::com::sun::star::io::IOException,
144 				::com::sun::star::embed::StorageWrappedTargetException,
145 				::com::sun::star::uno::RuntimeException );
146 
147     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL cloneEncryptedStreamElement(
148 			const ::rtl::OUString& aStreamName, const ::rtl::OUString& aPass )
149 		throw ( ::com::sun::star::embed::InvalidStorageException,
150 				::com::sun::star::lang::IllegalArgumentException,
151 				::com::sun::star::packages::NoEncryptionException,
152 				::com::sun::star::packages::WrongPasswordException,
153 				::com::sun::star::io::IOException,
154 				::com::sun::star::embed::StorageWrappedTargetException,
155 				::com::sun::star::uno::RuntimeException );
156 
157     virtual void SAL_CALL copyLastCommitTo(
158 			const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xTargetStorage )
159 		throw ( ::com::sun::star::embed::InvalidStorageException,
160 				::com::sun::star::lang::IllegalArgumentException,
161 				::com::sun::star::io::IOException,
162 				::com::sun::star::embed::StorageWrappedTargetException,
163 				::com::sun::star::uno::RuntimeException );
164 
165     virtual void SAL_CALL copyStorageElementLastCommitTo(
166 			const ::rtl::OUString& aStorName,
167 			const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xTargetStorage )
168 		throw ( ::com::sun::star::embed::InvalidStorageException,
169 				::com::sun::star::lang::IllegalArgumentException,
170 				::com::sun::star::io::IOException,
171 				::com::sun::star::embed::StorageWrappedTargetException,
172 				::com::sun::star::uno::RuntimeException );
173 
174     virtual sal_Bool SAL_CALL isStreamElement( const ::rtl::OUString& aElementName )
175 		throw ( ::com::sun::star::container::NoSuchElementException,
176 				::com::sun::star::lang::IllegalArgumentException,
177 				::com::sun::star::embed::InvalidStorageException,
178 				::com::sun::star::uno::RuntimeException );
179 
180     virtual sal_Bool SAL_CALL isStorageElement( const ::rtl::OUString& aElementName )
181 		throw ( ::com::sun::star::container::NoSuchElementException,
182 				::com::sun::star::lang::IllegalArgumentException,
183 				::com::sun::star::embed::InvalidStorageException,
184 				::com::sun::star::uno::RuntimeException );
185 
186     virtual void SAL_CALL removeElement( const ::rtl::OUString& aElementName )
187 		throw ( ::com::sun::star::embed::InvalidStorageException,
188 				::com::sun::star::lang::IllegalArgumentException,
189 				::com::sun::star::container::NoSuchElementException,
190 				::com::sun::star::io::IOException,
191 				::com::sun::star::embed::StorageWrappedTargetException,
192 				::com::sun::star::uno::RuntimeException );
193 
194     virtual void SAL_CALL renameElement( const ::rtl::OUString& rEleName, const ::rtl::OUString& rNewName )
195 		throw ( ::com::sun::star::embed::InvalidStorageException,
196 				::com::sun::star::lang::IllegalArgumentException,
197 				::com::sun::star::container::NoSuchElementException,
198 				::com::sun::star::container::ElementExistException,
199 				::com::sun::star::io::IOException,
200 				::com::sun::star::embed::StorageWrappedTargetException,
201 				::com::sun::star::uno::RuntimeException );
202 
203     virtual void SAL_CALL copyElementTo(	const ::rtl::OUString& aElementName,
204 										const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
205 										const ::rtl::OUString& aNewName )
206 		throw ( ::com::sun::star::embed::InvalidStorageException,
207 				::com::sun::star::lang::IllegalArgumentException,
208 				::com::sun::star::container::NoSuchElementException,
209 				::com::sun::star::container::ElementExistException,
210 				::com::sun::star::io::IOException,
211 				::com::sun::star::embed::StorageWrappedTargetException,
212 				::com::sun::star::uno::RuntimeException );
213 
214     virtual void SAL_CALL moveElementTo(	const ::rtl::OUString& aElementName,
215 										const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
216 										const ::rtl::OUString& rNewName )
217 		throw ( ::com::sun::star::embed::InvalidStorageException,
218 				::com::sun::star::lang::IllegalArgumentException,
219 				::com::sun::star::container::NoSuchElementException,
220 				::com::sun::star::container::ElementExistException,
221 				::com::sun::star::io::IOException,
222 				::com::sun::star::embed::StorageWrappedTargetException,
223 				::com::sun::star::uno::RuntimeException );
224 
225 	//____________________________________________________________________________________________________
226 	//	XNameAccess
227 	//____________________________________________________________________________________________________
228 
229     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
230 		throw ( ::com::sun::star::container::NoSuchElementException,
231 				::com::sun::star::lang::WrappedTargetException,
232 				::com::sun::star::uno::RuntimeException );
233 
234     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
235 		throw ( ::com::sun::star::uno::RuntimeException );
236 
237     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
238 		throw ( ::com::sun::star::uno::RuntimeException );
239 
240     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
241 		throw ( ::com::sun::star::uno::RuntimeException );
242 
243     virtual sal_Bool SAL_CALL hasElements()
244 		throw ( ::com::sun::star::uno::RuntimeException );
245 
246 	//____________________________________________________________________________________________________
247 	//	XComponent
248 	//____________________________________________________________________________________________________
249 
250     virtual void SAL_CALL dispose()
251 		throw ( ::com::sun::star::uno::RuntimeException );
252 
253     virtual void SAL_CALL addEventListener(
254 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
255 		throw ( ::com::sun::star::uno::RuntimeException );
256 
257     virtual void SAL_CALL removeEventListener(
258 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
259 		throw ( ::com::sun::star::uno::RuntimeException );
260 
261 	//____________________________________________________________________________________________________
262 	//	XPropertySet
263 	//____________________________________________________________________________________________________
264 
265     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
266 		throw ( ::com::sun::star::uno::RuntimeException );
267 
268     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
269 		throw ( ::com::sun::star::beans::UnknownPropertyException,
270 				::com::sun::star::beans::PropertyVetoException,
271 				::com::sun::star::lang::IllegalArgumentException,
272 				::com::sun::star::lang::WrappedTargetException,
273 				::com::sun::star::uno::RuntimeException );
274 
275     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
276 		throw ( ::com::sun::star::beans::UnknownPropertyException,
277 				::com::sun::star::lang::WrappedTargetException,
278 				::com::sun::star::uno::RuntimeException );
279 
280     virtual void SAL_CALL addPropertyChangeListener(
281 			const ::rtl::OUString& aPropertyName,
282 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
283 		throw ( ::com::sun::star::beans::UnknownPropertyException,
284 				::com::sun::star::lang::WrappedTargetException,
285 				::com::sun::star::uno::RuntimeException );
286 
287     virtual void SAL_CALL removePropertyChangeListener(
288 			const ::rtl::OUString& aPropertyName,
289 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
290 		throw ( ::com::sun::star::beans::UnknownPropertyException,
291 				::com::sun::star::lang::WrappedTargetException,
292 				::com::sun::star::uno::RuntimeException );
293 
294     virtual void SAL_CALL addVetoableChangeListener(
295 			const ::rtl::OUString& PropertyName,
296 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
297 		throw ( ::com::sun::star::beans::UnknownPropertyException,
298 				::com::sun::star::lang::WrappedTargetException,
299 				::com::sun::star::uno::RuntimeException );
300 
301     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
302 		throw ( ::com::sun::star::beans::UnknownPropertyException,
303 				::com::sun::star::lang::WrappedTargetException,
304 				::com::sun::star::uno::RuntimeException );
305 
306 	//____________________________________________________________________________________________________
307 	//	XHierarchicalStorageAccess
308 	//____________________________________________________________________________________________________
309 
310     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > SAL_CALL openStreamElementByHierarchicalName( const ::rtl::OUString& sStreamPath, ::sal_Int32 nOpenMode )
311 		throw ( ::com::sun::star::embed::InvalidStorageException,
312 				::com::sun::star::lang::IllegalArgumentException,
313 				::com::sun::star::packages::WrongPasswordException,
314 				::com::sun::star::io::IOException,
315 				::com::sun::star::embed::StorageWrappedTargetException,
316 				::com::sun::star::uno::RuntimeException );
317 
318     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > SAL_CALL openEncryptedStreamElementByHierarchicalName( const ::rtl::OUString& sStreamName, ::sal_Int32 nOpenMode, const ::rtl::OUString& sPassword )
319 		throw ( ::com::sun::star::embed::InvalidStorageException,
320 				::com::sun::star::lang::IllegalArgumentException,
321 				::com::sun::star::packages::NoEncryptionException,
322 				::com::sun::star::packages::WrongPasswordException,
323 				::com::sun::star::io::IOException,
324 				::com::sun::star::embed::StorageWrappedTargetException,
325 				::com::sun::star::uno::RuntimeException );
326 
327     virtual void SAL_CALL removeStreamElementByHierarchicalName( const ::rtl::OUString& sElementPath )
328 		throw ( ::com::sun::star::embed::InvalidStorageException,
329 				::com::sun::star::lang::IllegalArgumentException,
330 				::com::sun::star::container::NoSuchElementException,
331 				::com::sun::star::io::IOException,
332 				::com::sun::star::embed::StorageWrappedTargetException,
333 				::com::sun::star::uno::RuntimeException );
334 };
335 
336 #endif
337 
338