[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - cppuhelper/source

Henry Castro hcastro at collabora.com
Mon Aug 31 20:35:27 PDT 2015


 cppuhelper/source/defaultbootstrap.cxx |   17 ++++++++++++++++
 cppuhelper/source/gcc3.map             |    1 
 cppuhelper/source/servicemanager.cxx   |   35 +++++++++++++++++++++++++++++++++
 cppuhelper/source/servicemanager.hxx   |    2 +
 4 files changed, 55 insertions(+)

New commits:
commit 901999aea8559a41b9cd927f7feaa0af73754792
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Aug 31 23:33:15 2015 -0400

    cppuhelper: add loadImplementations
    
    pre-load all C++ component library.
    
    Change-Id: I95637b628c5a6340afce09b2d2033127c6f8f504

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 1fbbf8f..b135b2c 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -43,6 +43,18 @@ rtl::OUString getBootstrapVariable(
     return v;
 }
 
+void default_preInitBootstrap(rtl::OUString const & aUri)
+{
+    rtl::Bootstrap bsUri(aUri);
+    if (bsUri.getHandle() == 0)
+        throw css::uno::DeploymentException("Cannot open uno ini " + aUri);
+
+    // create the service manager
+    rtl::Reference< cppuhelper::ServiceManager > aManager(new cppuhelper::ServiceManager);
+    // read rdb files
+    aManager->init(getBootstrapVariable(bsUri, "UNO_SERVICES"));
+    aManager->loadImplementations();
+}
 }
 
 css::uno::Reference< css::uno::XComponentContext >
@@ -107,4 +119,9 @@ cppu::defaultBootstrap_InitialComponentContext()
     return defaultBootstrap_InitialComponentContext(getUnoIniUri());
 }
 
+void
+cppu::preInitBootstrap()
+{
+    default_preInitBootstrap(getUnoIniUri());
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map
index 12c29834a..3d7a5c6 100644
--- a/cppuhelper/source/gcc3.map
+++ b/cppuhelper/source/gcc3.map
@@ -423,6 +423,7 @@ global:
         # enableChangeListenerNotification
         _ZN4cppu19OPropertySetHelper232enableChangeListenerNotificationEh;
         _ZThn*_N4cppu19OPropertySetHelper232enableChangeListenerNotificationEh;
+        _ZN4cppu16preInitBootstrapEv;
 } UDK_3.7;
 
 LIBO_UDK_3.9 { # LibO 3.7
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 2140a2f..ffed6ba 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -42,6 +42,7 @@
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
 #include <uno/environment.hxx>
+#include <osl/module.hxx>
 
 #include "loadsharedlibcomponentfactory.hxx"
 
@@ -878,6 +879,40 @@ void cppuhelper::ServiceManager::loadImplementation(
     }
 }
 
+void cppuhelper::ServiceManager::loadImplementations()
+{
+    rtl::OUString aUri;
+    osl::MutexGuard g(rBHelper.rMutex);
+
+    for (Data::NamedImplementations::const_iterator iterator(
+            data_.namedImplementations.begin());
+            iterator != data_.namedImplementations.end(); ++iterator)
+    {
+        try
+        {
+            aUri = cppu::bootstrap_expandUri(iterator->second->info->uri);
+        }
+        catch (css::lang::IllegalArgumentException& aError)
+        {
+            throw css::uno::DeploymentException(
+                "Cannot expand URI" + iterator->second->info->uri + ": " + aError.Message,
+                static_cast< cppu::OWeakObject * >(this));
+        }
+
+        if (iterator->second->info->loader == "com.sun.star.loader.SharedLibrary" &&
+            iterator->second->status != Data::Implementation::STATUS_LOADED)
+        {
+            oslModule aModule = osl_loadModule( aUri.pData, SAL_LOADMODULE_NOW | SAL_LOADMODULE_GLOBAL );
+            SAL_INFO("lok", "loaded component library " << aUri << ( aModule ? " ok" : " no"));
+
+            // leak aModule
+            // osl_unloadModule(aModule);
+            if ( aModule )
+                iterator->second->status = Data::Implementation::STATUS_LOADED;
+        }
+    }
+}
+
 void cppuhelper::ServiceManager::disposing() {
     std::vector< css::uno::Reference<css::lang::XComponent> > sngls;
     std::vector< css::uno::Reference< css::lang::XComponent > > comps;
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index 903084b..ddf85965f 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -203,6 +203,8 @@ public:
         css::uno::Reference< css::uno::XComponentContext > const & context,
         boost::shared_ptr< Data::Implementation > & implementation);
 
+    void loadImplementations();
+
 private:
     virtual ~ServiceManager() {}
 


More information about the Libreoffice-commits mailing list