summaryrefslogtreecommitdiff
path: root/cpputools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-20 16:14:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 15:41:50 +0200
commit2a612907aef4c9987f906c6b98aa9b400f58f617 (patch)
tree6170f363054cabb1cd33af9208145827b22c83a1 /cpputools
parent3a481dde031ba416ec4ef0351130e26e49417418 (diff)
loplugin:flatten in connectivity..desktop
Change-Id: Iff59d3049ba40b4338ef8eec67d08a96b0834d2b Reviewed-on: https://gerrit.libreoffice.org/42578 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cpputools')
-rw-r--r--cpputools/source/unoexe/unoexe.cxx90
1 files changed, 44 insertions, 46 deletions
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