Code cleanup.

This commit is contained in:
Duncan Foster
2003-05-23 13:59:52 +00:00
parent 9ef5d4c61d
commit a1bedb45a3
5 changed files with 43 additions and 48 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptNameResolverImpl.cxx,v $
*
* $Revision: 1.25 $
* $Revision: 1.26 $
*
* last change: $Author: dfoster $ $Date: 2003-05-21 09:04:36 $
* last change: $Author: dfoster $ $Date: 2003-05-23 14:59:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -245,7 +245,7 @@ throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeE
{
filesysURL = getFilesysURL( scriptURI );
}
catch ( RuntimeException & e )
catch ( lang::IllegalArgumentException & e )
{
OUString temp = OUSTR( "ScriptNameResolverImpl::resolve: " );
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
@@ -471,7 +471,7 @@ SAL_THROW ( ( lang::IllegalArgumentException, css::security::AccessControlExcept
{
permissionURI = getFilesysURL( scriptURI );
}
catch ( RuntimeException & e )
catch ( lang::IllegalArgumentException & e )
{
OUString temp = OUSTR( "ScriptNameResolverImpl::resolveFromURI: " );
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
@@ -611,7 +611,7 @@ const ::rtl::OUString & permissionURI ) SAL_THROW ( ( RuntimeException, css::sec
//*************************************************************************
OUString
ScriptNameResolverImpl::getFilesysURL( const OUString & scriptURI )
throw( RuntimeException )
throw( lang::IllegalArgumentException )
{
OUString filePath;
OUString fileName;
@@ -652,7 +652,7 @@ throw( RuntimeException )
{
// we need to throw
OUString temp = OUSTR( "ScriptNameResolverImpl::getFilesysURL: error getting the filesysURL" );
throw RuntimeException( temp, Reference< XInterface >() );
throw lang::IllegalArgumentException( temp, Reference< XInterface >(), 0 );
}
filePath+=fileName;
OSL_TRACE( "ScriptNameResolverImpl::getFilesysURL: filesys URL = %s",

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptNameResolverImpl.hxx,v $
*
* $Revision: 1.12 $
* $Revision: 1.13 $
*
* last change: $Author: dfoster $ $Date: 2003-05-16 10:14:21 $
* last change: $Author: dfoster $ $Date: 2003-05-23 14:59:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -128,7 +128,7 @@ private:
SAL_THROW ( ( css::uno::RuntimeException ) );
::rtl::OUString
ScriptNameResolverImpl::getFilesysURL( const ::rtl::OUString & scriptURI )
throw( css::uno::RuntimeException );
throw( css::lang::IllegalArgumentException );
/**********************************************
Reference< XComponentContext > m_xContext

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptRuntimeManager.cxx,v $
*
* $Revision: 1.16 $
* $Revision: 1.17 $
*
* last change: $Author: dfoster $ $Date: 2003-05-21 09:04:36 $
* last change: $Author: dfoster $ $Date: 2003-05-23 14:59:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -237,20 +237,6 @@ Any SAL_CALL ScriptRuntimeManager::invoke(
OSL_TRACE("Storage sid is: %d\n", resolvedSid);
if (resolvedSid != scriptingConstantsPool.USER_STORAGE_ID &&
resolvedSid != scriptingConstantsPool.SHARED_STORAGE_ID)
{
/* LanguageType nLang = LANGUAGE_SYSTEM;
ResMgr *pResMgr = ResMgr::SearchCreateResMgr( "scripting" MAKE_NUMSTR(SUPD), nLang );
QueryBox aBox( NULL, ResId(DLG_SCRIPTEXEC, pResMgr));
sal_Int32 res = aBox.Execute();
delete pResMgr;
if (res == RET_NO)
{
return results;
} */
}
// modifying the XPropertySet on the resolved Context to contain the
// full script info
Any aResolvedScript;

View File

@@ -2,8 +2,8 @@
*
* $RCSfile: ScriptStorage.cxx,v $
*
* $Revision: 1.20 $
* last change: $Author: dfoster $ $Date: 2003-05-16 10:14:22 $
* $Revision: 1.21 $
* last change: $Author: dfoster $ $Date: 2003-05-23 14:59:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -119,6 +119,18 @@ ScriptStorage::ScriptStorage( const Reference <
validateXRef( m_xMgr,
"ScriptStorage::ScriptStorage : cannot get service manager" );
if( !mh_scriptLangs )
{
::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
if( !mh_scriptLangs )
{
mh_scriptLangs = new ScriptLanguages_hash();
(*mh_scriptLangs)[ OUString::createFromAscii( "bsh" ) ] =
OUString::createFromAscii( "BeanShell" );
(*mh_scriptLangs)[ OUString::createFromAscii( "js" ) ] =
OUString::createFromAscii( "Rhino" );
}
}
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
}
@@ -147,13 +159,6 @@ throw ( RuntimeException, Exception )
{ // Protect member variable writes
::osl::Guard< osl::Mutex > aGuard( m_mutex );
/* not sure whether Java scripts are supported as filesystem scripts
* mh_scriptLangs[ OUString::createFromAscii( "class" ) ] =
* OUString::createFromAscii( "Java" ); */
mh_scriptLangs[ OUString::createFromAscii( "bsh" ) ] =
OUString::createFromAscii( "BeanShell" );
mh_scriptLangs[ OUString::createFromAscii( "js" ) ] =
OUString::createFromAscii( "Rhino" );
// Check args
if ( args.getLength() != NUMBER_STORAGE_INITIALIZE_ARGS )
{
@@ -196,8 +201,8 @@ throw ( RuntimeException, Exception )
// extension that is associated with a script (eg. .bsh, .js etc)
OUString fileExtension = getFileExtension( m_stringUri );
// and see if this is in our scripts map
ScriptLanguages_hash::iterator h_it = mh_scriptLangs.find( fileExtension );
if ( h_it != mh_scriptLangs.end() )
ScriptLanguages_hash::iterator h_it = mh_scriptLangs->find( fileExtension );
if ( h_it != mh_scriptLangs->end() )
{
createForFilesystem( fileExtension );
}
@@ -408,19 +413,23 @@ throw ( RuntimeException, Exception )
// no x-platform issues here as we are dealing with URLs
sal_Int32 lastFileSep = xStringUri.lastIndexOf( '/' );
// the char just after the filesep
lastFileSep += 1;
sal_Int32 lastFileExt = xStringUri.lastIndexOf( fileExtension );
sal_Int32 startPath = xStringUri.indexOf( OUString::createFromAscii( "://" ) );
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 + 1,
lastFileExt - lastFileSep - 2 );
OUString fileName = xStringUri.copy( lastFileSep + 1, uriLength - lastFileSep -1 );
OUString filePath = xStringUri.copy( startPath + 3,
lastFileSep - startPath - 2 );
OUString filePathWithName = xStringUri.copy( startPath + 3,
uriLength - startPath - 3 );
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;
scriptData.language = mh_scriptLangs->find( fileExtension )->second;
OSL_TRACE( "\t language = %s", ::rtl::OUStringToOString(
scriptData.language, RTL_TEXTENCODING_ASCII_US ).pData->buffer );

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptStorage.hxx,v $
*
* $Revision: 1.12 $
* $Revision: 1.13 $
*
* last change: $Author: dfoster $ $Date: 2003-05-16 10:14:22 $
* last change: $Author: dfoster $ $Date: 2003-05-23 14:59:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -207,7 +207,7 @@ private:
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
::std::vector < ::rtl::OUString > mv_logicalNames;
ScriptLanguages_hash mh_scriptLangs;
static ScriptLanguages_hash* mh_scriptLangs;
ScriptInfo_hash mh_implementations;
ScriptOutput_hash mh_parcels;
sal_Int32 m_scriptStorageID;