154c06456SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 354c06456SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 454c06456SAndrew Rist * or more contributor license agreements. See the NOTICE file 554c06456SAndrew Rist * distributed with this work for additional information 654c06456SAndrew Rist * regarding copyright ownership. The ASF licenses this file 754c06456SAndrew Rist * to you under the Apache License, Version 2.0 (the 854c06456SAndrew Rist * "License"); you may not use this file except in compliance 954c06456SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1154c06456SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1354c06456SAndrew Rist * Unless required by applicable law or agreed to in writing, 1454c06456SAndrew Rist * software distributed under the License is distributed on an 1554c06456SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1654c06456SAndrew Rist * KIND, either express or implied. See the License for the 1754c06456SAndrew Rist * specific language governing permissions and limitations 1854c06456SAndrew Rist * under the License. 19cdf0e10cSrcweir * 2054c06456SAndrew Rist *************************************************************/ 2154c06456SAndrew Rist 2254c06456SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // Use UNICODE Windows and C API. 25cdf0e10cSrcweir #define _UNICODE 26cdf0e10cSrcweir #define UNICODE 27cdf0e10cSrcweir 28cdf0e10cSrcweir #ifdef _MSC_VER 29cdf0e10cSrcweir #pragma warning(push, 1) 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include <windows.h> 32cdf0e10cSrcweir #include "uno/environment.hxx" 33cdf0e10cSrcweir #ifdef _MSC_VER 34cdf0e10cSrcweir #pragma warning(pop) 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <tchar.h> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "native_share.h" 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "rtl/bootstrap.hxx" 42cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 43cdf0e10cSrcweir #include "cppuhelper/bootstrap.hxx" 44cdf0e10cSrcweir #include <delayimp.h> 45cdf0e10cSrcweir #include <stdio.h> 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::rtl; 48cdf0e10cSrcweir using namespace ::com::sun::star; 49cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace cli_ure { 52cdf0e10cSrcweir WCHAR * resolveLink(WCHAR * path); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55ff3f4ebcSOliver-Rainer Wittmann // INSTALL_PATH value needs to correspond to the Windows registry subkey 56ff3f4ebcSOliver-Rainer Wittmann // in main\scp2\source\ooo\registryitem_ooo.scp 57599cc5b4SOliver-Rainer Wittmann #define INSTALL_PATH L"Software\\OpenOffice\\UNO\\InstallPath" 58*3889e2e9SJürgen Schmidt #define INSTALL_PATH_64 L"Software\\Wow6432Node\\OpenOffice\\UNO\\InstallPath" 59cdf0e10cSrcweir #define BASIS_LINK L"\\basis-link" 60cdf0e10cSrcweir #define URE_LINK L"\\ure-link" 61cdf0e10cSrcweir #define URE_BIN L"\\bin" 62cdf0e10cSrcweir #define UNO_PATH L"UNO_PATH" 63cdf0e10cSrcweir 64cdf0e10cSrcweir namespace 65cdf0e10cSrcweir { 66cdf0e10cSrcweir 67cdf0e10cSrcweir /* 68cdf0e10cSrcweir * Gets the installation path from the Windows Registry for the specified 69cdf0e10cSrcweir * registry key. 70cdf0e10cSrcweir * 71cdf0e10cSrcweir * @param hroot open handle to predefined root registry key 72cdf0e10cSrcweir * @param subKeyName name of the subkey to open 73cdf0e10cSrcweir * 74cdf0e10cSrcweir * @return the installation path or NULL, if no installation was found or 75cdf0e10cSrcweir * if an error occured 76cdf0e10cSrcweir */ 77cdf0e10cSrcweir WCHAR* getPathFromRegistryKey( HKEY hroot, LPCWSTR subKeyName ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir HKEY hkey; 80cdf0e10cSrcweir DWORD type; 81cdf0e10cSrcweir TCHAR* data = NULL; 82cdf0e10cSrcweir DWORD size; 83cdf0e10cSrcweir 84cdf0e10cSrcweir /* open the specified registry key */ 85cdf0e10cSrcweir if ( RegOpenKeyEx( hroot, subKeyName, 0, KEY_READ, &hkey ) != ERROR_SUCCESS ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir return NULL; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir /* find the type and size of the default value */ 91cdf0e10cSrcweir if ( RegQueryValueEx( hkey, NULL, NULL, &type, NULL, &size) != ERROR_SUCCESS ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir RegCloseKey( hkey ); 94cdf0e10cSrcweir return NULL; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir /* get memory to hold the default value */ 98cdf0e10cSrcweir data = new WCHAR[size]; 99cdf0e10cSrcweir 100cdf0e10cSrcweir /* read the default value */ 101cdf0e10cSrcweir if ( RegQueryValueEx( hkey, NULL, NULL, &type, (LPBYTE) data, &size ) != ERROR_SUCCESS ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir RegCloseKey( hkey ); 104cdf0e10cSrcweir return NULL; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir /* release registry key handle */ 108cdf0e10cSrcweir RegCloseKey( hkey ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir return data; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir /* If the path does not end with '\' the las segment will be removed. 114cdf0e10cSrcweir path: C:\a\b 115cdf0e10cSrcweir -> C:\a 116cdf0e10cSrcweir @param io_path 117cdf0e10cSrcweir in/out parameter. The string is not reallocated. Simply a '\0' 118cdf0e10cSrcweir will be inserted to shorten the string. 119cdf0e10cSrcweir */ 120cdf0e10cSrcweir void oneDirUp(LPTSTR io_path) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir WCHAR * pEnd = io_path + lstrlen(io_path) - 1; 123cdf0e10cSrcweir while (pEnd > io_path //prevent crashing if provided string does not contain a backslash 124cdf0e10cSrcweir && *pEnd != L'\\') 125cdf0e10cSrcweir pEnd --; 126cdf0e10cSrcweir *pEnd = L'\0'; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir /* Returns the path to the program folder of the brand layer, 131cdf0e10cSrcweir for example c:/openoffice.org 3/program 132cdf0e10cSrcweir This path is either obtained from the environment variable UNO_PATH 133cdf0e10cSrcweir or the registry item 134599cc5b4SOliver-Rainer Wittmann "Software\\OpenOffice\\UNO\\InstallPath" 135cdf0e10cSrcweir either in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE 136cdf0e10cSrcweir The return value must be freed with delete[] 137cdf0e10cSrcweir */ 138cdf0e10cSrcweir WCHAR * getInstallPath() 139cdf0e10cSrcweir { 140cdf0e10cSrcweir WCHAR * szInstallPath = NULL; 141cdf0e10cSrcweir 142cdf0e10cSrcweir DWORD cChars = GetEnvironmentVariable(UNO_PATH, NULL, 0); 143cdf0e10cSrcweir if (cChars > 0) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir szInstallPath = new WCHAR[cChars]; 146cdf0e10cSrcweir cChars = GetEnvironmentVariable(UNO_PATH, szInstallPath, cChars); 147cdf0e10cSrcweir //If PATH is not set then it is no error 148cdf0e10cSrcweir if (cChars == 0) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir delete[] szInstallPath; 151cdf0e10cSrcweir return NULL; 152cdf0e10cSrcweir } 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir if (! szInstallPath) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir szInstallPath = getPathFromRegistryKey( HKEY_CURRENT_USER, INSTALL_PATH ); 158cdf0e10cSrcweir if ( szInstallPath == NULL ) 159cdf0e10cSrcweir { 160*3889e2e9SJürgen Schmidt /* read the key's default value from HKEY_LOCAL_USER */ 161*3889e2e9SJürgen Schmidt szInstallPath = getPathFromRegistryKey( HKEY_LOCAL_MACHINE, INSTALL_PATH_64 ); 162*3889e2e9SJürgen Schmidt } 163*3889e2e9SJürgen Schmidt else if ( szInstallPath == NULL ) 164*3889e2e9SJürgen Schmidt { 165cdf0e10cSrcweir /* read the key's default value from HKEY_LOCAL_MACHINE */ 166cdf0e10cSrcweir szInstallPath = getPathFromRegistryKey( HKEY_LOCAL_MACHINE, INSTALL_PATH ); 167cdf0e10cSrcweir } 168*3889e2e9SJürgen Schmidt else if ( szInstallPath == NULL ) 169*3889e2e9SJürgen Schmidt { 170*3889e2e9SJürgen Schmidt /* read the key's default value from HKEY_LOCAL_MACHINE */ 171*3889e2e9SJürgen Schmidt szInstallPath = getPathFromRegistryKey( HKEY_LOCAL_MACHINE, INSTALL_PATH_64 ); 172*3889e2e9SJürgen Schmidt } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir return szInstallPath; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir /* Returns the path to the URE/bin path, where cppuhelper lib resides. 178cdf0e10cSrcweir The returned string must be freed with delete[] 179cdf0e10cSrcweir */ 180cdf0e10cSrcweir WCHAR* getUnoPath() 181cdf0e10cSrcweir { 182cdf0e10cSrcweir WCHAR * szLinkPath = NULL; 183cdf0e10cSrcweir WCHAR * szUrePath = NULL; 184cdf0e10cSrcweir WCHAR * szUreBin = NULL; //the return value 185cdf0e10cSrcweir 186cdf0e10cSrcweir WCHAR * szInstallPath = getInstallPath(); 187cdf0e10cSrcweir if (szInstallPath) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir //build the path tho the basis-link file 190cdf0e10cSrcweir oneDirUp(szInstallPath); 191cdf0e10cSrcweir int sizeLinkPath = lstrlen(szInstallPath) + lstrlen(INSTALL_PATH) + 1; 192cdf0e10cSrcweir if (sizeLinkPath < MAX_PATH) 193cdf0e10cSrcweir sizeLinkPath = MAX_PATH; 194cdf0e10cSrcweir szLinkPath = new WCHAR[sizeLinkPath]; 195cdf0e10cSrcweir szLinkPath[0] = L'\0'; 196cdf0e10cSrcweir lstrcat(szLinkPath, szInstallPath); 197cdf0e10cSrcweir lstrcat(szLinkPath, BASIS_LINK); 198cdf0e10cSrcweir 199cdf0e10cSrcweir //get the path to the actual Basis folder 200cdf0e10cSrcweir if (cli_ure::resolveLink(szLinkPath)) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir //build the path to the ure-link file 203cdf0e10cSrcweir int sizeUrePath = lstrlen(szLinkPath) + lstrlen(URE_LINK) + 1; 204cdf0e10cSrcweir if (sizeUrePath < MAX_PATH) 205cdf0e10cSrcweir sizeUrePath = MAX_PATH; 206cdf0e10cSrcweir szUrePath = new WCHAR[sizeUrePath]; 207cdf0e10cSrcweir szUrePath[0] = L'\0'; 208cdf0e10cSrcweir lstrcat(szUrePath, szLinkPath); 209cdf0e10cSrcweir lstrcat(szUrePath, URE_LINK); 210cdf0e10cSrcweir 211cdf0e10cSrcweir //get the path to the actual Ure folder 212cdf0e10cSrcweir if (cli_ure::resolveLink(szUrePath)) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir //build the path to the URE/bin directory 215cdf0e10cSrcweir szUreBin = new WCHAR[lstrlen(szUrePath) + lstrlen(URE_BIN) + 1]; 216cdf0e10cSrcweir szUreBin[0] = L'\0'; 217cdf0e10cSrcweir lstrcat(szUreBin, szUrePath); 218cdf0e10cSrcweir lstrcat(szUreBin, URE_BIN); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >=2 223cdf0e10cSrcweir if (szUreBin) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir fwprintf(stdout,L"[cli_cppuhelper]: Path to URE libraries:\n %s \n", szUreBin); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir else 228cdf0e10cSrcweir { 229cdf0e10cSrcweir fwprintf(stdout,L"[cli_cppuhelper]: Failed to determine location of URE.\n"); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir #endif 232cdf0e10cSrcweir delete[] szInstallPath; 233cdf0e10cSrcweir delete[] szLinkPath; 234cdf0e10cSrcweir delete[] szUrePath; 235cdf0e10cSrcweir return szUreBin; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir 239cdf0e10cSrcweir /*We extend the path to contain the Ure/bin folder, 240cdf0e10cSrcweir so that components can use osl_loadModule with arguments, such as 241cdf0e10cSrcweir "reg3.dll". That is, the arguments are only the library names. 242cdf0e10cSrcweir */ 243cdf0e10cSrcweir void extendPath(LPCWSTR szUreBinPath) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir if (!szUreBinPath) 246cdf0e10cSrcweir return; 247cdf0e10cSrcweir 248cdf0e10cSrcweir WCHAR * sEnvPath = NULL; 249cdf0e10cSrcweir DWORD cChars = GetEnvironmentVariable(L"PATH", sEnvPath, 0); 250cdf0e10cSrcweir if (cChars > 0) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir sEnvPath = new WCHAR[cChars]; 253cdf0e10cSrcweir cChars = GetEnvironmentVariable(L"PATH", sEnvPath, cChars); 254cdf0e10cSrcweir //If PATH is not set then it is no error 255cdf0e10cSrcweir if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir delete[] sEnvPath; 258cdf0e10cSrcweir return; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261cdf0e10cSrcweir //prepare the new PATH. Add the Ure/bin directory at the front. 262cdf0e10cSrcweir //note also adding ';' 263cdf0e10cSrcweir WCHAR * sNewPath = new WCHAR[lstrlen(sEnvPath) + lstrlen(szUreBinPath) + 2]; 264cdf0e10cSrcweir sNewPath[0] = L'\0'; 265cdf0e10cSrcweir lstrcat(sNewPath, szUreBinPath); 266cdf0e10cSrcweir if (lstrlen(sEnvPath)) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir lstrcat(sNewPath, L";"); 269cdf0e10cSrcweir lstrcat(sNewPath, sEnvPath); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir BOOL bSet = SetEnvironmentVariable(L"PATH", sNewPath); 272cdf0e10cSrcweir 273cdf0e10cSrcweir delete[] sEnvPath; 274cdf0e10cSrcweir delete[] sNewPath; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir 278cdf0e10cSrcweir HMODULE loadFromPath(LPCWSTR sLibName) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir if (sLibName == NULL) 281cdf0e10cSrcweir return NULL; 282cdf0e10cSrcweir 283*3889e2e9SJürgen Schmidt // WCHAR * szUreBinPath = getUnoPath(); 284*3889e2e9SJürgen Schmidt WCHAR * szUreBinPath = getInstallPath(); 285cdf0e10cSrcweir if (!szUreBinPath) 286cdf0e10cSrcweir return NULL; 287cdf0e10cSrcweir 288cdf0e10cSrcweir extendPath(szUreBinPath); 289cdf0e10cSrcweir 290cdf0e10cSrcweir WCHAR* szFullPath = new WCHAR[lstrlen(sLibName) + lstrlen(szUreBinPath) + 2]; 291cdf0e10cSrcweir szFullPath[0] = L'\0'; 292cdf0e10cSrcweir lstrcat(szFullPath, szUreBinPath); 293cdf0e10cSrcweir lstrcat(szFullPath, L"\\"); 294cdf0e10cSrcweir lstrcat(szFullPath, sLibName); 295cdf0e10cSrcweir HMODULE handle = LoadLibraryEx(szFullPath, NULL, 296cdf0e10cSrcweir LOAD_WITH_ALTERED_SEARCH_PATH); 297cdf0e10cSrcweir 298cdf0e10cSrcweir delete[] szFullPath; 299cdf0e10cSrcweir delete[] szUreBinPath; 300cdf0e10cSrcweir return handle; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir /*Hook for delayed loading of libraries which this library is linked with. 304cdf0e10cSrcweir This is a failure hook. That is, it is only called when the loading of 305cdf0e10cSrcweir a library failed. It will be called when loading of cppuhelper failed. 306cdf0e10cSrcweir Because we extend the PATH to the URE/bin folder while this function is 307cdf0e10cSrcweir executed (see extendPath), all other libraries are found. 308cdf0e10cSrcweir */ 309cdf0e10cSrcweir extern "C" FARPROC WINAPI delayLoadHook( 310cdf0e10cSrcweir unsigned dliNotify, 311cdf0e10cSrcweir PDelayLoadInfo pdli 312cdf0e10cSrcweir ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir if (dliNotify == dliFailLoadLib) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir LPWSTR szLibName = NULL; 317cdf0e10cSrcweir //Convert the ansi file name to wchar_t* 318cdf0e10cSrcweir int size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pdli->szDll, -1, NULL, 0); 319cdf0e10cSrcweir if (size > 0) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir szLibName = new WCHAR[size]; 322cdf0e10cSrcweir if (! MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pdli->szDll, -1, szLibName, size)) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir return 0; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir HANDLE h = loadFromPath(szLibName); 328cdf0e10cSrcweir delete[] szLibName; 329cdf0e10cSrcweir return (FARPROC) h; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir return 0; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir ExternC 336cdf0e10cSrcweir PfnDliHook __pfnDliFailureHook2 = delayLoadHook; 337cdf0e10cSrcweir 338cdf0e10cSrcweir namespace uno 339cdf0e10cSrcweir { 340cdf0e10cSrcweir namespace util 341cdf0e10cSrcweir { 342cdf0e10cSrcweir 343cdf0e10cSrcweir /** Bootstrapping native UNO. 344cdf0e10cSrcweir 345cdf0e10cSrcweir Bootstrapping requires the existence of many libraries which are contained 346cdf0e10cSrcweir in an URE installation. To find and load these libraries the Windows 347599cc5b4SOliver-Rainer Wittmann registry keys HKEY_CURRENT_USER\Software\OpenOffice\Layer\URE\1 348599cc5b4SOliver-Rainer Wittmann and HKEY_LOCAL_MACHINE\Software\OpenOffice\Layer\URE\1 are examined. 349cdf0e10cSrcweir These contain a named value UREINSTALLLOCATION which holds a path to the URE 350cdf0e10cSrcweir installation folder. 351cdf0e10cSrcweir */ 352cdf0e10cSrcweir public __sealed __gc class Bootstrap 353cdf0e10cSrcweir { 354cdf0e10cSrcweir inline Bootstrap() {} 355cdf0e10cSrcweir 356cdf0e10cSrcweir public: 357cdf0e10cSrcweir 358cdf0e10cSrcweir /** Bootstraps the initial component context from a native UNO installation. 359cdf0e10cSrcweir 360cdf0e10cSrcweir @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext() 361cdf0e10cSrcweir */ 362cdf0e10cSrcweir static ::unoidl::com::sun::star::uno::XComponentContext * 363cdf0e10cSrcweir defaultBootstrap_InitialComponentContext(); 364cdf0e10cSrcweir 365cdf0e10cSrcweir /** Bootstraps the initial component context from a native UNO installation. 366cdf0e10cSrcweir 367cdf0e10cSrcweir @param ini_file 368cdf0e10cSrcweir a file URL of an ini file, e.g. uno.ini/unorc. (The ini file must 369cdf0e10cSrcweir reside next to the cppuhelper library) 370cdf0e10cSrcweir @param bootstrap_parameters 371cdf0e10cSrcweir bootstrap parameters (maybe null) 372cdf0e10cSrcweir 373cdf0e10cSrcweir @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext() 374cdf0e10cSrcweir */ 375cdf0e10cSrcweir static ::unoidl::com::sun::star::uno::XComponentContext * 376cdf0e10cSrcweir defaultBootstrap_InitialComponentContext( 377cdf0e10cSrcweir ::System::String * ini_file, 378cdf0e10cSrcweir ::System::Collections::IDictionaryEnumerator * 379cdf0e10cSrcweir bootstrap_parameters ); 380cdf0e10cSrcweir 381cdf0e10cSrcweir /** Bootstraps the initial component context from a native UNO installation. 382cdf0e10cSrcweir 383cdf0e10cSrcweir @see cppuhelper/bootstrap.hxx:bootstrap() 384cdf0e10cSrcweir */ 385cdf0e10cSrcweir static ::unoidl::com::sun::star::uno::XComponentContext * 386cdf0e10cSrcweir bootstrap(); 387cdf0e10cSrcweir }; 388cdf0e10cSrcweir 389cdf0e10cSrcweir //______________________________________________________________________________ 390cdf0e10cSrcweir ::unoidl::com::sun::star::uno::XComponentContext * 391cdf0e10cSrcweir Bootstrap::defaultBootstrap_InitialComponentContext( 392cdf0e10cSrcweir ::System::String * ini_file, 393cdf0e10cSrcweir ::System::Collections::IDictionaryEnumerator * bootstrap_parameters ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir if (0 != bootstrap_parameters) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir bootstrap_parameters->Reset(); 398cdf0e10cSrcweir while (bootstrap_parameters->MoveNext()) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir OUString key( 401cdf0e10cSrcweir String_to_ustring( __try_cast< ::System::String * >( 402cdf0e10cSrcweir bootstrap_parameters->get_Key() ) ) ); 403cdf0e10cSrcweir OUString value( 404cdf0e10cSrcweir String_to_ustring( __try_cast< ::System::String * >( 405cdf0e10cSrcweir bootstrap_parameters->get_Value() ) ) ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir ::rtl::Bootstrap::set( key, value ); 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir // bootstrap native uno 412cdf0e10cSrcweir Reference< XComponentContext > xContext; 413cdf0e10cSrcweir if (0 == ini_file) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir xContext = ::cppu::defaultBootstrap_InitialComponentContext(); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir else 418cdf0e10cSrcweir { 419cdf0e10cSrcweir xContext = ::cppu::defaultBootstrap_InitialComponentContext( 420cdf0e10cSrcweir String_to_ustring( __try_cast< ::System::String * >( ini_file ) ) ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir return __try_cast< ::unoidl::com::sun::star::uno::XComponentContext * >( 424cdf0e10cSrcweir to_cli( xContext ) ); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir //______________________________________________________________________________ 428cdf0e10cSrcweir ::unoidl::com::sun::star::uno::XComponentContext * 429cdf0e10cSrcweir Bootstrap::defaultBootstrap_InitialComponentContext() 430cdf0e10cSrcweir { 431cdf0e10cSrcweir return defaultBootstrap_InitialComponentContext( 0, 0 ); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir ::unoidl::com::sun::star::uno::XComponentContext * Bootstrap::bootstrap() 435cdf0e10cSrcweir { 436cdf0e10cSrcweir Reference<XComponentContext> xContext = ::cppu::bootstrap(); 437cdf0e10cSrcweir return __try_cast< ::unoidl::com::sun::star::uno::XComponentContext * >( 438cdf0e10cSrcweir to_cli( xContext ) ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } 444