summaryrefslogtreecommitdiff
path: root/unotools/source/ucbhelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 13:03:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-19 09:29:14 +0200
commitd1dc27fef899ff6cd70873cd945d5312a53e1b3a (patch)
tree53e4975c8b7af4d493d797d798d42f26fb241c80 /unotools/source/ucbhelper
parent2589f8a155d00b22078607ddd0229d155a394f3a (diff)
add utl::ByteReader pure class
which lets us skip the inefficiency of needing an extra buffer when reading via XInputStream Change-Id: Ic5334b7d11ea6a57bc1800f508fc69611a053af1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134348 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source/ucbhelper')
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 2d716f571586..b40be28f2225 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -27,6 +27,7 @@
#include <tools/urlobj.hxx>
#include <tools/solar.h>
#include <ucbhelper/interactionrequest.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/task/XInteractionAbort.hpp>
#include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
@@ -57,6 +58,7 @@
#include <comphelper/storagehelper.hxx>
#include <ucbhelper/content.hxx>
+#include <unotools/bytereader.hxx>
#include <mutex>
using namespace ::com::sun::star::uno;
@@ -1092,7 +1094,6 @@ ErrCode UcbLockBytes::ReadAt(sal_uInt64 const nPos,
return ERRCODE_IO_CANTSEEK;
}
- Sequence<sal_Int8> aData;
sal_Int32 nSize;
if(nCount > 0x7FFFFFFF)
@@ -1108,14 +1109,27 @@ ErrCode UcbLockBytes::ReadAt(sal_uInt64 const nPos,
return ERRCODE_IO_PENDING;
}
- nSize = xStream->readBytes( aData, sal_Int32(nCount) );
+ Reference< css::lang::XUnoTunnel > xTunnel( xStream, UNO_QUERY );
+ utl::ByteReader* pByteReader = nullptr;
+ if (xTunnel)
+ pByteReader = reinterpret_cast< utl::ByteReader* >( xTunnel->getSomething( utl::ByteReader::getUnoTunnelId() ) );
+
+ if (pByteReader)
+ {
+ nSize = pByteReader->readSomeBytes( static_cast<sal_Int8*>(pBuffer), sal_Int32(nCount) );
+ }
+ else
+ {
+ Sequence<sal_Int8> aData;
+ nSize = xStream->readBytes( aData, sal_Int32(nCount) );
+ memcpy (pBuffer, aData.getConstArray(), nSize);
+ }
}
catch (const IOException&)
{
return ERRCODE_IO_CANTREAD;
}
- memcpy (pBuffer, aData.getConstArray(), nSize);
if (pRead)
*pRead = static_cast<std::size_t>(nSize);