xref: /AOO41X/main/ucb/source/ucp/file/filstr.hxx (revision 6df1ea1f75e32b7bdb9b43f28f6c06e1fbd0c5ce)
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 #ifndef _FILSTR_HXX_
24 #define _FILSTR_HXX_
25 
26 #include <osl/mutex.hxx>
27 #include <rtl/ustring.hxx>
28 #include <cppuhelper/weak.hxx>
29 #include <ucbhelper/macros.hxx>
30 #include <com/sun/star/uno/XInterface.hpp>
31 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <com/sun/star/io/XSeekable.hpp>
33 #include <com/sun/star/io/XTruncate.hpp>
34 #include <com/sun/star/io/XInputStream.hpp>
35 #include <com/sun/star/io/XOutputStream.hpp>
36 #include <com/sun/star/io/XStream.hpp>
37 #include "com/sun/star/io/XAsyncOutputMonitor.hpp"
38 #include <com/sun/star/ucb/XContentProvider.hpp>
39 
40 #include "filrec.hxx"
41 
42 namespace fileaccess {
43 
44     // forward:
45     class shell;
46     class XInputStreamForStream;
47     class XOutputStreamForStream;
48 
49     class XStream_impl
50         : public cppu::OWeakObject,
51           public com::sun::star::lang::XTypeProvider,
52           public com::sun::star::io::XStream,
53           public com::sun::star::io::XSeekable,
54           public com::sun::star::io::XInputStream,
55           public com::sun::star::io::XOutputStream,
56           public com::sun::star::io::XTruncate,
57           public com::sun::star::io::XAsyncOutputMonitor
58     {
59         friend class XInputStreamForStream;
60         friend class XOutputStreamForStream;
61 
62     public:
63 
64         XStream_impl( shell* pMyShell,const rtl::OUString& aUncPath, sal_Bool bLock );
65 
66         /**
67          *  Returns an error code as given by filerror.hxx
68          */
69 
70         sal_Int32 SAL_CALL CtorSuccess();
71         sal_Int32 SAL_CALL getMinorError();
72 
73         virtual ~XStream_impl();
74 
75 
76         // OWeakObject
77 
78         virtual com::sun::star::uno::Any SAL_CALL
79         queryInterface(
80             const com::sun::star::uno::Type& rType )
81             throw( com::sun::star::uno::RuntimeException);
82 
83         virtual void SAL_CALL
84         acquire(
85             void )
86             throw();
87 
88         virtual void SAL_CALL
89         release(
90             void )
91             throw();
92 
93 
94         // XTypeProvider
95 
96         XTYPEPROVIDER_DECL()
97 
98 
99         // XStream
100 
101         virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
102         getInputStream(  )
103             throw( com::sun::star::uno::RuntimeException );
104 
105         virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL
106         getOutputStream(  )
107             throw( com::sun::star::uno::RuntimeException );
108 
109 
110         // XTruncate
111 
112         virtual void SAL_CALL truncate( void )
113             throw( com::sun::star::io::IOException,
114                    com::sun::star::uno::RuntimeException );
115 
116 
117         // XInputStream
118 
119         sal_Int32 SAL_CALL
120         readBytes(
121             com::sun::star::uno::Sequence< sal_Int8 >& aData,
122             sal_Int32 nBytesToRead )
123             throw( com::sun::star::io::NotConnectedException,
124                    com::sun::star::io::BufferSizeExceededException,
125                    com::sun::star::io::IOException,
126                    com::sun::star::uno::RuntimeException);
127 
128         sal_Int32 SAL_CALL
129         readSomeBytes(
130             com::sun::star::uno::Sequence< sal_Int8 >& aData,
131             sal_Int32 nMaxBytesToRead )
132             throw( com::sun::star::io::NotConnectedException,
133                    com::sun::star::io::BufferSizeExceededException,
134                    com::sun::star::io::IOException,
135                    com::sun::star::uno::RuntimeException);
136 
137 
138         void SAL_CALL
139         skipBytes(
140             sal_Int32 nBytesToSkip )
141             throw( com::sun::star::io::NotConnectedException,
142                    com::sun::star::io::BufferSizeExceededException,
143                    com::sun::star::io::IOException,
144                    com::sun::star::uno::RuntimeException );
145 
146         sal_Int32 SAL_CALL
147         available(
148             void )
149             throw( com::sun::star::io::NotConnectedException,
150                    com::sun::star::io::IOException,
151                    com::sun::star::uno::RuntimeException );
152 
153         void SAL_CALL
154         closeInput(
155             void )
156             throw( com::sun::star::io::NotConnectedException,
157                    com::sun::star::io::IOException,
158                    com::sun::star::uno::RuntimeException );
159 
160         // XSeekable
161 
162         void SAL_CALL
163         seek(
164             sal_Int64 location )
165             throw( com::sun::star::lang::IllegalArgumentException,
166                    com::sun::star::io::IOException,
167                    com::sun::star::uno::RuntimeException );
168 
169         sal_Int64 SAL_CALL
170         getPosition(
171             void )
172             throw( com::sun::star::io::IOException,
173                    com::sun::star::uno::RuntimeException );
174 
175         sal_Int64 SAL_CALL
176         getLength(
177             void )
178             throw( com::sun::star::io::IOException,
179                    com::sun::star::uno::RuntimeException );
180 
181 
182         // XOutputStream
183 
184         void SAL_CALL
185         writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
186             throw( com::sun::star::io::NotConnectedException,
187                    com::sun::star::io::BufferSizeExceededException,
188                    com::sun::star::io::IOException,
189                    com::sun::star::uno::RuntimeException);
190 
191 
192 
193         void SAL_CALL
194         flush()
195             throw( com::sun::star::io::NotConnectedException,
196                    com::sun::star::io::BufferSizeExceededException,
197                    com::sun::star::io::IOException,
198                    com::sun::star::uno::RuntimeException);
199 
200 
201         void SAL_CALL
202         closeOutput(
203             void )
204             throw( com::sun::star::io::NotConnectedException,
205                    com::sun::star::io::IOException,
206                    com::sun::star::uno::RuntimeException );
207 
208         virtual void SAL_CALL waitForCompletion()
209             throw (
210                 com::sun::star::io::IOException,
211                 com::sun::star::uno::RuntimeException);
212 
213     private:
214 
215         osl::Mutex   m_aMutex;
216         bool         m_bInputStreamCalled,m_bOutputStreamCalled;
217 
218         shell*       m_pMyShell;
219         com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider;
220         sal_Bool     m_nIsOpen;
221 
222         sal_Bool     m_bLock;
223 
224         ReconnectingFile    m_aFile;
225 
226         sal_Int32                                          m_nErrorCode;
227         sal_Int32                                          m_nMinorErrorCode;
228 
229         // Implementation methods
230 
231         void SAL_CALL
232         closeStream(
233             void )
234             throw( com::sun::star::io::NotConnectedException,
235                    com::sun::star::io::IOException,
236                    com::sun::star::uno::RuntimeException );
237 
238     };
239 
240 }  // end namespace XStream_impl
241 
242 #endif
243