1*6df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6df1ea1fSAndrew Rist  * distributed with this work for additional information
6*6df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
9*6df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6df1ea1fSAndrew Rist  *
11*6df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6df1ea1fSAndrew Rist  *
13*6df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
15*6df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*6df1ea1fSAndrew Rist  * specific language governing permissions and limitations
18*6df1ea1fSAndrew Rist  * under the License.
19*6df1ea1fSAndrew Rist  *
20*6df1ea1fSAndrew Rist  *************************************************************/
21*6df1ea1fSAndrew Rist 
22*6df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_TDOC_STGELEMS_HXX
25cdf0e10cSrcweir #define INCLUDED_TDOC_STGELEMS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <memory>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "osl/mutex.hxx"
30cdf0e10cSrcweir #include "rtl/ref.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "cppuhelper/implbase2.hxx"
33cdf0e10cSrcweir #include "cppuhelper/implbase5.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "com/sun/star/embed/XStorage.hpp"
36cdf0e10cSrcweir #include "com/sun/star/embed/XTransactedObject.hpp"
37cdf0e10cSrcweir #include "com/sun/star/io/XOutputStream.hpp"
38cdf0e10cSrcweir #include "com/sun/star/io/XStream.hpp"
39cdf0e10cSrcweir #include "com/sun/star/io/XTruncate.hpp"
40cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "tdoc_storage.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace tdoc_ucp {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir struct MutexHolder
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     osl::Mutex m_aMutex;
49cdf0e10cSrcweir };
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //=======================================================================
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class ParentStorageHolder : public MutexHolder
54cdf0e10cSrcweir {
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir     ParentStorageHolder(
57cdf0e10cSrcweir         const com::sun::star::uno::Reference<
58cdf0e10cSrcweir             com::sun::star::embed::XStorage > & xParentStorage,
59cdf0e10cSrcweir         const rtl::OUString & rUri );
60cdf0e10cSrcweir 
isParentARootStorage() const61cdf0e10cSrcweir     bool isParentARootStorage() const
62cdf0e10cSrcweir     { return m_bParentIsRootStorage; }
63cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
getParentStorage() const64cdf0e10cSrcweir     getParentStorage() const
65cdf0e10cSrcweir     { return m_xParentStorage; }
setParentStorage(const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStg)66cdf0e10cSrcweir     void setParentStorage( const com::sun::star::uno::Reference<
67cdf0e10cSrcweir                             com::sun::star::embed::XStorage > & xStg )
68cdf0e10cSrcweir     { osl::MutexGuard aGuard( m_aMutex ); m_xParentStorage = xStg; }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir private:
71cdf0e10cSrcweir     com::sun::star::uno::Reference<
72cdf0e10cSrcweir         com::sun::star::embed::XStorage > m_xParentStorage;
73cdf0e10cSrcweir     bool                                  m_bParentIsRootStorage;
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //=======================================================================
77cdf0e10cSrcweir 
78cdf0e10cSrcweir typedef
79cdf0e10cSrcweir     cppu::WeakImplHelper2<
80cdf0e10cSrcweir         com::sun::star::embed::XStorage,
81cdf0e10cSrcweir         com::sun::star::embed::XTransactedObject > StorageUNOBase;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir class Storage : public StorageUNOBase, public ParentStorageHolder
84cdf0e10cSrcweir {
85cdf0e10cSrcweir public:
86cdf0e10cSrcweir     Storage(
87cdf0e10cSrcweir         const com::sun::star::uno::Reference<
88cdf0e10cSrcweir             com::sun::star::lang::XMultiServiceFactory > & xSMgr,
89cdf0e10cSrcweir         const rtl::Reference< StorageElementFactory >  & xFactory,
90cdf0e10cSrcweir         const rtl::OUString & rUri,
91cdf0e10cSrcweir         const com::sun::star::uno::Reference<
92cdf0e10cSrcweir             com::sun::star::embed::XStorage > & xParentStorage,
93cdf0e10cSrcweir         const com::sun::star::uno::Reference<
94cdf0e10cSrcweir             com::sun::star::embed::XStorage > & xStorageToWrap );
95cdf0e10cSrcweir     virtual ~Storage();
96cdf0e10cSrcweir 
isDocumentStorage() const97cdf0e10cSrcweir     bool isDocumentStorage() const { return m_bIsDocumentStorage; }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     // XInterface
100cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL queryInterface(
101cdf0e10cSrcweir             const com::sun::star::uno::Type& aType )
102cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
103cdf0e10cSrcweir     virtual void SAL_CALL acquire()
104cdf0e10cSrcweir         throw ();
105cdf0e10cSrcweir     virtual void SAL_CALL release()
106cdf0e10cSrcweir         throw ();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     // XTypeProvider (implemnented by base, but needs to be overridden for
109cdf0e10cSrcweir     //                delegating to aggregate)
110cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
111cdf0e10cSrcweir     getTypes()
112cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
113cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
114cdf0e10cSrcweir     getImplementationId()
115cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     // XComponent ( one of XStorage bases )
118cdf0e10cSrcweir     virtual void SAL_CALL
119cdf0e10cSrcweir     dispose()
120cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
121cdf0e10cSrcweir     virtual void SAL_CALL
122cdf0e10cSrcweir     addEventListener( const com::sun::star::uno::Reference<
123cdf0e10cSrcweir                         com::sun::star::lang::XEventListener > & xListener )
124cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
125cdf0e10cSrcweir     virtual void SAL_CALL
126cdf0e10cSrcweir     removeEventListener( const com::sun::star::uno::Reference<
127cdf0e10cSrcweir                             com::sun::star::lang::XEventListener >& aListener )
128cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     // XNameAccess ( one of XStorage bases )
131cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
132cdf0e10cSrcweir     getByName( const rtl::OUString& aName )
133cdf0e10cSrcweir         throw ( com::sun::star::container::NoSuchElementException,
134cdf0e10cSrcweir                 com::sun::star::lang::WrappedTargetException,
135cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
136cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
137cdf0e10cSrcweir     getElementNames()
138cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
139cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
140cdf0e10cSrcweir     hasByName( const rtl::OUString& aName )
141cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     // XElementAccess (base of XNameAccess)
144cdf0e10cSrcweir     virtual com::sun::star::uno::Type SAL_CALL
145cdf0e10cSrcweir     getElementType()
146cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
147cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
148cdf0e10cSrcweir     hasElements()
149cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     // XStorage
152cdf0e10cSrcweir     virtual void SAL_CALL
153cdf0e10cSrcweir     copyToStorage( const com::sun::star::uno::Reference<
154cdf0e10cSrcweir                     com::sun::star::embed::XStorage >& xDest )
155cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
156cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
157cdf0e10cSrcweir                 com::sun::star::io::IOException,
158cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
159cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
160cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL
161cdf0e10cSrcweir     openStreamElement( const ::rtl::OUString& aStreamName,
162cdf0e10cSrcweir                        sal_Int32 nOpenMode )
163cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
164cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
165cdf0e10cSrcweir                 com::sun::star::packages::WrongPasswordException,
166cdf0e10cSrcweir                 com::sun::star::io::IOException,
167cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
168cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
169cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL
170cdf0e10cSrcweir     openEncryptedStreamElement( const ::rtl::OUString& aStreamName,
171cdf0e10cSrcweir                                 sal_Int32 nOpenMode,
172cdf0e10cSrcweir                                 const ::rtl::OUString& aPassword )
173cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
174cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
175cdf0e10cSrcweir                 com::sun::star::packages::NoEncryptionException,
176cdf0e10cSrcweir                 com::sun::star::packages::WrongPasswordException,
177cdf0e10cSrcweir                 com::sun::star::io::IOException,
178cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
179cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
180cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::embed::XStorage > SAL_CALL
181cdf0e10cSrcweir     openStorageElement( const ::rtl::OUString& aStorName,
182cdf0e10cSrcweir                         sal_Int32 nOpenMode )
183cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
184cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
185cdf0e10cSrcweir                 com::sun::star::io::IOException,
186cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
187cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
188cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL
189cdf0e10cSrcweir     cloneStreamElement( const ::rtl::OUString& aStreamName )
190cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
191cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
192cdf0e10cSrcweir                 com::sun::star::packages::WrongPasswordException,
193cdf0e10cSrcweir                 com::sun::star::io::IOException,
194cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
195cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
196cdf0e10cSrcweir     virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL
197cdf0e10cSrcweir     cloneEncryptedStreamElement( const ::rtl::OUString& aStreamName,
198cdf0e10cSrcweir                                  const ::rtl::OUString& aPassword )
199cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
200cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
201cdf0e10cSrcweir                 com::sun::star::packages::NoEncryptionException,
202cdf0e10cSrcweir                 com::sun::star::packages::WrongPasswordException,
203cdf0e10cSrcweir                 com::sun::star::io::IOException,
204cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
205cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
206cdf0e10cSrcweir     virtual void SAL_CALL
207cdf0e10cSrcweir     copyLastCommitTo( const com::sun::star::uno::Reference<
208cdf0e10cSrcweir                         com::sun::star::embed::XStorage >& xTargetStorage )
209cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
210cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
211cdf0e10cSrcweir                 com::sun::star::io::IOException,
212cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
213cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
214cdf0e10cSrcweir     virtual void SAL_CALL
215cdf0e10cSrcweir     copyStorageElementLastCommitTo( const ::rtl::OUString& aStorName,
216cdf0e10cSrcweir                                     const com::sun::star::uno::Reference<
217cdf0e10cSrcweir                                         com::sun::star::embed::XStorage > &
218cdf0e10cSrcweir                                             xTargetStorage )
219cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
220cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
221cdf0e10cSrcweir                 com::sun::star::io::IOException,
222cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
223cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
224cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
225cdf0e10cSrcweir     isStreamElement( const ::rtl::OUString& aElementName )
226cdf0e10cSrcweir         throw ( com::sun::star::container::NoSuchElementException,
227cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
228cdf0e10cSrcweir                 com::sun::star::embed::InvalidStorageException,
229cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
230cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
231cdf0e10cSrcweir     isStorageElement( const ::rtl::OUString& aElementName )
232cdf0e10cSrcweir         throw ( com::sun::star::container::NoSuchElementException,
233cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
234cdf0e10cSrcweir                 com::sun::star::embed::InvalidStorageException,
235cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
236cdf0e10cSrcweir     virtual void SAL_CALL
237cdf0e10cSrcweir     removeElement( const ::rtl::OUString& aElementName )
238cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
239cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
240cdf0e10cSrcweir                 com::sun::star::container::NoSuchElementException,
241cdf0e10cSrcweir                 com::sun::star::io::IOException,
242cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
243cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
244cdf0e10cSrcweir     virtual void SAL_CALL
245cdf0e10cSrcweir     renameElement( const ::rtl::OUString& aEleName,
246cdf0e10cSrcweir                    const ::rtl::OUString& aNewName )
247cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
248cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
249cdf0e10cSrcweir                 com::sun::star::container::NoSuchElementException,
250cdf0e10cSrcweir                 com::sun::star::container::ElementExistException,
251cdf0e10cSrcweir                 com::sun::star::io::IOException,
252cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
253cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
254cdf0e10cSrcweir     virtual void SAL_CALL
255cdf0e10cSrcweir     copyElementTo( const ::rtl::OUString& aElementName,
256cdf0e10cSrcweir                    const com::sun::star::uno::Reference<
257cdf0e10cSrcweir                     com::sun::star::embed::XStorage >& xDest,
258cdf0e10cSrcweir                    const ::rtl::OUString& aNewName )
259cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
260cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
261cdf0e10cSrcweir                 com::sun::star::container::NoSuchElementException,
262cdf0e10cSrcweir                 com::sun::star::container::ElementExistException,
263cdf0e10cSrcweir                 com::sun::star::io::IOException,
264cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
265cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
266cdf0e10cSrcweir     virtual void SAL_CALL
267cdf0e10cSrcweir     moveElementTo( const ::rtl::OUString& aElementName,
268cdf0e10cSrcweir                    const com::sun::star::uno::Reference<
269cdf0e10cSrcweir                     com::sun::star::embed::XStorage >& xDest,
270cdf0e10cSrcweir                    const ::rtl::OUString& rNewName )
271cdf0e10cSrcweir         throw ( com::sun::star::embed::InvalidStorageException,
272cdf0e10cSrcweir                 com::sun::star::lang::IllegalArgumentException,
273cdf0e10cSrcweir                 com::sun::star::container::NoSuchElementException,
274cdf0e10cSrcweir                 com::sun::star::container::ElementExistException,
275cdf0e10cSrcweir                 com::sun::star::io::IOException,
276cdf0e10cSrcweir                 com::sun::star::embed::StorageWrappedTargetException,
277cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     // XTransactedObject
280cdf0e10cSrcweir     virtual void SAL_CALL commit()
281cdf0e10cSrcweir         throw ( com::sun::star::io::IOException,
282cdf0e10cSrcweir                 com::sun::star::lang::WrappedTargetException,
283cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
284cdf0e10cSrcweir     virtual void SAL_CALL revert()
285cdf0e10cSrcweir         throw ( com::sun::star::io::IOException,
286cdf0e10cSrcweir                 com::sun::star::lang::WrappedTargetException,
287cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir private:
290cdf0e10cSrcweir     Storage( const rtl::Reference< Storage > & rFactory ); // n.i.
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     rtl::Reference< StorageElementFactory >         m_xFactory;
293cdf0e10cSrcweir     com::sun::star::uno::Reference<
294cdf0e10cSrcweir         com::sun::star::uno::XAggregation >         m_xAggProxy;
295cdf0e10cSrcweir     com::sun::star::uno::Reference<
296cdf0e10cSrcweir         com::sun::star::embed::XStorage >           m_xWrappedStorage;
297cdf0e10cSrcweir     com::sun::star::uno::Reference<
298cdf0e10cSrcweir         com::sun::star::embed::XTransactedObject >  m_xWrappedTransObj;
299cdf0e10cSrcweir     com::sun::star::uno::Reference<
300cdf0e10cSrcweir         com::sun::star::lang::XComponent >          m_xWrappedComponent;
301cdf0e10cSrcweir     com::sun::star::uno::Reference<
302cdf0e10cSrcweir         com::sun::star::lang::XTypeProvider >       m_xWrappedTypeProv;
303cdf0e10cSrcweir     bool                                            m_bIsDocumentStorage;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir     StorageElementFactory::StorageMap::iterator m_aContainerIt;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     friend class StorageElementFactory;
308cdf0e10cSrcweir     friend class std::auto_ptr< Storage >;
309cdf0e10cSrcweir };
310cdf0e10cSrcweir 
311cdf0e10cSrcweir //=======================================================================
312cdf0e10cSrcweir 
313cdf0e10cSrcweir typedef
314cdf0e10cSrcweir     cppu::WeakImplHelper2<
315cdf0e10cSrcweir         com::sun::star::io::XOutputStream,
316cdf0e10cSrcweir         com::sun::star::lang::XComponent > OutputStreamUNOBase;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir class OutputStream : public OutputStreamUNOBase, public ParentStorageHolder
319cdf0e10cSrcweir {
320cdf0e10cSrcweir public:
321cdf0e10cSrcweir     OutputStream(
322cdf0e10cSrcweir         const com::sun::star::uno::Reference<
323cdf0e10cSrcweir             com::sun::star::lang::XMultiServiceFactory > & xSMgr,
324cdf0e10cSrcweir         const rtl::OUString & rUri,
325cdf0e10cSrcweir         const com::sun::star::uno::Reference<
326cdf0e10cSrcweir             com::sun::star::embed::XStorage >  & xParentStorage,
327cdf0e10cSrcweir         const com::sun::star::uno::Reference<
328cdf0e10cSrcweir             com::sun::star::io::XOutputStream > & xStreamToWrap );
329cdf0e10cSrcweir     virtual ~OutputStream();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     // XInterface
332cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
333cdf0e10cSrcweir     queryInterface( const com::sun::star::uno::Type& aType )
334cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     // XTypeProvider (implemnented by base, but needs to be overridden for
337cdf0e10cSrcweir     //                delegating to aggregate)
338cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
339cdf0e10cSrcweir     getTypes()
340cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
341cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
342cdf0e10cSrcweir     getImplementationId()
343cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     // XOutputStream
346cdf0e10cSrcweir     virtual void SAL_CALL
347cdf0e10cSrcweir     writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
348cdf0e10cSrcweir         throw ( com::sun::star::io::NotConnectedException,
349cdf0e10cSrcweir                 com::sun::star::io::BufferSizeExceededException,
350cdf0e10cSrcweir                 com::sun::star::io::IOException,
351cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
352cdf0e10cSrcweir     virtual void SAL_CALL
353cdf0e10cSrcweir     flush(  )
354cdf0e10cSrcweir         throw ( com::sun::star::io::NotConnectedException,
355cdf0e10cSrcweir                 com::sun::star::io::BufferSizeExceededException,
356cdf0e10cSrcweir                 com::sun::star::io::IOException,
357cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
358cdf0e10cSrcweir     // Note: We need to intercept this one.
359cdf0e10cSrcweir     virtual void SAL_CALL
360cdf0e10cSrcweir     closeOutput(  )
361cdf0e10cSrcweir         throw ( com::sun::star::io::NotConnectedException,
362cdf0e10cSrcweir                 com::sun::star::io::BufferSizeExceededException,
363cdf0e10cSrcweir                 com::sun::star::io::IOException,
364cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     // XComponent
367cdf0e10cSrcweir     // Note: We need to intercept this one.
368cdf0e10cSrcweir     virtual void SAL_CALL
369cdf0e10cSrcweir     dispose()
370cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
371cdf0e10cSrcweir     virtual void SAL_CALL
372cdf0e10cSrcweir     addEventListener( const com::sun::star::uno::Reference<
373cdf0e10cSrcweir                         com::sun::star::lang::XEventListener >& xListener )
374cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
375cdf0e10cSrcweir     virtual void SAL_CALL
376cdf0e10cSrcweir     removeEventListener( const com::sun::star::uno::Reference<
377cdf0e10cSrcweir                             com::sun::star::lang::XEventListener >& aListener )
378cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
379cdf0e10cSrcweir 
380cdf0e10cSrcweir private:
381cdf0e10cSrcweir     com::sun::star::uno::Reference<
382cdf0e10cSrcweir         com::sun::star::uno::XAggregation >     m_xAggProxy;
383cdf0e10cSrcweir     com::sun::star::uno::Reference<
384cdf0e10cSrcweir         com::sun::star::io::XOutputStream >     m_xWrappedStream;
385cdf0e10cSrcweir     com::sun::star::uno::Reference<
386cdf0e10cSrcweir         com::sun::star::lang::XComponent >      m_xWrappedComponent;
387cdf0e10cSrcweir     com::sun::star::uno::Reference<
388cdf0e10cSrcweir         com::sun::star::lang::XTypeProvider >   m_xWrappedTypeProv;
389cdf0e10cSrcweir };
390cdf0e10cSrcweir 
391cdf0e10cSrcweir //=======================================================================
392cdf0e10cSrcweir 
393cdf0e10cSrcweir typedef cppu::WeakImplHelper5< com::sun::star::io::XStream,
394cdf0e10cSrcweir                                com::sun::star::io::XOutputStream,
395cdf0e10cSrcweir                                com::sun::star::io::XTruncate,
396cdf0e10cSrcweir                                com::sun::star::io::XInputStream,
397cdf0e10cSrcweir                                com::sun::star::lang::XComponent >
398cdf0e10cSrcweir         StreamUNOBase;
399cdf0e10cSrcweir 
400cdf0e10cSrcweir class Stream : public StreamUNOBase, public ParentStorageHolder
401cdf0e10cSrcweir {
402cdf0e10cSrcweir public:
403cdf0e10cSrcweir     Stream(
404cdf0e10cSrcweir         const com::sun::star::uno::Reference<
405cdf0e10cSrcweir             com::sun::star::lang::XMultiServiceFactory > & xSMgr,
406cdf0e10cSrcweir         const rtl::OUString & rUri,
407cdf0e10cSrcweir         const com::sun::star::uno::Reference<
408cdf0e10cSrcweir             com::sun::star::embed::XStorage >  & xParentStorage,
409cdf0e10cSrcweir         const com::sun::star::uno::Reference<
410cdf0e10cSrcweir             com::sun::star::io::XStream > & xStreamToWrap );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     virtual ~Stream();
413cdf0e10cSrcweir 
414cdf0e10cSrcweir     // XInterface
415cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL
416cdf0e10cSrcweir     queryInterface( const com::sun::star::uno::Type& aType )
417cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     // XTypeProvider (implemnented by base, but needs to be overridden for
420cdf0e10cSrcweir     //                delegating to aggregate)
421cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
422cdf0e10cSrcweir     getTypes()
423cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
424cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
425cdf0e10cSrcweir     getImplementationId()
426cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     // XStream
429cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
430cdf0e10cSrcweir         com::sun::star::io::XInputStream > SAL_CALL
431cdf0e10cSrcweir     getInputStream()
432cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     virtual com::sun::star::uno::Reference<
435cdf0e10cSrcweir         com::sun::star::io::XOutputStream > SAL_CALL
436cdf0e10cSrcweir     getOutputStream()
437cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
438cdf0e10cSrcweir 
439cdf0e10cSrcweir     // XOutputStream
440cdf0e10cSrcweir     virtual void SAL_CALL
441cdf0e10cSrcweir     writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
442cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
443cdf0e10cSrcweir                com::sun::star::io::BufferSizeExceededException,
444cdf0e10cSrcweir                com::sun::star::io::IOException,
445cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     virtual void SAL_CALL
448cdf0e10cSrcweir     flush()
449cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
450cdf0e10cSrcweir                com::sun::star::io::BufferSizeExceededException,
451cdf0e10cSrcweir                com::sun::star::io::IOException,
452cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
453cdf0e10cSrcweir 
454cdf0e10cSrcweir     virtual void SAL_CALL
455cdf0e10cSrcweir     closeOutput()
456cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
457cdf0e10cSrcweir                com::sun::star::io::IOException,
458cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir     // XTruncate
461cdf0e10cSrcweir     virtual void SAL_CALL
462cdf0e10cSrcweir     truncate()
463cdf0e10cSrcweir         throw( com::sun::star::io::IOException,
464cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     // XInputStream
467cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
468cdf0e10cSrcweir     readBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData,
469cdf0e10cSrcweir                sal_Int32 nBytesToRead )
470cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
471cdf0e10cSrcweir                com::sun::star::io::BufferSizeExceededException,
472cdf0e10cSrcweir                com::sun::star::io::IOException,
473cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
476cdf0e10cSrcweir     readSomeBytes( com::sun::star::uno::Sequence< sal_Int8 >& aData,
477cdf0e10cSrcweir                    sal_Int32 nMaxBytesToRead )
478cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
479cdf0e10cSrcweir                com::sun::star::io::BufferSizeExceededException,
480cdf0e10cSrcweir                com::sun::star::io::IOException,
481cdf0e10cSrcweir                com::sun::star::uno::RuntimeException);
482cdf0e10cSrcweir 
483cdf0e10cSrcweir     virtual void SAL_CALL
484cdf0e10cSrcweir     skipBytes( sal_Int32 nBytesToSkip )
485cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
486cdf0e10cSrcweir                com::sun::star::io::BufferSizeExceededException,
487cdf0e10cSrcweir                com::sun::star::io::IOException,
488cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
491cdf0e10cSrcweir     available()
492cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
493cdf0e10cSrcweir                com::sun::star::io::IOException,
494cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     virtual void SAL_CALL
497cdf0e10cSrcweir     closeInput()
498cdf0e10cSrcweir         throw( com::sun::star::io::NotConnectedException,
499cdf0e10cSrcweir                com::sun::star::io::IOException,
500cdf0e10cSrcweir                com::sun::star::uno::RuntimeException );
501cdf0e10cSrcweir 
502cdf0e10cSrcweir     // XComponent
503cdf0e10cSrcweir     // Note: We need to intercept this one.
504cdf0e10cSrcweir     virtual void SAL_CALL
505cdf0e10cSrcweir     dispose()
506cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
507cdf0e10cSrcweir     virtual void SAL_CALL
508cdf0e10cSrcweir     addEventListener( const com::sun::star::uno::Reference<
509cdf0e10cSrcweir             com::sun::star::lang::XEventListener >& xListener )
510cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
511cdf0e10cSrcweir     virtual void SAL_CALL
512cdf0e10cSrcweir     removeEventListener( const com::sun::star::uno::Reference<
513cdf0e10cSrcweir             com::sun::star::lang::XEventListener >& aListener )
514cdf0e10cSrcweir         throw ( com::sun::star::uno::RuntimeException );
515cdf0e10cSrcweir 
516cdf0e10cSrcweir private:
517cdf0e10cSrcweir     void commitChanges()
518cdf0e10cSrcweir         throw( com::sun::star::io::IOException );
519cdf0e10cSrcweir 
520cdf0e10cSrcweir     com::sun::star::uno::Reference<
521cdf0e10cSrcweir         com::sun::star::uno::XAggregation >     m_xAggProxy;
522cdf0e10cSrcweir     com::sun::star::uno::Reference<
523cdf0e10cSrcweir         com::sun::star::io::XStream >           m_xWrappedStream;
524cdf0e10cSrcweir     com::sun::star::uno::Reference<
525cdf0e10cSrcweir         com::sun::star::io::XOutputStream >     m_xWrappedOutputStream;
526cdf0e10cSrcweir     com::sun::star::uno::Reference<
527cdf0e10cSrcweir         com::sun::star::io::XTruncate >         m_xWrappedTruncate;
528cdf0e10cSrcweir     com::sun::star::uno::Reference<
529cdf0e10cSrcweir         com::sun::star::io::XInputStream >      m_xWrappedInputStream;
530cdf0e10cSrcweir     com::sun::star::uno::Reference<
531cdf0e10cSrcweir         com::sun::star::lang::XComponent >      m_xWrappedComponent;
532cdf0e10cSrcweir     com::sun::star::uno::Reference<
533cdf0e10cSrcweir         com::sun::star::lang::XTypeProvider >   m_xWrappedTypeProv;
534cdf0e10cSrcweir };
535cdf0e10cSrcweir 
536cdf0e10cSrcweir } // namespace tdoc_ucp
537cdf0e10cSrcweir 
538cdf0e10cSrcweir #endif /* !INCLUDED_TDOC_STGELEMS_HXX */
539