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