diff options
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 7b41eafbf9f1..3fdabfcfe430 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -175,40 +175,32 @@ void OStorageHelper::CopyInputToOutput( { static const sal_Int32 nConstBufferSize = 32000; - comphelper::ByteReader* pByteReader = dynamic_cast< comphelper::ByteReader* >( xInput.get() ); - comphelper::ByteWriter* pByteWriter = nullptr; - if (pByteReader) - pByteWriter = dynamic_cast< comphelper::ByteWriter* >( xOutput.get() ); - - if (pByteWriter) - { - sal_Int32 nRead; - sal_Int8 aTempBuf[ nConstBufferSize ]; - do - { - nRead = pByteReader->readSomeBytes ( aTempBuf, nConstBufferSize ); - pByteWriter->writeBytes ( aTempBuf, nRead ); - } - while ( nRead == nConstBufferSize ); - } - else + if (auto pByteReader = dynamic_cast< comphelper::ByteReader* >( xInput.get() )) { - sal_Int32 nRead; - uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize ); - - do + if (auto pByteWriter = dynamic_cast< comphelper::ByteWriter* >( xOutput.get() )) { - nRead = xInput->readBytes ( aSequence, nConstBufferSize ); - if ( nRead < nConstBufferSize ) + sal_Int32 nRead; + sal_Int8 aTempBuf[ nConstBufferSize ]; + do { - uno::Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead ); - xOutput->writeBytes ( aTempBuf ); + nRead = pByteReader->readSomeBytes ( aTempBuf, nConstBufferSize ); + pByteWriter->writeBytes ( aTempBuf, nRead ); } - else - xOutput->writeBytes ( aSequence ); + while ( nRead == nConstBufferSize ); + return; } - while ( nRead == nConstBufferSize ); } + + sal_Int32 nRead; + uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize ); + do + { + nRead = xInput->readBytes ( aSequence, nConstBufferSize ); + if ( nRead < nConstBufferSize ) + aSequence.realloc( nRead ); + xOutput->writeBytes ( aSequence ); + } + while ( nRead == nConstBufferSize ); } |