1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_cppuhelper.hxx" 26 27 #include <vector> 28 29 #include "rtl/string.hxx" 30 #include "rtl/bootstrap.hxx" 31 #include "osl/diagnose.h" 32 #include "osl/file.h" 33 #include "osl/module.h" 34 #include "osl/process.h" 35 #include "cppuhelper/shlib.hxx" 36 #include "cppuhelper/factory.hxx" 37 #include "cppuhelper/component_context.hxx" 38 #include "cppuhelper/servicefactory.hxx" 39 #include "cppuhelper/bootstrap.hxx" 40 41 #include "com/sun/star/uno/DeploymentException.hpp" 42 #include "com/sun/star/uno/XComponentContext.hpp" 43 #include "com/sun/star/lang/XInitialization.hpp" 44 #include "com/sun/star/lang/XSingleServiceFactory.hpp" 45 #include "com/sun/star/lang/XSingleComponentFactory.hpp" 46 #include "com/sun/star/beans/XPropertySet.hpp" 47 #include "com/sun/star/container/XSet.hpp" 48 #include "com/sun/star/container/XHierarchicalNameAccess.hpp" 49 #include "com/sun/star/registry/XSimpleRegistry.hpp" 50 #include "com/sun/star/registry/XImplementationRegistration.hpp" 51 #include "com/sun/star/security/XAccessController.hpp" 52 53 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) 54 55 56 using namespace ::rtl; 57 using namespace ::osl; 58 using namespace ::com::sun::star; 59 using namespace ::com::sun::star::uno; 60 namespace css = com::sun::star; 61 62 namespace cppu 63 { 64 65 // private forward decl 66 void addFactories( 67 char const * const * ppNames /* lib, implname, ..., 0 */, 68 OUString const & bootstrapPath, 69 Reference< lang::XMultiComponentFactory > const & xMgr, 70 Reference< registry::XRegistryKey > const & xKey ); 71 72 Reference< security::XAccessController > 73 createDefaultAccessController() SAL_THROW( () ); 74 75 Reference< lang::XSingleComponentFactory > 76 create_boostrap_macro_expander_factory() SAL_THROW( () ); 77 78 OUString const & get_this_libpath(); 79 80 81 static Reference< XInterface > SAL_CALL createInstance( 82 Reference< XInterface > const & xFactory, 83 Reference< XComponentContext > const & xContext = 84 Reference< XComponentContext >() ) 85 { 86 Reference< lang::XSingleComponentFactory > xFac( xFactory, UNO_QUERY ); 87 if (xFac.is()) 88 { 89 return xFac->createInstanceWithContext( xContext ); 90 } 91 else 92 { 93 Reference< lang::XSingleServiceFactory > xFac2( xFactory, UNO_QUERY ); 94 if (xFac2.is()) 95 { 96 OSL_ENSURE( !xContext.is(), "### ignoring context!" ); 97 return xFac2->createInstance(); 98 } 99 } 100 throw RuntimeException( 101 OUSTR("no factory object given!"), 102 Reference< XInterface >() ); 103 } 104 105 Reference< registry::XSimpleRegistry > SAL_CALL createSimpleRegistry( 106 OUString const & rBootstrapPath ) 107 SAL_THROW( () ) 108 { 109 try 110 { 111 return Reference< registry::XSimpleRegistry >( 112 createInstance( 113 loadSharedLibComponentFactory( 114 OUSTR("bootstrap.uno" SAL_DLLEXTENSION), 115 0 == rBootstrapPath.getLength() 116 ? get_this_libpath() : rBootstrapPath, 117 OUSTR("com.sun.star.comp.stoc.SimpleRegistry"), 118 Reference< lang::XMultiServiceFactory >(), 119 Reference< registry::XRegistryKey >() ) ), 120 UNO_QUERY ); 121 } 122 catch (Exception & exc) 123 { 124 #if OSL_DEBUG_LEVEL > 0 125 OString cstr_msg( 126 OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); 127 OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() ); 128 #else 129 (void) exc; // avoid warning about unused variable 130 #endif 131 } 132 133 return Reference< registry::XSimpleRegistry >(); 134 } 135 136 Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry( 137 OUString const & rBootstrapPath ) 138 SAL_THROW( () ) 139 { 140 try 141 { 142 return Reference< registry::XSimpleRegistry >( 143 createInstance( 144 loadSharedLibComponentFactory( 145 OUSTR("bootstrap.uno" SAL_DLLEXTENSION), 146 0 == rBootstrapPath.getLength() 147 ? get_this_libpath() : rBootstrapPath, 148 OUSTR("com.sun.star.comp.stoc.NestedRegistry"), 149 Reference< lang::XMultiServiceFactory >(), 150 Reference< registry::XRegistryKey >() ) ), 151 UNO_QUERY ); 152 } 153 catch (Exception & exc) 154 { 155 #if OSL_DEBUG_LEVEL > 0 156 OString cstr_msg( 157 OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); 158 OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() ); 159 #else 160 (void) exc; // avoid warning about unused variable 161 #endif 162 } 163 164 return Reference< registry::XSimpleRegistry >(); 165 } 166 167 168 /** bootstrap variables: 169 170 UNO_AC=<mode> [mandatory] 171 -- mode := { on, off, dynamic-only, single-user, single-default-user } 172 UNO_AC_SERVICE=<service_name> [optional] 173 -- override ac singleton service name 174 UNO_AC_SINGLEUSER=<user-id|nothing> [optional] 175 -- run with this user id or with default user policy (<nothing>) 176 set UNO_AC=single-[default-]user 177 UNO_AC_USERCACHE_SIZE=<cache_size> 178 -- number of user permission sets to be cached 179 180 UNO_AC_POLICYSERVICE=<service_name> [optional] 181 -- override policy singleton service name 182 UNO_AC_POLICYFILE=<file_url> [optional] 183 -- read policy out of simple text file 184 */ 185 static void add_access_control_entries( 186 ::std::vector< ContextEntry_Init > * values, 187 Bootstrap const & bootstrap ) 188 { 189 ContextEntry_Init entry; 190 ::std::vector< ContextEntry_Init > & context_values = *values; 191 192 OUString ac_policy; 193 if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE"), ac_policy )) 194 { 195 // overridden service name 196 // - policy singleton 197 entry.bLateInitService = true; 198 entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy"); 199 entry.value <<= ac_policy; 200 context_values.push_back( entry ); 201 } 202 else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE"), ac_policy )) 203 { 204 // check for file policy 205 // - file policy prop: file-name 206 if (0 != ac_policy.compareToAscii( 207 RTL_CONSTASCII_STRINGPARAM("file:///") )) 208 { 209 // no file url 210 OUString baseDir; 211 if ( ::osl_getProcessWorkingDir( &baseDir.pData ) 212 != osl_Process_E_None ) 213 { 214 OSL_ASSERT( false ); 215 } 216 OUString fileURL; 217 if ( ::osl_getAbsoluteFileURL( 218 baseDir.pData, ac_policy.pData, &fileURL.pData ) 219 != osl_File_E_None ) 220 { 221 OSL_ASSERT( false ); 222 } 223 ac_policy = fileURL; 224 } 225 226 entry.bLateInitService = false; 227 entry.name = 228 OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" 229 "file-name"); 230 entry.value <<= ac_policy; 231 context_values.push_back( entry ); 232 // - policy singleton 233 entry.bLateInitService = true; 234 entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy"); 235 entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy"); 236 context_values.push_back( entry ); 237 } // else policy singleton comes from storage 238 239 OUString ac_mode; 240 if (! bootstrap.getFrom( OUSTR("UNO_AC"), ac_mode )) 241 { 242 ac_mode = OUSTR("off"); // default 243 } 244 OUString ac_user; 245 if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER"), ac_user )) 246 { 247 // ac in single-user mode 248 if (ac_user.getLength()) 249 { 250 // - ac prop: single-user-id 251 entry.bLateInitService = false; 252 entry.name = 253 OUSTR("/services/com.sun.star.security.AccessController/" 254 "single-user-id"); 255 entry.value <<= ac_user; 256 context_values.push_back( entry ); 257 if (! ac_mode.equalsAsciiL( 258 RTL_CONSTASCII_STRINGPARAM("single-user") )) 259 { 260 throw SecurityException( 261 OUSTR("set UNO_AC=single-user " 262 "if you set UNO_AC_SINGLEUSER=<user-id>!"), 263 Reference< XInterface >() ); 264 } 265 } 266 else 267 { 268 if (! ac_mode.equalsAsciiL( 269 RTL_CONSTASCII_STRINGPARAM("single-default-user") )) 270 { 271 throw SecurityException( 272 OUSTR("set UNO_AC=single-default-user " 273 "if you set UNO_AC_SINGLEUSER=<nothing>!"), 274 Reference< XInterface >() ); 275 } 276 } 277 } 278 279 OUString ac_service; 280 if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE"), ac_service )) 281 { 282 // override service name 283 ac_service = OUSTR("com.sun.star.security.AccessController"); // default 284 // ac = OUSTR("com.sun.star.security.comp.stoc.AccessController"); 285 } 286 287 // - ac prop: user-cache-size 288 OUString ac_cache; 289 if (bootstrap.getFrom( OUSTR("UNO_AC_USERCACHE_SIZE"), ac_cache )) 290 { 291 // ac cache size 292 sal_Int32 n = ac_cache.toInt32(); 293 if (0 < n) 294 { 295 entry.bLateInitService = false; 296 entry.name = 297 OUSTR("/services/com.sun.star.security.AccessController/" 298 "user-cache-size"); 299 entry.value <<= n; 300 context_values.push_back( entry ); 301 } 302 } 303 304 // - ac prop: mode 305 // { "off", "on", "dynamic-only", "single-user", "single-default-user" } 306 entry.bLateInitService = false; 307 entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode"); 308 entry.value <<= ac_mode; 309 context_values.push_back( entry ); 310 // - ac singleton 311 entry.bLateInitService = true; 312 entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController"); 313 entry.value <<= ac_service; 314 context_values.push_back( entry ); 315 } 316 317 SAL_DLLPUBLIC_EXPORT 318 Reference< lang::XMultiComponentFactory > bootstrapInitialSF( 319 OUString const & rBootstrapPath ) 320 { 321 OUString const & bootstrap_path = 322 0 == rBootstrapPath.getLength() ? get_this_libpath() : rBootstrapPath; 323 324 Reference< lang::XMultiComponentFactory > xMgr( 325 createInstance( 326 loadSharedLibComponentFactory( 327 OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrap_path, 328 OUSTR("com.sun.star.comp.stoc.ORegistryServiceManager"), 329 Reference< lang::XMultiServiceFactory >(), 330 Reference< registry::XRegistryKey >() ) ), 331 UNO_QUERY ); 332 333 // add initial bootstrap services 334 static char const * ar[] = { 335 "bootstrap.uno" SAL_DLLEXTENSION, 336 "com.sun.star.comp.stoc.OServiceManagerWrapper", 337 "bootstrap.uno" SAL_DLLEXTENSION, 338 "com.sun.star.comp.stoc.DLLComponentLoader", 339 "bootstrap.uno" SAL_DLLEXTENSION, 340 "com.sun.star.comp.stoc.SimpleRegistry", 341 "bootstrap.uno" SAL_DLLEXTENSION, 342 "com.sun.star.comp.stoc.NestedRegistry", 343 "bootstrap.uno" SAL_DLLEXTENSION, 344 "com.sun.star.comp.stoc.TypeDescriptionManager", 345 "bootstrap.uno" SAL_DLLEXTENSION, 346 "com.sun.star.comp.stoc.ImplementationRegistration", 347 "bootstrap.uno" SAL_DLLEXTENSION, 348 "com.sun.star.security.comp.stoc.AccessController", 349 "bootstrap.uno" SAL_DLLEXTENSION, 350 "com.sun.star.security.comp.stoc.FilePolicy", 351 0 352 }; 353 addFactories( 354 ar, bootstrap_path, 355 xMgr, Reference< registry::XRegistryKey >() ); 356 357 return xMgr; 358 } 359 360 // returns context with UNinitialized smgr 361 Reference< XComponentContext > bootstrapInitialContext( 362 Reference< lang::XMultiComponentFactory > const & xSF, 363 Reference< registry::XSimpleRegistry > const & types_xRegistry, 364 Reference< registry::XSimpleRegistry > const & services_xRegistry, 365 OUString const & rBootstrapPath, Bootstrap const & bootstrap ) 366 { 367 Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY ); 368 if (! xSFInit.is()) 369 { 370 throw RuntimeException( 371 OUSTR("servicemanager does not support XInitialization!"), 372 Reference< XInterface >() ); 373 } 374 375 // basic context values 376 ContextEntry_Init entry; 377 ::std::vector< ContextEntry_Init > context_values; 378 context_values.reserve( 14 ); 379 380 // macro expander singleton for loader 381 entry.bLateInitService = true; 382 entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander"); 383 entry.value <<= create_boostrap_macro_expander_factory(); 384 context_values.push_back( entry ); 385 386 // tdmgr singleton 387 entry.bLateInitService = true; 388 entry.name = 389 OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager"); 390 entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager"); 391 context_values.push_back( entry ); 392 393 // read out singleton infos from registry 394 if (services_xRegistry.is()) 395 { 396 Reference< registry::XRegistryKey > xKey( 397 services_xRegistry->getRootKey() ); 398 if (xKey.is()) 399 { 400 xKey = xKey->openKey( OUSTR("/SINGLETONS") ); 401 if (xKey.is()) 402 { 403 entry.bLateInitService = true; 404 405 Sequence< Reference< registry::XRegistryKey > > keys( 406 xKey->openKeys() ); 407 Reference< registry::XRegistryKey > const * pKeys = 408 keys.getConstArray(); 409 for ( sal_Int32 nPos = keys.getLength(); nPos--; ) 410 { 411 css::uno::Sequence< rtl::OUString > impls( 412 css::uno::Reference< css::registry::XRegistryKey >( 413 pKeys[nPos]->openKey( 414 rtl::OUString( 415 RTL_CONSTASCII_USTRINGPARAM( 416 "REGISTERED_BY"))), 417 css::uno::UNO_SET_THROW)->getAsciiListValue()); 418 switch (impls.getLength()) { 419 case 0: 420 throw css::uno::DeploymentException( 421 (pKeys[nPos]->getKeyName() + 422 rtl::OUString( 423 RTL_CONSTASCII_USTRINGPARAM( 424 "/REGISTERED_BY is empty"))), 425 css::uno::Reference< css::uno::XInterface >()); 426 case 1: 427 break; 428 default: 429 OSL_TRACE( 430 ("arbitrarily chosing \"%s\" among multiple" 431 " implementations for \"%s\""), 432 rtl::OUStringToOString( 433 impls[0], RTL_TEXTENCODING_UTF8).getStr(), 434 rtl::OUStringToOString( 435 pKeys[nPos]->getKeyName(), 436 RTL_TEXTENCODING_UTF8).getStr()); 437 break; 438 } 439 context_values.push_back( 440 ContextEntry_Init( 441 (rtl::OUString( 442 RTL_CONSTASCII_USTRINGPARAM("/singletons/")) + 443 pKeys[nPos]->getKeyName().copy( 444 RTL_CONSTASCII_LENGTH("/SINGLETONS/"))), 445 css::uno::makeAny(impls[0]), 446 true)); 447 } 448 } 449 } 450 } 451 452 // ac, policy: 453 add_access_control_entries( &context_values, bootstrap ); 454 455 // smgr singleton 456 entry.bLateInitService = false; 457 entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager"); 458 entry.value <<= xSF; 459 context_values.push_back( entry ); 460 461 Reference< XComponentContext > xContext( 462 createComponentContext( 463 &context_values[ 0 ], context_values.size(), 464 Reference< XComponentContext >() ) ); 465 // set default context 466 Reference< beans::XPropertySet > xProps( xSF, UNO_QUERY ); 467 OSL_ASSERT( xProps.is() ); 468 if (xProps.is()) 469 { 470 xProps->setPropertyValue( 471 OUSTR("DefaultContext"), makeAny( xContext ) ); 472 } 473 474 Reference< container::XHierarchicalNameAccess > xTDMgr; 475 476 // get tdmgr singleton 477 if (xContext->getValueByName( 478 OUSTR("/singletons/" 479 "com.sun.star.reflection.theTypeDescriptionManager") ) 480 >>= xTDMgr) 481 { 482 if (types_xRegistry.is()) // insert rdb provider? 483 { 484 // add registry td provider factory to smgr and instance to tdmgr 485 Reference< lang::XSingleComponentFactory > xFac( 486 loadSharedLibComponentFactory( 487 OUSTR("bootstrap.uno" SAL_DLLEXTENSION), 488 0 == rBootstrapPath.getLength() 489 ? get_this_libpath() : rBootstrapPath, 490 OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"), 491 Reference< lang::XMultiServiceFactory >( xSF, UNO_QUERY ), 492 Reference< registry::XRegistryKey >() ), UNO_QUERY ); 493 OSL_ASSERT( xFac.is() ); 494 495 // smgr 496 Reference< container::XSet > xSet( xSF, UNO_QUERY ); 497 xSet->insert( makeAny( xFac ) ); 498 OSL_ENSURE( 499 xSet->has( makeAny( xFac ) ), 500 "### failed registering registry td provider at smgr!" ); 501 // tdmgr 502 xSet.set( xTDMgr, UNO_QUERY ); 503 OSL_ASSERT( xSet.is() ); 504 Any types_RDB( makeAny( types_xRegistry ) ); 505 Any rdbtdp( makeAny( xFac->createInstanceWithArgumentsAndContext( 506 Sequence< Any >( &types_RDB, 1 ), xContext ) ) ); 507 xSet->insert( rdbtdp ); 508 OSL_ENSURE( 509 xSet->has( rdbtdp ), 510 "### failed inserting registry td provider to tdmgr!" ); 511 } 512 // install callback 513 installTypeDescriptionManager( xTDMgr ); 514 } 515 516 return xContext; 517 } 518 519 static Reference< lang::XMultiComponentFactory > createImplServiceFactory( 520 const OUString & rWriteRegistry, 521 const OUString & rReadRegistry, 522 sal_Bool bReadOnly, 523 const OUString & rBootstrapPath ) 524 { 525 Reference< lang::XMultiComponentFactory > xSF( 526 bootstrapInitialSF( rBootstrapPath ) ); 527 528 Reference< registry::XSimpleRegistry > xRegistry; 529 530 // open a registry 531 sal_Bool bRegistryShouldBeValid = sal_False; 532 if (rWriteRegistry.getLength() && !rReadRegistry.getLength()) 533 { 534 bRegistryShouldBeValid = sal_True; 535 xRegistry.set( createSimpleRegistry( rBootstrapPath ) ); 536 if (xRegistry.is()) 537 { 538 if (bReadOnly) 539 { 540 xRegistry->open( rWriteRegistry, sal_True, sal_False ); 541 } 542 else 543 { 544 xRegistry->open( rWriteRegistry, sal_False, sal_True ); 545 } 546 } 547 } 548 else if (rWriteRegistry.getLength() && rReadRegistry.getLength()) 549 { 550 // default registry 551 bRegistryShouldBeValid = sal_True; 552 xRegistry.set( createNestedRegistry( rBootstrapPath ) ); 553 554 Reference< registry::XSimpleRegistry > xWriteReg( 555 createSimpleRegistry( rBootstrapPath ) ); 556 if (xWriteReg.is()) 557 { 558 if (bReadOnly) 559 { 560 try 561 { 562 xWriteReg->open( rWriteRegistry, sal_True, sal_False ); 563 } 564 catch (registry::InvalidRegistryException &) 565 { 566 } 567 568 if (! xWriteReg->isValid()) 569 { 570 throw RuntimeException( 571 OUSTR("specified first registry " 572 "could not be open readonly!"), 573 Reference< XInterface >() ); 574 } 575 } 576 else 577 { 578 xWriteReg->open( rWriteRegistry, sal_False, sal_True ); 579 } 580 } 581 582 Reference< registry::XSimpleRegistry > xReadReg( 583 createSimpleRegistry( rBootstrapPath ) ); 584 if (xReadReg.is()) 585 { 586 xReadReg->open( rReadRegistry, sal_True, sal_False ); 587 } 588 589 Reference< lang::XInitialization > xInit( xRegistry, UNO_QUERY ); 590 Sequence< Any > aInitSeq( 2 ); 591 aInitSeq[ 0 ] <<= xWriteReg; 592 aInitSeq[ 1 ] <<= xReadReg; 593 xInit->initialize( aInitSeq ); 594 } 595 596 if (bRegistryShouldBeValid && (!xRegistry.is() || !xRegistry->isValid())) 597 { 598 throw RuntimeException( 599 OUSTR("specified registry could not be initialized"), 600 Reference< XInterface >() ); 601 } 602 603 Bootstrap bootstrap; 604 Reference< XComponentContext > xContext( 605 bootstrapInitialContext( 606 xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); 607 608 // initialize sf 609 Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); 610 OSL_ASSERT( xInit.is() ); 611 Sequence< Any > aSFInit( 1 ); 612 aSFInit[ 0 ] <<= xRegistry; 613 xInit->initialize( aSFInit ); 614 615 return xSF; 616 } 617 618 Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory( 619 const OUString & rWriteRegistry, 620 const OUString & rReadRegistry, 621 sal_Bool bReadOnly, 622 const OUString & rBootstrapPath ) 623 { 624 return Reference< lang::XMultiServiceFactory >( createImplServiceFactory( 625 rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY ); 626 } 627 628 Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext( 629 Reference< registry::XSimpleRegistry > const & xRegistry, 630 OUString const & rBootstrapPath ) 631 { 632 Bootstrap bootstrap; 633 634 Reference< lang::XMultiComponentFactory > xSF( 635 bootstrapInitialSF( rBootstrapPath ) ); 636 Reference< XComponentContext > xContext( 637 bootstrapInitialContext( 638 xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); 639 640 // initialize sf 641 Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); 642 OSL_ASSERT( xInit.is() ); 643 Sequence< Any > aSFInit( 2 ); 644 aSFInit[ 0 ] <<= xRegistry; 645 aSFInit[ 1 ] <<= xContext; // default context 646 xInit->initialize( aSFInit ); 647 648 return xContext; 649 } 650 651 } 652