diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-04-23 20:15:30 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-06-04 20:58:12 +0200 |
commit | b00c351f0466c65ba51e980d8554e09efe0b7bd8 (patch) | |
tree | 177b83623c75746c9a998618b3f3850102e856bb /unotools | |
parent | 4900217e74e29c8e19c9a697883c21cbd50c9dbc (diff) |
Use getXWeak in unotools
Change-Id: I61ae9f11c3017442ac7461ca57f5625d1687fc68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150882
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/streaming/streamhelper.cxx | 14 | ||||
-rw-r--r-- | unotools/source/streaming/streamwrap.cxx | 18 | ||||
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 26 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 4 | ||||
-rw-r--r-- | unotools/source/ucbhelper/xtempfile.cxx | 26 |
5 files changed, 44 insertions, 44 deletions
diff --git a/unotools/source/streaming/streamhelper.cxx b/unotools/source/streaming/streamhelper.cxx index b5f07e6a6a7f..12f6ad7afd5a 100644 --- a/unotools/source/streaming/streamhelper.cxx +++ b/unotools/source/streaming/streamhelper.cxx @@ -31,10 +31,10 @@ namespace utl sal_Int32 SAL_CALL OInputStreamHelper::readBytes(css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) { if (!m_xLockBytes.is()) - throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::NotConnectedException(OUString(), getXWeak()); if (nBytesToRead < 0) - throw css::io::BufferSizeExceededException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); std::scoped_lock aGuard( m_aMutex ); if (aData.getLength() < nBytesToRead) @@ -45,7 +45,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(css::uno::Sequence< sal_Int8 >& m_nActPos += nRead; if (nError != ERRCODE_NONE) - throw css::io::IOException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::IOException(OUString(), getXWeak()); // adjust sequence if data read is lower than the desired data if (nRead < o3tl::make_unsigned(aData.getLength())) @@ -87,10 +87,10 @@ void SAL_CALL OInputStreamHelper::skipBytes(sal_Int32 nBytesToSkip) { std::scoped_lock aGuard( m_aMutex ); if (!m_xLockBytes.is()) - throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::NotConnectedException(OUString(), getXWeak()); if (nBytesToSkip < 0) - throw css::io::BufferSizeExceededException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); m_nActPos += nBytesToSkip; } @@ -99,7 +99,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::available() { std::scoped_lock aGuard( m_aMutex ); if (!m_xLockBytes.is()) - throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::NotConnectedException(OUString(), getXWeak()); return m_nAvailable; } @@ -108,7 +108,7 @@ void SAL_CALL OInputStreamHelper::closeInput() { std::scoped_lock aGuard( m_aMutex ); if (!m_xLockBytes.is()) - throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); + throw css::io::NotConnectedException(OUString(), getXWeak()); m_xLockBytes = nullptr; } diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx index 593f7a1f0b28..2f8a86981194 100644 --- a/unotools/source/streaming/streamwrap.cxx +++ b/unotools/source/streaming/streamwrap.cxx @@ -61,7 +61,7 @@ sal_Int32 SAL_CALL OInputStreamWrapper::readBytes(css::uno::Sequence< sal_Int8 > checkConnected(); if (nBytesToRead < 0) - throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); std::scoped_lock aGuard( m_aMutex ); @@ -83,7 +83,7 @@ sal_Int32 OInputStreamWrapper::readSomeBytes(sal_Int8* pData, sal_Int32 nBytesTo checkConnected(); if (nBytesToRead < 0) - throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); std::scoped_lock aGuard( m_aMutex ); @@ -98,7 +98,7 @@ sal_Int32 SAL_CALL OInputStreamWrapper::readSomeBytes(css::uno::Sequence< sal_In checkError(); if (nMaxBytesToRead < 0) - throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); if (m_pSvStream->eof()) { @@ -144,7 +144,7 @@ void SAL_CALL OInputStreamWrapper::closeInput() void OInputStreamWrapper::checkConnected() const { if (!m_pSvStream) - throw css::io::NotConnectedException(OUString(), const_cast<css::uno::XWeak*>(static_cast<const css::uno::XWeak*>(this))); + throw css::io::NotConnectedException(OUString(), const_cast<OInputStreamWrapper*>(this)->getXWeak()); } void OInputStreamWrapper::checkError() const @@ -154,7 +154,7 @@ void OInputStreamWrapper::checkError() const auto const e = m_pSvStream->SvStream::GetError(); if (e != ERRCODE_NONE) // TODO: really evaluate the error - throw css::io::NotConnectedException("utl::OInputStreamWrapper error " + e.toString(), const_cast<css::uno::XWeak*>(static_cast<const css::uno::XWeak*>(this))); + throw css::io::NotConnectedException("utl::OInputStreamWrapper error " + e.toString(), const_cast<OInputStreamWrapper*>(this)->getXWeak()); } //= OSeekableInputStreamWrapper @@ -218,7 +218,7 @@ void SAL_CALL OOutputStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int || (nWritten != static_cast<sal_uInt32>(aData.getLength())) ) { - throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); } } @@ -236,7 +236,7 @@ void OOutputStreamWrapper::checkError() const { if (rStream.GetError() != ERRCODE_NONE) // TODO: really evaluate the error - throw css::io::NotConnectedException(OUString(), const_cast<css::uno::XWeak*>(static_cast<const css::uno::XWeak*>(this))); + throw css::io::NotConnectedException(OUString(), const_cast<OOutputStreamWrapper*>(this)->getXWeak()); } //= OSeekableOutputStreamWrapper @@ -313,7 +313,7 @@ void SAL_CALL OStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int8 >& a || (nWritten != static_cast<sal_uInt32>(aData.getLength())) ) { - throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::BufferSizeExceededException(OUString(), getXWeak()); } } @@ -321,7 +321,7 @@ void SAL_CALL OStreamWrapper::flush() { m_pSvStream->FlushBuffer(); if (m_pSvStream->GetError() != ERRCODE_NONE) - throw css::io::NotConnectedException(OUString(),static_cast<css::uno::XWeak*>(this)); + throw css::io::NotConnectedException(OUString(), getXWeak()); } void SAL_CALL OStreamWrapper::closeOutput() diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 2cf7a94ec5ed..4c6749226d77 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -597,11 +597,11 @@ sal_Int32 SAL_CALL TempFileFastService::readBytes( css::uno::Sequence< sal_Int8 { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); if (nBytesToRead < 0) - throw css::io::BufferSizeExceededException( OUString(), static_cast< css::uno::XWeak * >(this)); + throw css::io::BufferSizeExceededException( OUString(), getXWeak()); if (aData.getLength() < nBytesToRead) aData.realloc(nBytesToRead); @@ -620,13 +620,13 @@ sal_Int32 SAL_CALL TempFileFastService::readSomeBytes( css::uno::Sequence< sal_I { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); checkError(); if (nMaxBytesToRead < 0) - throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); + throw css::io::BufferSizeExceededException( OUString(), getXWeak() ); if (mpStream->eof()) { @@ -641,7 +641,7 @@ void SAL_CALL TempFileFastService::skipBytes( sal_Int32 nBytesToSkip ) { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); checkError(); @@ -653,7 +653,7 @@ sal_Int32 SAL_CALL TempFileFastService::available() { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); @@ -667,7 +667,7 @@ void SAL_CALL TempFileFastService::closeInput() { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); mbInClosed = true; @@ -685,20 +685,20 @@ void SAL_CALL TempFileFastService::writeBytes( const css::uno::Sequence< sal_Int { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength()); checkError(); if ( nWritten != static_cast<sal_uInt32>(aData.getLength())) - throw css::io::BufferSizeExceededException( OUString(),static_cast < css::uno::XWeak * > ( this ) ); + throw css::io::BufferSizeExceededException( OUString(), getXWeak() ); } void SAL_CALL TempFileFastService::flush() { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); mpStream->Flush(); @@ -709,7 +709,7 @@ void SAL_CALL TempFileFastService::closeOutput() { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); mbOutClosed = true; if (mpStream) @@ -730,13 +730,13 @@ void SAL_CALL TempFileFastService::closeOutput() void TempFileFastService::checkError() const { if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE ) - throw css::io::NotConnectedException ( OUString(), const_cast < css::uno::XWeak * > ( static_cast < const css::uno::XWeak * > (this ) ) ); + throw css::io::NotConnectedException ( OUString(), const_cast < TempFileFastService * > (this)->getXWeak() ); } void TempFileFastService::checkConnected() { if (!mpStream) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); } // XSeekable diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index ad5289f9310f..0a46323b57eb 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -459,11 +459,11 @@ Moderator::Moderator( Reference < XActiveDataSink > xActiveSink(*pxSink,UNO_QUERY); if(xActiveSink.is()) - pxSink->set( static_cast<cppu::OWeakObject*>(new ModeratorsActiveDataSink(*this))); + pxSink->set(getXWeak(new ModeratorsActiveDataSink(*this))); Reference<XActiveDataStreamer> xStreamer( *pxSink, UNO_QUERY ); if ( xStreamer.is() ) - pxSink->set( static_cast<cppu::OWeakObject*>(new ModeratorsActiveDataStreamer(*this))); + pxSink->set(getXWeak(new ModeratorsActiveDataStreamer(*this))); if(dec == 0) m_aArg.Argument <<= aPostArg; diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx index 1515bc05f3e9..8c1da6c98504 100644 --- a/unotools/source/ucbhelper/xtempfile.cxx +++ b/unotools/source/ucbhelper/xtempfile.cxx @@ -109,11 +109,11 @@ sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >& { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); if (nBytesToRead < 0) - throw css::io::BufferSizeExceededException( OUString(), static_cast< css::uno::XWeak * >(this)); + throw css::io::BufferSizeExceededException( OUString(), getXWeak()); if (aData.getLength() < nBytesToRead) aData.realloc(nBytesToRead); @@ -131,13 +131,13 @@ sal_Int32 SAL_CALL OTempFileService::readSomeBytes( css::uno::Sequence< sal_Int8 { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); checkError(); if (nMaxBytesToRead < 0) - throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); + throw css::io::BufferSizeExceededException( OUString(), getXWeak() ); if (mpStream->eof()) { @@ -151,7 +151,7 @@ void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip ) { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); checkError(); @@ -162,7 +162,7 @@ sal_Int32 SAL_CALL OTempFileService::available( ) { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); @@ -175,7 +175,7 @@ void SAL_CALL OTempFileService::closeInput( ) { std::unique_lock aGuard( maMutex ); if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); mbInClosed = true; @@ -193,19 +193,19 @@ void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 > { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength()); checkError(); if ( nWritten != static_cast<sal_uInt32>(aData.getLength())) - throw css::io::BufferSizeExceededException( OUString(),static_cast < css::uno::XWeak * > ( this ) ); + throw css::io::BufferSizeExceededException( OUString(), getXWeak() ); } void SAL_CALL OTempFileService::flush( ) { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); checkConnected(); mpStream->Flush(); @@ -215,7 +215,7 @@ void SAL_CALL OTempFileService::closeOutput( ) { std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); mbOutClosed = true; if (mpStream) @@ -236,7 +236,7 @@ void SAL_CALL OTempFileService::closeOutput( ) void OTempFileService::checkError () const { if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE ) - throw css::io::NotConnectedException ( OUString(), const_cast < css::uno::XWeak * > ( static_cast < const css::uno::XWeak * > (this ) ) ); + throw css::io::NotConnectedException ( OUString(), const_cast < OTempFileService * > (this)->getXWeak() ); } void OTempFileService::checkConnected () { @@ -249,7 +249,7 @@ void OTempFileService::checkConnected () } if (!mpStream) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + throw css::io::NotConnectedException ( OUString(), getXWeak() ); } // XSeekable |