From bdeb57c23973f3ef79020847b2fe39f312cf3c0b Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Tue, 14 Jan 2014 09:09:57 +0100 Subject: Initialize constructor based implementations in one place. Change-Id: I324f25bb5ec7d792c3e015815f2a11b08f519764 --- cppuhelper/source/servicemanager.cxx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 4044c1ce0d56..bebeaa82e641 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -20,6 +20,7 @@ #include "com/sun/star/container/ElementExistException.hpp" #include "com/sun/star/container/XEnumeration.hpp" #include "com/sun/star/container/XNameContainer.hpp" +#include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/lang/XSingleComponentFactory.hpp" #include "com/sun/star/lang/XSingleServiceFactory.hpp" @@ -601,12 +602,18 @@ ImplementationWrapper::createInstanceWithArgumentsAndContext( throw (css::uno::Exception, css::uno::RuntimeException) { loadImplementation(Context); - return constructor_ != 0 - ? css::uno::Reference( - (*constructor_)(Context.get(), Arguments.get()), SAL_NO_ACQUIRE) - : factory1_.is() - ? factory1_->createInstanceWithArgumentsAndContext(Arguments, Context) - : factory2_->createInstanceWithArguments(Arguments); + if (constructor_ != 0) { + css::uno::Reference xRet( + (*constructor_)(Context.get(), Arguments.get()), SAL_NO_ACQUIRE); + css::uno::Reference xInit( + xRet, css::uno::UNO_QUERY); + if (xInit.is()) + xInit->initialize(Arguments); + return xRet; + } else + return factory1_.is() + ? factory1_->createInstanceWithArgumentsAndContext(Arguments, Context) + : factory2_->createInstanceWithArguments(Arguments); } css::uno::Reference< css::uno::XInterface > @@ -928,9 +935,14 @@ cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext( return css::uno::Reference< css::uno::XInterface >(); } if (impl->constructor != 0) { - return css::uno::Reference( + css::uno::Reference xRet( (*impl->constructor)(Context.get(), Arguments.get()), SAL_NO_ACQUIRE); + css::uno::Reference xInit( + xRet, css::uno::UNO_QUERY); + if (xInit.is()) + xInit->initialize(Arguments); + return xRet; } else if (impl->factory1.is()) { return impl->factory1->createInstanceWithArgumentsAndContext( Arguments, Context); -- cgit