summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-01-20 23:30:49 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-01-20 23:30:49 +0100
commit585d5621f17f0e70ae5bd2ad0a855ba8490d3b25 (patch)
tree5612316bff6c216e687de46f035a46e80b7b879e /cppuhelper
parent8804d3a63ae25d9211b3bf64d764c4eb4bd6c132 (diff)
Simplify code; STATUS_LOADED => component||factory1||factory2
Change-Id: I661eb69551eae3d888d156c6bd4291a532d0b6ab
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/servicemanager.cxx38
-rw-r--r--cppuhelper/source/servicemanager.hxx2
2 files changed, 15 insertions, 25 deletions
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<css::uno::XInterface>());
+ 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<css::uno::Any>()));
} 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<css::uno::XInterface>());
+ 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<css::uno::XInterface>());
+ 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<css::uno::XInterface>());
+ 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<css::uno::XInterface> createInstance(
css::uno::Reference<css::uno::XComponentContext> const &