[Libreoffice-commits] core.git: configure.ac scripting/java

Noel Grandin noel at peralex.com
Tue Jan 13 00:39:32 PST 2015


 configure.ac                                                                   |    4 --
 scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java      |   20 +++++++++-
 scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java |    3 +
 scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java    |   11 +++++
 scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java      |   16 ++++++--
 scripting/java/com/sun/star/script/framework/provider/ScriptContext.java       |    5 ++
 6 files changed, 49 insertions(+), 10 deletions(-)

New commits:
commit 3ab2d3a2c5b802ab88171770d19871e081c3252b
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Jan 13 08:34:10 2015 +0200

    fdo#88256 fix crash when running javascript macro
    
    caused by my commit 8583da1e934a49791ef8d86668f3d5c3c5dae1d7
    "java: remove unused fields"
    
    Change-Id: Ibcd6462e8229a0a6cb98ebfd16ce5d2ea45ca931

diff --git a/configure.ac b/configure.ac
index d4029a5..18a1e6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4527,10 +4527,6 @@ dnl Check for syslog header
 dnl ===================================================================
 AC_CHECK_HEADER(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
 
-# placeholder for future crash reporter feature
-ENABLE_CRASHDUMP=""
-AC_SUBST(ENABLE_CRASHDUMP)
-
 dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
 dnl ===================================================================
 AC_MSG_CHECKING([whether to turn warnings to errors])
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 c4ae664..71535e1 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 bc52cb5..6cdfd2a 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 2e9ee68..868af08 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 903a45f..8433203 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 ab01797..94181e7 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) {
 


More information about the Libreoffice-commits mailing list