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