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