INTEGRATION: CWS odbmacros2 (1.9.90); FILE MERGED
2008/01/02 14:42:12 fs 1.9.90.1: #i49133# allow script providers to be created with an XScriptInvocationContext instead of a mere TDOC URL
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptContext.java,v $
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Revision: 1.10 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2005-09-09 02:01:04 $
|
||||
* last change: $Author: kz $ $Date: 2008-03-06 16:09:59 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
@@ -34,25 +34,16 @@
|
||||
************************************************************************/
|
||||
package com.sun.star.script.framework.provider;
|
||||
|
||||
import com.sun.star.document.XScriptInvocationContext;
|
||||
import com.sun.star.frame.XModel;
|
||||
import com.sun.star.frame.XDesktop;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.beans.UnknownPropertyException;
|
||||
import com.sun.star.beans.PropertyVetoException;
|
||||
import com.sun.star.beans.XPropertyChangeListener;
|
||||
import com.sun.star.beans.XVetoableChangeListener;
|
||||
import com.sun.star.lang.WrappedTargetException;
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.AnyConverter;
|
||||
import com.sun.star.beans.PropertyAttribute;
|
||||
import com.sun.star.lib.uno.helper.PropertySet;
|
||||
import com.sun.star.uno.Type;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.sun.star.script.provider.XScriptContext;
|
||||
|
||||
import com.sun.star.script.framework.log.LogUtils;
|
||||
@@ -82,17 +73,19 @@ public class ScriptContext extends PropertySet implements XScriptContext
|
||||
|
||||
|
||||
public XModel m_xModel = null;
|
||||
public XScriptInvocationContext m_xInvocationContext = null;
|
||||
public String m_sDocURI = null;
|
||||
public XDesktop m_xDeskTop = null;
|
||||
public Integer m_iStorageID = null;
|
||||
public XComponentContext m_xComponentContext = null;
|
||||
|
||||
public ScriptContext( XComponentContext xmComponentContext,
|
||||
XDesktop xDesktop, XModel xModel)
|
||||
XDesktop xDesktop, XModel xModel, XScriptInvocationContext xInvocContext)
|
||||
{
|
||||
this.m_xDeskTop = xDesktop;
|
||||
this.m_xComponentContext = xmComponentContext;
|
||||
this.m_xModel = xModel;
|
||||
this.m_xInvocationContext = xInvocContext;
|
||||
|
||||
if ( m_xModel != null )
|
||||
{
|
||||
@@ -108,7 +101,7 @@ public class ScriptContext extends PropertySet implements XScriptContext
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xComponentContext");
|
||||
}
|
||||
|
||||
public static XScriptContext createContext( XModel xModel,
|
||||
public static XScriptContext createContext( XModel xModel, XScriptInvocationContext xInvocContext,
|
||||
XComponentContext xCtxt, XMultiComponentFactory xMCF)
|
||||
{
|
||||
XScriptContext sc = null;
|
||||
@@ -124,7 +117,7 @@ public class ScriptContext extends PropertySet implements XScriptContext
|
||||
UnoRuntime.queryInterface(XDesktop.class, xInterface);
|
||||
if ( xModel != null )
|
||||
{
|
||||
sc = new ScriptContext(xCtxt, xDesktop, xModel);
|
||||
sc = new ScriptContext(xCtxt, xDesktop, xModel, xInvocContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -150,6 +143,11 @@ public class ScriptContext extends PropertySet implements XScriptContext
|
||||
return m_xModel;
|
||||
}
|
||||
|
||||
public XScriptInvocationContext getInvocationContext()
|
||||
{
|
||||
return m_xInvocationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
Obtain the desktop reference on which the script can operate
|
||||
|
||||
|
@@ -4,9 +4,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptProviderForBeanShell.java,v $
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Revision: 1.10 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2005-09-09 02:02:35 $
|
||||
* last change: $Author: kz $ $Date: 2008-03-06 16:12:09 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
@@ -34,44 +34,26 @@
|
||||
************************************************************************/
|
||||
package com.sun.star.script.framework.provider.beanshell;
|
||||
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.lang.XMultiServiceFactory;
|
||||
import com.sun.star.lang.XSingleServiceFactory;
|
||||
import com.sun.star.registry.XRegistryKey;
|
||||
import com.sun.star.comp.loader.FactoryHelper;
|
||||
import com.sun.star.lang.XTypeProvider;
|
||||
import com.sun.star.lang.XServiceInfo;
|
||||
import com.sun.star.lang.XInitialization;
|
||||
import com.sun.star.frame.XModel;
|
||||
import com.sun.star.uno.AnyConverter;
|
||||
import com.sun.star.uno.Type;
|
||||
import com.sun.star.uno.Any;
|
||||
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.lang.WrappedTargetException;
|
||||
import com.sun.star.reflection.InvocationTargetException;
|
||||
|
||||
import com.sun.star.script.CannotConvertException;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
import bsh.BshClassManager;
|
||||
import bsh.Interpreter;
|
||||
|
||||
import com.sun.star.script.provider.XScriptContext;
|
||||
import com.sun.star.script.provider.XScriptProvider;
|
||||
import com.sun.star.document.XScriptInvocationContext;
|
||||
import com.sun.star.script.provider.XScript;
|
||||
import com.sun.star.script.provider.ScriptErrorRaisedException;
|
||||
import com.sun.star.script.provider.ScriptExceptionRaisedException;
|
||||
@@ -87,8 +69,6 @@ public class ScriptProviderForBeanShell
|
||||
{
|
||||
public static class _ScriptProviderForBeanShell extends ScriptProvider
|
||||
{
|
||||
private static ScriptEditorForBeanShell myScriptEditorForBeanShell;
|
||||
|
||||
public _ScriptProviderForBeanShell(XComponentContext ctx)
|
||||
{
|
||||
super (ctx, "BeanShell");
|
||||
@@ -102,7 +82,7 @@ public class ScriptProviderForBeanShell
|
||||
try
|
||||
{
|
||||
scriptData = getScriptData( scriptURI );
|
||||
ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel );
|
||||
ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel, m_xInvocContext );
|
||||
return script;
|
||||
}
|
||||
catch ( com.sun.star.uno.RuntimeException re )
|
||||
@@ -195,12 +175,15 @@ class ScriptImpl implements XScript
|
||||
private XComponentContext m_xContext;
|
||||
private XMultiComponentFactory m_xMultiComponentFactory;
|
||||
private XModel m_xModel;
|
||||
private XScriptInvocationContext m_xInvocContext;
|
||||
|
||||
ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel ) throws com.sun.star.uno.RuntimeException
|
||||
ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel,
|
||||
XScriptInvocationContext xContext ) throws com.sun.star.uno.RuntimeException
|
||||
{
|
||||
this.metaData = metaData;
|
||||
this.m_xContext = ctx;
|
||||
this.m_xModel = xModel;
|
||||
this.m_xInvocContext = xContext;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -289,7 +272,7 @@ class ScriptImpl implements XScript
|
||||
interpreter.setClassLoader(cl);
|
||||
try {
|
||||
interpreter.set("XSCRIPTCONTEXT",
|
||||
ScriptContext.createContext(m_xModel,
|
||||
ScriptContext.createContext(m_xModel, m_xInvocContext,
|
||||
m_xContext, m_xMultiComponentFactory));
|
||||
|
||||
interpreter.set("ARGUMENTS", aParams);
|
||||
@@ -370,7 +353,7 @@ class ScriptImpl implements XScript
|
||||
{
|
||||
editor = ScriptEditorForBeanShell.getEditor();
|
||||
editor.edit(
|
||||
ScriptContext.createContext(m_xModel,
|
||||
ScriptContext.createContext(m_xModel, m_xInvocContext,
|
||||
m_xContext, m_xMultiComponentFactory), metaData );
|
||||
editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
|
||||
}
|
||||
|
Reference in New Issue
Block a user