From 0c2b2c9babfd781e0d9d68bb2a14a045b0c6ec4c Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 23 Apr 2023 20:14:54 +0300 Subject: Use getXWeak in stoc Change-Id: Icd694eeae002ab28cbd06ba3097e9039e299de3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150871 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- stoc/test/javavm/jvm_interaction/interactionhandler.cxx | 5 ++--- stoc/test/registry_tdprovider/testregistrytdprovider.cxx | 2 +- stoc/test/tdmanager/testtdmanager.cxx | 2 +- stoc/test/testproxyfac.cxx | 10 +++++----- 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'stoc/test') diff --git a/stoc/test/javavm/jvm_interaction/interactionhandler.cxx b/stoc/test/javavm/jvm_interaction/interactionhandler.cxx index b82ef594afda..f1c4baf863cf 100644 --- a/stoc/test/javavm/jvm_interaction/interactionhandler.cxx +++ b/stoc/test/javavm/jvm_interaction/interactionhandler.cxx @@ -75,8 +75,7 @@ Any SAL_CALL Context::getValueByName( const OUString& Name) throw (RuntimeExcept Any retVal; if( Name.equals( INTERACTION_HANDLER_NAME)) { - Reference handler( static_cast(new InteractionHandler()), - UNO_QUERY); + Reference handler(new InteractionHandler()); retVal <<= handler; } return retVal; @@ -119,7 +118,7 @@ void SAL_CALL InteractionHandler::handle( const Reference< XInteractionRequest > sal_Bool test1(const Reference< XMultiServiceFactory > & xMgr ) { sal_Bool retVal= sal_True; - setCurrentContext( Reference( static_cast(new Context()), UNO_QUERY)); + setCurrentContext(Reference(new Context()); OUString sVMService("com.sun.star.java.JavaVirtualMachine"); Reference xXInt= xMgr->createInstance(sVMService); diff --git a/stoc/test/registry_tdprovider/testregistrytdprovider.cxx b/stoc/test/registry_tdprovider/testregistrytdprovider.cxx index 879859b92e27..46e3d0998b01 100644 --- a/stoc/test/registry_tdprovider/testregistrytdprovider.cxx +++ b/stoc/test/registry_tdprovider/testregistrytdprovider.cxx @@ -741,7 +741,7 @@ css::uno::Reference< css::uno::XInterface > Service::createInstance( css::uno::Reference< css::uno::XComponentContext > const & context) throw (css::uno::Exception) { - return static_cast< cppu::OWeakObject * >(new Service(context)); + return cppu::getXWeak(new Service(context)); } extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(char const * implName, diff --git a/stoc/test/tdmanager/testtdmanager.cxx b/stoc/test/tdmanager/testtdmanager.cxx index e466904b4314..7c9971d6aa64 100644 --- a/stoc/test/tdmanager/testtdmanager.cxx +++ b/stoc/test/tdmanager/testtdmanager.cxx @@ -275,7 +275,7 @@ css::uno::Reference< css::uno::XInterface > Service::createInstance( css::uno::Reference< css::uno::XComponentContext > const & context) throw (css::uno::Exception) { - return static_cast< cppu::OWeakObject * >(new Service(context)); + return cppu::getXWeak(new Service(context)); } extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(char const * implName, diff --git a/stoc/test/testproxyfac.cxx b/stoc/test/testproxyfac.cxx index 2388ac078b53..befc67ae8ee3 100644 --- a/stoc/test/testproxyfac.cxx +++ b/stoc/test/testproxyfac.cxx @@ -92,7 +92,7 @@ Any TargetObject::queryInterface( Type const & type ) return ret; throw lang::DisposedException( OUString( "my test exception" ), - static_cast< OWeakObject * >(this) ); + getXWeak() ); } int TargetObject::s_obj = 0; @@ -146,7 +146,7 @@ Reference< XInterface > TestMaster::create( Reference< reflection::XProxyFactory > const & xProxyFac ) { TestMaster * that = new TestMaster; - Reference< XInterface > xRet( static_cast< OWeakObject * >( that ) ); + Reference< XInterface > xRet( getXWeak( that ) ); { Reference< XAggregation > xAgg( xProxyFac->createProxy( xTarget ) ); // ownership take over @@ -162,7 +162,7 @@ Reference< XInterface > TestMaster::create( Reference< reflection::XProxyFactory > const & xProxyFac ) { return create( - static_cast< OWeakObject * >( new TargetObject ), xProxyFac ); + getXWeak( new TargetObject ), xProxyFac ); } @@ -268,7 +268,7 @@ SAL_IMPLEMENT_MAIN() Reference< XAggregation > x( xProxyFac->createProxy( - static_cast< OWeakObject * >( new TargetObject ) ) ); + getXWeak( new TargetObject ) ) ); // no call { @@ -303,7 +303,7 @@ SAL_IMPLEMENT_MAIN() test_proxyfac( xProxyFac->createProxy( - static_cast< OWeakObject * >( new TargetObject ) ), + getXWeak( new TargetObject ) ), OUString( "target" ), xProxyFac ); uno_dumpEnvironment( stdout, cpp_env.get(), 0 ); -- cgit