diff options
-rw-r--r-- | comphelper/source/streaming/memorystream.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/oslfile2streamwrap.cxx | 3 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageBuffer.cxx | 2 | ||||
-rw-r--r-- | sot/source/sdstor/ucbstorage.cxx | 11 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/std_inputstream.cxx | 2 | ||||
-rw-r--r-- | ucb/source/ucp/file/filstr.cxx | 3 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonInputStream.cxx | 2 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfInputStream.cxx | 2 | ||||
-rw-r--r-- | ucbhelper/source/provider/fd_inputstream.cxx | 2 | ||||
-rw-r--r-- | unotools/source/streaming/streamwrap.cxx | 11 | ||||
-rw-r--r-- | unotools/source/ucbhelper/xtempfile.cxx | 5 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/inputstream.cxx | 8 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/urlparameter.cxx | 2 |
13 files changed, 23 insertions, 32 deletions
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx index b85701c30321..39b2fa0a63c5 100644 --- a/comphelper/source/streaming/memorystream.cxx +++ b/comphelper/source/streaming/memorystream.cxx @@ -150,7 +150,7 @@ void SAL_CALL UNOMemoryStream::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL UNOMemoryStream::available() { - return static_cast< sal_Int32 >( maData.size() ) - mnCursor; + return std::min<sal_Int64>( SAL_MAX_INT32, maData.size() - mnCursor); } void SAL_CALL UNOMemoryStream::closeInput() diff --git a/comphelper/source/streaming/oslfile2streamwrap.cxx b/comphelper/source/streaming/oslfile2streamwrap.cxx index 342c4a907e08..198ff1ecea12 100644 --- a/comphelper/source/streaming/oslfile2streamwrap.cxx +++ b/comphelper/source/streaming/oslfile2streamwrap.cxx @@ -120,8 +120,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::available() eError = m_pFile->setPos(osl_Pos_Absolut, nPos); if (eError != FileBase::E_None) throw css::io::NotConnectedException(OUString(),static_cast<css::uno::XWeak*>(this)); - return sal::static_int_cast< sal_Int32 >( - std::max(nAvailable, sal::static_int_cast< sal_uInt64 >(SAL_MAX_INT32))); + return std::min<sal_Int64>(nAvailable, SAL_MAX_INT32); } diff --git a/package/source/zippackage/ZipPackageBuffer.cxx b/package/source/zippackage/ZipPackageBuffer.cxx index 8df0f3a96c9b..741c86629038 100644 --- a/package/source/zippackage/ZipPackageBuffer.cxx +++ b/package/source/zippackage/ZipPackageBuffer.cxx @@ -76,7 +76,7 @@ void SAL_CALL ZipPackageBuffer::skipBytes( sal_Int32 nBytesToSkip ) } sal_Int32 SAL_CALL ZipPackageBuffer::available( ) { - return static_cast < sal_Int32 > (m_nEnd - m_nCurrent); + return std::min<sal_Int64>(SAL_MAX_INT32, m_nEnd - m_nCurrent); } void SAL_CALL ZipPackageBuffer::closeInput( ) { diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index d7ffbbf7a756..a9780879e907 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -203,17 +203,10 @@ sal_Int32 SAL_CALL FileStreamWrapper_Impl::available() ::osl::MutexGuard aGuard( m_aMutex ); checkConnected(); - sal_uInt32 nPos = m_pSvStream->Tell(); - checkError(); - - m_pSvStream->Seek(STREAM_SEEK_TO_END); - checkError(); - - sal_Int32 nAvailable = static_cast<sal_Int32>(m_pSvStream->Tell()) - nPos; - m_pSvStream->Seek(nPos); + sal_Int64 nAvailable = m_pSvStream->remainingSize(); checkError(); - return nAvailable; + return std::min<sal_Int64>(SAL_MAX_INT32, nAvailable); } diff --git a/ucb/source/ucp/cmis/std_inputstream.cxx b/ucb/source/ucp/cmis/std_inputstream.cxx index e6a1431f8f7b..2130c3406995 100644 --- a/ucb/source/ucp/cmis/std_inputstream.cxx +++ b/ucb/source/ucp/cmis/std_inputstream.cxx @@ -127,7 +127,7 @@ namespace cmis sal_Int32 SAL_CALL StdInputStream::available( ) { - return sal::static_int_cast< sal_Int32 >( m_nLength - getPosition() ); + return std::min<sal_Int64>( SAL_MAX_INT32, m_nLength - getPosition() ); } void SAL_CALL StdInputStream::closeInput( ) diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx index 69fc4aa28283..2ef94c5e6529 100644 --- a/ucb/source/ucp/file/filstr.cxx +++ b/ucb/source/ucp/file/filstr.cxx @@ -170,7 +170,8 @@ XStream_impl::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL XStream_impl::available() { - return 0; + sal_Int64 avail = getLength() - getPosition(); + return std::min<sal_Int64>(avail, SAL_MAX_INT32); } diff --git a/ucb/source/ucp/webdav-neon/NeonInputStream.cxx b/ucb/source/ucp/webdav-neon/NeonInputStream.cxx index 3e43456a1838..848dc2b81cf8 100644 --- a/ucb/source/ucp/webdav-neon/NeonInputStream.cxx +++ b/ucb/source/ucp/webdav-neon/NeonInputStream.cxx @@ -105,7 +105,7 @@ void SAL_CALL NeonInputStream::skipBytes( sal_Int32 nBytesToSkip ) // Returns the number of unread bytes currently remaining on the stream sal_Int32 SAL_CALL NeonInputStream::available( ) { - return sal::static_int_cast<sal_Int32>(mLen - mPos); + return std::min<sal_Int64>(SAL_MAX_INT32, mLen - mPos); } void SAL_CALL NeonInputStream::closeInput() diff --git a/ucb/source/ucp/webdav/SerfInputStream.cxx b/ucb/source/ucp/webdav/SerfInputStream.cxx index f0f954d64855..498ed26e6c24 100644 --- a/ucb/source/ucp/webdav/SerfInputStream.cxx +++ b/ucb/source/ucp/webdav/SerfInputStream.cxx @@ -120,7 +120,7 @@ void SAL_CALL SerfInputStream::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL SerfInputStream::available( ) { - return sal::static_int_cast<sal_Int32>(mLen - mPos); + return std::min<sal_Int64>(SAL_MAX_INT32, mLen - mPos); } diff --git a/ucbhelper/source/provider/fd_inputstream.cxx b/ucbhelper/source/provider/fd_inputstream.cxx index 32c56b40b0fa..b34e39646a4f 100644 --- a/ucbhelper/source/provider/fd_inputstream.cxx +++ b/ucbhelper/source/provider/fd_inputstream.cxx @@ -99,7 +99,7 @@ namespace ucbhelper sal_Int32 SAL_CALL FdInputStream::available() { - return sal::static_int_cast<sal_Int32>(m_nLength - getPosition()); + return std::min<sal_Int64>(SAL_MAX_INT32, m_nLength - getPosition()); } diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx index fc68b8df300d..bcc365d961b1 100644 --- a/unotools/source/streaming/streamwrap.cxx +++ b/unotools/source/streaming/streamwrap.cxx @@ -107,17 +107,10 @@ sal_Int32 SAL_CALL OInputStreamWrapper::available() ::osl::MutexGuard aGuard( m_aMutex ); checkConnected(); - sal_uInt32 nPos = m_pSvStream->Tell(); - checkError(); - - m_pSvStream->Seek(STREAM_SEEK_TO_END); - checkError(); - - sal_Int32 nAvailable = static_cast<sal_Int32>(m_pSvStream->Tell()) - nPos; - m_pSvStream->Seek(nPos); + sal_Int64 nAvailable = m_pSvStream->remainingSize(); checkError(); - return nAvailable; + return std::min<sal_Int64>(SAL_MAX_INT32, nAvailable); } void SAL_CALL OInputStreamWrapper::closeInput() diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx index a9c955caf5c3..5437044b8586 100644 --- a/unotools/source/ucbhelper/xtempfile.cxx +++ b/unotools/source/ucbhelper/xtempfile.cxx @@ -206,11 +206,10 @@ sal_Int32 SAL_CALL OTempFileService::available( ) checkConnected(); - sal_uInt32 const nAvailable = - static_cast<sal_uInt32>(mpStream->remainingSize()); + sal_Int64 nAvailable = mpStream->remainingSize(); checkError(); - return nAvailable; + return std::min<sal_Int64>(SAL_MAX_INT32, nAvailable); } void SAL_CALL OTempFileService::closeInput( ) { diff --git a/xmlhelp/source/cxxhelp/provider/inputstream.cxx b/xmlhelp/source/cxxhelp/provider/inputstream.cxx index 19e88810799e..e5f18bb5fcc9 100644 --- a/xmlhelp/source/cxxhelp/provider/inputstream.cxx +++ b/xmlhelp/source/cxxhelp/provider/inputstream.cxx @@ -116,7 +116,13 @@ XInputStream_impl::skipBytes( sal_Int32 SAL_CALL XInputStream_impl::available() { - return 0; + sal_uInt64 uPos; + if( osl::FileBase::E_None != m_aFile.getPos( uPos ) ) + throw io::IOException(); + sal_uInt64 uSize; + if( osl::FileBase::E_None != m_aFile.getSize( uSize ) ) + throw io::IOException(); + return std::min<sal_uInt64>(SAL_MAX_INT32, uSize - uPos); } diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index fb0aa90cb62b..8ed8f80a1c69 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -924,7 +924,7 @@ void SAL_CALL InputStreamTransformer::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL InputStreamTransformer::available() { osl::MutexGuard aGuard( m_aMutex ); - return std::max<sal_Int32>(buffer.getLength() - pos, 0); + return std::min<sal_Int64>(SAL_MAX_INT32, buffer.getLength() - pos); } |