diff options
author | Henry Castro <hcastro@collabora.com> | 2015-09-07 17:17:22 -0400 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2016-02-15 22:23:19 +0200 |
commit | 8d7f29a933b62ffd754c6a0f05d25e55b8646e74 (patch) | |
tree | 919b7a9fc955a3281ebe904502c67dbba63a06f7 | |
parent | 6b41b89cc51b65fe3aa69099638ec4432782886a (diff) |
Re-work cppu::preInitBootstrap()
In the preinit stage, the preInitBootstrap is called to load
implementations for each service registered by the service manager.
All service requests are: initial Component Context and the process
service factory is set.
However, some services require that VCL is properly initialized.
Change-Id: Ib116e3da172b860f2df4d672f6181b5de0b7e6b2
-rw-r--r-- | cppuhelper/source/defaultbootstrap.cxx | 27 | ||||
-rw-r--r-- | cppuhelper/source/gcc3.map | 2 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 2 | ||||
-rw-r--r-- | include/cppuhelper/detail/preinit.hxx | 10 |
4 files changed, 28 insertions, 13 deletions
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx index c0a2c2edc6f7..9ff68e1cbae2 100644 --- a/cppuhelper/source/defaultbootstrap.cxx +++ b/cppuhelper/source/defaultbootstrap.cxx @@ -109,18 +109,25 @@ cppu::defaultBootstrap_InitialComponentContext() } void -cppu::preInitBootstrap() +cppu::preInitBootstrap(css::uno::Reference< css::uno::XComponentContext > const & xContext) { - rtl::OUString iniUri(getUnoIniUri()); - rtl::Bootstrap bs(iniUri); - if (bs.getHandle() == nullptr) - throw css::uno::DeploymentException("Cannot open uno ini " + iniUri); + if (!xContext.is()) + throw css::uno::DeploymentException("preInit: XComponentContext is not created"); + + css::uno::Reference< css::uno::XInterface > xService; + xContext->getValueByName("/singletons/com.sun.star.lang.theServiceManager") >>= xService; + if (!xService.is()) + throw css::uno::DeploymentException("preInit: XMultiComponentFactory is not created"); + + rtl::Reference<cppuhelper::ServiceManager> aService(reinterpret_cast<cppuhelper::ServiceManager*>(xService.get())); - // create the service manager - rtl::Reference< cppuhelper::ServiceManager > aManager(new cppuhelper::ServiceManager); - // read rdb files - aManager->init(getBootstrapVariable(bs, "UNO_SERVICES")); - aManager->loadAllImplementations(); + // pre-requisites: + // In order to load implementations and invoke + // component factory it is required: + // 1) defaultBootstrap_InitialComponentContext() + // 2) comphelper::setProcessServiceFactory(xSFactory); + // 3) InitVCL() + aService->loadAllImplementations(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 20d0e137eef6..658b3ca2b981 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -439,5 +439,5 @@ GLIBCXX_3.4 { PRIVATE_1.0 { # LibO 5.2 global: - _ZN4cppu16preInitBootstrapEv; + _ZN4cppu16preInitBootstrapERKN3com3sun4star3uno9ReferenceINS3_17XComponentContextEEE; }; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index f24ecd2553ad..f69bdd5dafb6 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1914,7 +1914,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char { InitVCL(); // pre-load all component libraries. - cppu::preInitBootstrap(); + cppu::preInitBootstrap(xContext); // Release Solar Mutex, lo_startmain thread should acquire it. Application::ReleaseSolarMutex(); } diff --git a/include/cppuhelper/detail/preinit.hxx b/include/cppuhelper/detail/preinit.hxx index b21929aa58d8..d152cf250003 100644 --- a/include/cppuhelper/detail/preinit.hxx +++ b/include/cppuhelper/detail/preinit.hxx @@ -17,8 +17,16 @@ namespace cppu #if defined LIBO_INTERNAL_ONLY +/** Preload all shared library components with service manager upon + information from bootstrap variables. + + This function tries to find its parameters via these bootstrap variables: + + - UNO_SERVICES -- a space separated list of file urls of service rdbs + +*/ CPPUHELPER_DLLPUBLIC void SAL_CALL -preInitBootstrap(); +preInitBootstrap(css::uno::Reference< css::uno::XComponentContext > const & xContext); #endif // LIBO_INTERNAL_ONLY |