scripting/Jar_ScriptFramework.mk
| 1
scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
| 4
scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
| 61 ------
scripting/java/com/sun/star/script/framework/provider/ScriptEditorBase.java
| 73 ++++++++
scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
| 6
scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
| 91 ++++------
scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
| 6
7 files changed, 129 insertions(+), 113 deletions(-)
New commits:
commit 92617320938b6710dc9cb8eac48ab85c2ceaa867
Author: Samuel Mehrbrodt <[email protected]>
AuthorDate: Tue May 31 09:10:57 2022 +0200
Commit: Samuel Mehrbrodt <[email protected]>
CommitDate: Tue May 31 09:10:57 2022 +0200
Revert "Related tdf#116767: Call URLClassLoader.close"
This reverts commit 418533f0af7cd303d559c8fb136c49e7e9fb0d79.
diff --git
a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
index 0974b8874110..b5e6e3085bd2 100644
---
a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
+++
b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
@@ -33,7 +33,7 @@ public class ClassLoaderFactory {
private ClassLoaderFactory() {}
- public static URLClassLoader getURLClassLoader(ScriptMetaData scriptData) {
+ public static ClassLoader getURLClassLoader(ScriptMetaData scriptData) {
ClassLoader parent = scriptData.getClass().getClassLoader();
URL[] classPath = scriptData.getClassPath();
LogUtils.DEBUG("Classpath has length " + classPath.length);
@@ -45,7 +45,7 @@ public class ClassLoaderFactory {
return getURLClassLoader(parent, classPath);
}
- public static URLClassLoader getURLClassLoader(final ClassLoader parent,
+ public static ClassLoader getURLClassLoader(final ClassLoader parent,
final URL[] classpath) {
return AccessController.doPrivileged(
new PrivilegedAction<URLClassLoader>() {
diff --git
a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
index 63dc3169f759..eeea0d49ebe5 100644
---
a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
+++
b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
@@ -45,8 +45,6 @@ import com.sun.star.uno.Any;
import com.sun.star.uno.Type;
import com.sun.star.uno.XComponentContext;
-import java.io.IOException;
-import java.net.URLClassLoader;
import java.util.ArrayList;
public class ScriptProviderForJava {
@@ -184,63 +182,56 @@ class ScriptImpl implements XScript {
ScriptDescriptor scriptDesc =
new ScriptDescriptor(metaData.getLanguageName());
+ LogUtils.DEBUG("Classloader starting...");
+
+ ClassLoader scriptLoader =
+ ClassLoaderFactory.getURLClassLoader(metaData);
+
+ LogUtils.DEBUG("Classloader finished...");
+
+ ArrayList<Object> invocationArgList = new ArrayList<Object>();
Object[] invocationArgs = null;
- ScriptProxy script = null;
- LogUtils.DEBUG("Classloader starting...");
+ LogUtils.DEBUG("Parameter Mapping...");
- try (URLClassLoader scriptLoader =
ClassLoaderFactory.getURLClassLoader(metaData)) {
- LogUtils.DEBUG("Classloader finished...");
+ // Setup Context Object
+ XScriptContext xSc =
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory);
- ArrayList<Object> invocationArgList = new ArrayList<Object>();
+ scriptDesc.addArgumentType(XScriptContext.class);
+ invocationArgList.add(xSc);
- LogUtils.DEBUG("Parameter Mapping...");
+ for (int i = 0; i < params.length; i++) {
+ scriptDesc.addArgumentType(params[ i ].getClass());
+ invocationArgList.add(params[ i ]);
+ }
- // Setup Context Object
- XScriptContext xSc =
- ScriptContext.createContext(m_xModel, m_xInvocContext,
- m_xContext,
m_xMultiComponentFactory);
+ if (!invocationArgList.isEmpty()) {
+ invocationArgs = invocationArgList.toArray();
+ }
- scriptDesc.addArgumentType(XScriptContext.class);
- invocationArgList.add(xSc);
+ LogUtils.DEBUG("ScriptProxy starting... ");
+ ScriptProxy script = null;
- for (int i = 0; i < params.length; i++) {
- scriptDesc.addArgumentType(params[ i ].getClass());
- invocationArgList.add(params[ i ]);
- }
+ try {
- if (!invocationArgList.isEmpty()) {
- invocationArgs = invocationArgList.toArray();
- }
+ String className = metaData.getLanguageName().substring(0,
+ metaData.getLanguageName().lastIndexOf('.'));
- LogUtils.DEBUG("ScriptProxy starting... ");
+ LogUtils.DEBUG("About to load Class " + className + " starting...
");
- try {
+ long start = new java.util.Date().getTime();
+ Class<?> c = scriptLoader.loadClass(className);
+ long end = new java.util.Date().getTime();
- String className = metaData.getLanguageName().substring(0,
-
metaData.getLanguageName().lastIndexOf('.'));
-
- LogUtils.DEBUG("About to load Class " + className + "
starting... ");
-
- long start = new java.util.Date().getTime();
- Class<?> c = scriptLoader.loadClass(className);
- long end = new java.util.Date().getTime();
-
- LogUtils.DEBUG("loadClass took: " + (end - start) +
"milliseconds");
-
- try {
- LogUtils.DEBUG("class loaded ... ");
- script = m_resolutionPolicy.getProxy(scriptDesc, c);
- LogUtils.DEBUG("script resolved ... ");
- } catch (NoSuchMethodException e) {
- // Framework error
- ScriptFrameworkErrorException e2 = new
ScriptFrameworkErrorException(
- e.toString(), null, metaData.getLanguageName(),
- metaData.getLanguage(),
ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
- e2.initCause(e);
- throw e2;
- }
- } catch (ClassNotFoundException e) {
+ LogUtils.DEBUG("loadClass took: " + (end - start) +
"milliseconds");
+
+ try {
+ LogUtils.DEBUG("class loaded ... ");
+ script = m_resolutionPolicy.getProxy(scriptDesc, c);
+ LogUtils.DEBUG("script resolved ... ");
+ } catch (NoSuchMethodException e) {
// Framework error
ScriptFrameworkErrorException e2 = new
ScriptFrameworkErrorException(
e.toString(), null, metaData.getLanguageName(),
@@ -248,11 +239,11 @@ class ScriptImpl implements XScript {
e2.initCause(e);
throw e2;
}
- } catch (IOException e) {
+ } catch (ClassNotFoundException e) {
// Framework error
ScriptFrameworkErrorException e2 = new
ScriptFrameworkErrorException(
- e.toString(), null, metaData.getLanguageName(),
metaData.getLanguage(),
- ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ e.toString(), null, metaData.getLanguageName(),
+ metaData.getLanguage(),
ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
e2.initCause(e);
throw e2;
}
commit fedf2e4c4b2800698a23e88ef65a8a2c6ba68684
Author: Stephan Bergmann <[email protected]>
AuthorDate: Mon Oct 18 14:37:05 2021 +0200
Commit: Samuel Mehrbrodt <[email protected]>
CommitDate: Mon May 30 11:51:06 2022 +0200
Revert incompatible ScriptEditor change
...from interface to abstract class, in
1c42afc194da2288c5a738b727952e80c323885c
"Respect DisableMacrosExecution option in javascript editor". It caused
3rd-
party code like ScriptProviderForooRexx.oxt to fail to install.
Change-Id: I532f27fdce806e471a8551646adbb3aecf80bcee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123745
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <[email protected]>
(cherry picked from commit d425cd604cb4d30862640851b11a31e742d81336)
diff --git a/scripting/Jar_ScriptFramework.mk b/scripting/Jar_ScriptFramework.mk
index 9bf31b62cb64..0a2aa86f8cac 100644
--- a/scripting/Jar_ScriptFramework.mk
+++ b/scripting/Jar_ScriptFramework.mk
@@ -49,6 +49,7 @@ $(eval $(call gb_Jar_add_sourcefiles,ScriptFramework,\
scripting/java/com/sun/star/script/framework/provider/PathUtils \
scripting/java/com/sun/star/script/framework/provider/ScriptContext \
scripting/java/com/sun/star/script/framework/provider/ScriptEditor \
+ scripting/java/com/sun/star/script/framework/provider/ScriptEditorBase \
scripting/java/com/sun/star/script/framework/provider/ScriptProvider \
scripting/java/com/sun/star/script/framework/provider/SwingInvocation \
scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog \
diff --git
a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
index 395a1b6a8abb..32ebd2fefb41 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
@@ -18,62 +18,13 @@
package com.sun.star.script.framework.provider;
-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.provider.XScriptContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.UnoRuntime;
-import javax.swing.JOptionPane;
-import javax.swing.JDialog;
-
-public abstract class ScriptEditor {
- public XScriptContext context;
-
- public abstract Object execute() throws Exception;
- public abstract void indicateErrorLine(int lineNum);
- public abstract void edit(XScriptContext context, ScriptMetaData entry);
- public abstract String getTemplate();
- public abstract String getExtension();
-
- public void setContext(XScriptContext context) {
- this.context = context;
- }
-
- public boolean isMacroExecutionEnabled() {
- 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;
- }
-
- // Wraps long error messages
- private static class NarrowOptionPane extends JOptionPane {
- private static final long serialVersionUID = 1L;
- public int getMaxCharactersPerLineCount() {
- return 100;
- }
- }
-
- public void showErrorMessage(String message) {
- JOptionPane optionPane = new NarrowOptionPane();
- optionPane.setMessage(message);
- optionPane.setMessageType(JOptionPane.ERROR_MESSAGE);
- JDialog dialog = optionPane.createDialog(null, "Error");
- dialog.setVisible(true);
- }
+public interface ScriptEditor {
+ Object execute() throws Exception;
+ void indicateErrorLine(int lineNum);
+ void edit(XScriptContext context, ScriptMetaData entry);
+ String getTemplate();
+ String getExtension();
}
\ No newline at end of file
diff --git
a/scripting/java/com/sun/star/script/framework/provider/ScriptEditorBase.java
b/scripting/java/com/sun/star/script/framework/provider/ScriptEditorBase.java
new file mode 100644
index 000000000000..1a8bf33a5395
--- /dev/null
+++
b/scripting/java/com/sun/star/script/framework/provider/ScriptEditorBase.java
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package com.sun.star.script.framework.provider;
+
+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.provider.XScriptContext;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+
+import javax.swing.JOptionPane;
+import javax.swing.JDialog;
+
+public abstract class ScriptEditorBase implements ScriptEditor {
+ public XScriptContext context;
+
+ public void setContext(XScriptContext context) {
+ this.context = context;
+ }
+
+ public boolean isMacroExecutionEnabled() {
+ 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;
+ }
+
+ // Wraps long error messages
+ private static class NarrowOptionPane extends JOptionPane {
+ private static final long serialVersionUID = 1L;
+ public int getMaxCharactersPerLineCount() {
+ return 100;
+ }
+ }
+
+ public void showErrorMessage(String message) {
+ JOptionPane optionPane = new NarrowOptionPane();
+ optionPane.setMessage(message);
+ optionPane.setMessageType(JOptionPane.ERROR_MESSAGE);
+ JDialog dialog = optionPane.createDialog(null, "Error");
+ dialog.setVisible(true);
+ }
+}
\ No newline at end of file
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 2a972df92ff6..0ab265ecc799 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
@@ -19,7 +19,7 @@ package com.sun.star.script.framework.provider.beanshell;
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.ScriptEditorBase;
import com.sun.star.script.framework.provider.SwingInvocation;
import com.sun.star.script.provider.XScriptContext;
@@ -49,7 +49,7 @@ import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.BorderFactory;
-public class ScriptEditorForBeanShell extends ScriptEditor implements
ActionListener {
+public class ScriptEditorForBeanShell extends ScriptEditorBase implements
ActionListener {
private JFrame frame;
private String filename;
diff --git
a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index 8bb0828aff03..1f0e8fd72a16 100644
---
a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++
b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -20,7 +20,7 @@ package com.sun.star.script.framework.provider.javascript;
import com.sun.star.script.framework.container.ScriptMetaData;
import com.sun.star.script.framework.log.LogUtils;
-import com.sun.star.script.framework.provider.ScriptEditor;
+import com.sun.star.script.framework.provider.ScriptEditorBase;
import com.sun.star.script.framework.provider.SwingInvocation;
import com.sun.star.script.provider.XScriptContext;
@@ -40,7 +40,7 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.tools.debugger.Main;
import org.mozilla.javascript.tools.debugger.ScopeProvider;
-public class ScriptEditorForJavaScript extends ScriptEditor {
+public class ScriptEditorForJavaScript extends ScriptEditorBase {
// global ScriptEditorForJavaScript instance
private static ScriptEditorForJavaScript theScriptEditorForJavaScript;
commit 0fd8f6e35896689633ee0fa9e63bc4f55904c836
Author: Andrea Gelmini <[email protected]>
AuthorDate: Fri Aug 28 11:59:42 2020 +0200
Commit: Samuel Mehrbrodt <[email protected]>
CommitDate: Mon May 30 11:50:55 2022 +0200
Fix typos in code
It passed "make check" on Linux
Change-Id: Id7c7ac1b88d290ed71f03fa28dec144bcd29b692
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101590
Tested-by: Jenkins
Reviewed-by: Julien Nabet <[email protected]>
(cherry picked from commit f10a4e20100515f1fc95b3254ac52894ec59bdda)
diff --git
a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
index dbcb3b0bc7a9..395a1b6a8abb 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
@@ -43,7 +43,7 @@ public abstract class ScriptEditor {
this.context = context;
}
- public boolean isMacroExectionEnabled() {
+ public boolean isMacroExecutionEnabled() {
XNameAccess xNameAccess = null;
try {
String sAccess = "com.sun.star.configuration.ConfigurationAccess";
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 31c26dc51334..2a972df92ff6 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
@@ -170,7 +170,7 @@ public class ScriptEditorForBeanShell extends ScriptEditor
implements ActionList
*
*/
public Object execute() throws Exception {
- if (!isMacroExectionEnabled()) {
+ if (!isMacroExecutionEnabled()) {
showErrorMessage("Macro Execution has been disabled.");
return null;
}
diff --git
a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index 4cf5cc3384ca..8bb0828aff03 100644
---
a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++
b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -196,7 +196,7 @@ public class ScriptEditorForJavaScript extends ScriptEditor
{
private ScriptEditorForJavaScript(XScriptContext context, URL url) {
setContext(context);
// Need to check that before showing the window. Checking in execute()
has no effect.
- if (!isMacroExectionEnabled()) {
+ if (!isMacroExecutionEnabled()) {
showErrorMessage("Macro Execution has been disabled.");
return ;
}