main/scripting/source/storage/ScriptStorage.cxx
//*************************************************************************
// private method to create the usual data structures for scripts located
// on the filesystem. 
// parcelURI = the path to the script
// functionName = the full filename with extension
// logicalName = the filename without the extension
private method to create the usual data structures for scripts located
on the filesystem.
parcelURI = the path to the script
functionName = the full filename with extension
logicalName = the filename without the extension
private method to create the usual data structures for scripts located on the filesystem . parcelURI = the path to the script functionName = the full filename with extension logicalName = the filename without the extension
void
ScriptStorage::createForFilesystem( const OUString & fileExtension )
throw ( RuntimeException, Exception )
{
    OUString xStringUri = ::rtl::Uri::decode( m_stringUri, 
        rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US );
    sal_Int32 lastFileSep = xStringUri.lastIndexOf( '/' );
    lastFileSep += 1;
    sal_Int32 lastFileExt = xStringUri.lastIndexOf( fileExtension );
    OUString searchString = OUString::createFromAscii( "://" );
    sal_Int32 searchStringLength = searchString.getLength();
    sal_Int32 startPath = xStringUri.indexOf( searchString );
    sal_Int32 uriLength = xStringUri.getLength();
    OUString fileNameNoExt = xStringUri.copy( lastFileSep , 
        lastFileExt - lastFileSep  - 1 );
    OUString fileName = xStringUri.copy( lastFileSep, uriLength - lastFileSep );
    OUString filePath = xStringUri.copy( startPath + searchStringLength, 
        lastFileSep - startPath - searchStringLength );
    OUString filePathWithName = xStringUri.copy( startPath + searchStringLength,
        uriLength - startPath - searchStringLength );
    ScriptData scriptData;
    scriptData.language = mh_scriptLangs->find( fileExtension )->second;
    OSL_TRACE( "\t language = %s", ::rtl::OUStringToOString( 
        scriptData.language, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
    scriptData.functionname = fileName;
    OSL_TRACE( "\t functionName = %s", ::rtl::OUStringToOString( 
        scriptData.functionname, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
    scriptData.parcelURI = filePath;
    OSL_TRACE( "\t parcelURI = %s", ::rtl::OUStringToOString( 
        scriptData.parcelURI, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
    scriptData.logicalname = fileNameNoExt;
    OSL_TRACE( "\t logicalName = %s", ::rtl::OUStringToOString( 
        scriptData.logicalname, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
    ScriptFunction_hash sfh;
    sfh[ scriptData.functionname ] = scriptData;
    mh_implementations[ scriptData.language ] = sfh;
    m_bInitialised = true; 
}
void ScriptStorage :: createForFilesystem ( const OUString & fileExtension ) throw ( RuntimeException , Exception ) { OUString xStringUri = :: rtl :: Uri :: decode ( m_stringUri , rtl_UriDecodeWithCharset , RTL_TEXTENCODING_ASCII_US ) ; sal_Int32 lastFileSep = xStringUri . lastIndexOf ( ' ' ) ; lastFileSep += 1 ; sal_Int32 lastFileExt = xStringUri . lastIndexOf ( fileExtension ) ; OUString searchString = OUString :: createFromAscii ( " " ) ; sal_Int32 searchStringLength = searchString . getLength ( ) ; sal_Int32 startPath = xStringUri . indexOf ( searchString ) ; sal_Int32 uriLength = xStringUri . getLength ( ) ; OUString fileNameNoExt = xStringUri . copy ( lastFileSep , lastFileExt - lastFileSep - 1 ) ; OUString fileName = xStringUri . copy ( lastFileSep , uriLength - lastFileSep ) ; OUString filePath = xStringUri . copy ( startPath + searchStringLength , lastFileSep - startPath - searchStringLength ) ; OUString filePathWithName = xStringUri . copy ( startPath + searchStringLength , uriLength - startPath - searchStringLength ) ; ScriptData scriptData ; scriptData . language = mh_scriptLangs -> find ( fileExtension ) -> second ; OSL_TRACE ( " \t " , :: rtl :: OUStringToOString ( scriptData . language , RTL_TEXTENCODING_ASCII_US ) . pData -> buffer ) ; scriptData . functionname = fileName ; OSL_TRACE ( " \t " , :: rtl :: OUStringToOString ( scriptData . functionname , RTL_TEXTENCODING_ASCII_US ) . pData -> buffer ) ; scriptData . parcelURI = filePath ; OSL_TRACE ( " \t " , :: rtl :: OUStringToOString ( scriptData . parcelURI , RTL_TEXTENCODING_ASCII_US ) . pData -> buffer ) ; scriptData . logicalname = fileNameNoExt ; OSL_TRACE ( " \t " , :: rtl :: OUStringToOString ( scriptData . logicalname , RTL_TEXTENCODING_ASCII_US ) . pData -> buffer ) ; ScriptFunction_hash sfh ; sfh [ scriptData . functionname ] = scriptData ; mh_implementations [ scriptData . language ] = sfh ; m_bInitialised = true ; }
private method to create the usual data structures for scripts located
on the filesystem.
private method to create the usual data structures for scripts located on the filesystem .
// need to decode as file urls are encoded // no x-platform issues here as we are dealing with URLs // the char just after the filesep // do we need to encode this? //scriptData.functionname = ::rtl::Uri::encode( fileName,  //rtl_UriCharClassUricNoSlash, rtl_UriEncodeCheckEscapes, //RTL_TEXTENCODING_ASCII_US ); // and now push onto the usual structures