summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-01-13 08:34:10 +0200
committerNoel Grandin <noel@peralex.com>2015-01-13 10:38:48 +0200
commit3ab2d3a2c5b802ab88171770d19871e081c3252b (patch)
tree64e474fc827e202ce964b3c497727652f61bc23c /scripting
parentb6013382694b7c9784c404a101d6d505919e067d (diff)
fdo#88256 fix crash when running javascript macro
caused by my commit 8583da1e934a49791ef8d86668f3d5c3c5dae1d7 "java: remove unused fields" Change-Id: Ibcd6462e8229a0a6cb98ebfd16ce5d2ea45ca931
Diffstat (limited to 'scripting')
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java20
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java3
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java11
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java16
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptContext.java5
5 files changed, 49 insertions, 6 deletions
diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
index c4ae6648d756..71535e1127ec 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
@@ -55,6 +55,11 @@ public class ParcelBrowseNode extends PropertySet implements
private Collection<XBrowseNode> browsenodes;
private final ParcelContainer container;
private Parcel parcel;
+ // these four are properties, they are accessed via reflection
+ public boolean deletable = true;
+ public boolean editable = false;
+ public boolean creatable = false;
+ public boolean renamable = true;
public ParcelBrowseNode(ScriptProvider provider, ParcelContainer container,
String parcelName) {
@@ -75,15 +80,28 @@ public class ParcelBrowseNode extends PropertySet implements
registerProperty("Editable", new Type(boolean.class), (short)0, "editable");
registerProperty("Creatable", new Type(boolean.class), (short)0, "creatable");
registerProperty("Renamable", new Type(boolean.class), (short)0, "renamable");
+ if (provider.hasScriptEditor())
+ {
+ this.creatable = true;
+ }
+ String parcelDirUrl = parcel.getPathToParcel();
XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
XMultiComponentFactory xFac = xCtx.getServiceManager();
try {
- UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class,
xFac.createInstanceWithContext(
"com.sun.star.ucb.SimpleFileAccess",
xCtx));
+ if ( xSFA != null && ( xSFA.isReadOnly( parcelDirUrl ) ||
+ container.isUnoPkg() ) )
+ {
+ deletable = false;
+ editable = false;
+ creatable = false;
+ renamable = false;
+ }
} catch (com.sun.star.uno.Exception e) {
// TODO propagate potential errors
LogUtils.DEBUG("Caught exception creating ParcelBrowseNode " + e);
diff --git a/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
index bc52cb534357..6cdfd2a774d3 100644
--- a/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
@@ -37,6 +37,9 @@ public class PkgProviderBrowseNode extends ProviderBrowseNode {
container.getParcelContainerDir());
LogUtils.DEBUG("*** PkgProviderBrowseNode ctor, container has num parcels = " +
container.getElementNames().length);
+ deletable = false;
+ editable = false;
+ creatable = false;
}
@Override public String getName() {
diff --git a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
index 2e9ee6828184..868af0874618 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
@@ -52,6 +52,10 @@ public class ProviderBrowseNode extends PropertySet implements
private final String name;
protected ParcelContainer container;
private final XComponentContext m_xCtx;
+ // these are properties, they are accessed by reflection
+ public boolean deletable = true;
+ public boolean creatable = true;
+ public boolean editable = false;
public ProviderBrowseNode(ScriptProvider provider, ParcelContainer container,
XComponentContext xCtx) {
@@ -68,10 +72,15 @@ public class ProviderBrowseNode extends PropertySet implements
XMultiComponentFactory xFac = m_xCtx.getServiceManager();
try {
- UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class,
xFac.createInstanceWithContext(
"com.sun.star.ucb.SimpleFileAccess",
xCtx));
+ if ( container.isUnoPkg() || xSFA.isReadOnly( container.getParcelContainerDir() ) )
+ {
+ deletable = false;
+ creatable = false;
+ }
}
// TODO propage errors
catch (com.sun.star.uno.Exception e) {
diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
index 903a45f1793e..843320318c56 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -58,25 +58,32 @@ public class ScriptBrowseNode extends PropertySet implements
private Parcel parent;
private String name;
- private boolean editable;
- private boolean deletable = false;
- private boolean renamable = false;
+ // these are properties, accessed by reflection
+ public String uri;
+ public String description;
+ public boolean editable;
+ public boolean deletable = false;
+ public boolean renamable = false;
public ScriptBrowseNode(ScriptProvider provider, Parcel parent, String name) {
this.provider = provider;
this.name = name;
this.parent = parent;
+ ScriptMetaData data = null;
XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
XMultiComponentFactory xFac = xCtx.getServiceManager();
try {
+ data = (ScriptMetaData)parent.getByName( name );
XSimpleFileAccess xSFA = UnoRuntime.queryInterface(
XSimpleFileAccess.class,
xFac.createInstanceWithContext(
"com.sun.star.ucb.SimpleFileAccess",
xCtx));
+ uri = data.getShortFormScriptURL();
+ description = data.getDescription();
if (provider.hasScriptEditor()) {
this.editable = true;
@@ -147,7 +154,9 @@ public class ScriptBrowseNode extends PropertySet implements
LogUtils.DEBUG("** caught exception getting script data for " + name +
" ->" + e.toString());
}
+ uri = data.getShortFormScriptURL();
}
+
// implementation of XInvocation interface
public XIntrospectionAccess getIntrospection() {
return null;
@@ -250,6 +259,7 @@ public class ScriptBrowseNode extends PropertySet implements
LogUtils.DEBUG("Now remove old script");
parent.removeByName(name);
+ uri = data.getShortFormScriptURL();
name = languageName;
result = new Any(new Type(XBrowseNode.class), this);
} catch (NoSuchElementException nse) {
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 ab01797b9ccd..94181e7b13d6 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
@@ -44,13 +44,16 @@ public class ScriptContext extends PropertySet implements XScriptContext {
private final static String DOC_URI = "SCRIPTING_DOC_URI";
- private final XModel m_xModel;
+ public final XModel m_xModel;
private final XScriptInvocationContext m_xInvocationContext;
private final XDesktop m_xDeskTop;
private final XComponentContext m_xComponentContext;
+ // property, accessed via reflection
+ public String m_sDocURI = null;
+
private ScriptContext(XComponentContext xmComponentContext, XDesktop xDesktop,
XModel xModel, XScriptInvocationContext xInvocContext) {