summaryrefslogtreecommitdiff
path: root/unotools
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 /unotools
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 'unotools')
-rw-r--r--unotools/source/streaming/streamwrap.cxx18
-rw-r--r--unotools/source/ucbhelper/xtempfile.cxx9
2 files changed, 6 insertions, 21 deletions
diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx
index bcc365d961b1..97d05180b020 100644
--- a/unotools/source/streaming/streamwrap.cxx
+++ b/unotools/source/streaming/streamwrap.cxx
@@ -177,16 +177,11 @@ sal_Int64 SAL_CALL OSeekableInputStreamWrapper::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;
}
//= OOutputStreamWrapper
@@ -268,16 +263,11 @@ sal_Int64 SAL_CALL OSeekableOutputStreamWrapper::getPosition( )
sal_Int64 SAL_CALL OSeekableOutputStreamWrapper::getLength( )
{
- sal_uInt32 nCurrentPos = rStream.Tell();
checkError();
- rStream.Seek(STREAM_SEEK_TO_END);
- sal_uInt32 nEndPos = rStream.Tell();
- rStream.Seek(nCurrentPos);
-
- checkError();
+ sal_Int64 nEndPos = rStream.TellEnd();
- return static_cast<sal_Int64>(nEndPos);
+ return nEndPos;
}
OStreamWrapper::~OStreamWrapper() = default;
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 5437044b8586..8bfe8b14a009 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -338,16 +338,11 @@ sal_Int64 SAL_CALL OTempFileService::getLength( )
::osl::MutexGuard aGuard( maMutex );
checkConnected();
- sal_uInt32 nCurrentPos = mpStream->Tell();
checkError();
- mpStream->Seek(STREAM_SEEK_TO_END);
- sal_uInt32 nEndPos = mpStream->Tell();
- mpStream->Seek(nCurrentPos);
+ sal_Int64 nEndPos = mpStream->TellEnd();
- checkError();
-
- return static_cast<sal_Int64>(nEndPos);
+ return nEndPos;
}
// XStream