xref: /AOO41X/main/package/inc/ZipPackageBuffer.hxx (revision f319bb99b6b251a37b98027a84e8048ce3778b1f)
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 _ZIP_PACKAGE_BUFFER_HXX
24 #define _ZIP_PACKAGE_BUFFER_HXX
25 
26 #include <com/sun/star/io/XOutputStream.hpp>
27 #include <com/sun/star/io/XSeekable.hpp>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #ifndef _CPPUHELPER_IMPLBASE3_HXX
30 #include <cppuhelper/implbase3.hxx>
31 #endif
32 
33 class ZipPackage;
34 
35 class ZipPackageBuffer : public ::cppu::WeakImplHelper3
36 <
37     com::sun::star::io::XInputStream,
38     com::sun::star::io::XOutputStream,
39     com::sun::star::io::XSeekable
40 >
41 {
42 protected:
43     com::sun::star::uno::Sequence < sal_Int8 > m_aBuffer;
44     sal_Int64 m_nBufferSize, m_nEnd, m_nCurrent;
45     sal_Bool m_bMustInitBuffer;
46 public:
47     ZipPackageBuffer(sal_Int64 nNewBufferSize);
48     virtual ~ZipPackageBuffer(void);
49 
realloc(sal_Int32 nSize)50     inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
getConstArray() const51     inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
getSequence() const52     inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
53 
54     // XInputStream
55     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
56         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
57     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
58         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
59     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
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 available(  )
62         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
63     virtual void SAL_CALL closeInput(  )
64         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
65     // XOutputStream
66     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
67         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
68     virtual void SAL_CALL flush(  )
69         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
70     virtual void SAL_CALL closeOutput(  )
71         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
72     // XSeekable
73     virtual void SAL_CALL seek( sal_Int64 location )
74         throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
75     virtual sal_Int64 SAL_CALL getPosition(  )
76         throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
77     virtual sal_Int64 SAL_CALL getLength(  )
78         throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
79 };
80 #endif
81