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>
This commit is contained in:
Mike Kaganski
2023-04-23 20:15:30 +03:00
parent 4900217e74
commit b00c351f04
5 changed files with 44 additions and 44 deletions

View File

@@ -31,10 +31,10 @@ namespace utl
sal_Int32 SAL_CALL OInputStreamHelper::readBytes(css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) sal_Int32 SAL_CALL OInputStreamHelper::readBytes(css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
{ {
if (!m_xLockBytes.is()) if (!m_xLockBytes.is())
throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); throw css::io::NotConnectedException(OUString(), getXWeak());
if (nBytesToRead < 0) 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 ); std::scoped_lock aGuard( m_aMutex );
if (aData.getLength() < nBytesToRead) if (aData.getLength() < nBytesToRead)
@@ -45,7 +45,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::readBytes(css::uno::Sequence< sal_Int8 >&
m_nActPos += nRead; m_nActPos += nRead;
if (nError != ERRCODE_NONE) 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 // adjust sequence if data read is lower than the desired data
if (nRead < o3tl::make_unsigned(aData.getLength())) 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 ); std::scoped_lock aGuard( m_aMutex );
if (!m_xLockBytes.is()) if (!m_xLockBytes.is())
throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); throw css::io::NotConnectedException(OUString(), getXWeak());
if (nBytesToSkip < 0) if (nBytesToSkip < 0)
throw css::io::BufferSizeExceededException(OUString(), static_cast<css::uno::XWeak*>(this)); throw css::io::BufferSizeExceededException(OUString(), getXWeak());
m_nActPos += nBytesToSkip; m_nActPos += nBytesToSkip;
} }
@@ -99,7 +99,7 @@ sal_Int32 SAL_CALL OInputStreamHelper::available()
{ {
std::scoped_lock aGuard( m_aMutex ); std::scoped_lock aGuard( m_aMutex );
if (!m_xLockBytes.is()) if (!m_xLockBytes.is())
throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); throw css::io::NotConnectedException(OUString(), getXWeak());
return m_nAvailable; return m_nAvailable;
} }
@@ -108,7 +108,7 @@ void SAL_CALL OInputStreamHelper::closeInput()
{ {
std::scoped_lock aGuard( m_aMutex ); std::scoped_lock aGuard( m_aMutex );
if (!m_xLockBytes.is()) if (!m_xLockBytes.is())
throw css::io::NotConnectedException(OUString(), static_cast<css::uno::XWeak*>(this)); throw css::io::NotConnectedException(OUString(), getXWeak());
m_xLockBytes = nullptr; m_xLockBytes = nullptr;
} }

View File

