summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-23 20:14:58 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-06-18 10:14:05 +0200
commit627984834cffbe6d1afce8b2be91277c221525b8 (patch)
tree27bfd2d4aa3ed19980ef308fdad537e54719c6bd /svl
parentf983e193523f9c7ac605627bbf3f3ad576ee7f03 (diff)
Use getXWeak in svl
Change-Id: Ia000bf4afa60a4e5bf1469fef7a611ab07e73331 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150872 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/fsstor/fsfactory.cxx20
-rw-r--r--svl/source/fsstor/fsstorage.cxx10
-rw-r--r--svl/source/fsstor/oinputstreamcontainer.cxx2
-rw-r--r--svl/source/fsstor/ostreamcontainer.cxx2
-rw-r--r--svl/source/items/style.cxx2
5 files changed, 16 insertions, 20 deletions
diff --git a/svl/source/fsstor/fsfactory.cxx b/svl/source/fsstor/fsfactory.cxx
index 81c2bcff307d..ed88fe789b72 100644
--- a/svl/source/fsstor/fsfactory.cxx
+++ b/svl/source/fsstor/fsfactory.cxx
@@ -45,12 +45,10 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstance()
aTempURL, uno::Reference< ucb::XCommandEnvironment >(),
comphelper::getProcessComponentContext() );
- return uno::Reference< uno::XInterface >(
- static_cast< OWeakObject* >(
+ return cppu::getXWeak(
new FSStorage( aResultContent,
embed::ElementModes::READWRITE,
- m_xContext ) ),
- uno::UNO_QUERY );
+ m_xContext ) );
}
/**
@@ -79,7 +77,7 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithA
("second argument to css.embed.FileSystemStorageFactory."
"createInstanceWithArguments must be a"
" css.embed.ElementModes"),
- static_cast< OWeakObject * >(this), -1);
+ getXWeak(), -1);
}
// it's always possible to read written storage in this implementation
nStorageMode |= embed::ElementModes::READ;
@@ -94,7 +92,7 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithA
("first argument to"
" css.embed.FileSystemStorageFactory.createInstanceWithArguments"
" must be a (non-empty) URL"),
- static_cast< OWeakObject * >(this), -1);
+ getXWeak(), -1);
}
// allow to use other ucp's
@@ -107,7 +105,7 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithA
("URL \"" + aURL + "\" passed as first argument to"
" css.embed.FileSystemStorageFactory.createInstanceWithArguments"
" must be a file URL denoting a directory"),
- static_cast< OWeakObject * >(this), -1);
+ getXWeak(), -1);
}
if ( ( nStorageMode & embed::ElementModes::WRITE ) && !( nStorageMode & embed::ElementModes::NOCREATE ) )
@@ -117,18 +115,16 @@ uno::Reference< uno::XInterface > SAL_CALL FSStorageFactory::createInstanceWithA
("URL \"" + aURL + "\" passed to"
" css.embed.FileSystemStorageFactory.createInstanceWithArguments"
" does not denote an existing directory"),
- static_cast< OWeakObject * >(this));
+ getXWeak());
::ucbhelper::Content aResultContent(
aURL, uno::Reference< ucb::XCommandEnvironment >(),
comphelper::getProcessComponentContext() );
// create storage based on source
- return uno::Reference< uno::XInterface >(
- static_cast< OWeakObject* >( new FSStorage( aResultContent,
+ return cppu::getXWeak( new FSStorage( aResultContent,
nStorageMode,
- m_xContext ) ),
- uno::UNO_QUERY );
+ m_xContext ) );
}
OUString SAL_CALL FSStorageFactory::getImplementationName()
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 65e243d7ddad..501dd0fd7dd5 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -246,7 +246,7 @@ void SAL_CALL FSStorage::copyToStorage( const uno::Reference< embed::XStorage >&
{
std::unique_lock aGuard( m_aMutex );
- if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject*> ( this ), uno::UNO_QUERY ) )
+ if ( !xDest.is() || xDest == getXWeak() )
throw lang::IllegalArgumentException(); // TODO:
try
@@ -775,7 +775,7 @@ uno::Any SAL_CALL FSStorage::getByName( const OUString& aName )
{
uno::Any aCaught( ::cppu::getCaughtException() );
throw lang::WrappedTargetException( "Can not open element!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -816,7 +816,7 @@ uno::Sequence< OUString > SAL_CALL FSStorage::getElementNames()
{
uno::Any aCaught( ::cppu::getCaughtException() );
throw lang::WrappedTargetRuntimeException( "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
}
@@ -828,7 +828,7 @@ uno::Sequence< OUString > SAL_CALL FSStorage::getElementNames()
{
uno::Any aCaught( ::cppu::getCaughtException() );
throw lang::WrappedTargetRuntimeException( "Can not open storage!",
- static_cast< OWeakObject* >( this ),
+ getXWeak(),
aCaught );
}
@@ -890,7 +890,7 @@ void FSStorage::disposeImpl(std::unique_lock<std::mutex>& rGuard)
{
if ( m_aListenersContainer.getLength(rGuard) )
{
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
+ lang::EventObject aSource( getXWeak() );
m_aListenersContainer.disposeAndClear( rGuard, aSource );
}
}
diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx b/svl/source/fsstor/oinputstreamcontainer.cxx
index 9c4caaea2e58..f3a3a68c8f76 100644
--- a/svl/source/fsstor/oinputstreamcontainer.cxx
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -230,7 +230,7 @@ void SAL_CALL OFSInputStreamContainer::dispose( )
m_xInputStream->closeInput();
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ lang::EventObject aSource( getXWeak() );
m_aListenersContainer.disposeAndClear( aGuard, aSource );
m_bDisposed = true;
diff --git a/svl/source/fsstor/ostreamcontainer.cxx b/svl/source/fsstor/ostreamcontainer.cxx
index 744d9ce5cfe1..53814285880e 100644
--- a/svl/source/fsstor/ostreamcontainer.cxx
+++ b/svl/source/fsstor/ostreamcontainer.cxx
@@ -225,7 +225,7 @@ void SAL_CALL OFSStreamContainer::dispose()
m_bOutputClosed = true;
}
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ lang::EventObject aSource( getXWeak() );
m_aListenersContainer.disposeAndClear( aGuard, aSource );
m_bDisposed = true;
}
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index e766dcb09f65..40ba0ca85f72 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -726,7 +726,7 @@ void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p )
// this works well under normal conditions (checked breaking and counting
// on SfxStyleSheetBase constructors and destructors)
- // css::uno::Reference< css::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), css::uno::UNO_QUERY );
+ // css::uno::Reference< css::lang::XComponent > xComp( getXWeak((*aIter).get()), css::uno::UNO_QUERY );
// if( xComp.is() ) try
// {
// xComp->dispose();