xref: /aoo41x/main/ucb/source/ucp/file/filstr.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir  /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _FILSTR_HXX_
28*cdf0e10cSrcweir #define _FILSTR_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <osl/mutex.hxx>
31*cdf0e10cSrcweir #include <rtl/ustring.hxx>
32*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
33*cdf0e10cSrcweir #include <ucbhelper/macros.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
41*cdf0e10cSrcweir #include "com/sun/star/io/XAsyncOutputMonitor.hpp"
42*cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include "filrec.hxx"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace fileaccess {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir 	// forward:
49*cdf0e10cSrcweir 	class shell;
50*cdf0e10cSrcweir 	class XInputStreamForStream;
51*cdf0e10cSrcweir 	class XOutputStreamForStream;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 	class XStream_impl
54*cdf0e10cSrcweir 		: public cppu::OWeakObject,
55*cdf0e10cSrcweir 		  public com::sun::star::lang::XTypeProvider,
56*cdf0e10cSrcweir 		  public com::sun::star::io::XStream,
57*cdf0e10cSrcweir 		  public com::sun::star::io::XSeekable,
58*cdf0e10cSrcweir           public com::sun::star::io::XInputStream,
59*cdf0e10cSrcweir           public com::sun::star::io::XOutputStream,
60*cdf0e10cSrcweir 		  public com::sun::star::io::XTruncate,
61*cdf0e10cSrcweir           public com::sun::star::io::XAsyncOutputMonitor
62*cdf0e10cSrcweir 	{
63*cdf0e10cSrcweir 		friend class XInputStreamForStream;
64*cdf0e10cSrcweir 		friend class XOutputStreamForStream;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 	public:
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 		XStream_impl( shell* pMyShell,const rtl::OUString& aUncPath, sal_Bool bLock );
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 		/**
71*cdf0e10cSrcweir 		 *  Returns an error code as given by filerror.hxx
72*cdf0e10cSrcweir 		 */
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 		sal_Int32 SAL_CALL CtorSuccess();
75*cdf0e10cSrcweir 		sal_Int32 SAL_CALL getMinorError();
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 		virtual ~XStream_impl();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         // OWeakObject
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 		virtual com::sun::star::uno::Any SAL_CALL
83*cdf0e10cSrcweir 		queryInterface(
84*cdf0e10cSrcweir 			const com::sun::star::uno::Type& rType )
85*cdf0e10cSrcweir 			throw( com::sun::star::uno::RuntimeException);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 		virtual void SAL_CALL
88*cdf0e10cSrcweir 		acquire(
89*cdf0e10cSrcweir 			void )
90*cdf0e10cSrcweir 			throw();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 		virtual void SAL_CALL
93*cdf0e10cSrcweir 		release(
94*cdf0e10cSrcweir 			void )
95*cdf0e10cSrcweir 			throw();
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 		// XTypeProvider
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 		XTYPEPROVIDER_DECL()
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 		// XStream
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
106*cdf0e10cSrcweir 		getInputStream(  )
107*cdf0e10cSrcweir 			throw( com::sun::star::uno::RuntimeException );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 		virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL
110*cdf0e10cSrcweir 		getOutputStream(  )
111*cdf0e10cSrcweir 			throw( com::sun::star::uno::RuntimeException );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 		// XTruncate
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 		virtual void SAL_CALL truncate( void )
117*cdf0e10cSrcweir 			throw( com::sun::star::io::IOException,
118*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir         // XInputStream
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 		sal_Int32 SAL_CALL
124*cdf0e10cSrcweir 		readBytes(
125*cdf0e10cSrcweir 			com::sun::star::uno::Sequence< sal_Int8 >& aData,
126*cdf0e10cSrcweir 			sal_Int32 nBytesToRead )
127*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
128*cdf0e10cSrcweir 				   com::sun::star::io::BufferSizeExceededException,
129*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
130*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 		sal_Int32 SAL_CALL
133*cdf0e10cSrcweir 		readSomeBytes(
134*cdf0e10cSrcweir 			com::sun::star::uno::Sequence< sal_Int8 >& aData,
135*cdf0e10cSrcweir 			sal_Int32 nMaxBytesToRead )
136*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
137*cdf0e10cSrcweir 				   com::sun::star::io::BufferSizeExceededException,
138*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
139*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 		void SAL_CALL
143*cdf0e10cSrcweir 		skipBytes(
144*cdf0e10cSrcweir 			sal_Int32 nBytesToSkip )
145*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
146*cdf0e10cSrcweir 				   com::sun::star::io::BufferSizeExceededException,
147*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
148*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 		sal_Int32 SAL_CALL
151*cdf0e10cSrcweir 		available(
152*cdf0e10cSrcweir 			void )
153*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
154*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
155*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		void SAL_CALL
158*cdf0e10cSrcweir 		closeInput(
159*cdf0e10cSrcweir 			void )
160*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
161*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
162*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         // XSeekable
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 		void SAL_CALL
167*cdf0e10cSrcweir 		seek(
168*cdf0e10cSrcweir 			sal_Int64 location )
169*cdf0e10cSrcweir 			throw( com::sun::star::lang::IllegalArgumentException,
170*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
171*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 		sal_Int64 SAL_CALL
174*cdf0e10cSrcweir 		getPosition(
175*cdf0e10cSrcweir 			void )
176*cdf0e10cSrcweir 			throw( com::sun::star::io::IOException,
177*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 		sal_Int64 SAL_CALL
180*cdf0e10cSrcweir 		getLength(
181*cdf0e10cSrcweir 			void )
182*cdf0e10cSrcweir 			throw( com::sun::star::io::IOException,
183*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         // XOutputStream
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 		void SAL_CALL
189*cdf0e10cSrcweir 		writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
190*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
191*cdf0e10cSrcweir 				   com::sun::star::io::BufferSizeExceededException,
192*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
193*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 		void SAL_CALL
198*cdf0e10cSrcweir 		flush()
199*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
200*cdf0e10cSrcweir 				   com::sun::star::io::BufferSizeExceededException,
201*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
202*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir         void SAL_CALL
206*cdf0e10cSrcweir 		closeOutput(
207*cdf0e10cSrcweir 			void )
208*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
209*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
210*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         virtual void SAL_CALL waitForCompletion()
213*cdf0e10cSrcweir             throw (
214*cdf0e10cSrcweir                 com::sun::star::io::IOException,
215*cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException);
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	private:
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 		osl::Mutex   m_aMutex;
220*cdf0e10cSrcweir 		bool         m_bInputStreamCalled,m_bOutputStreamCalled;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 		shell*       m_pMyShell;
223*cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider;
224*cdf0e10cSrcweir 		sal_Bool     m_nIsOpen;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir         sal_Bool     m_bLock;
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		ReconnectingFile    m_aFile;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 		sal_Int32                                          m_nErrorCode;
231*cdf0e10cSrcweir 		sal_Int32                                          m_nMinorErrorCode;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 		// Implementation methods
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 		void SAL_CALL
236*cdf0e10cSrcweir 		closeStream(
237*cdf0e10cSrcweir 			void )
238*cdf0e10cSrcweir 			throw( com::sun::star::io::NotConnectedException,
239*cdf0e10cSrcweir 				   com::sun::star::io::IOException,
240*cdf0e10cSrcweir 				   com::sun::star::uno::RuntimeException );
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	};
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir }  // end namespace XStream_impl
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir #endif
247