Kaydet (Commit) 19bbfc0b authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 655a39d8
......@@ -47,8 +47,8 @@ public:
ImgProdLockBytes( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rStreamRef );
virtual ~ImgProdLockBytes();
virtual ErrCode ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const SAL_OVERRIDE;
virtual ErrCode WriteAt( sal_Size nPos, const void* pBuffer, sal_Size nCount, sal_Size* pWritten ) SAL_OVERRIDE;
virtual ErrCode ReadAt( sal_uInt64 nPos, void* pBuffer, sal_Size nCount, sal_Size * pRead ) const SAL_OVERRIDE;
virtual ErrCode WriteAt( sal_uInt64 nPos, const void* pBuffer, sal_Size nCount, sal_Size * pWritten ) SAL_OVERRIDE;
virtual ErrCode Flush() const SAL_OVERRIDE;
virtual ErrCode SetSize( sal_Size nSize ) SAL_OVERRIDE;
virtual ErrCode Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const SAL_OVERRIDE;
......@@ -94,9 +94,8 @@ ImgProdLockBytes::~ImgProdLockBytes()
{
}
ErrCode ImgProdLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const
ErrCode ImgProdLockBytes::ReadAt(sal_uInt64 const nPos,
void* pBuffer, sal_Size nCount, sal_Size * pRead) const
{
if( GetStream() )
{
......@@ -125,9 +124,8 @@ ErrCode ImgProdLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount,
}
}
ErrCode ImgProdLockBytes::WriteAt( sal_Size nPos, const void* pBuffer, sal_Size nCount, sal_Size* pWritten )
ErrCode ImgProdLockBytes::WriteAt(sal_uInt64 const nPos,
const void* pBuffer, sal_Size nCount, sal_Size * pWritten)
{
if( GetStream() )
return SvLockBytes::WriteAt( nPos, pBuffer, nCount, pWritten );
......
......@@ -32,7 +32,7 @@ class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes
{
com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >
m_xOutputStream;
sal_uInt32 m_nPosition;
sal_uInt64 m_nPosition;
public:
TYPEINFO_OVERRIDE();
......@@ -43,10 +43,10 @@ public:
rTheOutputStream):
m_xOutputStream(rTheOutputStream), m_nPosition(0) {}
virtual ErrCode ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *) const SAL_OVERRIDE;
virtual ErrCode ReadAt(sal_uInt64, void *, sal_uLong, sal_uInt64 *) const SAL_OVERRIDE;
virtual ErrCode WriteAt(sal_uLong nPos, const void * pBuffer, sal_uLong nCount,
sal_uLong * pWritten) SAL_OVERRIDE;
virtual ErrCode WriteAt(sal_uInt64 nPos, const void * pBuffer, sal_uLong nCount,
sal_uInt64 * pWritten) SAL_OVERRIDE;
virtual ErrCode Flush() const SAL_OVERRIDE;
......@@ -57,9 +57,9 @@ public:
virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount,
sal_uLong * pWritten) SAL_OVERRIDE;
virtual sal_uLong Tell() const SAL_OVERRIDE;
virtual sal_uInt64 Tell() const SAL_OVERRIDE;
virtual sal_uLong Seek(sal_uLong) SAL_OVERRIDE;
virtual sal_uInt64 Seek(sal_uInt64) SAL_OVERRIDE;
virtual void Terminate() SAL_OVERRIDE;
};
......
......@@ -129,9 +129,9 @@ public:
virtual void SetSynchronMode(bool bTheSync = true) { m_bSync = bTheSync; }
virtual bool IsSynchronMode() const { return m_bSync; }
virtual ErrCode ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
virtual ErrCode ReadAt(sal_uInt64 nPos, void * pBuffer, sal_Size nCount,
sal_Size * pRead) const;
virtual ErrCode WriteAt(sal_Size nPos, const void * pBuffer, sal_Size nCount,
virtual ErrCode WriteAt(sal_uInt64 nPos, const void * pBuffer, sal_Size nCount,
sal_Size * pWritten);
virtual ErrCode Flush() const;
......@@ -157,9 +157,9 @@ public:
virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount,
sal_Size * pWritten) = 0;
virtual sal_Size Tell() const = 0;
virtual sal_uInt64 Tell() const = 0;
virtual sal_Size Seek(sal_Size nPos) = 0;
virtual sal_uInt64 Seek(sal_uInt64 nPos) = 0;
virtual void Terminate() = 0;
};
......@@ -170,7 +170,7 @@ SV_DECL_IMPL_REF(SvOpenLockBytes);
class SvAsyncLockBytes: public SvOpenLockBytes
{
sal_Size m_nSize;
sal_uInt64 m_nSize;
bool m_bTerminated;
public:
......@@ -179,17 +179,17 @@ public:
SvAsyncLockBytes(SvStream * pStream, bool bOwner):
SvOpenLockBytes(pStream, bOwner), m_nSize(0), m_bTerminated(false) {}
virtual ErrCode ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
virtual ErrCode ReadAt(sal_uInt64 nPos, void * pBuffer, sal_Size nCount,
sal_Size * pRead) const SAL_OVERRIDE;
virtual ErrCode WriteAt(sal_Size nPos, const void * pBuffer, sal_Size nCount,
virtual ErrCode WriteAt(sal_uInt64 nPos, const void * pBuffer, sal_Size nCount,
sal_Size * pWritten) SAL_OVERRIDE;
virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount,
sal_Size * pWritten) SAL_OVERRIDE;
virtual sal_Size Tell() const SAL_OVERRIDE { return m_nSize; }
virtual sal_uInt64 Tell() const SAL_OVERRIDE { return m_nSize; }
virtual sal_Size Seek(sal_Size nPos) SAL_OVERRIDE;
virtual sal_uInt64 Seek(sal_uInt64 nPos) SAL_OVERRIDE;
virtual void Terminate() SAL_OVERRIDE { m_bTerminated = true; }
};
......
......@@ -43,13 +43,13 @@ class UNOTOOLS_DLLPUBLIC OInputStreamHelper : public InputStreamHelper_Base
{
::osl::Mutex m_aMutex;
SvLockBytesRef m_xLockBytes;
sal_uInt32 m_nActPos;
sal_uInt64 m_nActPos;
sal_Int32 m_nAvailable; // this is typically the chunk(buffer) size
public:
OInputStreamHelper(const SvLockBytesRef& _xLockBytes,
sal_uInt32 _nAvailable,
sal_uInt32 _nPos = 0)
sal_uInt64 _nPos = 0)
:m_xLockBytes(_xLockBytes)
,m_nActPos(_nPos)
,m_nAvailable(_nAvailable){}
......
......@@ -132,8 +132,8 @@ public:
// SvLockBytes
virtual void SetSynchronMode (bool bSynchron) SAL_OVERRIDE;
virtual ErrCode ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const SAL_OVERRIDE;
virtual ErrCode WriteAt ( sal_uLong, const void*, sal_uLong, sal_uLong *pWritten) SAL_OVERRIDE;
virtual ErrCode ReadAt(sal_uInt64 nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const SAL_OVERRIDE;
virtual ErrCode WriteAt(sal_uInt64, const void*, sal_uLong, sal_uLong *pWritten) SAL_OVERRIDE;
virtual ErrCode Flush (void) const SAL_OVERRIDE;
virtual ErrCode SetSize (sal_uLong) SAL_OVERRIDE;
virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const SAL_OVERRIDE;
......
......@@ -931,7 +931,7 @@ OutlineToImpressFinalizer::OutlineToImpressFinalizer (
static const sal_Size nBufferSize = 4096;
::boost::scoped_array<sal_Int8> pBuffer (new sal_Int8[nBufferSize]);
sal_Size nReadPosition (0);
sal_uInt64 nReadPosition(0);
bool bLoop (true);
while (bLoop)
{
......
......@@ -138,14 +138,14 @@ inline sal_uInt32 SvDataPipe_Impl::getReadPosition() const
TYPEINIT1(SvOutputStreamOpenLockBytes, SvOpenLockBytes)
// virtual
ErrCode SvOutputStreamOpenLockBytes::ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *)
ErrCode SvOutputStreamOpenLockBytes::ReadAt(sal_uInt64, void *, sal_uLong, sal_uLong*)
const
{
return ERRCODE_IO_CANTREAD;
}
// virtual
ErrCode SvOutputStreamOpenLockBytes::WriteAt(sal_uLong nPos, void const * pBuffer,
ErrCode SvOutputStreamOpenLockBytes::WriteAt(sal_uInt64 const nPos, void const * pBuffer,
sal_uLong nCount, sal_uLong * pWritten)
{
if (nPos != m_nPosition)
......@@ -215,13 +215,13 @@ ErrCode SvOutputStreamOpenLockBytes::FillAppend(void const * pBuffer,
}
// virtual
sal_uLong SvOutputStreamOpenLockBytes::Tell() const
sal_uInt64 SvOutputStreamOpenLockBytes::Tell() const
{
return m_nPosition;
}
// virtual
sal_uLong SvOutputStreamOpenLockBytes::Seek(sal_uLong)
sal_uInt64 SvOutputStreamOpenLockBytes::Seek(sal_uInt64)
{
return m_nPosition;
}
......@@ -293,8 +293,7 @@ SvLockBytesInputStream::readBytes(uno::Sequence< sal_Int8 > & rData,
while (nSize < nBytesToRead)
{
sal_Size nCount;
ErrCode nError = m_xLockBytes->ReadAt(static_cast<sal_Size>(
m_nPosition),
ErrCode nError = m_xLockBytes->ReadAt(m_nPosition,
rData.getArray() + nSize,
nBytesToRead - nSize, &nCount);
if (nError != ERRCODE_NONE && nError != ERRCODE_IO_PENDING)
......@@ -327,7 +326,7 @@ SvLockBytesInputStream::readSomeBytes(uno::Sequence< sal_Int8 > & rData,
ErrCode nError;
do
{
nError = m_xLockBytes->ReadAt(static_cast<sal_Size>(m_nPosition),
nError = m_xLockBytes->ReadAt(m_nPosition,
rData.getArray(),
nMaxBytesToRead < 0 ?
0 : nMaxBytesToRead,
......
......@@ -173,7 +173,7 @@ void SvLockBytes::close()
TYPEINIT0(SvLockBytes);
// virtual
ErrCode SvLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
ErrCode SvLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, sal_Size nCount,
sal_Size * pRead) const
{
if (!m_pStream)
......@@ -190,7 +190,7 @@ ErrCode SvLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
}
// virtual
ErrCode SvLockBytes::WriteAt(sal_Size nPos, const void * pBuffer, sal_Size nCount,
ErrCode SvLockBytes::WriteAt(sal_uInt64 const nPos, const void * pBuffer, sal_Size nCount,
sal_Size * pWritten)
{
if (!m_pStream)
......@@ -258,7 +258,7 @@ TYPEINIT1(SvOpenLockBytes, SvLockBytes);
TYPEINIT1(SvAsyncLockBytes, SvOpenLockBytes);
// virtual
ErrCode SvAsyncLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
ErrCode SvAsyncLockBytes::ReadAt(sal_uInt64 const nPos, void * pBuffer, sal_Size nCount,
sal_Size * pRead) const
{
if (m_bTerminated)
......@@ -274,7 +274,7 @@ ErrCode SvAsyncLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
}
// virtual
ErrCode SvAsyncLockBytes::WriteAt(sal_Size nPos, const void * pBuffer,
ErrCode SvAsyncLockBytes::WriteAt(sal_uInt64 const nPos, const void * pBuffer,
sal_Size nCount, sal_Size * pWritten)
{
if (m_bTerminated)
......@@ -304,7 +304,7 @@ ErrCode SvAsyncLockBytes::FillAppend(const void * pBuffer, sal_Size nCount,
}
// virtual
sal_Size SvAsyncLockBytes::Seek(sal_Size nPos)
sal_uInt64 SvAsyncLockBytes::Seek(sal_uInt64 const nPos)
{
if (nPos != STREAM_SEEK_TO_END)
m_nSize = nPos;
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment