summaryrefslogtreecommitdiff
path: root/sot
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-10-11 18:49:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-15 07:56:42 +0200
commit9ec8bf8f22fe74884185492ef2576ce79b41e4f1 (patch)
tree0b162c71c51a55125a2ce6055632d4f96180f431 /sot
parenta84e3df74eecc8778e3d5be5dd80ad4ddb511edf (diff)
add SvStream::TellEnd
and simplify callsites to use it instead of the current "seek to end, find pos, seek back to original pos" pattern Change-Id: Ib5828868f73c341891efc759af8bd4695ae2f33c Reviewed-on: https://gerrit.libreoffice.org/61738 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sot')
-rw-r--r--sot/source/sdstor/stg.cxx6
-rw-r--r--sot/source/sdstor/stgcache.cxx6
-rw-r--r--sot/source/sdstor/stgdir.cxx4
-rw-r--r--sot/source/sdstor/stgstrms.cxx4
-rw-r--r--sot/source/sdstor/storage.cxx5
-rw-r--r--sot/source/sdstor/ucbstorage.cxx15
6 files changed, 12 insertions, 28 deletions
diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx
index bb74237bff5a..60147cd319ee 100644
--- a/sot/source/sdstor/stg.cxx
+++ b/sot/source/sdstor/stg.cxx
@@ -374,7 +374,7 @@ Storage::Storage( SvStream& r, bool bDirect )
if( r.GetError() == ERRCODE_NONE )
{
pIo->SetStrm( &r, false );
- sal_uInt64 nSize = r.Seek( STREAM_SEEK_TO_END );
+ sal_uInt64 nSize = r.TellEnd();
r.Seek( 0 );
// Initializing is OK if the stream is empty
Init( nSize == 0 );
@@ -419,7 +419,7 @@ Storage::Storage( UCBStorageStream& rStrm, bool bDirect )
pIo->SetStrm( &rStrm );
- sal_uInt64 nSize = pStream->Seek( STREAM_SEEK_TO_END );
+ sal_uInt64 nSize = pStream->TellEnd();
pStream->Seek( 0 );
// Initializing is OK if the stream is empty
Init( nSize == 0 );
@@ -444,7 +444,7 @@ void Storage::Init( bool bCreate )
OSL_ENSURE( pIo, "The pointer may not be empty at this point!" );
if( pIo->Good() && pIo->GetStrm() )
{
- sal_uInt64 nSize = pIo->GetStrm()->Seek( STREAM_SEEK_TO_END );
+ sal_uInt64 nSize = pIo->GetStrm()->TellEnd();
pIo->GetStrm()->Seek( 0 );
if( nSize )
{
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx
index e21ac2335af0..532b74e3d501 100644
--- a/sot/source/sdstor/stgcache.cxx
+++ b/sot/source/sdstor/stgcache.cxx
@@ -111,10 +111,8 @@ void StgCache::SetPhysPageSize( short n )
if ( n >= 512 )
{
m_nPageSize = n;
- sal_uInt64 nPos = m_pStrm->Tell();
- sal_uInt64 nFileSize = m_pStrm->Seek( STREAM_SEEK_TO_END );
+ sal_uInt64 nFileSize = m_pStrm->TellEnd();
m_nPages = lcl_GetPageCount( nFileSize, m_nPageSize );
- m_pStrm->Seek( nPos );
}
}
@@ -295,7 +293,7 @@ bool StgCache::Open( const OUString& rName, StreamMode nMode )
SetStrm( pFileStrm, true );
if( pFileStrm->IsOpen() )
{
- sal_uInt64 nFileSize = m_pStrm->Seek( STREAM_SEEK_TO_END );
+ sal_uInt64 nFileSize = m_pStrm->TellEnd();
m_nPages = lcl_GetPageCount( nFileSize, m_nPageSize );
m_pStrm->Seek( 0 );
}
diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx
index 4fcb13b85ac8..da729a9031ef 100644
--- a/sot/source/sdstor/stgdir.cxx
+++ b/sot/source/sdstor/stgdir.cxx
@@ -738,9 +738,7 @@ void StgDirStrm::SetupEntry( sal_Int32 n, StgDirEntry* pUpper )
if( p )
{
SvStream *pUnderlyingStream = m_rIo.GetStrm();
- sal_uInt64 nCur = pUnderlyingStream->Tell();
- sal_uInt64 nUnderlyingStreamSize = pUnderlyingStream->Seek(STREAM_SEEK_TO_END);
- pUnderlyingStream->Seek(nCur);
+ sal_uInt64 nUnderlyingStreamSize = pUnderlyingStream->TellEnd();
bool bOk(false);
StgDirEntry* pCur = new StgDirEntry( p, STGENTRY_SIZE, nUnderlyingStreamSize, &bOk );
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index ae140fdb128a..35d99f27751f 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -1212,9 +1212,7 @@ sal_uInt64 StgTmpStrm::GetSize() const
sal_uInt64 n;
if( m_pStrm )
{
- sal_uInt64 old = m_pStrm->Tell();
- n = m_pStrm->Seek( STREAM_SEEK_TO_END );
- m_pStrm->Seek( old );
+ n = m_pStrm->TellEnd();
}
else
n = nEndOfData;
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index cb484cca4215..829dd82cb4c8 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -177,10 +177,7 @@ void SotStorageStream::SetSize(sal_uInt64 const nNewSize)
sal_uInt32 SotStorageStream::GetSize() const
{
- sal_uInt64 nPos = Tell();
- const_cast<SotStorageStream *>(this)->Seek( STREAM_SEEK_TO_END );
- sal_uInt64 nSize = Tell();
- const_cast<SotStorageStream *>(this)->Seek( nPos );
+ sal_uInt64 nSize = const_cast<SotStorageStream*>(this)->TellEnd();
return nSize;
}
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index c5c8c13fb088..05027ed580b2 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -262,16 +262,11 @@ sal_Int64 SAL_CALL FileStreamWrapper_Impl::getLength( )
::osl::MutexGuard aGuard( m_aMutex );
checkConnected();
- sal_uInt32 nCurrentPos = m_pSvStream->Tell();
checkError();
- m_pSvStream->Seek(STREAM_SEEK_TO_END);
- sal_uInt32 nEndPos = m_pSvStream->Tell();
- m_pSvStream->Seek(nCurrentPos);
+ sal_Int64 nEndPos = m_pSvStream->TellEnd();
- checkError();
-
- return static_cast<sal_Int64>(nEndPos);
+ return nEndPos;
}
@@ -2875,8 +2870,7 @@ bool UCBStorage::IsStorageFile( SvStream* pFile )
return false;
sal_uInt64 nPos = pFile->Tell();
- pFile->Seek( STREAM_SEEK_TO_END );
- if ( pFile->Tell() < 4 )
+ if ( pFile->TellEnd() < 4 )
return false;
pFile->Seek(0);
@@ -2905,8 +2899,7 @@ OUString UCBStorage::GetLinkedFile( SvStream &rStream )
{
OUString aString;
sal_uInt64 nPos = rStream.Tell();
- rStream.Seek( STREAM_SEEK_TO_END );
- if ( !rStream.Tell() )
+ if ( !rStream.TellEnd() )
return aString;
rStream.Seek(0);