summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-23 19:45:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-25 07:15:19 +0100
commit8d17c555ad913b787927ab327586965c04048505 (patch)
tree4c5627721ba03dd72ee2ab4eb74819f56c072246 /unotools
parent9bfc42015acd6ae3475ab7927ccc006507cc38a2 (diff)
osl::Mutex->std::mutex in OTempFileService
Change-Id: If841031faf5b214a1978422b93b59cfa32fcd299 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127400 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/ucbhelper/XTempFile.hxx4
-rw-r--r--unotools/source/ucbhelper/xtempfile.cxx61
2 files changed, 34 insertions, 31 deletions
diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx
index a59abd5ae622..7fcaefb7be1f 100644
--- a/unotools/source/ucbhelper/XTempFile.hxx
+++ b/unotools/source/ucbhelper/XTempFile.hxx
@@ -28,7 +28,7 @@
#include <com/sun/star/beans/XFastPropertySet.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <unotools/tempfile.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -50,7 +50,7 @@ class OTempFileService : public OTempFileBase
{
protected:
std::optional<utl::TempFile> mpTempFile;
- ::osl::Mutex maMutex;
+ std::mutex maMutex;
SvStream* mpStream;
bool mbRemoveFile;
bool mbInClosed;
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index d0f566c9e26c..a8ace5da6725 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -56,7 +56,7 @@ css::uno::Sequence< css::uno::Type > SAL_CALL OTempFileService::getTypes( )
sal_Bool SAL_CALL OTempFileService::getRemoveFile()
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( !mpTempFile )
{
@@ -68,7 +68,7 @@ sal_Bool SAL_CALL OTempFileService::getRemoveFile()
};
void SAL_CALL OTempFileService::setRemoveFile( sal_Bool _removefile )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( !mpTempFile )
{
@@ -81,7 +81,7 @@ void SAL_CALL OTempFileService::setRemoveFile( sal_Bool _removefile )
};
OUString SAL_CALL OTempFileService::getUri()
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( !mpTempFile )
{
@@ -93,7 +93,7 @@ OUString SAL_CALL OTempFileService::getUri()
};
OUString SAL_CALL OTempFileService::getResourceName()
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( !mpTempFile )
{
@@ -107,7 +107,7 @@ OUString SAL_CALL OTempFileService::getResourceName()
sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -128,27 +128,28 @@ sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >&
}
sal_Int32 SAL_CALL OTempFileService::readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
{
- ::osl::MutexGuard aGuard( maMutex );
- if ( mbInClosed )
- throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
+ {
+ std::unique_lock aGuard( maMutex );
+ if ( mbInClosed )
+ throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
- checkConnected();
- checkError();
+ checkConnected();
+ checkError();
- if (nMaxBytesToRead < 0)
- throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) );
+ if (nMaxBytesToRead < 0)
+ throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) );
- if (mpStream->eof())
- {
- aData.realloc(0);
- return 0;
+ if (mpStream->eof())
+ {
+ aData.realloc(0);
+ return 0;
+ }
}
- else
- return readBytes(aData, nMaxBytesToRead);
+ return readBytes(aData, nMaxBytesToRead);
}
void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -159,7 +160,7 @@ void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip )
}
sal_Int32 SAL_CALL OTempFileService::available( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -172,7 +173,7 @@ sal_Int32 SAL_CALL OTempFileService::available( )
}
void SAL_CALL OTempFileService::closeInput( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -190,7 +191,7 @@ void SAL_CALL OTempFileService::closeInput( )
void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 >& aData )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -202,7 +203,7 @@ void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 >
}
void SAL_CALL OTempFileService::flush( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -212,7 +213,7 @@ void SAL_CALL OTempFileService::flush( )
}
void SAL_CALL OTempFileService::closeOutput( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) );
@@ -249,9 +250,11 @@ void OTempFileService::checkConnected ()
void SAL_CALL OTempFileService::seek( sal_Int64 nLocation )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
checkConnected();
- if ( nLocation < 0 || nLocation > getLength() )
+ checkError();
+ sal_Int64 nEndPos = mpStream->TellEnd();
+ if ( nLocation < 0 || nLocation > nEndPos )
throw css::lang::IllegalArgumentException();
mpStream->Seek(static_cast<sal_uInt32>(nLocation) );
@@ -259,7 +262,7 @@ void SAL_CALL OTempFileService::seek( sal_Int64 nLocation )
}
sal_Int64 SAL_CALL OTempFileService::getPosition( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
checkConnected();
sal_uInt32 nPos = mpStream->Tell();
@@ -268,7 +271,7 @@ sal_Int64 SAL_CALL OTempFileService::getPosition( )
}
sal_Int64 SAL_CALL OTempFileService::getLength( )
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
checkConnected();
checkError();
@@ -294,7 +297,7 @@ css::uno::Reference< css::io::XOutputStream > SAL_CALL OTempFileService::getOutp
void SAL_CALL OTempFileService::truncate()
{
- ::osl::MutexGuard aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
checkConnected();
// SetStreamSize() call does not change the position
mpStream->Seek( 0 );