@@ -61,7 +61,7 @@ sal_Int32 SAL_CALL OInputStreamWrapper::readBytes(css::uno::Sequence< sal_Int8 >
checkConnected(); checkConnected();
if (nBytesToRead < 0) 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 ); std::scoped_lock aGuard( m_aMutex );
@@ -83,7 +83,7 @@ sal_Int32 OInputStreamWrapper::readSomeBytes(sal_Int8* pData, sal_Int32 nBytesTo
checkConnected(); checkConnected();
if (nBytesToRead < 0) 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 ); std::scoped_lock aGuard( m_aMutex );
@@ -98,7 +98,7 @@ sal_Int32 SAL_CALL OInputStreamWrapper::readSomeBytes(css::uno::Sequence< sal_In
checkError(); checkError();
if (nMaxBytesToRead < 0) if (nMaxBytesToRead < 0)
throw css::io::BufferSizeExceededException(OUString(),static_cast<css::uno::XWeak*>(this)); throw css::io::BufferSizeExceededException(OUString(), getXWeak());
if (m_pSvStream->eof()) if (m_pSvStream->eof())
{ {
@@ -144,7 +144,7 @@ void SAL_CALL OInputStreamWrapper::closeInput()
void OInputStreamWrapper::checkConnected() const void OInputStreamWrapper::checkConnected() const
{ {
if (!m_pSvStream) 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 void OInputStreamWrapper::checkError() const
@@ -154,7 +154,7 @@ void OInputStreamWrapper::checkError() const
auto const e = m_pSvStream->SvStream::GetError(); auto const e = m_pSvStream->SvStream::GetError();
if (e != ERRCODE_NONE) if (e != ERRCODE_NONE)
// TODO: really evaluate the error // 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 //= OSeekableInputStreamWrapper
@@ -218,7 +218,7 @@ void SAL_CALL OOutputStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int
|| (nWritten != static_cast<sal_uInt32>(aData.getLength())) || (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) if (rStream.GetError() != ERRCODE_NONE)
// TODO: really evaluate the error // 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 //= OSeekableOutputStreamWrapper
@@ -313,7 +313,7 @@ void SAL_CALL OStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int8 >& a
|| (nWritten != static_cast<sal_uInt32>(aData.getLength())) || (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(); m_pSvStream->FlushBuffer();
if (m_pSvStream->GetError() != ERRCODE_NONE) 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() void SAL_CALL OStreamWrapper::closeOutput()

View File

@@ -597,11 +597,11 @@ sal_Int32 SAL_CALL TempFileFastService::readBytes( css::uno::Sequence< sal_Int8
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
if (nBytesToRead < 0) if (nBytesToRead < 0)
throw css::io::BufferSizeExceededException( OUString(), static_cast< css::uno::XWeak * >(this)); throw css::io::BufferSizeExceededException( OUString(), getXWeak());
if (aData.getLength() < nBytesToRead) if (aData.getLength() < nBytesToRead)
aData.realloc(nBytesToRead); aData.realloc(nBytesToRead);
@@ -620,13 +620,13 @@ sal_Int32 SAL_CALL TempFileFastService::readSomeBytes( css::uno::Sequence< sal_I
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
checkError(); checkError();
if (nMaxBytesToRead < 0) if (nMaxBytesToRead < 0)
throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); throw css::io::BufferSizeExceededException( OUString(), getXWeak() );
if (mpStream->eof()) if (mpStream->eof())
{ {
@@ -641,7 +641,7 @@ void SAL_CALL TempFileFastService::skipBytes( sal_Int32 nBytesToSkip )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
checkError(); checkError();
@@ -653,7 +653,7 @@ sal_Int32 SAL_CALL TempFileFastService::available()
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
@@ -667,7 +667,7 @@ void SAL_CALL TempFileFastService::closeInput()
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
mbInClosed = true; mbInClosed = true;
@@ -685,20 +685,20 @@ void SAL_CALL TempFileFastService::writeBytes( const css::uno::Sequence< sal_Int
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength()); sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength());
checkError(); checkError();
if ( nWritten != static_cast<sal_uInt32>(aData.getLength())) 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() void SAL_CALL TempFileFastService::flush()
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
mpStream->Flush(); mpStream->Flush();
@@ -709,7 +709,7 @@ void SAL_CALL TempFileFastService::closeOutput()
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
mbOutClosed = true; mbOutClosed = true;
if (mpStream) if (mpStream)
@@ -730,13 +730,13 @@ void SAL_CALL TempFileFastService::closeOutput()
void TempFileFastService::checkError() const void TempFileFastService::checkError() const
{ {
if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE ) 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() void TempFileFastService::checkConnected()
{ {
if (!mpStream) if (!mpStream)
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
} }
// XSeekable // XSeekable

View File

@@ -459,11 +459,11 @@ Moderator::Moderator(
Reference < XActiveDataSink > xActiveSink(*pxSink,UNO_QUERY); Reference < XActiveDataSink > xActiveSink(*pxSink,UNO_QUERY);
if(xActiveSink.is()) if(xActiveSink.is())
pxSink->set( static_cast<cppu::OWeakObject*>(new ModeratorsActiveDataSink(*this))); pxSink->set(getXWeak(new ModeratorsActiveDataSink(*this)));
Reference<XActiveDataStreamer> xStreamer( *pxSink, UNO_QUERY ); Reference<XActiveDataStreamer> xStreamer( *pxSink, UNO_QUERY );
if ( xStreamer.is() ) if ( xStreamer.is() )
pxSink->set( static_cast<cppu::OWeakObject*>(new ModeratorsActiveDataStreamer(*this))); pxSink->set(getXWeak(new ModeratorsActiveDataStreamer(*this)));
if(dec == 0) if(dec == 0)
m_aArg.Argument <<= aPostArg; m_aArg.Argument <<= aPostArg;

View File

@@ -109,11 +109,11 @@ sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >&
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
if (nBytesToRead < 0) if (nBytesToRead < 0)
throw css::io::BufferSizeExceededException( OUString(), static_cast< css::uno::XWeak * >(this)); throw css::io::BufferSizeExceededException( OUString(), getXWeak());
if (aData.getLength() < nBytesToRead) if (aData.getLength() < nBytesToRead)
aData.realloc(nBytesToRead); aData.realloc(nBytesToRead);
@@ -131,13 +131,13 @@ sal_Int32 SAL_CALL OTempFileService::readSomeBytes( css::uno::Sequence< sal_Int8
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
checkError(); checkError();
if (nMaxBytesToRead < 0) if (nMaxBytesToRead < 0)
throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); throw css::io::BufferSizeExceededException( OUString(), getXWeak() );
if (mpStream->eof()) if (mpStream->eof())
{ {
@@ -151,7 +151,7 @@ void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
checkError(); checkError();
@@ -162,7 +162,7 @@ sal_Int32 SAL_CALL OTempFileService::available( )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
@@ -175,7 +175,7 @@ void SAL_CALL OTempFileService::closeInput( )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbInClosed ) if ( mbInClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
mbInClosed = true; mbInClosed = true;
@@ -193,19 +193,19 @@ void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 >
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength()); sal_uInt32 nWritten = mpStream->WriteBytes(aData.getConstArray(), aData.getLength());
checkError(); checkError();
if ( nWritten != static_cast<sal_uInt32>(aData.getLength())) 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( ) void SAL_CALL OTempFileService::flush( )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
checkConnected(); checkConnected();
mpStream->Flush(); mpStream->Flush();
@@ -215,7 +215,7 @@ void SAL_CALL OTempFileService::closeOutput( )
{ {
std::unique_lock aGuard( maMutex ); std::unique_lock aGuard( maMutex );
if ( mbOutClosed ) if ( mbOutClosed )
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
mbOutClosed = true; mbOutClosed = true;
if (mpStream) if (mpStream)
@@ -236,7 +236,7 @@ void SAL_CALL OTempFileService::closeOutput( )
void OTempFileService::checkError () const void OTempFileService::checkError () const
{ {
if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE ) 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 () void OTempFileService::checkConnected ()
{ {
@@ -249,7 +249,7 @@ void OTempFileService::checkConnected ()
} }
if (!mpStream) if (!mpStream)
throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); throw css::io::NotConnectedException ( OUString(), getXWeak() );
} }
// XSeekable // XSeekable