From 2a612907aef4c9987f906c6b98aa9b400f58f617 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 Sep 2017 16:14:49 +0200 Subject: loplugin:flatten in connectivity..desktop Change-Id: Iff59d3049ba40b4338ef8eec67d08a96b0834d2b Reviewed-on: https://gerrit.libreoffice.org/42578 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cpputools/source/unoexe/unoexe.cxx | 90 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'cpputools/source') diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index 3d9a18a31931..bc35b6ef9d0f 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -165,66 +165,64 @@ static Reference< XInterface > loadComponent( { // determine loader to be used sal_Int32 nDot = rLocation.lastIndexOf( '.' ); - if (nDot > 0 && nDot < rLocation.getLength()) + if (nDot <= 0 || nDot >= rLocation.getLength()) { - Reference< XImplementationLoader > xLoader; + throw RuntimeException( + "location \"" + rLocation + "\" has no extension! Cannot determine loader to be used!" ); + } - OUString aExt( rLocation.copy( nDot +1 ) ); + Reference< XImplementationLoader > xLoader; - if (aExt == "dll" || aExt == "exe" || aExt == "dylib" || aExt == "so") - { - createInstance( - xLoader, xContext, "com.sun.star.loader.SharedLibrary" ); - } - else if (aExt == "jar" || aExt == "class") + OUString aExt( rLocation.copy( nDot +1 ) ); + + if (aExt == "dll" || aExt == "exe" || aExt == "dylib" || aExt == "so") + { + createInstance( + xLoader, xContext, "com.sun.star.loader.SharedLibrary" ); + } + else if (aExt == "jar" || aExt == "class") + { + createInstance( + xLoader, xContext, "com.sun.star.loader.Java" ); + } + else + { + throw RuntimeException( + "unknown extension of \"" + rLocation + "\"! No loader available!" ); + } + + Reference< XInterface > xInstance; + + // activate + Reference< XInterface > xFactory( xLoader->activate( + rImplName, OUString(), rLocation, Reference< XRegistryKey >() ) ); + if (xFactory.is()) + { + Reference< XSingleComponentFactory > xCFac( xFactory, UNO_QUERY ); + if (xCFac.is()) { - createInstance( - xLoader, xContext, "com.sun.star.loader.Java" ); + xInstance = xCFac->createInstanceWithContext( xContext ); } else { - throw RuntimeException( - "unknown extension of \"" + rLocation + "\"! No loader available!" ); - } - - Reference< XInterface > xInstance; - - // activate - Reference< XInterface > xFactory( xLoader->activate( - rImplName, OUString(), rLocation, Reference< XRegistryKey >() ) ); - if (xFactory.is()) - { - Reference< XSingleComponentFactory > xCFac( xFactory, UNO_QUERY ); - if (xCFac.is()) + Reference< XSingleServiceFactory > xSFac( xFactory, UNO_QUERY ); + if (xSFac.is()) { - xInstance = xCFac->createInstanceWithContext( xContext ); - } - else - { - Reference< XSingleServiceFactory > xSFac( xFactory, UNO_QUERY ); - if (xSFac.is()) - { - out( "\n> warning: ignoring context for implementation \"" ); - out( rImplName ); - out( "\"!" ); - xInstance = xSFac->createInstance(); - } + out( "\n> warning: ignoring context for implementation \"" ); + out( rImplName ); + out( "\"!" ); + xInstance = xSFac->createInstance(); } } - - if (! xInstance.is()) - { - throw RuntimeException( - "activating component \"" + rImplName + "\" from location \"" + rLocation + "\" failed!" ); - } - - return xInstance; } - else + + if (! xInstance.is()) { throw RuntimeException( - "location \"" + rLocation + "\" has no extension! Cannot determine loader to be used!" ); + "activating component \"" + rImplName + "\" from location \"" + rLocation + "\" failed!" ); } + + return xInstance; } class OInstanceProvider -- cgit v1.2.3