From 19bbfc0b39d79a90539fd3094d9b6d7d81619a45 Mon Sep 17 00:00:00 2001
From: Michael Stahl <mstahl@redhat.com>
Date: Fri, 28 Mar 2014 23:03:57 +0100
Subject: tools: allow 64-bit positions on SvLockBytes

Bump stream positions to 64 bits on:

SvLockBytes::ReadAt()
SvLockBytes::WriteAt()
SvAsyncLockBytes::m_nSize
SvOpenLockBytes::Seek()
SvOpenLockBytes::Tell()
SvOutputStreamOpenLockBytes::m_nPosition
OInputStreamHelper::m_nActPos

Change-Id: Ica3b674e0ab23a756260a51475e97a5396ecdddb
---
 unotools/source/streaming/streamhelper.cxx | 9 +++------
 unotools/source/ucbhelper/ucblockbytes.cxx | 6 ++++--
 2 files changed, 7 insertions(+), 8 deletions(-)

(limited to 'unotools')

diff --git a/unotools/source/streaming/streamhelper.cxx b/unotools/source/streaming/streamhelper.cxx
index 519e6c7455ad..569d6e180dd0 100644
--- a/unotools/source/streaming/streamhelper.cxx
+++ b/unotools/source/streaming/streamhelper.cxx
@@ -47,10 +47,9 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >&
     ::osl::MutexGuard aGuard( m_aMutex );
     aData.realloc(nBytesToRead);
 
-    sal_Size nRead;
+    sal_Size nRead(0);
     ErrCode nError = m_xLockBytes->ReadAt(m_nActPos, (void*)aData.getArray(), nBytesToRead, &nRead);
-    // FIXME  nRead could be truncated on 64-bit arches
-    m_nActPos += (sal_uInt32)nRead;
+    m_nActPos += nRead;
 
     if (nError != ERRCODE_NONE)
         throw stario::IOException(OUString(), static_cast<staruno::XWeak*>(this));
@@ -65,9 +64,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >&
 void SAL_CALL OInputStreamHelper::seek( sal_Int64 location ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
 {
     ::osl::MutexGuard aGuard( m_aMutex );
-    // cast is truncating, but position would be truncated as soon as
-    // put into SvLockBytes anyway
-    m_nActPos = sal::static_int_cast<sal_uInt32>(location);
+    m_nActPos = location;
 }
 
 sal_Int64 SAL_CALL OInputStreamHelper::getPosition(  ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 7253efff8a3d..4d49bc177812 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -1374,7 +1374,8 @@ void UcbLockBytes::SetSynchronMode (bool bSynchron)
 }
 
 
-ErrCode UcbLockBytes::ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const
+ErrCode UcbLockBytes::ReadAt(sal_uInt64 const nPos,
+        void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const
 {
     if ( IsSynchronMode() )
     {
@@ -1442,7 +1443,8 @@ ErrCode UcbLockBytes::ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount,
 }
 
 
-ErrCode UcbLockBytes::WriteAt ( sal_uLong nPos, const void *pBuffer, sal_uLong nCount, sal_uLong *pWritten)
+ErrCode UcbLockBytes::WriteAt(sal_uInt64 const nPos, const void *pBuffer,
+        sal_uLong nCount, sal_uLong *pWritten)
 {
     if ( pWritten )
         *pWritten = 0;
-- 
cgit