diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2004-05-19 07:23:17 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2004-05-19 07:23:17 +0000 |
commit | 3832dce636eec83f65484bb1cd12708b762fbde8 (patch) | |
tree | 53784fc6fd6f7dc37a848546e16c0885675a4ad0 /scripting/java/com/sun/star/script/framework/provider/ScriptContext.java | |
parent | 7959acfbf95a9ecdc3c366be055b980eabddc654 (diff) |
INTEGRATION: CWS scriptingf4 (1.5.4); FILE MERGED
2004/05/07 17:18:26 npower 1.5.4.1: #i28818#
Changes to support Scripting context created from the ScriptProvider, not created in BrowseNodes any more. Behavior of the ScriptContext class has been changed so that for and application script ( e.g. user or share ) the getDocument() method will rerturn the currently selected document. If it is a document script then the getDocument() method will return the document for the location of the script.
Diffstat (limited to 'scripting/java/com/sun/star/script/framework/provider/ScriptContext.java')
-rw-r--r-- | scripting/java/com/sun/star/script/framework/provider/ScriptContext.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java index ed2fd57182..7b849ce95d 100644 --- a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java +++ b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java @@ -2,9 +2,9 @@ * * $RCSfile: ScriptContext.java,v $ * -* $Revision: 1.5 $ +* $Revision: 1.6 $ * -* last change: $Author: svesik $ $Date: 2004-04-19 23:09:11 $ +* last change: $Author: rt $ $Date: 2004-05-19 08:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -155,14 +155,21 @@ public class ScriptContext extends PropertySet implements XScriptContext (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xComponentContext"); } - public static ScriptContext createContext(Object invocationCtx, + public static XScriptContext createContext(Object invocationCtx, XComponentContext xCtxt, XMultiComponentFactory xMCF) { - ScriptContext sc = null; + XScriptContext sc = null; + XModel xModel = null; try { - XPropertySet invocationCtxPropSet = (XPropertySet) - UnoRuntime.queryInterface( XPropertySet.class, invocationCtx); + XPropertySet invocationCtxPropSet = null; + if ( invocationCtx != null ) + { + invocationCtxPropSet = (XPropertySet) + UnoRuntime.queryInterface( XPropertySet.class, invocationCtx); + xModel = ( XModel ) UnoRuntime.queryInterface( + XModel.class, invocationCtxPropSet.getPropertyValue( DOC_REF ) ); + } Object xInterface = null; XDesktop xDesktop = null; @@ -172,10 +179,17 @@ public class ScriptContext extends PropertySet implements XScriptContext xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); - sc = new ScriptContext(xCtxt, xDesktop, invocationCtxPropSet); + if ( xModel != null ) + { + sc = new ScriptContext(xCtxt, xDesktop, invocationCtxPropSet); + } + else + { + sc = new EditorScriptContext( xCtxt, xDesktop ); + } } catch ( Exception e ) { - LogUtils.DEBUG( LogUtils.getTrace( e ) ); + e.printStackTrace(); } return sc; } |