/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * 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/.
*/
namespace net_uno
{ extern"C" {
SAL_DLLPUBLIC_EXPORT IntPtr bootstrap(const Context aContext)
{ try
{ // Bootstrap UNO and start a LibreOffice process if needed
Reference<XComponentContext> xContext(::cppu::bootstrap());
// Get a mapping between the C++ and .NET environments
Environment cpp_env(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
Environment net_env(u"" UNO_LB_NET ""_ustr, new Context(aContext));
Mapping mapping(cpp_env.get(), net_env.get()); if (!mapping.is())
{
Reference<lang::XComponent> xComp(xContext, UNO_QUERY); if (xComp.is())
{
xComp->dispose();
}
throw RuntimeException(u"could not get mapping between C++ and .NET"_ustr);
}
SAL_DLLPUBLIC_EXPORT IntPtr defaultBootstrap_InitialComponentContext(const sal_Unicode* sIniFile, const sal_Unicode* sParams, const Context aContext)
{ try
{ // Set bootstrap parameters, merged into a single string (at least for now) // to avoid dealing with lifetimes and memory of multiple strings if (sParams)
{
OUString paramsStr(sParams); for (size_t i = 0; i != std::u16string_view::npos;)
{
std::u16string_view name(o3tl::getToken(paramsStr, u'|', i));
OUString key(name.substr(0, name.find_first_of('=')));
OUString val(name.substr(key.getLength() + 1));
::rtl::Bootstrap::set(key, val);
}
}
// Bootstrap UNO
Reference<XComponentContext> xContext; if (sIniFile)
{
xContext = ::cppu::defaultBootstrap_InitialComponentContext(OUString(sIniFile));
} else
{
xContext = ::cppu::defaultBootstrap_InitialComponentContext();
}
// Get a mapping between the C++ and .NET environments
Environment cpp_env(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
Environment net_env(u"" UNO_LB_NET ""_ustr, new Context(aContext));
Mapping mapping(cpp_env.get(), net_env.get()); if (!mapping.is())
{
Reference<lang::XComponent> xComp(xContext, UNO_QUERY); if (xComp.is())
{
xComp->dispose();
}
throw RuntimeException(u"could not get mapping between C++ and .NET"_ustr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.