merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / inc / oslstream.hxx
blob4ea8868b6327e8260633c66eec3a30e9a527e20e
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: oslstream.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #ifndef _CONFIGMGR_OSLSTREAM_HXX_
32 #define _CONFIGMGR_OSLSTREAM_HXX_
34 #include <com/sun/star/io/XOutputStream.hpp>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #include <cppuhelper/implbase1.hxx>
37 #include <osl/mutex.hxx>
39 #include "bufferedfile.hxx"
41 namespace osl
43 class File;
46 namespace configmgr
48 namespace stario = ::com::sun::star::io;
49 namespace staruno = ::com::sun::star::uno;
51 // -----------------------------------------------------------------------------
52 /// OSLInputStreamWrapper - implementation of XInputStream on an (unbuffered) osl::File
53 class OSLInputStreamWrapper : public ::cppu::WeakImplHelper1<stario::XInputStream>
55 ::osl::Mutex m_aMutex;
56 ::osl::File* m_pFile;
57 sal_Bool m_bFileOwner : 1;
59 public:
60 /// c'tor. _rStream must live at least until closeInput() is called on this stream
61 OSLInputStreamWrapper(::osl::File& _rStream);
62 /// c'tor. if bOwner is <FALSE/> *pStream must live at least until closeInput() is called on this stream
63 OSLInputStreamWrapper(::osl::File* pStream, sal_Bool bOwner=sal_False);
64 virtual ~OSLInputStreamWrapper();
66 // stario::XInputStream
67 virtual sal_Int32 SAL_CALL
68 readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
69 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
71 virtual sal_Int32 SAL_CALL
72 readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead)
73 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
75 virtual void SAL_CALL
76 skipBytes(sal_Int32 nBytesToSkip)
77 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
79 virtual sal_Int32 SAL_CALL available() throw(stario::NotConnectedException, staruno::RuntimeException);
80 virtual void SAL_CALL closeInput() throw(stario::NotConnectedException, staruno::RuntimeException);
83 // -----------------------------------------------------------------------------
84 /// OSLOutputStreamWrapper - implementation of XOutputStream on an (unbuffered) osl::File
85 class OSLOutputStreamWrapper : public ::cppu::WeakImplHelper1<stario::XOutputStream>
87 ::osl::Mutex m_aMutex;
88 ::osl::File& rFile;
90 public:
91 /// c'tor. _rStream must live at least until closeOutput() is called on this stream
92 OSLOutputStreamWrapper(::osl::File& _rFile) :rFile(_rFile) { }
94 // stario::XOutputStream
95 virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData)
96 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
98 virtual void SAL_CALL flush()
99 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
101 virtual void SAL_CALL closeOutput()
102 throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException);
104 // -----------------------------------------------------------------------------
105 /// BufferedFileOutputStream - buffered implementation of XOutputStream on an osl::File
106 class BufferedFileOutputStream: public ::cppu::WeakImplHelper1<stario::XOutputStream>
108 BufferedOutputFile m_aFile;
110 public:
111 BufferedFileOutputStream(rtl::OUString const & aFileURL, bool bCreate=true, sal_uInt32 nBufferSizeHint=0);
112 virtual ~BufferedFileOutputStream();
114 // stario::XOutputStream
115 virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData)
116 throw(stario::NotConnectedException, stario::BufferSizeExceededException,
117 stario::IOException, staruno::RuntimeException);
119 virtual void SAL_CALL flush()
120 throw(stario::NotConnectedException, stario::BufferSizeExceededException,
121 stario::IOException, staruno::RuntimeException);
123 virtual void SAL_CALL closeOutput()
124 throw(stario::NotConnectedException, stario::BufferSizeExceededException,
125 stario::IOException, staruno::RuntimeException);
127 // -----------------------------------------------------------------------------
129 } // namespace configmgr
131 #endif // _CONFIGMGR_OSLSTREAM_HXX_