INTEGRATION: CWS scriptingf5 (1.3.8); FILE MERGED
2004/04/02 10:25:35 dfoster 1.3.8.5: #i27294# Fixed problem with security check. Removed printStackTrace calls in java code. Fixed problems with create/delete of parcels/scripts in document storage 2004/02/25 18:20:32 npower 1.3.8.4: #i25272# Added a container implementation ( new com/sun/star/script/framework/container defined ) to better seperate Browse functionality from io and script registry. 2004/02/19 17:53:11 toconnor 1.3.8.3: #i25276# - BeanShell and JavaScript providers should pass parameters 2004/02/17 15:06:06 toconnor 1.3.8.2: #i25262# - Execute modified source in editor window if one exists 2004/02/12 08:38:59 npower 1.3.8.1: #i23681# , #ii23682# Initial modification for support of create/delete of scripts support for script organiser
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: ScriptProviderForBeanShell.java,v $
|
* $RCSfile: ScriptProviderForBeanShell.java,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.3 $
|
* $Revision: 1.4 $
|
||||||
*
|
*
|
||||||
* last change: $Author: rt $ $Date: 2004-01-05 13:27:41 $
|
* last change: $Author: svesik $ $Date: 2004-04-19 23:11:14 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -100,12 +100,14 @@ import drafts.com.sun.star.script.provider.XScript;
|
|||||||
|
|
||||||
import com.sun.star.script.framework.provider.*;
|
import com.sun.star.script.framework.provider.*;
|
||||||
import com.sun.star.script.framework.log.*;
|
import com.sun.star.script.framework.log.*;
|
||||||
import com.sun.star.script.framework.browse.ScriptMetaData;
|
import com.sun.star.script.framework.container.ScriptMetaData;
|
||||||
|
|
||||||
public class ScriptProviderForBeanShell
|
public class ScriptProviderForBeanShell
|
||||||
{
|
{
|
||||||
public static class _ScriptProviderForBeanShell extends ScriptProvider
|
public static class _ScriptProviderForBeanShell extends ScriptProvider
|
||||||
{
|
{
|
||||||
|
private static ScriptEditorForBeanShell myScriptEditorForBeanShell;
|
||||||
|
|
||||||
public _ScriptProviderForBeanShell(XComponentContext ctx)
|
public _ScriptProviderForBeanShell(XComponentContext ctx)
|
||||||
{
|
{
|
||||||
super (ctx, "BeanShell");
|
super (ctx, "BeanShell");
|
||||||
@@ -127,7 +129,18 @@ public class ScriptProviderForBeanShell
|
|||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasScriptEditor()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptEditor getScriptEditor()
|
||||||
|
{
|
||||||
|
return ScriptEditorForBeanShell.getEditor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a factory for creating the service.
|
* Returns a factory for creating the service.
|
||||||
* This method is called by the <code>JavaLoader</code>
|
* This method is called by the <code>JavaLoader</code>
|
||||||
@@ -214,7 +227,7 @@ class ScriptImpl implements XScript
|
|||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
LogUtils.DEBUG( LogUtils.getTrace( e ) );
|
||||||
throw new com.sun.star.uno.RuntimeException(
|
throw new com.sun.star.uno.RuntimeException(
|
||||||
"Error constructing ScriptImpl [beanshell]: "
|
"Error constructing ScriptImpl [beanshell]: "
|
||||||
+ e.getMessage() );
|
+ e.getMessage() );
|
||||||
@@ -259,12 +272,6 @@ class ScriptImpl implements XScript
|
|||||||
aOutParamIndex[0] = new short[0];
|
aOutParamIndex[0] = new short[0];
|
||||||
aOutParam[0] = new Object[0];
|
aOutParam[0] = new Object[0];
|
||||||
|
|
||||||
String parcelURI = metaData.getParcelLocation();
|
|
||||||
|
|
||||||
if ( !parcelURI.endsWith( "/" ) )
|
|
||||||
{
|
|
||||||
parcelURI += "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassLoader cl = null;
|
ClassLoader cl = null;
|
||||||
try {
|
try {
|
||||||
@@ -283,29 +290,36 @@ class ScriptImpl implements XScript
|
|||||||
interpreter.set("context",
|
interpreter.set("context",
|
||||||
ScriptContext.createContext(m_oInvokeContext,
|
ScriptContext.createContext(m_oInvokeContext,
|
||||||
m_xContext, m_xMultiComponentFactory));
|
m_xContext, m_xMultiComponentFactory));
|
||||||
|
|
||||||
|
interpreter.set("ARGUMENTS", aParams);
|
||||||
}
|
}
|
||||||
catch (bsh.EvalError e) {
|
catch (bsh.EvalError e) {
|
||||||
throw new InvocationTargetException(e.getMessage());
|
throw new InvocationTargetException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream is = null;;
|
|
||||||
try {
|
try {
|
||||||
String script = parcelURI + metaData.getLanguageName();
|
String source = null;
|
||||||
Object result = null;
|
Object result = null;
|
||||||
|
|
||||||
|
ScriptEditorForBeanShell editor =
|
||||||
|
ScriptEditorForBeanShell.getEditor(
|
||||||
|
metaData.getSourceURL() );
|
||||||
|
|
||||||
try {
|
if (editor != null && editor.isModified())
|
||||||
is = PathUtils.getScriptFileStream( script );
|
{
|
||||||
|
source = editor.getText();
|
||||||
}
|
}
|
||||||
catch (IOException ioe) {
|
else
|
||||||
throw new InvocationTargetException(ioe.getMessage());
|
{
|
||||||
|
source = metaData.getSource();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is == null)
|
if ( source == null || source.length() == 0 )
|
||||||
throw new InvocationTargetException(
|
throw new InvocationTargetException(
|
||||||
"Couldn't read script: " + script);
|
"Couldn't read script: " + metaData.getSourceURL() );
|
||||||
|
|
||||||
result = interpreter.eval(new InputStreamReader(is));
|
result = interpreter.eval( source );
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return new Any(new Type(), null);
|
return new Any(new Type(), null);
|
||||||
@@ -314,19 +328,6 @@ class ScriptImpl implements XScript
|
|||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new InvocationTargetException(ex.getMessage());
|
throw new InvocationTargetException(ex.getMessage());
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( is != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user