From 543158edba6678d3d76eee983a9d4edd2a422fee Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 17 Sep 2012 16:56:19 +0200 Subject: Require XComponentContext.getServiceManager to throw instead of returning null This is such a fatal error that there is probably no point in trying to handle it, so allow to simplify client code by removing the requirement to check for a null return value. Simplified some client code accordingly (modules configmgr and ure, and the code generated by cppumaker and javamaker). Change-Id: I51c0b270ec73409374f7439a47ee061407a46e31 --- ure/source/uretest/JavaClient.java | 7 +------ ure/source/uretest/cppmain.cc | 11 ++--------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'ure/source') diff --git a/ure/source/uretest/JavaClient.java b/ure/source/uretest/JavaClient.java index d37e6f8f5f74..f86d61af66cf 100644 --- a/ure/source/uretest/JavaClient.java +++ b/ure/source/uretest/JavaClient.java @@ -23,7 +23,6 @@ import com.sun.star.bridge.XBridgeFactory; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.connection.Connector; import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lib.uno.helper.UnoUrl; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; @@ -34,13 +33,9 @@ public final class JavaClient { public static void main(String[] arguments) throws Exception { XComponentContext context = Bootstrap.createInitialComponentContext( null); - XMultiComponentFactory manager = context.getServiceManager(); - if (manager == null) { - throw new NullPointerException("no service manager"); - } XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, - manager.createInstanceWithContext( + context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); if (factory == null) { throw new NullPointerException("no bridge factory"); diff --git a/ure/source/uretest/cppmain.cc b/ure/source/uretest/cppmain.cc index 3cc496c14496..54e6c6890018 100644 --- a/ure/source/uretest/cppmain.cc +++ b/ure/source/uretest/cppmain.cc @@ -26,7 +26,6 @@ #include #include "com/sun/star/lang/XMain.hpp" -#include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" @@ -141,18 +140,12 @@ private: "com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTscript", "com.sun.star.uri.VndSunStarPkgUrlReferenceFactory" }; - ::css::uno::Reference< ::css::lang::XMultiComponentFactory > manager( - context_->getServiceManager()); - if (!manager.is()) { - throw ::css::uno::RuntimeException( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("no service manager")), - static_cast< ::cppu::OWeakObject * >(this)); - } for (::std::size_t i = 0; i < SAL_N_ELEMENTS(services); ++i) { ::rtl::OUString name(::rtl::OUString::createFromAscii(services[i])); ::css::uno::Reference< ::css::uno::XInterface > instance; try { - instance = manager->createInstanceWithContext(name, context_); + instance = context_->getServiceManager()->createInstanceWithContext( + name, context_); } catch (::css::uno::RuntimeException &) { throw; } catch (::css::uno::Exception &) { -- cgit