xref: /trunk/main/ucb/source/ucp/file/filstr.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
82         virtual void SAL_CALL
83         acquire(
84             void )
85             throw();
86 
87         virtual void SAL_CALL
88         release(
89             void )
90             throw();
91 
92 
93         // XTypeProvider
94 
95         XTYPEPROVIDER_DECL()
96 
97 
98         // XStream
99 
100         virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL
101         getInputStream(  );
102 
103         virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL
104         getOutputStream(  );
105 
106 
107         // XTruncate
108 
109         virtual void SAL_CALL truncate( void );
110 
111 
112         // XInputStream
113 
114         sal_Int32 SAL_CALL
115         readBytes(
116             com::sun::star::uno::Sequence< sal_Int8 >& aData,
117             sal_Int32 nBytesToRead );
118 
119         sal_Int32 SAL_CALL
120         readSomeBytes(
121             com::sun::star::uno::Sequence< sal_Int8 >& aData,
122             sal_Int32 nMaxBytesToRead );
123 
124 
125         void SAL_CALL
126         skipBytes(
127             sal_Int32 nBytesToSkip );
128 
129         sal_Int32 SAL_CALL
130         available(
131             void );
132 
133         void SAL_CALL
134         closeInput(
135             void );
136 
137         // XSeekable
138 
139         void SAL_CALL
140         seek(
141             sal_Int64 location );
142 
143         sal_Int64 SAL_CALL
144         getPosition(
145             void );
146 
147         sal_Int64 SAL_CALL
148         getLength(
149             void );
150 
151 
152         // XOutputStream
153 
154         void SAL_CALL
155         writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData );
156 
157 
158 
159         void SAL_CALL
160         flush();
161 
162 
163         void SAL_CALL
164         closeOutput(
165             void );
166 
167         virtual void SAL_CALL waitForCompletion();
168 
169     private:
170 
171         osl::Mutex   m_aMutex;
172         bool         m_bInputStreamCalled,m_bOutputStreamCalled;
173 
174         shell*       m_pMyShell;
175         com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider;
176         sal_Bool     m_nIsOpen;
177 
178         sal_Bool     m_bLock;
179 
180         ReconnectingFile    m_aFile;
181 
182         sal_Int32                                          m_nErrorCode;
183         sal_Int32                                          m_nMinorErrorCode;
184 
185         // Implementation methods
186 
187         void SAL_CALL
188         closeStream(
189             void );
190 
191     };
192 
193 }  // end namespace XStream_impl
194 
195 #endif
196