summaryrefslogtreecommitdiff
path: root/package
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
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')
-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
-rw-r--r--package/source/zippackage/ZipPackage.cxx30
-rw-r--r--package/source/zippackage/ZipPackageEntry.cxx2
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx2
-rw-r--r--package/source/zippackage/ZipPackageFolderEnumeration.cxx3
-rw-r--r--package/source/zippackage/zipfileaccess.cxx4
9 files changed, 58 insertions, 66 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" ) )
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index eb7346236bb1..9c841ec58bc6 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -728,7 +728,7 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
{
// The URL is not acceptable
throw css::uno::Exception (THROW_WHERE "Bad arguments.",
- static_cast < ::cppu::OWeakObject * > ( this ) );
+ getXWeak() );
}
}
@@ -785,7 +785,7 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
throw css::packages::zip::ZipIOException (
THROW_WHERE "Bad Zip File, " + message,
- static_cast < ::cppu::OWeakObject * > ( this ) );
+ getXWeak() );
}
}
@@ -799,7 +799,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName )
if (aName == "/")
// root directory.
- return Any ( uno::Reference < XInterface > ( static_cast<cppu::OWeakObject*>(m_xRootFolder.get()) ) );
+ return Any ( uno::Reference( cppu::getXWeak(m_xRootFolder.get()) ) );
nStreamIndex = aName.lastIndexOf ( '/' );
bool bFolder = nStreamIndex == nIndex-1; // last character is '/'.
@@ -822,7 +822,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName )
sTemp = aName.copy ( nDirIndex == -1 ? 0 : nDirIndex+1, nStreamIndex-nDirIndex-1 );
if (pFolder && sTemp == pFolder->getName())
- return Any(uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(pFolder)));
+ return Any(uno::Reference(cppu::getXWeak(pFolder)));
}
else
{
@@ -868,7 +868,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName )
{
if ( nStreamIndex != -1 )
m_aRecent[sDirName] = pPrevious; // cache it.
- return Any ( uno::Reference < XInterface > ( static_cast<cppu::OWeakObject*>(pCurrent) ) );
+ return Any ( uno::Reference( cppu::getXWeak(pCurrent) ) );
}
sTemp = aName.copy( nOldIndex );
@@ -1032,7 +1032,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(
THROW_WHERE "Error adding mimetype to the ZipOutputStream!",
- static_cast < OWeakObject * > ( this ),
+ getXWeak(),
anyEx );
}
}
@@ -1327,7 +1327,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
throw WrappedTargetException(
THROW_WHERE "Problem writing the original content!",
- static_cast < OWeakObject * > ( this ),
+ getXWeak(),
aCaught );
}
else
@@ -1337,7 +1337,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
OUString aErrTxt(THROW_WHERE "This package is unusable!");
embed::UseBackupException aException( aErrTxt, uno::Reference< uno::XInterface >(), OUString() );
throw WrappedTargetException( aErrTxt,
- static_cast < OWeakObject * > ( this ),
+ getXWeak(),
Any ( aException ) );
}
}
@@ -1406,7 +1406,7 @@ void SAL_CALL ZipPackage::commitChanges()
{
IOException aException;
throw WrappedTargetException(THROW_WHERE "This package is read only!",
- static_cast < OWeakObject * > ( this ), Any ( aException ) );
+ getXWeak(), Any ( aException ) );
}
// first the writeTempFile is called, if it returns a stream the stream should be written to the target
// if no stream was returned, the file was written directly, nothing should be done
@@ -1419,7 +1419,7 @@ void SAL_CALL ZipPackage::commitChanges()
{
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(THROW_WHERE "Temporary file should be creatable!",
- static_cast < OWeakObject * > ( this ), anyEx );
+ getXWeak(), anyEx );
}
if ( xTempInStream.is() )
{
@@ -1433,7 +1433,7 @@ void SAL_CALL ZipPackage::commitChanges()
{
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(THROW_WHERE "Temporary file should be seekable!",
- static_cast < OWeakObject * > ( this ), anyEx );
+ getXWeak(), anyEx );
}
try
@@ -1445,7 +1445,7 @@ void SAL_CALL ZipPackage::commitChanges()
{
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(THROW_WHERE "Temporary file should be connectable!",
- static_cast < OWeakObject * > ( this ), anyEx );
+ getXWeak(), anyEx );
}
if ( m_eMode == e_IMode_XStream )
@@ -1474,7 +1474,7 @@ void SAL_CALL ZipPackage::commitChanges()
{
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(THROW_WHERE "This package is read only!",
- static_cast < OWeakObject * > ( this ), anyEx );
+ getXWeak(), anyEx );
}
try
@@ -1574,7 +1574,7 @@ void SAL_CALL ZipPackage::commitChanges()
css::uno::Any anyEx = cppu::getCaughtException();
throw WrappedTargetException(
THROW_WHERE "This package may be read only!",
- static_cast < OWeakObject * > ( this ),
+ getXWeak(),
anyEx );
}
}
@@ -1609,7 +1609,7 @@ void ZipPackage::DisconnectFromTargetAndThrowException_Impl( const uno::Referenc
OUString aErrTxt(THROW_WHERE "This package is read only!");
embed::UseBackupException aException( aErrTxt, uno::Reference< uno::XInterface >(), aTempURL );
throw WrappedTargetException( aErrTxt,
- static_cast < OWeakObject * > ( this ),
+ getXWeak(),
Any ( aException ) );
}
diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx
index cbbcf5e9a468..56337109ecaf 100644
--- a/package/source/zippackage/ZipPackageEntry.cxx
+++ b/package/source/zippackage/ZipPackageEntry.cxx
@@ -78,7 +78,7 @@ void SAL_CALL ZipPackageEntry::setName( const OUString& aName )
uno::Reference< XInterface > SAL_CALL ZipPackageEntry::getParent( )
{
// return uno::Reference< XInterface >( xParent, UNO_QUERY );
- return uno::Reference< XInterface >( static_cast< ::cppu::OWeakObject* >( mpParent ), UNO_QUERY );
+ return cppu::getXWeak( mpParent );
}
void ZipPackageEntry::doSetParent ( ZipPackageFolder * pNewParent )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 175536415a48..906f36111497 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -197,7 +197,7 @@ ZipContentInfo& ZipPackageFolder::doGetByName( const OUString& aName )
uno::Any SAL_CALL ZipPackageFolder::getByName( const OUString& aName )
{
- return uno::Any ( uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(doGetByName ( aName ).xPackageEntry.get())) );
+ return uno::Any ( uno::Reference(cppu::getXWeak(doGetByName ( aName ).xPackageEntry.get())) );
}
uno::Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( )
{
diff --git a/package/source/zippackage/ZipPackageFolderEnumeration.cxx b/package/source/zippackage/ZipPackageFolderEnumeration.cxx
index 5d091de0e1e4..080592c95ffa 100644
--- a/package/source/zippackage/ZipPackageFolderEnumeration.cxx
+++ b/package/source/zippackage/ZipPackageFolderEnumeration.cxx
@@ -46,8 +46,7 @@ uno::Any SAL_CALL ZipPackageFolderEnumeration::nextElement()
uno::Any aAny;
if (aIterator == rContents.end())
throw container::NoSuchElementException(THROW_WHERE);
- aAny <<= uno::Reference<XInterface>(
- static_cast<cppu::OWeakObject*>((*aIterator).second.xPackageEntry.get()));
+ aAny <<= uno::Reference(cppu::getXWeak((*aIterator).second.xPackageEntry.get()));
++aIterator;
return aAny;
}
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index 2921ec947209..d693a51ceceb 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -286,7 +286,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const OUString& aName )
{
css::uno::Any anyEx = cppu::getCaughtException();
throw lang::WrappedTargetException( "This package is unusable!",
- static_cast < OWeakObject * > ( this ), anyEx);
+ getXWeak(), anyEx);
}
if ( !xEntryStream.is() )
@@ -412,7 +412,7 @@ void SAL_CALL OZipFileAccess::dispose()
if ( m_pListenersContainer )
{
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
m_pListenersContainer->disposeAndClear( aSource );
m_pListenersContainer.reset();
}