build fix
[LibreOffice.git] / cli_ure / source / native / native_bootstrap.cxx
blob2ff980fa776f02f4079754b25e11b384a41810b1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // Use UNICODE Windows and C API.
21 #define _UNICODE
22 #define UNICODE
24 #ifdef _MSC_VER
25 #pragma warning(push, 1)
26 #endif
27 #include <windows.h>
28 #ifdef _MSC_VER
29 #pragma warning(pop)
30 #endif
32 #include <tchar.h>
34 #include "native_share.h"
36 #include "rtl/bootstrap.hxx"
37 #include "com/sun/star/uno/XComponentContext.hpp"
38 #include "cppuhelper/bootstrap.hxx"
39 #include <stdio.h>
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
44 namespace uno
46 namespace util
49 /** Bootstrapping native UNO.
51 Bootstrapping requires the existence of many libraries which are contained
52 in an URE installation. To find and load these libraries the Windows
53 registry keys HKEY_CURRENT_USER\Software\LibreOffice\Layer\URE\1
54 and HKEY_LOCAL_MACHINE\Software\LibreOffice\Layer\URE\1 are examined.
55 These contain a named value UREINSTALLLOCATION which holds a path to the URE
56 installation folder.
58 public ref class Bootstrap sealed
60 inline Bootstrap() {}
62 public:
64 /** Bootstraps the initial component context from a native UNO installation.
66 @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext()
68 static ::unoidl::com::sun::star::uno::XComponentContext ^
69 defaultBootstrap_InitialComponentContext();
71 /** Bootstraps the initial component context from a native UNO installation.
73 @param ini_file
74 a file URL of an ini file, e.g. uno.ini/unorc. (The ini file must
75 reside next to the cppuhelper library)
76 @param bootstrap_parameters
77 bootstrap parameters (maybe null)
79 @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext()
81 static ::unoidl::com::sun::star::uno::XComponentContext ^
82 defaultBootstrap_InitialComponentContext(
83 ::System::String ^ ini_file,
84 ::System::Collections::IDictionaryEnumerator ^
85 bootstrap_parameters );
87 /** Bootstraps the initial component context from a native UNO installation.
89 @see cppuhelper/bootstrap.hxx:bootstrap()
91 static ::unoidl::com::sun::star::uno::XComponentContext ^
92 bootstrap();
96 ::unoidl::com::sun::star::uno::XComponentContext ^
97 Bootstrap::defaultBootstrap_InitialComponentContext(
98 ::System::String ^ ini_file,
99 ::System::Collections::IDictionaryEnumerator ^ bootstrap_parameters )
101 if (nullptr != bootstrap_parameters)
103 bootstrap_parameters->Reset();
104 while (bootstrap_parameters->MoveNext())
106 OUString key(
107 String_to_ustring( safe_cast< ::System::String ^ >(
108 bootstrap_parameters->Key ) ) );
109 OUString value(
110 String_to_ustring( safe_cast< ::System::String ^ >(
111 bootstrap_parameters->Value ) ) );
113 ::rtl::Bootstrap::set( key, value );
117 // bootstrap native uno
118 Reference< XComponentContext > xContext;
119 if (nullptr == ini_file)
121 xContext = ::cppu::defaultBootstrap_InitialComponentContext();
123 else
125 xContext = ::cppu::defaultBootstrap_InitialComponentContext(
126 String_to_ustring( safe_cast< ::System::String ^ >( ini_file ) ) );
129 return safe_cast< ::unoidl::com::sun::star::uno::XComponentContext ^ >(
130 to_cli( xContext ) );
134 ::unoidl::com::sun::star::uno::XComponentContext ^
135 Bootstrap::defaultBootstrap_InitialComponentContext()
137 return defaultBootstrap_InitialComponentContext( nullptr, nullptr );
140 ::unoidl::com::sun::star::uno::XComponentContext ^ Bootstrap::bootstrap()
142 Reference<XComponentContext> xContext = ::cppu::bootstrap();
143 return safe_cast< ::unoidl::com::sun::star::uno::XComponentContext ^ >(
144 to_cli( xContext ) );
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */