2012-04-20 22:46:42 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2013-04-19 21:10:42 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-04-20 22:46:42 +02:00
|
|
|
*
|
2013-04-19 21:10:42 +01:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-04-20 22:46:42 +02:00
|
|
|
*/
|
|
|
|
|
2014-06-04 16:23:19 +02:00
|
|
|
#include <sal/config.h>
|
2012-04-20 22:46:42 +02:00
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-06-04 16:23:19 +02:00
|
|
|
#include <com/sun/star/uno/DeploymentException.hpp>
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#include <com/sun/star/uno/Reference.hxx>
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2014-11-18 00:06:30 +01:00
|
|
|
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
|
2014-06-04 16:23:19 +02:00
|
|
|
#include <cppuhelper/bootstrap.hxx>
|
|
|
|
#include <cppuhelper/component_context.hxx>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
2012-04-20 22:46:42 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
using rtl::OUString;
|
|
|
|
|
2012-04-20 22:46:42 +02:00
|
|
|
#include "macro_expander.hxx"
|
|
|
|
#include "paths.hxx"
|
2013-01-15 16:28:30 +01:00
|
|
|
#include "servicemanager.hxx"
|
2013-04-17 16:43:13 +02:00
|
|
|
#include "typemanager.hxx"
|
2012-04-20 22:46:42 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-01-15 17:22:16 +01:00
|
|
|
rtl::OUString getBootstrapVariable(
|
|
|
|
rtl::Bootstrap const & bootstrap, rtl::OUString const & name)
|
2012-04-20 22:46:42 +02:00
|
|
|
{
|
2013-01-15 17:22:16 +01:00
|
|
|
rtl::OUString v;
|
|
|
|
if (!bootstrap.getFrom(name, v)) {
|
|
|
|
throw css::uno::DeploymentException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"Cannot obtain " + name + " from uno ini");
|
2013-01-15 17:22:16 +01:00
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Reference< css::uno::XComponentContext >
|
|
|
|
cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
|
|
|
|
{
|
|
|
|
rtl::Bootstrap bs(iniUri);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (bs.getHandle() == nullptr) {
|
2013-01-15 17:22:16 +01:00
|
|
|
throw css::uno::DeploymentException(
|
2014-05-23 12:03:21 +02:00
|
|
|
"Cannot open uno ini " + iniUri);
|
2013-01-15 17:22:16 +01:00
|
|
|
}
|
2013-01-15 16:28:30 +01:00
|
|
|
rtl::Reference< cppuhelper::ServiceManager > smgr(
|
2013-05-08 12:29:53 +02:00
|
|
|
new cppuhelper::ServiceManager);
|
|
|
|
smgr->init(getBootstrapVariable(bs, "UNO_SERVICES"));
|
|
|
|
rtl::Reference< cppuhelper::TypeManager > tmgr(new cppuhelper::TypeManager);
|
|
|
|
tmgr->init(getBootstrapVariable(bs, "UNO_TYPES"));
|
2012-04-20 22:46:42 +02:00
|
|
|
std::vector< cppu::ContextEntry_Init > context_values;
|
|
|
|
context_values.push_back(
|
|
|
|
cppu::ContextEntry_Init(
|
|
|
|
"/singletons/com.sun.star.lang.theServiceManager",
|
|
|
|
css::uno::makeAny(
|
|
|
|
css::uno::Reference< css::uno::XInterface >(
|
|
|
|
static_cast< cppu::OWeakObject * >(smgr.get()))),
|
|
|
|
false));
|
2013-04-17 16:43:13 +02:00
|
|
|
context_values.push_back(
|
|
|
|
cppu::ContextEntry_Init(
|
|
|
|
"/singletons/com.sun.star.reflection.theTypeDescriptionManager",
|
|
|
|
css::uno::makeAny(
|
|
|
|
css::uno::Reference< css::uno::XInterface >(
|
|
|
|
static_cast< cppu::OWeakObject * >(tmgr.get()))),
|
|
|
|
false));
|
2012-04-20 22:46:42 +02:00
|
|
|
context_values.push_back( //TODO: from services.rdb?
|
|
|
|
cppu::ContextEntry_Init(
|
|
|
|
"/singletons/com.sun.star.util.theMacroExpander",
|
|
|
|
css::uno::makeAny(
|
|
|
|
cppuhelper::detail::create_bootstrap_macro_expander_factory()),
|
|
|
|
true));
|
2013-01-16 13:57:03 +01:00
|
|
|
smgr->addSingletonContextEntries(&context_values);
|
2013-01-16 09:31:07 +01:00
|
|
|
context_values.push_back(
|
|
|
|
cppu::ContextEntry_Init(
|
|
|
|
"/services/com.sun.star.security.AccessController/mode",
|
|
|
|
css::uno::makeAny(rtl::OUString("off")), false));
|
|
|
|
context_values.push_back(
|
|
|
|
cppu::ContextEntry_Init(
|
|
|
|
"/singletons/com.sun.star.security.theAccessController",
|
|
|
|
css::uno::makeAny(
|
|
|
|
rtl::OUString("com.sun.star.security.AccessController")),
|
|
|
|
true));
|
2012-04-20 22:46:42 +02:00
|
|
|
assert(!context_values.empty());
|
|
|
|
css::uno::Reference< css::uno::XComponentContext > context(
|
2016-03-05 18:03:25 +02:00
|
|
|
createComponentContext(&context_values[0], context_values.size()));
|
2012-04-20 22:46:42 +02:00
|
|
|
smgr->setContext(context);
|
2013-04-17 16:43:13 +02:00
|
|
|
cppu::installTypeDescriptionManager(tmgr.get());
|
2012-04-20 22:46:42 +02:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
css::uno::Reference< css::uno::XComponentContext >
|
|
|
|
cppu::defaultBootstrap_InitialComponentContext()
|
|
|
|
{
|
|
|
|
return defaultBootstrap_InitialComponentContext(getUnoIniUri());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|