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