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_scripting.hxx" 26 27 #include <vector> 28 #include <stdlib.h> 29 30 #include <cppuhelper/implementationentry.hxx> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include <com/sun/star/security/AccessControlException.hpp> 33 34 #include <util/util.hxx> 35 #include <util/scriptingconstants.hxx> 36 37 #include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp> 38 #include <drafts/com/sun/star/script/framework/security/XScriptSecurity.hpp> 39 40 #include "ScriptNameResolverImpl.hxx" 41 #include "ScriptRuntimeManager.hxx" 42 43 using namespace ::rtl; 44 using namespace ::com::sun::star; 45 using namespace ::com::sun::star::uno; 46 using namespace ::drafts::com::sun::star::script::framework; 47 48 namespace scripting_runtimemgr 49 { 50 51 const sal_Char* const LANGUAGE_TO_RESOLVE_ON[] = { "All" }; // should be configurable 52 OUString nrs_implName = OUString::createFromAscii( 53 "drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ); 54 OUString nrs_serviceName = OUString::createFromAscii( 55 "drafts.com.sun.star.script.framework.runtime.DefaultScriptNameResolver" ); 56 Sequence< OUString > nrs_serviceNames = Sequence< OUString >( &nrs_serviceName, 1 ); 57 58 const char* const SCRIPTSTORAGEMANAGER_SERVICE = 59 "/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager"; 60 61 extern ::rtl_StandardModuleCount s_moduleCount; 62 63 // define storages to search 64 static ::std::vector< sal_Int32 >* m_pSearchIDs = NULL; 65 66 //************************************************************************* 67 ScriptNameResolverImpl::ScriptNameResolverImpl( 68 const Reference< XComponentContext > & xContext ) : 69 m_xContext( xContext, UNO_SET_THROW ) 70 { 71 OSL_TRACE( "< ScriptNameResolverImpl ctor called >\n" ); 72 validateXRef( m_xContext, "ScriptNameResolverImpl::ScriptNameResolverImpl: invalid context" ); 73 m_xMultiComFac.set( m_xContext->getServiceManager(), UNO_SET_THROW ); 74 75 if( !m_pSearchIDs ) 76 { 77 osl::Guard< osl::Mutex > aGuard( m_mutex ); 78 if( !m_pSearchIDs ) 79 { 80 scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 81 scripting_constants::ScriptingConstantsPool::instance(); 82 m_pSearchIDs = new ::std::vector< sal_Int32 >(); 83 m_pSearchIDs->push_back( scriptingConstantsPool.DOC_STORAGE_ID_NOT_SET ); 84 m_pSearchIDs->push_back( scriptingConstantsPool.USER_STORAGE_ID ); 85 m_pSearchIDs->push_back( scriptingConstantsPool.SHARED_STORAGE_ID ); 86 } 87 } 88 89 s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); 90 } 91 92 //************************************************************************* 93 ScriptNameResolverImpl::~ScriptNameResolverImpl() 94 { 95 OSL_TRACE( "< ScriptNameResolverImpl dtor called >\n" ); 96 s_moduleCount.modCnt.release( &s_moduleCount.modCnt ); 97 } 98 99 //************************************************************************* 100 Reference< storage::XScriptInfo > ScriptNameResolverImpl::resolve( 101 const ::rtl::OUString & scriptURI, Any& invocationCtx ) 102 { 103 104 Reference< storage::XScriptInfo > resolvedName; 105 Reference< beans::XPropertySet > xPropSetScriptingContext; 106 scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 107 scripting_constants::ScriptingConstantsPool::instance(); 108 109 OSL_TRACE( "ScriptNameResolverImpl::resolve: in resolve - start" ); 110 111 if ( sal_False == ( invocationCtx >>= xPropSetScriptingContext ) ) 112 { 113 throw RuntimeException( OUSTR( 114 "ScriptNameResolverImpl::resolve : unable to get XScriptingContext from param" ), 115 Reference< XInterface > () ); 116 } 117 118 Any any; 119 OUString docUri; 120 sal_Int32 filesysScriptStorageID = -1; 121 Reference < storage::XScriptStorageManager > xScriptStorageMgr; 122 sal_Int32 docSid; 123 try 124 { 125 any = xPropSetScriptingContext->getPropertyValue( 126 scriptingConstantsPool.DOC_URI ); 127 OSL_TRACE( "ScriptNameResolverImpl::resolve: in resolve - got anyUri" ); 128 if ( sal_False == ( any >>= docUri ) ) 129 { 130 throw RuntimeException( OUSTR( 131 "ScriptNameResolverImpl::resolve : unable to get doc Uri from xPropSetScriptingContext" ), 132 Reference< XInterface > () ); 133 } 134 any = xPropSetScriptingContext->getPropertyValue( 135 scriptingConstantsPool.DOC_STORAGE_ID ); 136 if ( sal_False == ( any >>= docSid ) ) 137 { 138 throw RuntimeException( OUSTR( 139 "ScriptNameResolverImpl::resolve : unable to get doc storage id from xPropSetScriptingContext" ), 140 Reference< XInterface > () ); 141 } 142 } 143 catch ( Exception & e ) 144 { 145 OUString temp = OUSTR( 146 "ScriptNameResolverImpl::resolve : problem with getPropertyValue" ); 147 throw RuntimeException( temp.concat( e.Message ), 148 Reference< XInterface > () ); 149 } 150 #ifdef _DEBUG 151 catch ( ... ) 152 { 153 throw RuntimeException( OUSTR( 154 "ScriptNameResolverImpl::resolve Unknown Exception caught - RuntimeException rethrown" ), 155 Reference< XInterface > () ); 156 } 157 #endif 158 159 160 ::rtl::OString docUriO( 161 ::rtl::OUStringToOString( docUri , RTL_TEXTENCODING_ASCII_US ) ); 162 OSL_TRACE( 163 "ScriptNameResolverImpl::resolve: *** >>> DOC URI: %s, doc sid is %d\n", 164 docUriO.pData->buffer, docSid ); 165 166 167 OSL_TRACE( "ScriptNameResolverImpl::resolve Starting..." ); 168 OUString docString = OUString::createFromAscii( "location=document" ); 169 OUString userString = OUString::createFromAscii( "location=user" ); 170 OUString shareString = OUString::createFromAscii( "location=share" ); 171 OUString filesysString = OUString::createFromAscii( "location=filesystem" ); 172 173 // initialise vector with doc, user and share 174 175 // m_pSearchIDs is initialised as follows, 176 // m_pSearchIDs [ 0 ] empty 177 // m_pSearchIDs [ 1 ] user storage id 178 // m_pSearchIDs [ 2 ] share " " 179 180 ::std::vector< sal_Int32 > m_vSearchIDs = *m_pSearchIDs; 181 m_vSearchIDs[ 0 ] = docSid; 182 183 if ( scriptURI.indexOf( docString ) != -1 ) 184 { 185 OSL_TRACE("Full resolution available, search document"); 186 // search in document 187 m_vSearchIDs.resize( 1 ); 188 } 189 else if ( scriptURI.indexOf( userString ) != -1 ) 190 { 191 OSL_TRACE("Full resolution available, search user"); 192 // search in user 193 m_vSearchIDs[ 0 ] = ( *m_pSearchIDs )[ 1 ]; 194 m_vSearchIDs.resize( 1 ); 195 } 196 else if ( scriptURI.indexOf( shareString ) != -1 ) 197 { 198 OSL_TRACE("Full resolution available, search share"); 199 // search in share 200 m_vSearchIDs[ 0 ] = ( *m_pSearchIDs )[ 2 ]; 201 m_vSearchIDs.resize( 1 ); 202 } 203 else if ( scriptURI.indexOf( filesysString ) != -1 ) 204 { 205 OSL_TRACE("Full resolution available, create & search filesystem"); 206 OUString filesysURL; 207 try 208 { 209 filesysURL = getFilesysURL( scriptURI ); 210 } 211 catch ( lang::IllegalArgumentException & e ) 212 { 213 OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: " ); 214 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); 215 } 216 Reference< XInterface > xInterface( 217 m_xMultiComFac->createInstanceWithContext( 218 ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), 219 m_xContext 220 ), 221 UNO_SET_THROW 222 ); 223 Reference < ucb::XSimpleFileAccess > xSimpleFileAccess = Reference < 224 ucb::XSimpleFileAccess > ( xInterface, UNO_QUERY_THROW ); 225 226 // do we need to encode this? hope not. 227 OSL_TRACE( ">>>> About to create storage for %s", 228 ::rtl::OUStringToOString( filesysURL, 229 RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 230 // ask storage manager to create storage 231 try 232 { 233 // need to get the ScriptStorageManager 234 xScriptStorageMgr.set( m_xContext->getValueByName( 235 scriptingConstantsPool.SCRIPTSTORAGEMANAGER_SERVICE ), UNO_QUERY_THROW ); 236 filesysScriptStorageID = 237 xScriptStorageMgr->createScriptStorageWithURI( 238 xSimpleFileAccess, filesysURL ); 239 OSL_TRACE( ">>>> Created storage %d - for %s ", 240 filesysScriptStorageID, ::rtl::OUStringToOString( 241 filesysURL, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 242 } 243 catch ( RuntimeException & e ) 244 { 245 OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: " ); 246 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); 247 } 248 m_vSearchIDs[ 0 ] = filesysScriptStorageID; 249 m_vSearchIDs.resize( 1 ); 250 } 251 else 252 { 253 OSL_TRACE("Only partial uri available, search doc, user & share"); 254 // is this illegal or do we search in a default way 255 // if we get to here a uri has been passed in that has: 256 // a) not got a location specified 257 // b) an illegal location 258 259 // detect illegal location 260 if ( scriptURI.indexOf( OUString::createFromAscii( "location=" ) ) != -1 ) 261 { 262 OSL_TRACE( 263 "ScriptNameResolver::resolve, throwing IllegalArgException" ); 264 throw lang::IllegalArgumentException( 265 OUSTR( "invalid URI: " ).concat( scriptURI ), 266 Reference < XInterface > (), 1 ); 267 268 } 269 // leave vSearchIDs take care of the search... 270 } 271 272 ::std::vector< sal_Int32 >::const_iterator iter; 273 ::std::vector< sal_Int32 >::const_iterator iterEnd = m_vSearchIDs.end(); 274 275 for ( iter = m_vSearchIDs.begin() ; iter != iterEnd; ++iter ) 276 { 277 try 278 { 279 OSL_TRACE( "** about to resolve from storage using id %d from vector of size %d", 280 *iter, m_vSearchIDs.size() ); 281 if ( ( resolvedName = resolveURIFromStorageID( *iter, docUri, scriptURI ) ).is() ) 282 { 283 OSL_TRACE( "found match in uri from storage %d", *iter ); 284 xPropSetScriptingContext->setPropertyValue( 285 scriptingConstantsPool.RESOLVED_STORAGE_ID, makeAny(*iter) ); 286 break; 287 } 288 289 } 290 catch ( css::security::AccessControlException & e ) 291 { 292 // no execute permission 293 OSL_TRACE( "ScriptNameResolverImpl::resolve : AccessControlException " ); 294 continue; 295 } 296 catch ( beans::UnknownPropertyException & e ) 297 { 298 OUString temp = OUSTR( 299 "ScriptNameResolverImpl::resolve : UnknownPropertyException" ); 300 throw RuntimeException( temp.concat( e.Message ), 301 Reference< XInterface > () ); 302 } 303 catch ( beans::PropertyVetoException & e ) 304 { 305 OUString temp = OUSTR( 306 "ScriptNameResolverImpl::resolve : PropertyVetoException " ); 307 throw RuntimeException( temp.concat( e.Message ), 308 Reference< XInterface > () ); 309 } 310 catch ( lang::IllegalArgumentException & e ) 311 { 312 OUString temp = OUSTR( 313 "ScriptNameResolverImpl::resolve : IllegalArgumentException " ); 314 throw lang::IllegalArgumentException( temp.concat( e.Message ), 315 Reference< XInterface > (), e.ArgumentPosition ); 316 } 317 catch ( lang::WrappedTargetException & e ) 318 { 319 OUString temp = OUSTR( 320 "ScriptNameResolverImpl::resolve : WrappedTargetException " ); 321 throw RuntimeException( temp.concat( e.Message ), 322 Reference< XInterface > () ); 323 } 324 catch ( Exception & e ) 325 { 326 OSL_TRACE( 327 "Exception thrown by storage %d, failed to match uri: %s", 328 *iter, 329 ::rtl::OUStringToOString( e.Message, 330 RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 331 OUString temp = OUSTR( 332 "ScriptNameResolverImpl::resolve : unknown exception" ); 333 throw RuntimeException( temp.concat( e.Message ), 334 Reference< XInterface > () ); 335 } 336 #ifdef _DEBUG 337 catch ( ... ) 338 { 339 OSL_TRACE( 340 "unknown exception thrown by storage %d, failed to match uri", 341 *iter ); 342 OUString temp = OUSTR( 343 "ScriptNameResolverImpl::resolve Unknown exception caught - RuntimeException rethrown" ); 344 throw RuntimeException( temp, 345 Reference< XInterface > () ); 346 } 347 #endif 348 349 } 350 if ( !resolvedName.is() ) 351 { 352 if( filesysScriptStorageID > 2 ) 353 { 354 // get the filesys storage and dispose of it 355 Reference< XInterface > xScriptStorage( xScriptStorageMgr->getScriptStorage( filesysScriptStorageID ), UNO_SET_THROW ); 356 Reference< storage::XScriptInfoAccess > xScriptInfoAccess = Reference< 357 storage::XScriptInfoAccess > ( xScriptStorage, UNO_QUERY_THROW ); 358 Sequence< Reference< storage::XScriptInfo > > results = 359 xScriptInfoAccess->getAllImplementations( ); 360 Reference < lang::XEventListener > xEL_ScriptStorageMgr(( xScriptStorageMgr ,UNO_QUERY_THROW ); 361 lang::EventObject event( results[ 0 ] ); 362 xEL_ScriptStorageMgr->disposing( event ); 363 } 364 throw lang::IllegalArgumentException( OUSTR( 365 "ScriptNameResolverImpl::resolve: no script found for uri=" ).concat( scriptURI ), 366 Reference< XInterface > (), 0 ); 367 } 368 return resolvedName; 369 } 370 371 //************************************************************************* 372 OUString SAL_CALL 373 ScriptNameResolverImpl::getImplementationName( ) 374 { 375 return nrs_implName; 376 } 377 378 //************************************************************************* 379 sal_Bool SAL_CALL 380 ScriptNameResolverImpl::supportsService( const OUString& serviceName ) 381 { 382 OUString const * pNames = nrs_serviceNames.getConstArray(); 383 for ( sal_Int32 nPos = nrs_serviceNames.getLength(); nPos--; ) 384 { 385 if ( serviceName.equals( pNames[ nPos ] ) ) 386 { 387 return sal_True; 388 } 389 } 390 return sal_False; 391 } 392 393 //************************************************************************* 394 395 Reference< storage::XScriptInfo > 396 ScriptNameResolverImpl::resolveURIFromStorageID 397 ( sal_Int32 sid, const ::rtl::OUString & docURI, 398 const ::rtl::OUString& scriptURI ) 399 { 400 Reference< storage::XScriptInfo > resolvedScriptInfo; 401 scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 402 scripting_constants::ScriptingConstantsPool::instance(); 403 if ( sid == scriptingConstantsPool.DOC_STORAGE_ID_NOT_SET ) 404 { 405 OSL_TRACE( "@@@@ **** ScriptNameResolverImpl::resolve DOC_STORAGE_ID_NOT_SET" ); 406 return resolvedScriptInfo; 407 } 408 try 409 { 410 OUString permissionURI = docURI; 411 OUString filesysString = OUString::createFromAscii( "location=filesystem" ); 412 if ( scriptURI.indexOf( filesysString ) != -1 ) 413 { 414 // in the case of filesys scripts we're checking whether the 415 // location of the script, rather than the location of the document, 416 // has execute permission 417 try 418 { 419 permissionURI = getFilesysURL( scriptURI ); 420 } 421 catch ( lang::IllegalArgumentException & e ) 422 { 423 OUString temp = OUSTR( "ScriptNameResolverImpl::resolveFromURI: " ); 424 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); 425 } 426 } 427 Reference< storage::XScriptInfoAccess > storage( getStorageInstance( sid, permissionURI ), UNO_SET_THROW ); 428 Sequence< Reference< storage::XScriptInfo > > results = 429 storage->getImplementations( scriptURI ); 430 431 const sal_Int32 length = results.getLength(); 432 433 if ( !length ) 434 { 435 return resolvedScriptInfo; 436 } 437 438 OSL_TRACE( "ScriptNameResolverImpl::resolve Got some results..." ); 439 // if we get results, just return first in list, 440 // storage has already matched language, function name etc. if 441 // that information was in the uri 442 resolvedScriptInfo = results[ 0 ]; 443 } 444 catch ( css::security::AccessControlException & ace ) 445 { 446 OUString temp = OUSTR( 447 "ScriptRuntimeManager::resolveURIFromStorageID AccessControlException: " ); 448 throw css::security::AccessControlException( temp.concat( ace.Message ), 449 Reference< XInterface > (), 450 ace.LackingPermission ); 451 } 452 catch ( lang::IllegalArgumentException & iae ) 453 { 454 OUString temp = OUSTR( 455 "ScriptRuntimeManager::resolveURIFromStorageID IllegalArgumentException: " ); 456 throw lang::IllegalArgumentException( temp.concat( iae.Message ), 457 Reference< XInterface > (), 458 iae.ArgumentPosition ); 459 } 460 catch ( RuntimeException & re ) 461 { 462 OUString temp = OUSTR( 463 "ScriptRuntimeManager::resolveURIFromStorageID RuntimeException: " ); 464 throw RuntimeException( temp.concat( re.Message ), 465 Reference< XInterface > () ); 466 } 467 catch ( Exception & e ) 468 { 469 OUString temp = OUSTR( 470 "ScriptNameResolverImpl::resolveURIFromStorageID : Exception caught - RuntimeException rethrown" ); 471 throw RuntimeException( temp.concat( e.Message ), 472 Reference< XInterface > () ); 473 } 474 #ifdef _DEBUG 475 catch ( ... ) 476 { 477 throw RuntimeException( OUSTR( 478 "ScriptNameResolverImpl::resolveURIFromStorageID Unknown exception caught - RuntimeException rethrown" ), 479 Reference< XInterface > () ); 480 } 481 #endif 482 return resolvedScriptInfo; 483 } 484 //************************************************************************* 485 486 Reference< storage::XScriptInfoAccess > 487 488 ScriptNameResolverImpl::getStorageInstance( sal_Int32 sid, 489 const ::rtl::OUString & permissionURI ) 490 { 491 Reference< storage::XScriptInfoAccess > xScriptInfoAccess; 492 try 493 { 494 Reference< XInterface > xInterface( m_xContext->getValueByName( 495 OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) ), UNO_QUERY_THROW ); 496 // check that we have permissions for this storage 497 Reference< dcsssf::security::XScriptSecurity > xScriptSecurity( xInterface, UNO_QUERY_THROW ); 498 scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 499 scripting_constants::ScriptingConstantsPool::instance(); 500 // if we dealing with a document storage (ie. not user or share 501 // we need to check the permission 502 if( ( sid != scriptingConstantsPool.USER_STORAGE_ID ) && 503 ( sid != scriptingConstantsPool.SHARED_STORAGE_ID ) ) 504 { 505 xScriptSecurity->checkPermission( permissionURI, 506 OUString::createFromAscii( "execute" ) ); 507 // if we get here, the checkPermission hasn't thrown an 508 // AccessControlException, ie. permission has been granted 509 OSL_TRACE( "ScriptNameResolverImpl::getStorageInstance: got execute permission for ID=%d", sid ); 510 } 511 Reference< storage::XScriptStorageManager > xScriptStorageManager( xInterface, UNO_QUERY_THROW ); 512 Reference< XInterface > xScriptStorage( ScriptStorageManager->getScriptStorage( sid ), UNO_SET_THROW ); 513 xScriptInfoAccess.set( xScriptStorage, UNO_QUERY_THROW ); 514 } 515 catch ( lang::IllegalArgumentException & e ) 516 { 517 OUString temp = OUSTR( "ScriptNameResolverImpl::getStorageInstance: " ); 518 throw lang::IllegalArgumentException( temp.concat( e.Message ), 519 Reference< XInterface >(), e.ArgumentPosition ); 520 } 521 catch ( css::security::AccessControlException & e ) 522 { 523 OUString temp = OUSTR( "ScriptNameResolverImpl::getStorageInstance: AccessControlException " ); 524 throw css::security::AccessControlException( temp.concat( e.Message ), Reference< XInterface >(), e.LackingPermission ); 525 } 526 catch ( RuntimeException & re ) 527 { 528 OUString temp = OUSTR( "ScriptNameResolverImpl::getStorageInstance: " ); 529 throw RuntimeException( temp.concat( re.Message ), Reference< XInterface >() ); 530 } 531 catch ( Exception & e ) 532 { 533 OUString temp = OUSTR( "ScriptNameResolverImpl::getStorageInstance: " ); 534 throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); 535 } 536 return xScriptInfoAccess; 537 } 538 //************************************************************************* 539 OUString 540 ScriptNameResolverImpl::getFilesysURL( const OUString & scriptURI ) 541 { 542 OUString filePath; 543 OUString fileName; 544 OUString filesysString = OUString::createFromAscii( "location=filesystem" ); 545 sal_Int32 locationPos = scriptURI.indexOf( filesysString ); 546 // expect location=filesys:file:///foo/bar/myscript.bsh etc 547 // except the file url at this point is encoded 548 // so we should be ok searching for the '&' 549 sal_Int32 filesysStrLen = filesysString.getLength() + 1; 550 sal_Int32 endOfLocn = scriptURI.indexOf( '&', locationPos ); 551 if (endOfLocn == -1 ) 552 { 553 filePath = scriptURI.copy( locationPos + filesysString.getLength() + 1 ); 554 } 555 else 556 { 557 filePath = scriptURI.copy( locationPos + filesysStrLen, 558 endOfLocn - locationPos - filesysStrLen ); 559 } 560 //file name shoul also be encoded so again ok to search for '&' 561 OUString functionKey = OUString::createFromAscii( "function=" ); 562 sal_Int32 functionKeyLength = functionKey.getLength(); 563 sal_Int32 functionNamePos = scriptURI.indexOf( functionKey ); 564 if ( functionNamePos > 0 ) 565 { 566 sal_Int32 endOfFn = scriptURI.indexOf( '&', functionNamePos ); 567 if ( endOfFn == -1 ) 568 { 569 fileName = scriptURI.copy( functionNamePos + functionKeyLength ); 570 } 571 else 572 { 573 fileName = scriptURI.copy( functionNamePos + functionKeyLength, 574 endOfFn - functionNamePos - functionKeyLength ); 575 } 576 } 577 else 578 { 579 // we need to throw 580 OUString temp = OUSTR( "ScriptNameResolverImpl::getFilesysURL: error getting the filesysURL" ); 581 throw lang::IllegalArgumentException( temp, Reference< XInterface >(), 0 ); 582 } 583 filePath+=fileName; 584 OSL_TRACE( "ScriptNameResolverImpl::getFilesysURL: filesys URL = %s", 585 ::rtl::OUStringToOString( filePath, 586 RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 587 return filePath; 588 } 589 //************************************************************************* 590 Sequence<OUString> SAL_CALL 591 ScriptNameResolverImpl::getSupportedServiceNames( ) 592 { 593 return nrs_serviceNames; 594 } 595 596 //************************************************************************* 597 Reference< XInterface > SAL_CALL scriptnri_create( 598 Reference< XComponentContext > const & xComponentContext ) 599 { 600 return ( cppu::OWeakObject * ) new ScriptNameResolverImpl( xComponentContext ); 601 } 602 603 //************************************************************************* 604 Sequence< OUString > scriptnri_getSupportedServiceNames() SAL_THROW( () ) 605 { 606 return nrs_serviceNames; 607 } 608 609 //************************************************************************* 610 OUString scriptnri_getImplementationName() SAL_THROW( () ) 611 { 612 return nrs_implName; 613 } 614 } // namespace scripting_runtimemgr 615