Update ooo320-m1
[ooovba.git] / ucb / source / ucp / gvfs / stream.hxx
blob0245a3a95df96f49ff7682ec56504a8ee742a82d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stream.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _GVFSSTREAM_HXX_
31 #define _GVFSSTREAM_HXX_
33 #include <sal/types.h>
34 #include <rtl/ustring.hxx>
35 #include <cppuhelper/weak.hxx>
36 #include <com/sun/star/io/XStream.hpp>
37 #include <com/sun/star/io/XInputStream.hpp>
38 #include <com/sun/star/io/XOutputStream.hpp>
39 #include <com/sun/star/io/XTruncate.hpp>
40 #include <com/sun/star/io/XSeekable.hpp>
42 #include <libgnomevfs/gnome-vfs-handle.h>
44 namespace gvfs
47 class Stream : public ::com::sun::star::io::XStream,
48 public ::com::sun::star::io::XInputStream,
49 public ::com::sun::star::io::XOutputStream,
50 public ::com::sun::star::io::XTruncate,
51 public ::com::sun::star::io::XSeekable,
52 public ::cppu::OWeakObject
54 private:
55 GnomeVFSHandle *m_handle;
56 GnomeVFSFileInfo m_info;
57 osl::Mutex m_aMutex;
58 sal_Bool m_eof;
59 sal_Bool m_bInputStreamCalled;
60 sal_Bool m_bOutputStreamCalled;
61 gchar *m_pURI; // necessary to be able to simulate gnome_vfs_truncate if not supported
62 GnomeVFSOpenMode m_nOpenMode;// necessary to be able to simulate gnome_vfs_truncate if not supported
64 void throwOnError( GnomeVFSResult result )
65 throw( ::com::sun::star::io::NotConnectedException,
66 ::com::sun::star::io::BufferSizeExceededException,
67 ::com::sun::star::io::IOException,
68 ::com::sun::star::uno::RuntimeException );
70 void closeStream( void )
71 throw( ::com::sun::star::io::NotConnectedException,
72 ::com::sun::star::io::IOException,
73 ::com::sun::star::uno::RuntimeException );
75 public:
76 Stream ( GnomeVFSHandle *handle,
77 const GnomeVFSFileInfo *aInfo,
78 const gchar *uri,
79 GnomeVFSOpenMode open_mode );
80 virtual ~Stream();
82 // XInterface
83 virtual com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & type )
84 throw( ::com::sun::star::uno::RuntimeException );
85 virtual void SAL_CALL acquire( void )
86 throw ()
87 { OWeakObject::acquire(); }
88 virtual void SAL_CALL release( void )
89 throw()
90 { OWeakObject::release(); }
92 // XStream
93 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream( )
94 throw( com::sun::star::uno::RuntimeException );
96 virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( )
97 throw( com::sun::star::uno::RuntimeException );
99 // XInputStream
100 virtual sal_Int32 SAL_CALL readBytes(
101 ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
102 sal_Int32 nBytesToRead )
103 throw( ::com::sun::star::io::NotConnectedException,
104 ::com::sun::star::io::BufferSizeExceededException,
105 ::com::sun::star::io::IOException,
106 ::com::sun::star::uno::RuntimeException );
108 virtual sal_Int32 SAL_CALL readSomeBytes(
109 ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
110 sal_Int32 nMaxBytesToRead )
111 throw( ::com::sun::star::io::NotConnectedException,
112 ::com::sun::star::io::BufferSizeExceededException,
113 ::com::sun::star::io::IOException,
114 ::com::sun::star::uno::RuntimeException );
116 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
117 throw( ::com::sun::star::io::NotConnectedException,
118 ::com::sun::star::io::BufferSizeExceededException,
119 ::com::sun::star::io::IOException,
120 ::com::sun::star::uno::RuntimeException );
122 virtual sal_Int32 SAL_CALL available( void )
123 throw( ::com::sun::star::io::NotConnectedException,
124 ::com::sun::star::io::IOException,
125 ::com::sun::star::uno::RuntimeException );
127 virtual void SAL_CALL closeInput( void )
128 throw( ::com::sun::star::io::NotConnectedException,
129 ::com::sun::star::io::IOException,
130 ::com::sun::star::uno::RuntimeException );
132 // XSeekable
133 virtual void SAL_CALL seek( sal_Int64 location )
134 throw( ::com::sun::star::lang::IllegalArgumentException,
135 ::com::sun::star::io::IOException,
136 ::com::sun::star::uno::RuntimeException );
138 virtual sal_Int64 SAL_CALL getPosition()
139 throw( ::com::sun::star::io::IOException,
140 ::com::sun::star::uno::RuntimeException );
142 virtual sal_Int64 SAL_CALL getLength()
143 throw( ::com::sun::star::io::IOException,
144 ::com::sun::star::uno::RuntimeException );
146 // XOutputStream
147 virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
148 throw( com::sun::star::io::NotConnectedException,
149 com::sun::star::io::BufferSizeExceededException,
150 com::sun::star::io::IOException,
151 com::sun::star::uno::RuntimeException);
153 virtual void SAL_CALL flush( void )
154 throw( com::sun::star::io::NotConnectedException,
155 com::sun::star::io::BufferSizeExceededException,
156 com::sun::star::io::IOException,
157 com::sun::star::uno::RuntimeException);
160 virtual void SAL_CALL closeOutput( void )
161 throw( com::sun::star::io::NotConnectedException,
162 com::sun::star::io::IOException,
163 com::sun::star::uno::RuntimeException );
165 // XTruncate
166 virtual void SAL_CALL truncate( void )
167 throw( com::sun::star::io::IOException,
168 com::sun::star::uno::RuntimeException );
171 } // namespace gvfs
172 #endif // _GVFSSTREAM_HXX_