summaryrefslogtreecommitdiff
path: root/package/source/xstor
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-23 20:14:19 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-06-18 09:25:38 +0200
commit89a25bcda3dde0147f7b4f24eccfffa3216c8c0e (patch)
tree30bcba1b3cabbf320ffb61a56634f1093ea242eb /package/source/xstor
parent678cb270a68efac78db790f6509ae4774e1d25bc (diff)
Use getXWeak in package
Change-Id: I838b7c0e45a2a701d400fb7189c5396ed4525a70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150860 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'package/source/xstor')
-rw-r--r--package/source/xstor/ocompinstream.cxx4
-rw-r--r--package/source/xstor/owriteablestream.cxx22
-rw-r--r--package/source/xstor/xfactory.cxx6
-rw-r--r--package/source/xstor/xstorage.cxx51
4 files changed, 38 insertions, 45 deletions
diff --git a/package/source/xstor/ocompinstream.cxx b/package/source/xstor/ocompinstream.cxx
index b5931c0c0918..a7dd8ab2191a 100644
--- a/package/source/xstor/ocompinstream.cxx
+++ b/package/source/xstor/ocompinstream.cxx
@@ -189,7 +189,7 @@ void OInputCompStream::InternalDispose()
// the source object is also a kind of locker for the current object
// since the listeners could dispose the object while being notified
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ lang::EventObject aSource( getXWeak() );
if ( m_pInterfaceContainer )
m_pInterfaceContainer->disposeAndClear( aSource );
@@ -213,7 +213,7 @@ void SAL_CALL OInputCompStream::dispose( )
if ( m_pInterfaceContainer )
{
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ lang::EventObject aSource( getXWeak() );
m_pInterfaceContainer->disposeAndClear( aSource );
}
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 97b78249f6d8..22f1f54b3311 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -1305,9 +1305,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
- uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream();
- if ( !xTempOut.is() )
- throw uno::RuntimeException();
+ uno::Reference < io::XOutputStream > xTempOut(xTempFile->getOutputStream(), uno::UNO_SET_THROW);
if ( xDataToCopy.is() )
::comphelper::OStorageHelper::CopyInputToOutput( xDataToCopy, xTempOut );
@@ -1322,9 +1320,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
// TODO: remember last state of m_bUseCommonEncryption
if ( !xTargetStream.is() )
xTargetStream.set(
- static_cast< ::cppu::OWeakObject* >(
- new OInputSeekStream( xInStream, InsertOwnProps( aProps, m_bUseCommonEncryption ), m_nStorageType ) ),
- uno::UNO_QUERY_THROW );
+ new OInputSeekStream( xInStream, InsertOwnProps( aProps, m_bUseCommonEncryption ), m_nStorageType ) );
}
void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTargetStream )
@@ -1989,7 +1985,7 @@ uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream()
catch( const io::IOException& r )
{
throw lang::WrappedTargetRuntimeException("OWriteStream::getOutputStream: Could not create backing temp file",
- static_cast < OWeakObject * > ( this ), css::uno::Any ( r ) );
+ getXWeak(), css::uno::Any ( r ) );
}
if ( !m_pImpl )
@@ -2329,7 +2325,7 @@ void SAL_CALL OWriteStream::dispose()
uno::Any aCaught( ::cppu::getCaughtException() );
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException("Can not commit/revert the storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -2341,7 +2337,7 @@ void SAL_CALL OWriteStream::dispose()
// for now the listener is just notified at the end of the method to workaround the problem
// in future a more elegant way should be found
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
m_aListenersContainer.disposeAndClear( aSource );
}
@@ -2458,7 +2454,7 @@ sal_Bool SAL_CALL OWriteStream::hasEncryptionData()
uno::Any aCaught( ::cppu::getCaughtException() );
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( "Problems on hasEncryptionData!",
- static_cast< ::cppu::OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -3011,7 +3007,7 @@ void OWriteStream::BroadcastTransaction( sal_Int8 nMessage )
throw lang::DisposedException();
}
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
comphelper::OInterfaceContainerHelper2* pContainer =
m_aListenersContainer.getContainer(
@@ -3090,7 +3086,7 @@ void SAL_CALL OWriteStream::commit()
uno::Any aCaught( ::cppu::getCaughtException() );
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw embed::StorageWrappedTargetException( "Problems on commit!",
- static_cast< ::cppu::OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -3146,7 +3142,7 @@ void SAL_CALL OWriteStream::revert()
uno::Any aCaught(::cppu::getCaughtException());
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw embed::StorageWrappedTargetException("Problems on revert!",
- static_cast<::cppu::OWeakObject*>(this),
+ getXWeak(),
aCaught);
}
}
diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx
index 0ee4ae0cc51d..d611ddfabe6c 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -74,7 +74,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstance()
// TODO: reimplement TempStream service to support XStream interface
uno::Reference < io::XStream > xTempStream(new utl::TempFileFastService);
- return static_cast<OWeakObject*>(new OStorage(xTempStream, embed::ElementModes::READWRITE,
+ return cppu::getXWeak(new OStorage(xTempStream, embed::ElementModes::READWRITE,
uno::Sequence<beans::PropertyValue>(), m_xContext,
embed::StorageFormats::PACKAGE));
}
@@ -239,7 +239,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
if ( !CheckPackageSignature_Impl( xInputStream, xSeekable ) )
throw io::IOException("package signature check failed, probably not a package file", nullptr); // TODO: this is not a package file
- return static_cast<OWeakObject*>(
+ return cppu::getXWeak(
new OStorage(xInputStream, nStorageMode, aPropsToSet, m_xContext, nStorageType));
}
else if ( xStream.is() )
@@ -258,7 +258,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
if ( !CheckPackageSignature_Impl( xStream->getInputStream(), xSeekable ) )
throw io::IOException(); // TODO: this is not a package file
- return static_cast<OWeakObject*>(
+ return cppu::getXWeak(
new OStorage(xStream, nStorageMode, aPropsToSet, m_xContext, nStorageType));
}
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 6e22a853c18f..e2c0207a1553 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -1796,7 +1796,7 @@ void OStorage::InternalDispose( bool bNotifyImpl )
// the source object is also a kind of locker for the current object
// since the listeners could dispose the object while being notified
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
m_aListenersContainer.disposeAndClear( aSource );
if ( !m_pImpl )
@@ -1891,7 +1891,7 @@ void OStorage::BroadcastModifiedIfNecessary()
SAL_WARN_IF( m_bReadOnlyWrap, "package.xstor", "The storage can not be modified at all!" );
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
comphelper::OInterfaceContainerHelper2* pContainer =
m_aListenersContainer.getContainer(
@@ -1923,7 +1923,7 @@ void OStorage::BroadcastTransaction( sal_Int8 nMessage )
SAL_WARN_IF( m_bReadOnlyWrap, "package.xstor", "The storage can not be modified at all!" );
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
comphelper::OInterfaceContainerHelper2* pContainer =
m_aListenersContainer.getContainer(
@@ -2161,7 +2161,7 @@ void SAL_CALL OStorage::copyToStorage( const uno::Reference< embed::XStorage >&
throw lang::DisposedException( THROW_WHERE );
}
- if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) )
+ if ( !xDest.is() || xDest == getXWeak() )
throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 );
try {
@@ -2934,7 +2934,7 @@ void SAL_CALL OStorage::copyElementTo( const OUString& aElementName,
throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 );
if ( !xDest.is() )
- // || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
+ // || xDest == getXWeak() )
throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 );
if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )
@@ -3018,10 +3018,7 @@ void SAL_CALL OStorage::moveElementTo( const OUString& aElementName,
throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.",
uno::Reference<uno::XInterface>(), 1);
- if (!xDest.is()
- || xDest
- == uno::Reference<uno::XInterface>(static_cast<OWeakObject*>(this),
- uno::UNO_QUERY))
+ if (!xDest.is() || xDest == getXWeak())
throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 2);
if (m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML
@@ -3565,7 +3562,7 @@ void SAL_CALL OStorage::commit()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw embed::StorageWrappedTargetException( THROW_WHERE "Problems on commit!",
- static_cast< ::cppu::OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -3634,7 +3631,7 @@ void SAL_CALL OStorage::revert()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw embed::StorageWrappedTargetException(THROW_WHERE "Problems on revert!",
- static_cast<::cppu::OWeakObject*>(this),
+ getXWeak(),
aCaught);
}
}
@@ -3798,7 +3795,7 @@ uno::Any SAL_CALL OStorage::getByName( const OUString& aName )
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetException( THROW_WHERE "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -3830,7 +3827,7 @@ uno::Sequence< OUString > SAL_CALL OStorage::getElementNames()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -3867,7 +3864,7 @@ sal_Bool SAL_CALL OStorage::hasByName( const OUString& aName )
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -3913,7 +3910,7 @@ sal_Bool SAL_CALL OStorage::hasElements()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -3944,7 +3941,7 @@ void SAL_CALL OStorage::dispose()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -4017,7 +4014,7 @@ void SAL_CALL OStorage::removeEncryption()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4081,7 +4078,7 @@ void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValu
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4146,7 +4143,7 @@ void SAL_CALL OStorage::setEncryptionAlgorithms( const uno::Sequence< beans::Nam
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4167,7 +4164,7 @@ void SAL_CALL OStorage::setEncryptionAlgorithms( const uno::Sequence< beans::Nam
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -4206,7 +4203,7 @@ void SAL_CALL OStorage::setGpgProperties( const uno::Sequence< uno::Sequence< be
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4227,7 +4224,7 @@ void SAL_CALL OStorage::setGpgProperties( const uno::Sequence< uno::Sequence< be
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -4263,7 +4260,7 @@ uno::Sequence< beans::NamedValue > SAL_CALL OStorage::getEncryptionAlgorithms()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4283,7 +4280,7 @@ uno::Sequence< beans::NamedValue > SAL_CALL OStorage::getEncryptionAlgorithms()
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetRuntimeException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -4435,7 +4432,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName )
throw lang::WrappedTargetException(
"Can't read contents!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -4491,7 +4488,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName )
SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught));
throw lang::WrappedTargetException( THROW_WHERE "Can not open package!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -4991,7 +4988,7 @@ void SAL_CALL OStorage::copyElementDirectlyTo(
|| aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, false ) )
throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 );
- if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
+ if ( !xDest.is() || xDest == getXWeak() )
throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 );
if ( m_pImpl->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) )