From 585d5621f17f0e70ae5bd2ad0a855ba8490d3b25 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 20 Jan 2014 23:30:49 +0100 Subject: Simplify code; STATUS_LOADED => component||factory1||factory2 Change-Id: I661eb69551eae3d888d156c6bd4291a532d0b6ab --- cppuhelper/source/servicemanager.cxx | 38 +++++++++++++----------------------- cppuhelper/source/servicemanager.hxx | 2 +- 2 files changed, 15 insertions(+), 25 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index af964fe634a8..0eb30aa0e9c1 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -711,13 +711,8 @@ cppuhelper::ServiceManager::Data::Implementation::createInstance( if (factory1.is()) { return factory1->createInstanceWithContext(context); } - if (factory2.is()) { - return factory2->createInstance(); - } - throw css::uno::DeploymentException( - ("Implementation " + info->name - + " does not provide a constructor or factory"), - css::uno::Reference()); + assert(factory2.is()); + return factory2->createInstance(); } else { osl::MutexGuard g(mutex); //TODO: must be a non-recursive mutex if (singleton.is()) { @@ -732,13 +727,9 @@ cppuhelper::ServiceManager::Data::Implementation::createInstance( context.get(), css::uno::Sequence())); } else if (factory1.is()) { singleton = factory1->createInstanceWithContext(context); - } else if (factory2.is()) { - singleton = factory2->createInstance(); } else { - throw css::uno::DeploymentException( - ("Implementation " + info->name - + " does not provide a constructor or factory"), - css::uno::Reference()); + assert(factory2.is()); + singleton = factory2->createInstance(); } dispose = singleton.is() && !singletonRequest; return singleton; @@ -771,12 +762,8 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments( return factory1->createInstanceWithArgumentsAndContext( arguments, context); } - if (factory2.is()) { - return factory2->createInstanceWithArguments(arguments); - } - throw css::uno::DeploymentException( - "Implementation " + info->name + " does not provide a factory", - css::uno::Reference()); + assert(factory2.is()); + return factory2->createInstanceWithArguments(arguments); } else { osl::MutexGuard g(mutex); //TODO: must be a non-recursive mutex if (singleton.is()) { @@ -800,12 +787,9 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments( } else if (factory1.is()) { singleton = factory1->createInstanceWithArgumentsAndContext( arguments, context); - } else if (factory2.is()) { - singleton = factory2->createInstanceWithArguments(arguments); } else { - throw css::uno::DeploymentException( - "Implementation " + info->name + " does not provide a factory", - css::uno::Reference()); + assert(factory2.is()); + singleton = factory2->createInstanceWithArguments(arguments); } dispose = singleton.is() && !singletonRequest; return singleton; @@ -1694,6 +1678,12 @@ void cppuhelper::ServiceManager::insertLegacyFactory( if (!f1.is()) { f2 = css::uno::Reference< css::lang::XSingleServiceFactory >( factoryInfo, css::uno::UNO_QUERY); + if (!f2.is()) { + throw css::lang::IllegalArgumentException( + ("Bad XServiceInfo argument implements neither" + " XSingleComponentFactory nor XSingleServiceFactory"), + static_cast< cppu::OWeakObject * >(this), 0); + } } css::uno::Reference< css::lang::XComponent > comp( factoryInfo, css::uno::UNO_QUERY); diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx index 8a3bc7fb69a3..a9522a564e5e 100644 --- a/cppuhelper/source/servicemanager.hxx +++ b/cppuhelper/source/servicemanager.hxx @@ -121,7 +121,7 @@ public: factory1(theFactory1), factory2(theFactory2), component(theComponent), status(STATUS_LOADED), dispose(false) - {} + { assert(theFactory1.is() || theFactory2.is()); } css::uno::Reference createInstance( css::uno::Reference const & -- cgit v1.2.3