Updates from code review for end of September release

This commit is contained in:
John Rice
2002-09-27 11:16:30 +00:00
parent a9dcd87448
commit e168de6dd3
18 changed files with 2476 additions and 1985 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptRuntimeManager.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: aledoux $ $Date: 2002-09-24 12:59:32 $
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,12 +59,10 @@
*
************************************************************************/
#include <stdio.h>
#include <cppuhelper/implementationentry.hxx>
#include "ScriptRuntimeManager.hxx"
#include "ScriptNameResolverImpl.hxx"
#include "ScriptRuntimeManager.hxx"
#include <util/util.hxx>
using namespace ::rtl;
@@ -76,19 +74,19 @@ using namespace ::drafts::com::sun::star::script::framework;
namespace scripting_runtimemgr
{
static const sal_Char* const SERVICENAME="drafts.com.sun.star.script.framework.ScriptRuntimeManager";
static const sal_Char* const IMPLNAME="drafts.com.sun.star.script.framework.ScriptRuntimeManager";
static OUString s_implName = ::rtl::OUString::createFromAscii(IMPLNAME);
static OUString s_serviceName = ::rtl::OUString::createFromAscii(SERVICENAME);
static OUString s_implName = ::rtl::OUString::createFromAscii(
"drafts.com.sun.star.script.framework.ScriptRuntimeManager" );
static OUString s_serviceName = ::rtl::OUString::createFromAscii(
"drafts.com.sun.star.script.framework.ScriptRuntimeManager" );
static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
//*************************************************************************
// ScriptRuntimeManager Constructor
ScriptRuntimeManager::ScriptRuntimeManager(const Reference< XComponentContext > & xContext)
: m_xContext( xContext )
ScriptRuntimeManager::ScriptRuntimeManager(
const Reference< XComponentContext > & xContext ) :
m_xContext( xContext )
{
OSL_TRACE( "< ScriptRuntimeManager ctor called >\n" );
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
@@ -104,29 +102,35 @@ ScriptRuntimeManager::~ScriptRuntimeManager()
//*************************************************************************
// Get the proper XScriptInvocation
Reference <XScriptInvocation> SAL_CALL ScriptRuntimeManager::getScriptRuntime(const Reference<scripturi::XScriptURI>& scriptURI)
throw(RuntimeException)
Reference< XScriptInvocation > SAL_CALL ScriptRuntimeManager::getScriptRuntime(
const Reference< scripturi::XScriptURI >& scriptURI )
throw( RuntimeException )
{
OSL_TRACE("** ==> ScriptRuntimeManager in getScriptRuntime\n");
OSL_TRACE( "** ==> ScriptRuntimeManager in getScriptRuntime\n" );
Reference< XScriptInvocation > xScriptInvocation;
validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptRuntime: No context available");
validateXRef( m_xContext,
"ScriptRuntimeManager::GetScriptRuntime: No context available" );
Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
validateXRef(xMgr, "ScriptRuntimeManager::GetScriptRuntime: No service manager available");
validateXRef( xMgr,
"ScriptRuntimeManager::GetScriptRuntime: No service manager available" );
try
{
Reference< XInterface > xx;
Any a = m_xContext->getValueByName(OUString::createFromAscii("/singletons/drafts.com.sun.star.script.framework.theScriptRuntimeForJava"));
Any a = m_xContext->getValueByName( OUString::createFromAscii(
"/singletons/drafts.com.sun.star.script.framework.theScriptRuntimeForJava" ) );
a >>= xx;
validateXRef(xx, "ScriptRuntimeManager::GetScriptRuntime: cannot get ScriptRuntimeForJava Service");
xScriptInvocation = Reference<XScriptInvocation>(xx, UNO_QUERY_THROW);
validateXRef( xx,
"ScriptRuntimeManager::GetScriptRuntime: cannot get ScriptRuntimeForJava Service"
);
xScriptInvocation = Reference< XScriptInvocation >( xx, UNO_QUERY_THROW );
}
catch (Exception &e)
catch ( Exception & e )
{
OUString temp = OUSTR("ScriptRuntimeManager::GetScriptRuntime: ");
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
OUString temp = OUSTR( "ScriptRuntimeManager::GetScriptRuntime: " );
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
}
return xScriptInvocation;
@@ -134,27 +138,33 @@ throw(RuntimeException)
//*************************************************************************
// Get the proper XScriptNameResolver
Reference <XScriptNameResolver> SAL_CALL
Reference< XScriptNameResolver > SAL_CALL
ScriptRuntimeManager::getScriptNameResolver()
throw(RuntimeException)
throw( RuntimeException )
{
OSL_TRACE("** ==> ScriptRuntimeManager in getScriptNameResolver\n");
OSL_TRACE( "** ==> ScriptRuntimeManager in getScriptNameResolver\n" );
Reference< XScriptNameResolver > xScriptNameResolver;
validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptNameResolver: No context available");
validateXRef( m_xContext,
"ScriptRuntimeManager::GetScriptNameResolver: No context available" );
Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
validateXRef(xMgr, "ScriptRuntimeManager::GetScriptRuntime: No Service Manager available");
validateXRef( xMgr,
"ScriptRuntimeManager::GetScriptRuntime: No Service Manager available" );
try
{
Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.DefaultScriptNameResolver"),m_xContext );
validateXRef(xx, "ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" );
xScriptNameResolver = Reference<XScriptNameResolver>(xx, UNO_QUERY_THROW);
Reference< XInterface > xx = xMgr->createInstanceWithContext(
OUString::createFromAscii(
"drafts.com.sun.star.script.framework.DefaultScriptNameResolver" ),
m_xContext );
validateXRef( xx,
"ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" );
xScriptNameResolver = Reference< XScriptNameResolver >( xx, UNO_QUERY_THROW );
}
catch (Exception &e)
catch ( Exception & e )
{
OUString temp = OUSTR("ScriptRuntimeManager::GetScriptNameResolver: ");
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
OUString temp = OUSTR( "ScriptRuntimeManager::GetScriptNameResolver: " );
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
}
return xScriptNameResolver;
}
@@ -162,10 +172,13 @@ throw(RuntimeException)
//*************************************************************************
// XScriptInvocation implementation
Any SAL_CALL ScriptRuntimeManager::invoke(
const Reference < scripturi::XScriptURI > & scriptURI,
const Any& invocationCtx, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, RuntimeException)
const Reference< scripturi::XScriptURI > & scriptURI,
const Any& invocationCtx, const Sequence< Any >& aParams,
Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
throw ( lang::IllegalArgumentException, script::CannotConvertException,
reflection::InvocationTargetException, RuntimeException )
{
OSL_TRACE("** ==> ScriptRuntimeManager in runtimemgr invoke\n");
OSL_TRACE( "** ==> ScriptRuntimeManager in runtimemgr invoke\n" );
Any results;
// Initialise resolved context with invocation context,
// the resolved context (resolvedCtx will be modified by the
@@ -174,45 +187,51 @@ Any SAL_CALL ScriptRuntimeManager::invoke(
Any resolvedCtx = invocationCtx;
try
{
Reference< scripturi::XScriptURI > resolvedURI = resolve(scriptURI, resolvedCtx);
validateXRef(resolvedURI, "ScriptRuntimeManager::invoke: No resolvedURI" );
Reference< scripturi::XScriptURI > resolvedURI = resolve( scriptURI,
resolvedCtx );
validateXRef( resolvedURI, "ScriptRuntimeManager::invoke: No resolvedURI" );
Reference< XScriptInvocation > xScriptInvocation = getScriptRuntime(resolvedURI);
validateXRef(xScriptInvocation, "ScriptRuntimeManager::invoke: cannot get instance of language specific runtime.");
Reference< XScriptInvocation > xScriptInvocation =
getScriptRuntime( resolvedURI );
validateXRef( xScriptInvocation,
"ScriptRuntimeManager::invoke: cannot get instance of language specific runtime." );
results = xScriptInvocation->invoke(resolvedURI,resolvedCtx,aParams,
aOutParamIndex,aOutParam);
results = xScriptInvocation->invoke( resolvedURI, resolvedCtx, aParams,
aOutParamIndex, aOutParam );
}
catch (lang::IllegalArgumentException & iae)
catch ( lang::IllegalArgumentException & iae )
{
OUString temp = OUSTR("ScriptRuntimeManager::invoke IllegalArgumentException: ");
throw lang::IllegalArgumentException(temp.concat(iae.Message),
Reference<XInterface> (), iae.ArgumentPosition);
OUString temp = OUSTR( "ScriptRuntimeManager::invoke IllegalArgumentException: " );
throw lang::IllegalArgumentException( temp.concat( iae.Message ),
Reference< XInterface > (),
iae.ArgumentPosition );
}
catch (script::CannotConvertException & cce)
catch ( script::CannotConvertException & cce )
{
OUString temp = OUSTR("ScriptRuntimeManager::invoke CannotConvertException: ");
throw script::CannotConvertException(temp.concat(cce.Message),
Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex);
OUString temp = OUSTR( "ScriptRuntimeManager::invoke CannotConvertException: " );
throw script::CannotConvertException( temp.concat( cce.Message ),
Reference< XInterface > (),
cce.DestinationTypeClass, cce.Reason,
cce.ArgumentIndex );
}
catch (reflection::InvocationTargetException & ite)
catch ( reflection::InvocationTargetException & ite )
{
OUString temp = OUSTR("ScriptRuntimeManager::invoke InvocationTargetException: ");
throw reflection::InvocationTargetException(temp.concat(ite.Message),
Reference<XInterface> (), ite.TargetException);
OUString temp = OUSTR( "ScriptRuntimeManager::invoke InvocationTargetException: " );
throw reflection::InvocationTargetException( temp.concat( ite.Message ),
Reference< XInterface > (), ite.TargetException );
}
catch (RuntimeException & re)
catch ( RuntimeException & re )
{
OUString temp = OUSTR("ScriptRuntimeManager::invoke RuntimeException: ");
throw RuntimeException(temp.concat(re.Message),
Reference<XInterface> ());
OUString temp = OUSTR( "ScriptRuntimeManager::invoke RuntimeException: " );
throw RuntimeException( temp.concat( re.Message ),
Reference< XInterface > () );
}
#ifdef _DEBUG
catch ( ... )
{
throw RuntimeException(OUSTR("ScriptRuntimeManager::invoke UnknownException: "),
Reference<XInterface> ());
throw RuntimeException( OUSTR( "ScriptRuntimeManager::invoke UnknownException: " ),
Reference< XInterface > () );
}
#endif
return results;
@@ -220,42 +239,50 @@ Any SAL_CALL ScriptRuntimeManager::invoke(
//*************************************************************************
// XScriptNameResolver implementation
Reference<scripturi::XScriptURI> SAL_CALL ScriptRuntimeManager::resolve(const Reference<scripturi::XScriptURI>& scriptURI,Any& invocationCtx)
throw(lang::IllegalArgumentException, script::CannotConvertException, RuntimeException)
Reference< scripturi::XScriptURI > SAL_CALL
ScriptRuntimeManager::resolve( const Reference< scripturi::XScriptURI >& scriptURI,
Any& invocationCtx )
throw( lang::IllegalArgumentException, script::CannotConvertException, RuntimeException )
{
OSL_TRACE("** ==> ScriptRuntimeManager in resolve\n");
OSL_TRACE( "** ==> ScriptRuntimeManager in resolve\n" );
Reference< scripturi::XScriptURI > resolvedURI;
Reference< XScriptNameResolver > xScriptNameResolver = getScriptNameResolver();
validateXRef(xScriptNameResolver, "ScriptRuntimeManager::resolve: No ScriptNameResolver");
validateXRef( xScriptNameResolver,
"ScriptRuntimeManager::resolve: No ScriptNameResolver" );
try
{
resolvedURI = xScriptNameResolver->resolve(scriptURI,invocationCtx);
resolvedURI = xScriptNameResolver->resolve( scriptURI, invocationCtx );
}
catch (lang::IllegalArgumentException & iae)
catch ( lang::IllegalArgumentException & iae )
{
OUString temp = OUSTR("ScriptRuntimeManager::resolve IllegalArgumentException: ");
throw lang::IllegalArgumentException(temp.concat(iae.Message),
Reference<XInterface> (), iae.ArgumentPosition);
OUString temp =
OUSTR( "ScriptRuntimeManager::resolve IllegalArgumentException: " );
throw lang::IllegalArgumentException( temp.concat( iae.Message ),
Reference< XInterface > (),
iae.ArgumentPosition );
}
catch (script::CannotConvertException & cce)
catch ( script::CannotConvertException & cce )
{
OUString temp = OUSTR("ScriptRuntimeManager::resolve CannotConvertException: ");
throw script::CannotConvertException(temp.concat(cce.Message),
Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex);
OUString temp = OUSTR( "ScriptRuntimeManager::resolve CannotConvertException: " );
throw script::CannotConvertException( temp.concat( cce.Message ),
Reference< XInterface > (),
cce.DestinationTypeClass, cce.Reason,
cce.ArgumentIndex );
}
catch (RuntimeException & re)
catch ( RuntimeException & re )
{
OUString temp = OUSTR("ScriptRuntimeManager::resolve RuntimeException: ");
throw RuntimeException(temp.concat(re.Message),
Reference<XInterface> ());
OUString temp = OUSTR( "ScriptRuntimeManager::resolve RuntimeException: " );
throw RuntimeException( temp.concat( re.Message ),
Reference< XInterface > () );
}
#ifdef _DEBUG
catch ( ... )
{
throw RuntimeException(OUSTR("ScriptRuntimeManager::resolve UnknownException: "),
Reference<XInterface> ());
throw RuntimeException(
OUSTR( "ScriptRuntimeManager::resolve UnknownException: " ),
Reference< XInterface > () );
}
#endif
@@ -263,20 +290,20 @@ throw(lang::IllegalArgumentException, script::CannotConvertException, RuntimeExc
}
//*************************************************************************
OUString SAL_CALL ScriptRuntimeManager::getImplementationName( )
throw(RuntimeException)
OUString SAL_CALL ScriptRuntimeManager::getImplementationName( )
throw( RuntimeException )
{
return s_implName;
}
//*************************************************************************
sal_Bool SAL_CALL ScriptRuntimeManager::supportsService( const OUString& serviceName )
throw(RuntimeException)
throw( RuntimeException )
{
OUString const * pNames = s_serviceNames.getConstArray();
for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
{
if (serviceName.equals( pNames[ nPos ] ))
if ( serviceName.equals( pNames[ nPos ] ) )
{
return sal_True;
}
@@ -285,28 +312,28 @@ throw(RuntimeException)
}
//*************************************************************************
Sequence<OUString> SAL_CALL ScriptRuntimeManager::getSupportedServiceNames( )
throw(RuntimeException)
Sequence<OUString> SAL_CALL ScriptRuntimeManager::getSupportedServiceNames( )
throw( RuntimeException )
{
return s_serviceNames;
}
//*************************************************************************
static Reference<XInterface> SAL_CALL srm_create(
static Reference< XInterface > SAL_CALL srm_create(
const Reference< XComponentContext > & xCompC )
{
return (cppu::OWeakObject *)new ScriptRuntimeManager( xCompC );
return ( cppu::OWeakObject * ) new ScriptRuntimeManager( xCompC );
}
//*************************************************************************
static Sequence<OUString> srm_getSupportedServiceNames( )
static Sequence<OUString> srm_getSupportedServiceNames( )
SAL_THROW( () )
{
return s_serviceNames;
}
//*************************************************************************
static OUString srm_getImplementationName( )
static OUString srm_getImplementationName( )
SAL_THROW( () )
{
return s_implName;
@@ -315,7 +342,7 @@ SAL_THROW( () )
//*************************************************************************
Reference< XInterface > SAL_CALL scriptnri_create(
Reference< XComponentContext > const & xComponentContext )
SAL_THROW( (Exception) );
SAL_THROW( ( Exception ) );
//*************************************************************************
Sequence< OUString > scriptnri_getSupportedServiceNames() SAL_THROW( () );
@@ -340,16 +367,17 @@ static struct cppu::ImplementationEntry s_entries [] =
};
} // Namespace
//##################################################################################################
//#### EXPORTED ####################################################################################
//##################################################################################################
//#######################################################################################
//#### EXPORTED #########################################################################
//#######################################################################################
/**
* Gives the environment this component belongs to.
*/
extern "C"
{
void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName,
uno_Environment ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
@@ -361,9 +389,11 @@ extern "C"
* @param pServiceManager the service manager
* @param pRegistryKey the registry key
*/
sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory * pServiceManager,
registry::XRegistryKey * pRegistryKey )
{
return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_runtimemgr::s_entries);
return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey,
::scripting_runtimemgr::s_entries );
}
/**
@@ -371,11 +401,15 @@ extern "C"
*
* @param pImplName name of implementation
* @param pServiceManager a service manager, need for component creation
* @param pRegistryKey the registry key for this component, need for persistent data
* @param pRegistryKey the registry key for this component, need for persistent
* data
* @return a component factory
*/
void * SAL_CALL component_getFactory(const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
void * SAL_CALL component_getFactory( const sal_Char * pImplName,
lang::XMultiServiceFactory * pServiceManager,
registry::XRegistryKey * pRegistryKey )
{
return ::cppu::component_getFactoryHelper(pImplName, pServiceManager, pRegistryKey, ::scripting_runtimemgr::s_entries);
return ::cppu::component_getFactoryHelper( pImplName, pServiceManager,
pRegistryKey, ::scripting_runtimemgr::s_entries );
}
}