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: ...@@ -47,8 +47,8 @@ public:
ImgProdLockBytes( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rStreamRef ); ImgProdLockBytes( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rStreamRef );
virtual ~ImgProdLockBytes(); virtual ~ImgProdLockBytes();
virtual ErrCode ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const SAL_OVERRIDE; 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, sal_Size* pWritten ) 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 Flush() const SAL_OVERRIDE;
virtual ErrCode SetSize( sal_Size nSize ) SAL_OVERRIDE; virtual ErrCode SetSize( sal_Size nSize ) SAL_OVERRIDE;
virtual ErrCode Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const SAL_OVERRIDE; virtual ErrCode Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const SAL_OVERRIDE;
...@@ -94,9 +94,8 @@ ImgProdLockBytes::~ImgProdLockBytes() ...@@ -94,9 +94,8 @@ ImgProdLockBytes::~ImgProdLockBytes()
{ {
} }
ErrCode ImgProdLockBytes::ReadAt(sal_uInt64 const nPos,
void* pBuffer, sal_Size nCount, sal_Size * pRead) const
ErrCode ImgProdLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const
{ {
if( GetStream() ) if( GetStream() )
{ {
...@@ -125,9 +124,8 @@ ErrCode ImgProdLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, ...@@ -125,9 +124,8 @@ ErrCode ImgProdLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount,
} }
} }
ErrCode ImgProdLockBytes::WriteAt(sal_uInt64 const nPos,
const void* pBuffer, sal_Size nCount, sal_Size * pWritten)
ErrCode ImgProdLockBytes::WriteAt( sal_Size nPos, const void* pBuffer, sal_Size nCount, sal_Size* pWritten )
{ {
if( GetStream() ) if( GetStream() )
return SvLockBytes::WriteAt( nPos, pBuffer, nCount, pWritten ); return SvLockBytes::WriteAt( nPos, pBuffer, nCount, pWritten );
......
...@@ -32,7 +32,7 @@ class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes ...@@ -32,7 +32,7 @@ class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes
{ {
com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >
m_xOutputStream; m_xOutputStream;
sal_uInt32 m_nPosition; sal_uInt64 m_nPosition;
public: public:
TYPEINFO_OVERRIDE(); TYPEINFO_OVERRIDE();
...@@ -43,10 +43,10 @@ public: ...@@ -43,10 +43,10 @@ public:
rTheOutputStream): rTheOutputStream):
m_xOutputStream(rTheOutputStream), m_nPosition(0) {} 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, virtual ErrCode WriteAt(sal_uInt64 nPos, const void * pBuffer, sal_uLong nCount,
sal_uLong * pWritten) SAL_OVERRIDE; sal_uInt64 * pWritten) SAL_OVERRIDE;
virtual ErrCode Flush() const SAL_OVERRIDE; virtual ErrCode Flush() const SAL_OVERRIDE;
...@@ -57,9 +57,9 @@ public: ...@@ -57,9 +57,9 @@ public:
virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount, virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount,
sal_uLong * pWritten) SAL_OVERRIDE; 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; virtual void Terminate() SAL_OVERRIDE;
}; };
......
...@@ -129,9 +129,9 @@ public: ...@@ -129,9 +129,9 @@ public:
virtual void SetSynchronMode(bool bTheSync = true) { m_bSync = bTheSync; } virtual void SetSynchronMode(bool bTheSync = true) { m_bSync = bTheSync; }
virtual bool IsSynchronMode() const { return m_bSync; } 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; 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); sal_Size * pWritten);
virtual ErrCode Flush() const; virtual ErrCode Flush() const;
...@@ -157,9 +157,9 @@ public: ...@@ -157,9 +157,9 @@ public:
virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount, virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount,
sal_Size * pWritten) = 0; 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; virtual void Terminate() = 0;
}; };
...@@ -170,7 +170,7 @@ SV_DECL_IMPL_REF(SvOpenLockBytes); ...@@ -170,7 +170,7 @@ SV_DECL_IMPL_REF(SvOpenLockBytes);
class SvAsyncLockBytes: public SvOpenLockBytes class SvAsyncLockBytes: public SvOpenLockBytes
{ {
sal_Size m_nSize; sal_uInt64 m_nSize;
bool m_bTerminated; bool m_bTerminated;
public: public:
...@@ -179,17 +179,17 @@ public: ...@@ -179,17 +179,17 @@ public:
SvAsyncLockBytes(SvStream * pStream, bool bOwner): SvAsyncLockBytes(SvStream * pStream, bool bOwner):
SvOpenLockBytes(pStream, bOwner), m_nSize(0), m_bTerminated(false) {} 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; 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; sal_Size * pWritten) SAL_OVERRIDE;
virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount, virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount,
sal_Size * pWritten) SAL_OVERRIDE; 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; } virtual void Terminate() SAL_OVERRIDE { m_bTerminated = true; }
}; };
......
...@@ -43,13 +43,13 @@ class UNOTOOLS_DLLPUBLIC OInputStreamHelper : public InputStreamHelper_Base ...@@ -43,13 +43,13 @@ class UNOTOOLS_DLLPUBLIC OInputStreamHelper : public InputStreamHelper_Base
{ {
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
SvLockBytesRef m_xLockBytes; SvLockBytesRef m_xLockBytes;
sal_uInt32 m_nActPos; sal_uInt64 m_nActPos;
sal_Int32 m_nAvailable; // this is typically the chunk(buffer) size sal_Int32 m_nAvailable; // this is typically the chunk(buffer) size
public: public:
OInputStreamHelper(const SvLockBytesRef& _xLockBytes, OInputStreamHelper(const SvLockBytesRef& _xLockBytes,
sal_uInt32 _nAvailable, sal_uInt32 _nAvailable,
sal_uInt32 _nPos = 0) sal_uInt64 _nPos = 0)
:m_xLockBytes(_xLockBytes) :m_xLockBytes(_xLockBytes)
,m_nActPos(_nPos) ,m_nActPos(_nPos)
,m_nAvailable(_nAvailable){} ,m_nAvailable(_nAvailable){}
......
...@@ -132,8 +132,8 @@ public: ...@@ -132,8 +132,8 @@ public:
// SvLockBytes // SvLockBytes
virtual void SetSynchronMode (bool bSynchron) SAL_OVERRIDE; 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 ReadAt(sal_uInt64 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 WriteAt(sal_uInt64, const void*, sal_uLong, sal_uLong *pWritten) SAL_OVERRIDE;
virtual ErrCode Flush (void) const SAL_OVERRIDE; virtual ErrCode Flush (void) const SAL_OVERRIDE;
virtual ErrCode SetSize (sal_uLong) SAL_OVERRIDE; virtual ErrCode SetSize (sal_uLong) SAL_OVERRIDE;
virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const SAL_OVERRIDE; virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const SAL_OVERRIDE;
......
...@@ -931,7 +931,7 @@ OutlineToImpressFinalizer::OutlineToImpressFinalizer ( ...@@ -931,7 +931,7 @@ OutlineToImpressFinalizer::OutlineToImpressFinalizer (
static const sal_Size nBufferSize = 4096; static const sal_Size nBufferSize = 4096;
::boost::scoped_array<sal_Int8> pBuffer (new sal_Int8[nBufferSize]); ::boost::scoped_array<sal_Int8> pBuffer (new sal_Int8[nBufferSize]);
sal_Size nReadPosition (0); sal_uInt64 nReadPosition(0);
bool bLoop (true); bool bLoop (true);
while (bLoop) while (bLoop)
{ {
......
...@@ -138,14 +138,14 @@ inline sal_uInt32 SvDataPipe_Impl::getReadPosition() const ...@@ -138,14 +138,14 @@ inline sal_uInt32 SvDataPipe_Impl::getReadPosition() const
TYPEINIT1(SvOutputStreamOpenLockBytes, SvOpenLockBytes) TYPEINIT1(SvOutputStreamOpenLockBytes, SvOpenLockBytes)
// virtual // virtual
ErrCode SvOutputStreamOpenLockBytes::ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *) ErrCode SvOutputStreamOpenLockBytes::ReadAt(sal_uInt64, void *, sal_uLong, sal_uLong*)
const const
{ {
return ERRCODE_IO_CANTREAD; return ERRCODE_IO_CANTREAD;
} }
// virtual // 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) sal_uLong nCount, sal_uLong * pWritten)
{ {
if (nPos != m_nPosition) if (nPos != m_nPosition)
...@@ -215,13 +215,13 @@ ErrCode SvOutputStreamOpenLockBytes::FillAppend(void const * pBuffer, ...@@ -215,13 +215,13 @@ ErrCode SvOutputStreamOpenLockBytes::FillAppend(void const * pBuffer,
} }
// virtual // virtual
sal_uLong SvOutputStreamOpenLockBytes::Tell() const sal_uInt64 SvOutputStreamOpenLockBytes::Tell() const
{ {
return m_nPosition; return m_nPosition;
} }
// virtual // virtual
sal_uLong SvOutputStreamOpenLockBytes::Seek(sal_uLong) sal_uInt64 SvOutputStreamOpenLockBytes::Seek(sal_uInt64)
{ {
return m_nPosition; return m_nPosition;
} }
...@@ -293,8 +293,7 @@ SvLockBytesInputStream::readBytes(uno::Sequence< sal_Int8 > & rData, ...@@ -293,8 +293,7 @@ SvLockBytesInputStream::readBytes(uno::Sequence< sal_Int8 > & rData,
while (nSize < nBytesToRead) while (nSize < nBytesToRead)
{ {
sal_Size nCount; sal_Size nCount;
ErrCode nError = m_xLockBytes->ReadAt(static_cast<sal_Size>( ErrCode nError = m_xLockBytes->ReadAt(m_nPosition,
m_nPosition),
rData.getArray() + nSize, rData.getArray() + nSize,
nBytesToRead - nSize, &nCount); nBytesToRead - nSize, &nCount);
if (nError != ERRCODE_NONE && nError != ERRCODE_IO_PENDING) if (nError != ERRCODE_NONE && nError != ERRCODE_IO_PENDING)
...@@ -327,7 +326,7 @@ SvLockBytesInputStream::readSomeBytes(uno::Sequence< sal_Int8 > & rData, ...@@ -327,7 +326,7 @@ SvLockBytesInputStream::readSomeBytes(uno::Sequence< sal_Int8 > & rData,
ErrCode nError; ErrCode nError;
do do
{ {
nError = m_xLockBytes->ReadAt(static_cast<sal_Size>(m_nPosition), nError = m_xLockBytes->ReadAt(m_nPosition,
rData.getArray(), rData.getArray(),
nMaxBytesToRead < 0 ? nMaxBytesToRead < 0 ?
0 : nMaxBytesToRead, 0 : nMaxBytesToRead,
......
...@@ -173,7 +173,7 @@ void SvLockBytes::close() ...@@ -173,7 +173,7 @@ void SvLockBytes::close()
TYPEINIT0(SvLockBytes); TYPEINIT0(SvLockBytes);
// virtual // 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 sal_Size * pRead) const
{ {
if (!m_pStream) if (!m_pStream)
...@@ -190,7 +190,7 @@ ErrCode SvLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount, ...@@ -190,7 +190,7 @@ ErrCode SvLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
} }
// virtual // 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) sal_Size * pWritten)
{ {
if (!m_pStream) if (!m_pStream)
...@@ -258,7 +258,7 @@ TYPEINIT1(SvOpenLockBytes, SvLockBytes); ...@@ -258,7 +258,7 @@ TYPEINIT1(SvOpenLockBytes, SvLockBytes);
TYPEINIT1(SvAsyncLockBytes, SvOpenLockBytes); TYPEINIT1(SvAsyncLockBytes, SvOpenLockBytes);
// virtual // 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 sal_Size * pRead) const
{ {
if (m_bTerminated) if (m_bTerminated)
...@@ -274,7 +274,7 @@ ErrCode SvAsyncLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount, ...@@ -274,7 +274,7 @@ ErrCode SvAsyncLockBytes::ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount,
} }
// virtual // 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) sal_Size nCount, sal_Size * pWritten)
{ {
if (m_bTerminated) if (m_bTerminated)
...@@ -304,7 +304,7 @@ ErrCode SvAsyncLockBytes::FillAppend(const void * pBuffer, sal_Size nCount, ...@@ -304,7 +304,7 @@ ErrCode SvAsyncLockBytes::FillAppend(const void * pBuffer, sal_Size nCount,
} }
// virtual // virtual
sal_Size SvAsyncLockBytes::Seek(sal_Size nPos) sal_uInt64 SvAsyncLockBytes::Seek(sal_uInt64 const nPos)
{ {
if (nPos != STREAM_SEEK_TO_END) if (nPos != STREAM_SEEK_TO_END)
m_nSize = nPos; m_nSize = nPos;
......
...@@ -47,10 +47,9 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >& ...@@ -47,10 +47,9 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >&
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
aData.realloc(nBytesToRead); aData.realloc(nBytesToRead);
sal_Size nRead; sal_Size nRead(0);
ErrCode nError = m_xLockBytes->ReadAt(m_nActPos, (void*)aData.getArray(), nBytesToRead, &nRead); ErrCode nError = m_xLockBytes->ReadAt(m_nActPos, (void*)aData.getArray(), nBytesToRead, &nRead);
// FIXME nRead could be truncated on 64-bit arches m_nActPos += nRead;
m_nActPos += (sal_uInt32)nRead;
if (nError != ERRCODE_NONE) if (nError != ERRCODE_NONE)
throw stario::IOException(OUString(), static_cast<staruno::XWeak*>(this)); throw stario::IOException(OUString(), static_cast<staruno::XWeak*>(this));
...@@ -65,9 +64,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(staruno::Sequence< sal_Int8 >& ...@@ -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) 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 ); ::osl::MutexGuard aGuard( m_aMutex );
// cast is truncating, but position would be truncated as soon as m_nActPos = location;
// put into SvLockBytes anyway
m_nActPos = sal::static_int_cast<sal_uInt32>(location);
} }
sal_Int64 SAL_CALL OInputStreamHelper::getPosition( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) 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) ...@@ -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() ) if ( IsSynchronMode() )
{ {
...@@ -1442,7 +1443,8 @@ ErrCode UcbLockBytes::ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount, ...@@ -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 ) if ( pWritten )
*pWritten = 0; *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