merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / ucp / webdav / NeonInputStream.hxx
blobceefbf5db2e2e6ead93df9beb9fb29bb4715b4f3
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: NeonInputStream.hxx,v $
10 * $Revision: 1.8 $
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 _NEONINPUTSTREAM_HXX_
31 #define _NEONINPUTSTREAM_HXX_
33 #include <sal/types.h>
34 #include <osl/mutex.hxx>
35 #include <osl/signal.h>
36 #include <rtl/ustring.hxx>
37 #include <cppuhelper/weak.hxx>
39 #include <com/sun/star/io/XStream.hpp>
40 #include <com/sun/star/io/XInputStream.hpp>
41 #include <com/sun/star/io/XOutputStream.hpp>
42 #include <com/sun/star/io/XSeekable.hpp>
43 #include <com/sun/star/io/XTruncate.hpp>
44 #include <com/sun/star/ucb/Lock.hpp>
46 #include "DAVRequestEnvironment.hxx"
48 namespace webdav_ucp
51 // -------------------------------------------------------------------
52 // NeonInputStream
53 // A simple XInputStream implementation provided specifically for use
54 // by the DAVSession::GET method.
55 // -------------------------------------------------------------------
56 class NeonInputStream : public ::com::sun::star::io::XStream,
57 public ::com::sun::star::io::XInputStream,
58 public ::com::sun::star::io::XOutputStream,
59 public ::com::sun::star::io::XSeekable,
60 public ::com::sun::star::io::XTruncate,
61 public ::cppu::OWeakObject
63 private:
64 com::sun::star::uno::Sequence< sal_Int8 > m_aInputBuffer;
65 sal_Int64 m_nLen; // cannot be just m_aInputBuffer.getLength() - the buffer can be bigger
66 sal_Int64 m_nPos;
68 sal_Bool m_bDirty;
70 rtl::OUString m_aURL;
72 osl::Mutex m_aLock;
74 public:
75 NeonInputStream( void );
76 virtual ~NeonInputStream();
78 // Add some data to the end of the stream
79 void AddToStream( const char * inBuf, sal_Int32 inLen );
81 // Associate a URL with this stream
82 void SetURL( const rtl::OUString &rURL );
84 // XInterface
85 virtual com::sun::star::uno::Any SAL_CALL queryInterface(
86 const ::com::sun::star::uno::Type & type )
87 throw( ::com::sun::star::uno::RuntimeException );
89 virtual void SAL_CALL acquire( void )
90 throw ()
91 { OWeakObject::acquire(); }
93 virtual void SAL_CALL release( void )
94 throw()
95 { OWeakObject::release(); }
97 // XStream
98 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream( void )
99 throw( com::sun::star::uno::RuntimeException );
101 virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( void )
102 throw( com::sun::star::uno::RuntimeException );
104 // XInputStream
105 virtual sal_Int32 SAL_CALL readBytes(
106 ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
107 sal_Int32 nBytesToRead )
108 throw( ::com::sun::star::io::NotConnectedException,
109 ::com::sun::star::io::BufferSizeExceededException,
110 ::com::sun::star::io::IOException,
111 ::com::sun::star::uno::RuntimeException );
113 virtual sal_Int32 SAL_CALL readSomeBytes(
114 ::com::sun::star::uno::Sequence< sal_Int8 > & aData,
115 sal_Int32 nMaxBytesToRead )
116 throw( ::com::sun::star::io::NotConnectedException,
117 ::com::sun::star::io::BufferSizeExceededException,
118 ::com::sun::star::io::IOException,
119 ::com::sun::star::uno::RuntimeException );
121 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
122 throw( ::com::sun::star::io::NotConnectedException,
123 ::com::sun::star::io::BufferSizeExceededException,
124 ::com::sun::star::io::IOException,
125 ::com::sun::star::uno::RuntimeException );
127 virtual sal_Int32 SAL_CALL available( void )
128 throw( ::com::sun::star::io::NotConnectedException,
129 ::com::sun::star::io::IOException,
130 ::com::sun::star::uno::RuntimeException );
132 virtual void SAL_CALL closeInput( void )
133 throw( ::com::sun::star::io::NotConnectedException,
134 ::com::sun::star::io::IOException,
135 ::com::sun::star::uno::RuntimeException );
137 // XSeekable
138 virtual void SAL_CALL seek( sal_Int64 location )
139 throw( ::com::sun::star::lang::IllegalArgumentException,
140 ::com::sun::star::io::IOException,
141 ::com::sun::star::uno::RuntimeException );
143 virtual sal_Int64 SAL_CALL getPosition()
144 throw( ::com::sun::star::io::IOException,
145 ::com::sun::star::uno::RuntimeException );
147 virtual sal_Int64 SAL_CALL getLength()
148 throw( ::com::sun::star::io::IOException,
149 ::com::sun::star::uno::RuntimeException );
151 // XOutputStream
152 virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
153 throw( com::sun::star::io::NotConnectedException,
154 com::sun::star::io::BufferSizeExceededException,
155 com::sun::star::io::IOException,
156 com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL flush( void )
159 throw( com::sun::star::io::NotConnectedException,
160 com::sun::star::io::BufferSizeExceededException,
161 com::sun::star::io::IOException,
162 com::sun::star::uno::RuntimeException);
165 virtual void SAL_CALL closeOutput( void )
166 throw( com::sun::star::io::NotConnectedException,
167 com::sun::star::io::IOException,
168 com::sun::star::uno::RuntimeException );
170 // XTruncate
171 virtual void SAL_CALL truncate( void )
172 throw( com::sun::star::io::IOException,
173 com::sun::star::uno::RuntimeException );
176 } // namespace webdav_ucp
177 #endif // _NEONINPUTSTREAM_HXX_