xref: /aoo41x/main/oox/inc/oox/ole/vbainputstream.hxx (revision e3508121)
1*e3508121SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e3508121SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e3508121SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e3508121SAndrew Rist  * distributed with this work for additional information
6*e3508121SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e3508121SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e3508121SAndrew Rist  * "License"); you may not use this file except in compliance
9*e3508121SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e3508121SAndrew Rist  *
11*e3508121SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e3508121SAndrew Rist  *
13*e3508121SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e3508121SAndrew Rist  * software distributed under the License is distributed on an
15*e3508121SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e3508121SAndrew Rist  * KIND, either express or implied.  See the License for the
17*e3508121SAndrew Rist  * specific language governing permissions and limitations
18*e3508121SAndrew Rist  * under the License.
19*e3508121SAndrew Rist  *
20*e3508121SAndrew Rist  *************************************************************/
21*e3508121SAndrew Rist 
22*e3508121SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef OOX_OLE_VBAINPUTSTREAM_HXX
25cdf0e10cSrcweir #define OOX_OLE_VBAINPUTSTREAM_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vector>
28cdf0e10cSrcweir #include "oox/helper/binaryinputstream.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace oox {
31cdf0e10cSrcweir namespace ole {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // ============================================================================
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /** A non-seekable input stream that implements run-length decompression. */
36cdf0e10cSrcweir class VbaInputStream : public BinaryInputStream
37cdf0e10cSrcweir {
38cdf0e10cSrcweir public:
39cdf0e10cSrcweir     explicit            VbaInputStream( BinaryInputStream& rInStrm );
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     /** Returns -1, stream size is not determinable. */
42cdf0e10cSrcweir     virtual sal_Int64   size() const;
43cdf0e10cSrcweir     /** Returns -1, stream position is not tracked. */
44cdf0e10cSrcweir     virtual sal_Int64   tell() const;
45cdf0e10cSrcweir     /** Does nothing, stream is not seekable. */
46cdf0e10cSrcweir     virtual void        seek( sal_Int64 nPos );
47cdf0e10cSrcweir     /** Closes the input stream but not the wrapped stream. */
48cdf0e10cSrcweir     virtual void        close();
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     /** Reads nBytes bytes to the passed sequence.
51cdf0e10cSrcweir         @return  Number of bytes really read. */
52cdf0e10cSrcweir     virtual sal_Int32   readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 );
53cdf0e10cSrcweir     /** Reads nBytes bytes to the (existing) buffer opMem.
54cdf0e10cSrcweir         @return  Number of bytes really read. */
55cdf0e10cSrcweir     virtual sal_Int32   readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
56cdf0e10cSrcweir     /** Seeks the stream forward by the passed number of bytes. */
57cdf0e10cSrcweir     virtual void        skip( sal_Int32 nBytes, size_t nAtomSize = 1 );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir private:
60cdf0e10cSrcweir     /** If no data left in chunk buffer, reads the next chunk from stream. */
61cdf0e10cSrcweir     bool                updateChunk();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir private:
64cdf0e10cSrcweir     typedef ::std::vector< sal_uInt8 > ChunkBuffer;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     BinaryInputStream*  mpInStrm;
67cdf0e10cSrcweir     ChunkBuffer         maChunk;
68cdf0e10cSrcweir     size_t              mnChunkPos;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // ============================================================================
72cdf0e10cSrcweir 
73cdf0e10cSrcweir } // namespace ole
74cdf0e10cSrcweir } // namespace oox
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #endif
77