LibreOffice Module cppuhelper (master) 1
defaultbootstrap.cxx
Go to the documentation of this file.
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 <vector>
13
14#include <com/sun/star/uno/DeploymentException.hpp>
15#include <com/sun/star/uno/Any.hxx>
16#include <com/sun/star/uno/Reference.hxx>
17#include <com/sun/star/lang/XSingleComponentFactory.hpp>
20#include <cppuhelper/weak.hxx>
21#include <rtl/bootstrap.hxx>
22#include <rtl/ref.hxx>
23#include <rtl/ustring.hxx>
24
25#include "macro_expander.hxx"
26#include "paths.hxx"
27#include "servicemanager.hxx"
28#include "typemanager.hxx"
29
30namespace com :: sun :: star :: uno { class XComponentContext; }
31
32namespace {
33
34OUString getBootstrapVariable(
35 rtl::Bootstrap const & bootstrap, OUString const & name)
36{
37 OUString v;
38 if (!bootstrap.getFrom(name, v)) {
39 throw css::uno::DeploymentException(
40 "Cannot obtain " + name + " from uno ini");
41 }
42 return v;
43}
44
45}
46
47css::uno::Reference< css::uno::XComponentContext >
49{
50 rtl::Bootstrap bs(iniUri);
51 if (bs.getHandle() == nullptr) {
52 throw css::uno::DeploymentException(
53 "Cannot open uno ini " + iniUri);
54 }
55 rtl::Reference smgr(
57 smgr->init(getBootstrapVariable(bs, "UNO_SERVICES"));
59 tmgr->init(getBootstrapVariable(bs, "UNO_TYPES"));
60 std::vector< cppu::ContextEntry_Init > context_values
61 {
63 "/singletons/com.sun.star.lang.theServiceManager",
64 css::uno::Any(
65 css::uno::Reference< css::uno::XInterface >(
66 static_cast< cppu::OWeakObject * >(smgr.get()))),
67 false),
69 "/singletons/com.sun.star.reflection.theTypeDescriptionManager",
70 css::uno::Any(
71 css::uno::Reference< css::uno::XInterface >(
72 static_cast< cppu::OWeakObject * >(tmgr.get()))),
73 false),
74 cppu::ContextEntry_Init( //TODO: from services.rdb?
75 "/singletons/com.sun.star.util.theMacroExpander",
76 css::uno::Any(
78 true)
79 };
80 smgr->addSingletonContextEntries(&context_values);
81 context_values.push_back(
83 "/services/com.sun.star.security.AccessController/mode",
84 css::uno::Any(OUString("off")), false));
85 context_values.push_back(
87 "/singletons/com.sun.star.security.theAccessController",
88 css::uno::Any(
89 OUString("com.sun.star.security.AccessController")),
90 true));
91 css::uno::Reference< css::uno::XComponentContext > context(
92 createComponentContext(context_values.data(), context_values.size()));
93 smgr->setContext(context);
95 return context;
96}
97
98css::uno::Reference< css::uno::XComponentContext >
100{
102}
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class to implement a UNO object supporting weak references, i.e.
Definition: weak.hxx:48
float v
sal_Bool SAL_CALL installTypeDescriptionManager(Reference< container::XHierarchicalNameAccess > const &xTDMgr_c)
Definition: tdmgr.cxx:633
OUString getUnoIniUri()
Definition: paths.cxx:55
Reference< XComponentContext > SAL_CALL createComponentContext(ContextEntry_Init const *pEntries, sal_Int32 nEntries, Reference< XComponentContext > const &xDelegate)
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
Bootstraps an initial component context with service manager upon information from bootstrap variable...
Reference< lang::XSingleComponentFactory > create_bootstrap_macro_expander_factory()
def bootstrap()
Context entries init struct calling createComponentContext().