LCOV - code coverage report
Current view: top level - cppuhelper/source - defaultbootstrap.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 28 30 93.3 %
Date: 2014-11-03 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <sal/config.h>
      11             : 
      12             : #include <cassert>
      13             : #include <vector>
      14             : 
      15             : #include <com/sun/star/uno/DeploymentException.hpp>
      16             : #include <com/sun/star/uno/Any.hxx>
      17             : #include <com/sun/star/uno/Reference.hxx>
      18             : #include <com/sun/star/uno/XComponentContext.hpp>
      19             : #include <cppuhelper/bootstrap.hxx>
      20             : #include <cppuhelper/component_context.hxx>
      21             : #include <rtl/bootstrap.hxx>
      22             : #include <rtl/ref.hxx>
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : using rtl::OUString;
      26             : 
      27             : #include "macro_expander.hxx"
      28             : #include "paths.hxx"
      29             : #include "servicemanager.hxx"
      30             : #include "typemanager.hxx"
      31             : 
      32             : namespace {
      33             : 
      34        1328 : rtl::OUString getBootstrapVariable(
      35             :     rtl::Bootstrap const & bootstrap, rtl::OUString const & name)
      36             : {
      37        1328 :     rtl::OUString v;
      38        1328 :     if (!bootstrap.getFrom(name, v)) {
      39             :         throw css::uno::DeploymentException(
      40           0 :             "Cannot obtain " + name + " from uno ini");
      41             :     }
      42        1328 :     return v;
      43             : }
      44             : 
      45             : }
      46             : 
      47             : css::uno::Reference< css::uno::XComponentContext >
      48         664 : cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
      49             : {
      50         664 :     rtl::Bootstrap bs(iniUri);
      51         664 :     if (bs.getHandle() == 0) {
      52             :         throw css::uno::DeploymentException(
      53           0 :             "Cannot open uno ini " + iniUri);
      54             :     }
      55             :     rtl::Reference< cppuhelper::ServiceManager > smgr(
      56        1328 :         new cppuhelper::ServiceManager);
      57         664 :     smgr->init(getBootstrapVariable(bs, "UNO_SERVICES"));
      58        1328 :     rtl::Reference< cppuhelper::TypeManager > tmgr(new cppuhelper::TypeManager);
      59         664 :     tmgr->init(getBootstrapVariable(bs, "UNO_TYPES"));
      60        1328 :     cppu::ContextEntry_Init entry;
      61        1328 :     std::vector< cppu::ContextEntry_Init > context_values;
      62             :     context_values.push_back(
      63             :         cppu::ContextEntry_Init(
      64             :             "/singletons/com.sun.star.lang.theServiceManager",
      65             :             css::uno::makeAny(
      66             :                 css::uno::Reference< css::uno::XInterface >(
      67         664 :                     static_cast< cppu::OWeakObject * >(smgr.get()))),
      68         664 :             false));
      69             :     context_values.push_back(
      70             :         cppu::ContextEntry_Init(
      71             :             "/singletons/com.sun.star.reflection.theTypeDescriptionManager",
      72             :             css::uno::makeAny(
      73             :                 css::uno::Reference< css::uno::XInterface >(
      74         664 :                     static_cast< cppu::OWeakObject * >(tmgr.get()))),
      75         664 :             false));
      76             :     context_values.push_back( //TODO: from services.rdb?
      77             :         cppu::ContextEntry_Init(
      78             :             "/singletons/com.sun.star.util.theMacroExpander",
      79             :             css::uno::makeAny(
      80             :                 cppuhelper::detail::create_bootstrap_macro_expander_factory()),
      81         664 :             true));
      82         664 :     smgr->addSingletonContextEntries(&context_values);
      83             :     context_values.push_back(
      84             :         cppu::ContextEntry_Init(
      85             :             "/services/com.sun.star.security.AccessController/mode",
      86         664 :             css::uno::makeAny(rtl::OUString("off")), false));
      87             :     context_values.push_back(
      88             :         cppu::ContextEntry_Init(
      89             :             "/singletons/com.sun.star.security.theAccessController",
      90             :             css::uno::makeAny(
      91             :                 rtl::OUString("com.sun.star.security.AccessController")),
      92         664 :             true));
      93             :     assert(!context_values.empty());
      94             :     css::uno::Reference< css::uno::XComponentContext > context(
      95             :         createComponentContext(
      96        1328 :             &context_values[0], context_values.size(),
      97        1992 :             css::uno::Reference< css::uno::XComponentContext >()));
      98         664 :     smgr->setContext(context);
      99         664 :     cppu::installTypeDescriptionManager(tmgr.get());
     100        1328 :     return context;
     101             : }
     102             : 
     103             : css::uno::Reference< css::uno::XComponentContext >
     104         664 : cppu::defaultBootstrap_InitialComponentContext()
     105             : {
     106         664 :     return defaultBootstrap_InitialComponentContext(getUnoIniUri());
     107             : }
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10