21#include <osl/diagnose.h>
29const sal_uInt16 VBACHUNK_SIGMASK = 0x7000;
30const sal_uInt16 VBACHUNK_SIG = 0x3000;
31const sal_uInt16 VBACHUNK_COMPRESSED = 0x8000;
32const sal_uInt16 VBACHUNK_LENMASK = 0x0FFF;
44 OSL_ENSURE( nSig == VBASTREAM_SIGNATURE,
"VbaInputStream::VbaInputStream - wrong signature" );
73 orData.realloc( ::std::max< sal_Int32 >( nBytes, 0 ) );
76 nRet =
readMemory( orData.getArray(), nBytes, nAtomSize );
78 orData.realloc( nRet );
91 sal_Int32 nReadBytes = ::std::min( nBytes, nChunkLeft );
94 mnChunkPos +=
static_cast< size_t >( nReadBytes );
106 sal_Int32 nSkipBytes = ::std::min( nBytes, nChunkLeft );
107 mnChunkPos +=
static_cast< size_t >( nSkipBytes );
108 nBytes -= nSkipBytes;
121 if(
mbEof )
return false;
124 bool bIgnoreBrokenSig = ( (nHeader & VBACHUNK_SIGMASK) != VBACHUNK_SIG );
127 bool bCompressed =
getFlag( nHeader, VBACHUNK_COMPRESSED );
128 sal_uInt16 nChunkLen = (nHeader & VBACHUNK_LENMASK) + 1;
129 OSL_ENSURE( bCompressed || (nChunkLen == 4096),
"VbaInputStream::updateChunk - invalid uncompressed chunk size" );
136 if ( bIgnoreBrokenSig )
147 sal_uInt16 nChunkPos = 0;
154 if( nTokenFlags & 1 )
157 nChunkPos = nChunkPos + 2;
161 sal_uInt16
nLength = extractValue< sal_uInt16 >( nCopyToken, 0, 16 -
nBitCount ) + 3;
163 sal_uInt16 nOffset = extractValue< sal_uInt16 >( nCopyToken, 16 -
nBitCount,
nBitCount ) + 1;
165 OSL_ENSURE( !
mbEof,
"VbaInputStream::updateChunk - invalid offset or size in copy token" );
172 const sal_uInt8* pnFrom = pnTo - nOffset;
174 size_t nRunLen = ::std::min< size_t >(
nLength, nOffset );
175 while( pnTo < pnEnd )
177 size_t nStepLen = ::std::min< size_t >( nRunLen, pnEnd - pnTo );
178 memcpy( pnTo, pnFrom, nStepLen );
Base class for binary stream classes.
bool isEof() const
Returns true, if the stream position is invalid (EOF).
virtual sal_Int64 tell() const =0
Implementations return the current stream position, if possible.
virtual void seek(sal_Int64 nPos)=0
Implementations seek the stream to the passed position, if the stream is seekable.
bool mbEof
End of stream flag.
css::uno::Sequence< sal_Int8 > StreamDataSequence
bool getFlag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.