1*f319bb99SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f319bb99SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f319bb99SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f319bb99SAndrew Rist  * distributed with this work for additional information
6*f319bb99SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f319bb99SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f319bb99SAndrew Rist  * "License"); you may not use this file except in compliance
9*f319bb99SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f319bb99SAndrew Rist  *
11*f319bb99SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f319bb99SAndrew Rist  *
13*f319bb99SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f319bb99SAndrew Rist  * software distributed under the License is distributed on an
15*f319bb99SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f319bb99SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f319bb99SAndrew Rist  * specific language governing permissions and limitations
18*f319bb99SAndrew Rist  * under the License.
19*f319bb99SAndrew Rist  *
20*f319bb99SAndrew Rist  *************************************************************/
21*f319bb99SAndrew Rist 
22*f319bb99SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _WRITESTREAM_HXX_
25cdf0e10cSrcweir #define _WRITESTREAM_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
28cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
29cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
30cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
31cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp>
32cdf0e10cSrcweir #include <com/sun/star/packages/XDataSinkEncrSupport.hpp>
33cdf0e10cSrcweir #include <com/sun/star/packages/NoEncryptionException.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
37cdf0e10cSrcweir #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
38cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
39cdf0e10cSrcweir #include <com/sun/star/embed/XRelationshipAccess.hpp>
40cdf0e10cSrcweir #include <com/sun/star/embed/XExtendedStorageStream.hpp>
41cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
42cdf0e10cSrcweir #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/StringPair.hpp>
45cdf0e10cSrcweir #include <com/sun/star/logging/XSimpleLogRing.hpp>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
49cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
50cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #include <list>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include "ocompinstream.hxx"
57cdf0e10cSrcweir #include "mutexholder.hxx"
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir struct PreCreationStruct
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	SotMutexHolderRef m_rMutexRef;
63cdf0e10cSrcweir 
PreCreationStructPreCreationStruct64cdf0e10cSrcweir 	PreCreationStruct()
65cdf0e10cSrcweir 	: m_rMutexRef( new SotMutexHolder )
66cdf0e10cSrcweir 	{}
67cdf0e10cSrcweir 
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir namespace cppu {
71cdf0e10cSrcweir 	class OTypeCollection;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir namespace package {
75cdf0e10cSrcweir     void StaticAddLog( const ::rtl::OUString& aMessage );
76cdf0e10cSrcweir     bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 );
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir struct WSInternalData_Impl
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	SotMutexHolderRef m_rSharedMutexRef;
82cdf0e10cSrcweir 	::cppu::OTypeCollection* m_pTypeCollection;
83cdf0e10cSrcweir 	::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners
84cdf0e10cSrcweir 	sal_Int32 m_nStorageType;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	// the mutex reference MUST NOT be empty
WSInternalData_ImplWSInternalData_Impl87cdf0e10cSrcweir 	WSInternalData_Impl( const SotMutexHolderRef rMutexRef, sal_Int32 nStorageType )
88cdf0e10cSrcweir 	: m_rSharedMutexRef( rMutexRef )
89cdf0e10cSrcweir 	, m_pTypeCollection( NULL )
90cdf0e10cSrcweir 	, m_aListenersContainer( rMutexRef->GetMutex() )
91cdf0e10cSrcweir 	, m_nStorageType( nStorageType )
92cdf0e10cSrcweir 	{}
93cdf0e10cSrcweir };
94cdf0e10cSrcweir 
95cdf0e10cSrcweir typedef ::std::list< OInputCompStream* > InputStreamsList_Impl;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir struct OStorage_Impl;
98cdf0e10cSrcweir class OWriteStream;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir struct OWriteStream_Impl : public PreCreationStruct
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	friend struct OStorage_Impl;
103cdf0e10cSrcweir 	friend class OWriteStream;
104cdf0e10cSrcweir 	friend class OInputCompStream;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	OWriteStream*	m_pAntiImpl;
107cdf0e10cSrcweir 	::rtl::OUString m_aTempURL;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xCacheStream;
110cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xCacheSeek;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	InputStreamsList_Impl m_aInputStreamsList;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     sal_Bool                        m_bHasDataToFlush;    // only modified elements will be sent to the original content
115cdf0e10cSrcweir     sal_Bool                        m_bFlushed;      // sending the streams is coordinated by the root storage of the package
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::packages::XDataSinkEncrSupport > m_xPackageStream;
118cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::logging::XSimpleLogRing >  m_xLogRing;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	OStorage_Impl* m_pParent;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aProps;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	sal_Bool m_bForceEncrypted;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	sal_Bool m_bUseCommonEncryption;
129cdf0e10cSrcweir 	sal_Bool m_bHasCachedEncryptionData;
130cdf0e10cSrcweir     ::comphelper::SequenceAsHashMap m_aEncryptionData;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     sal_Bool m_bCompressedSetExplicit;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > m_xPackage;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	sal_Bool m_bHasInsertedStreamOptimization;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	sal_Int32 m_nStorageType;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	// Relations info related data, stored in *.rels file in OFOPXML format
141cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xOrigRelInfoStream;
142cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > m_aOrigRelInfo;
143cdf0e10cSrcweir 	sal_Bool m_bOrigRelInfoBroken;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > m_aNewRelInfo;
146cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xNewRelInfoStream;
147cdf0e10cSrcweir 	sal_Int16 m_nRelInfoStatus;
148cdf0e10cSrcweir     sal_Int32 m_nRelId;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
151cdf0e10cSrcweir private:
152cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > GetServiceFactory();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     ::rtl::OUString GetFilledTempFileIfNo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream );
155cdf0e10cSrcweir 	::rtl::OUString FillTempGetFileName();
156cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >		GetTempFileAsStream();
157cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >	GetTempFileAsInputStream();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream_Impl( sal_Int32 nStreamMode,
160cdf0e10cSrcweir 																						sal_Bool bHierarchyAccess );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	::comphelper::SequenceAsHashMap GetCommonRootEncryptionData() throw ( ::com::sun::star::packages::NoEncryptionException );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > ReadPackageStreamProperties();
165cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > InsertOwnProps(
166cdf0e10cSrcweir 							const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps,
167cdf0e10cSrcweir 							sal_Bool bUseCommonEncryption );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir public:
170cdf0e10cSrcweir 	OWriteStream_Impl(
171cdf0e10cSrcweir 				OStorage_Impl* pParent,
172cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::packages::XDataSinkEncrSupport >& xPackageStream,
173cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >& xPackage,
174cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
175cdf0e10cSrcweir 				sal_Bool bForceEncrypted,
176cdf0e10cSrcweir 				sal_Int32 nStorageType,
177cdf0e10cSrcweir                 sal_Bool bDefaultCompress,
178cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xRelInfoStream =
179cdf0e10cSrcweir 					::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >() );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	~OWriteStream_Impl();
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     void CleanCacheStream();
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     void AddLog( const ::rtl::OUString& aMessage );
186cdf0e10cSrcweir 
UsesCommonEncryption_ImplOWriteStream_Impl187cdf0e10cSrcweir 	sal_Bool UsesCommonEncryption_Impl() { return m_bUseCommonEncryption; }
HasTempFile_ImplOWriteStream_Impl188cdf0e10cSrcweir 	sal_Bool HasTempFile_Impl() { return ( m_aTempURL.getLength() != 0 ); }
189cdf0e10cSrcweir 	sal_Bool IsTransacted();
190cdf0e10cSrcweir 
HasWriteOwner_ImplOWriteStream_Impl191cdf0e10cSrcweir 	sal_Bool HasWriteOwner_Impl() { return ( m_pAntiImpl != NULL ); }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	void InsertIntoPackageFolder(
194cdf0e10cSrcweir 			const ::rtl::OUString& aName,
195cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xParentPackageFolder );
196cdf0e10cSrcweir 
SetToBeCommitedOWriteStream_Impl197cdf0e10cSrcweir 	void SetToBeCommited() { m_bFlushed = sal_True; }
198cdf0e10cSrcweir 
HasCachedEncryptionDataOWriteStream_Impl199cdf0e10cSrcweir 	sal_Bool HasCachedEncryptionData() { return m_bHasCachedEncryptionData; }
GetCachedEncryptionDataOWriteStream_Impl200cdf0e10cSrcweir 	::comphelper::SequenceAsHashMap& GetCachedEncryptionData() { return m_aEncryptionData; }
201cdf0e10cSrcweir 
IsModifiedOWriteStream_Impl202cdf0e10cSrcweir 	sal_Bool IsModified() { return m_bHasDataToFlush || m_bFlushed; }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 	sal_Bool IsEncrypted();
205cdf0e10cSrcweir 	void SetDecrypted();
206cdf0e10cSrcweir 	void SetEncrypted( const ::comphelper::SequenceAsHashMap& aEncryptionData );
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	void DisposeWrappers();
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	void InsertStreamDirectly(
211cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream,
212cdf0e10cSrcweir 			const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	void Commit();
215cdf0e10cSrcweir 	void Revert();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	void Free( sal_Bool bMust ); // allows to try to disconnect from the temporary stream
218cdf0e10cSrcweir 				 				// in case bMust is set to sal_True the method
219cdf0e10cSrcweir 								// will throw exception in case the file is still busy
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	void SetModified(); // can be done only by parent storage after renaming
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetStreamProperties();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > GetAllRelationshipsIfAny();
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	void CopyInternallyTo_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xDestStream,
228cdf0e10cSrcweir 								const ::comphelper::SequenceAsHashMap& aEncryptionData );
229cdf0e10cSrcweir 	void CopyInternallyTo_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xDestStream );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream(
232cdf0e10cSrcweir 						sal_Int32 nStreamMode,
233cdf0e10cSrcweir 						const ::comphelper::SequenceAsHashMap& aEncryptionData,
234cdf0e10cSrcweir 						sal_Bool bHierarchyAccess );
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream(
237cdf0e10cSrcweir 						sal_Int32 nStreamMode,
238cdf0e10cSrcweir 						sal_Bool bHierarchyAccess );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetRawInStream();
242cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetPlainRawInStream();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	void InputStreamDisposed( OInputCompStream* pStream );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	void CreateReadonlyCopyBasedOnData(
247cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xDataToCopy,
248cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps,
249cdf0e10cSrcweir 					sal_Bool bUseCommonEncryption,
250cdf0e10cSrcweir 					::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	void GetCopyOfLastCommit( ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream );
253cdf0e10cSrcweir 	void GetCopyOfLastCommit(
254cdf0e10cSrcweir 				  ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream,
255cdf0e10cSrcweir 							const ::comphelper::SequenceAsHashMap& aEncryptionData );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	void CommitStreamRelInfo(
259cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xRelStorage,
260cdf0e10cSrcweir 					const ::rtl::OUString& aOrigStreamName,
261cdf0e10cSrcweir 					const ::rtl::OUString& aNewStreamName );
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	void ReadRelInfoIfNecessary();
264cdf0e10cSrcweir 
GetNewRelIdOWriteStream_Impl265cdf0e10cSrcweir     sal_Int32 GetNewRelId() { return m_nRelId ++; }
266cdf0e10cSrcweir };
267cdf0e10cSrcweir 
268cdf0e10cSrcweir class OWriteStream : ::com::sun::star::lang::XTypeProvider
269cdf0e10cSrcweir 			, public ::com::sun::star::io::XInputStream
270cdf0e10cSrcweir 			, public ::com::sun::star::io::XOutputStream
271cdf0e10cSrcweir 			, public ::com::sun::star::embed::XExtendedStorageStream
272cdf0e10cSrcweir 			, public ::com::sun::star::io::XSeekable
273cdf0e10cSrcweir 			, public ::com::sun::star::io::XTruncate
274cdf0e10cSrcweir 			, public ::com::sun::star::embed::XEncryptionProtectedSource2
275cdf0e10cSrcweir 			, public ::com::sun::star::embed::XRelationshipAccess
276cdf0e10cSrcweir 			, public ::com::sun::star::embed::XTransactedObject
277cdf0e10cSrcweir 			, public ::com::sun::star::embed::XTransactionBroadcaster
278cdf0e10cSrcweir 			, public ::com::sun::star::beans::XPropertySet
279cdf0e10cSrcweir 			, public ::cppu::OWeakObject
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	friend struct OWriteStream_Impl;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir protected:
284cdf0e10cSrcweir 	::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInStream;
285cdf0e10cSrcweir 	::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > m_xOutStream;
286cdf0e10cSrcweir 	::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	OWriteStream_Impl* m_pImpl;
289cdf0e10cSrcweir 	WSInternalData_Impl* m_pData;
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 	sal_Bool m_bInStreamDisconnected;
292cdf0e10cSrcweir 	sal_Bool m_bInitOnDemand;
293cdf0e10cSrcweir     sal_Int64 m_nInitPosition;
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	sal_Bool m_bTransacted;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	OWriteStream( OWriteStream_Impl* pImpl, sal_Bool bTransacted );
298cdf0e10cSrcweir 	OWriteStream( OWriteStream_Impl* pImpl, ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xStream, sal_Bool bTransacted );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	void CloseOutput_Impl();
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	void CopyToStreamInternally_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xStream );
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	void ModifyParentUnlockMutex_Impl( ::osl::ResettableMutexGuard& aGuard );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	void BroadcastTransaction( sal_Int8 nMessage );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir public:
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	virtual ~OWriteStream();
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 	void CheckInitOnDemand();
313cdf0e10cSrcweir     void DeInit();
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	// XInterface
316cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
317cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
318cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw();
319cdf0e10cSrcweir 	virtual void SAL_CALL release() throw();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	//	XTypeProvider
322cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
323cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
324cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
325cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	// XInputStream
328cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
329cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
330cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
331cdf0e10cSrcweir     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
332cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
333cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL available(  )
334cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
335cdf0e10cSrcweir     virtual void SAL_CALL closeInput(  )
336cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	// XOutputStream
339cdf0e10cSrcweir     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
340cdf0e10cSrcweir     virtual void SAL_CALL flush(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
341cdf0e10cSrcweir     virtual void SAL_CALL closeOutput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	//XSeekable
344cdf0e10cSrcweir     virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
345cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
346cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	//XStream
349cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
350cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	// XTruncate
353cdf0e10cSrcweir     virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	//XComponent
356cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
357cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
358cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	//XEncryptionProtectedSource
361cdf0e10cSrcweir     virtual void SAL_CALL setEncryptionPassword( const ::rtl::OUString& aPass )
362cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException,
363cdf0e10cSrcweir 				::com::sun::star::io::IOException );
364cdf0e10cSrcweir     virtual void SAL_CALL removeEncryption()
365cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException,
366cdf0e10cSrcweir 				::com::sun::star::io::IOException );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	//XEncryptionProtectedSource2
369cdf0e10cSrcweir     virtual void SAL_CALL setEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	//XRelationshipAccess
372cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL hasByID( const ::rtl::OUString& sID ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
373cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getTargetByID( const ::rtl::OUString& sID ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
374cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getTypeByID( const ::rtl::OUString& sID ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
375cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > SAL_CALL getRelationshipByID( const ::rtl::OUString& sID ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
376cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > SAL_CALL getRelationshipsByType( const ::rtl::OUString& sType ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
377cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > SAL_CALL getAllRelationships(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
378cdf0e10cSrcweir     virtual void SAL_CALL insertRelationshipByID( const ::rtl::OUString& sID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aEntry, ::sal_Bool bReplace ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
379cdf0e10cSrcweir     virtual void SAL_CALL removeRelationshipByID( const ::rtl::OUString& sID ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
380cdf0e10cSrcweir     virtual void SAL_CALL insertRelationships( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > >& aEntries, ::sal_Bool bReplace ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
381cdf0e10cSrcweir     virtual void SAL_CALL clearRelationships(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	//XPropertySet
384cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw ( ::com::sun::star::uno::RuntimeException );
385cdf0e10cSrcweir     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
386cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
387cdf0e10cSrcweir     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
388cdf0e10cSrcweir     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
389cdf0e10cSrcweir     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
390cdf0e10cSrcweir     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	// XTransactedObject
393cdf0e10cSrcweir     virtual void SAL_CALL commit()
394cdf0e10cSrcweir 		throw ( ::com::sun::star::io::IOException,
395cdf0e10cSrcweir 				::com::sun::star::embed::StorageWrappedTargetException,
396cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
397cdf0e10cSrcweir     virtual void SAL_CALL revert()
398cdf0e10cSrcweir 		throw ( ::com::sun::star::io::IOException,
399cdf0e10cSrcweir 				::com::sun::star::embed::StorageWrappedTargetException,
400cdf0e10cSrcweir 				::com::sun::star::uno::RuntimeException );
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 	// XTransactionBroadcaster
403cdf0e10cSrcweir     virtual void SAL_CALL addTransactionListener(
404cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XTransactionListener >& aListener )
405cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException );
406cdf0e10cSrcweir     virtual void SAL_CALL removeTransactionListener(
407cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XTransactionListener >& aListener )
408cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir };
411cdf0e10cSrcweir 
412cdf0e10cSrcweir #endif
413cdf0e10cSrcweir 
414