summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-08 09:32:36 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-12-04 13:42:21 +0100
commit6fddb0251b76109b67818270ab6e58d3a0392d72 (patch)
tree0d1cc2374857a6c1c60bb1bba1f5d987ce62af98
parent5f17232d9403a1d740ac49edc9dedf90dfa61b85 (diff)
Respect DisableMacrosExecution option in beanshell editor
Change-Id: I0713b3d1ab45519aef25b5bd3d912baf2252d37b Reviewed-on: https://gerrit.libreoffice.org/82262 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
index 279e75fb3584..c56994cc46b0 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -17,11 +17,17 @@
*/
package com.sun.star.script.framework.provider.beanshell;
+import com.sun.star.beans.NamedValue;
+import com.sun.star.configuration.theDefaultProvider;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.script.framework.container.ScriptMetaData;
import com.sun.star.script.framework.provider.ClassLoaderFactory;
import com.sun.star.script.framework.provider.ScriptEditor;
import com.sun.star.script.framework.provider.SwingInvocation;
import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
@@ -172,10 +178,33 @@ public class ScriptEditorForBeanShell implements ScriptEditor, ActionListener {
*
*/
public Object execute() throws Exception {
+ if (!isMacroExectionEnabled()) {
+ showErrorMessage("Macro Execution has been disabled.");
+ return null;
+ }
+
frame.toFront();
return model.execute(context, cl);
}
+ private boolean isMacroExectionEnabled() {
+ XNameAccess xNameAccess = null;
+ try {
+ String sAccess = "com.sun.star.configuration.ConfigurationAccess";
+ XMultiServiceFactory xMSFCfg = theDefaultProvider.get(context.getComponentContext());
+ Object oAccess = xMSFCfg.createInstanceWithArguments(sAccess,
+ new Object[] { new NamedValue("nodepath", "org.openoffice.Office.Common/Security/Scripting") });
+ xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oAccess);
+ Object result = xNameAccess.getByName("DisableMacrosExecution");
+ boolean bMacrosDisabled = AnyConverter.toBoolean(result);
+ if (bMacrosDisabled)
+ return false;
+ } catch (com.sun.star.uno.Exception e) {
+ return false;
+ }
+ return true;
+ }
+
/**
* Opens an editor window for the specified ScriptMetaData.
* If an editor window is already open for that data it will be