diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-18 15:50:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-19 09:31:43 +0200 |
commit | ba91bc19023f3d7158ef9e394665eb5eb89c4037 (patch) | |
tree | 4fdacef635894c2fe0c5a3e16b04b07353654770 /oox | |
parent | f320d1edeb2c95a21479baaf6ef77344f8df62e4 (diff) |
fix SequenceOutputStream constness
Change-Id: I6e1039c077602b2cb42702cb4131f9503ef533c2
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/filterbase.cxx | 2 | ||||
-rw-r--r-- | oox/source/helper/binaryoutputstream.cxx | 35 |
2 files changed, 32 insertions, 5 deletions
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 4945039c901b..6ac5048072bf 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -379,7 +379,7 @@ VbaProject& FilterBase::getVbaProject() const return *mxImpl->mxVbaProject; } -bool FilterBase::importBinaryData( StreamDataSequence const & orDataSeq, const OUString& rStreamName ) +bool FilterBase::importBinaryData( StreamDataSequence & orDataSeq, const OUString& rStreamName ) { OSL_ENSURE( !rStreamName.isEmpty(), "FilterBase::importBinaryData - empty stream name" ); if( rStreamName.isEmpty() ) diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index f75e2f5bc024..652b768f81b9 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -130,9 +130,10 @@ void BinaryOutputStream::writeCompressedUnicodeArray( const OUString& rString, b writeUnicodeArray( rString ); } -SequenceOutputStream::SequenceOutputStream( StreamDataSequence const & rData ) : +SequenceOutputStream::SequenceOutputStream( StreamDataSequence & rData ) : BinaryStreamBase( true ), - SequenceSeekableStream( rData ) + mpData( &rData ), + mnPos( 0 ) { } @@ -147,12 +148,38 @@ void SequenceOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size if( mpData && (nBytes > 0) ) { if( mpData->getLength() - mnPos < nBytes ) - const_cast< StreamDataSequence* >( mpData )->realloc( mnPos + nBytes ); - memcpy( const_cast< StreamDataSequence* >( mpData )->getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) ); + mpData->realloc( mnPos + nBytes ); + memcpy( mpData->getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) ); mnPos += nBytes; } } +sal_Int64 SequenceOutputStream::size() const +{ + return mpData ? mpData->getLength() : -1; +} + +sal_Int64 SequenceOutputStream::tell() const +{ + return mpData ? mnPos : -1; +} + +void SequenceOutputStream::seek( sal_Int64 nPos ) +{ + if( mpData ) + { + mnPos = getLimitedValue< sal_Int32, sal_Int64 >( nPos, 0, mpData->getLength() ); + mbEof = mnPos != nPos; + } +} + +void SequenceOutputStream::close() +{ + mpData = nullptr; + mbEof = true; +} + + } // namespace oox /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |