1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _ZIP_PACKAGE_BUFFER_HXX
28 #define _ZIP_PACKAGE_BUFFER_HXX
29 
30 #include <com/sun/star/io/XOutputStream.hpp>
31 #include <com/sun/star/io/XSeekable.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #ifndef _CPPUHELPER_IMPLBASE3_HXX
34 #include <cppuhelper/implbase3.hxx>
35 #endif
36 
37 class ZipPackage;
38 
39 class ZipPackageBuffer : public ::cppu::WeakImplHelper3
40 <
41 	com::sun::star::io::XInputStream,
42 	com::sun::star::io::XOutputStream,
43 	com::sun::star::io::XSeekable
44 >
45 {
46 protected:
47 	com::sun::star::uno::Sequence < sal_Int8 > m_aBuffer;
48 	sal_Int64 m_nBufferSize, m_nEnd, m_nCurrent;
49 	sal_Bool m_bMustInitBuffer;
50 public:
51 	ZipPackageBuffer(sal_Int64 nNewBufferSize);
52 	virtual ~ZipPackageBuffer(void);
53 
54 	inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
55 	inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
56 	inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
57 
58 	// XInputStream
59     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
60 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
61     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
62 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
63     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
64 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
65     virtual sal_Int32 SAL_CALL available(  )
66 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
67     virtual void SAL_CALL closeInput(  )
68 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
69 	// XOutputStream
70     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
71 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
72     virtual void SAL_CALL flush(  )
73 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
74     virtual void SAL_CALL closeOutput(  )
75 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
76 	// XSeekable
77     virtual void SAL_CALL seek( sal_Int64 location )
78 		throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
79     virtual sal_Int64 SAL_CALL getPosition(  )
80 		throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
81     virtual sal_Int64 SAL_CALL getLength(  )
82 		throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
83 };
84 #endif
85