[libreoffice/f17] Resolves: fdo#49517 Java macro embedded in document will not run
sbergmann
sbergmann at fedoraproject.org
Mon Oct 29 10:56:07 UTC 2012
commit 8c5081676863161e3c9cede3402c17994ad3167f
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Oct 29 11:55:43 2012 +0100
Resolves: fdo#49517 Java macro embedded in document will not run
...evert-fdo-46102-Load-Java-scripts-with-cl.patch | 216 ++++++++++++++++++++
libreoffice.spec | 7 +-
2 files changed, 222 insertions(+), 1 deletions(-)
---
diff --git a/0001-fdo-49517-Revert-fdo-46102-Load-Java-scripts-with-cl.patch b/0001-fdo-49517-Revert-fdo-46102-Load-Java-scripts-with-cl.patch
new file mode 100644
index 0000000..aa99499
--- /dev/null
+++ b/0001-fdo-49517-Revert-fdo-46102-Load-Java-scripts-with-cl.patch
@@ -0,0 +1,216 @@
+From 7ea7fb009ddcfb0723e88ba0c5778b5fdbe2b553 Mon Sep 17 00:00:00 2001
+From: Stephan Bergmann <sbergman at redhat.com>
+Date: Fri, 26 Oct 2012 16:22:16 +0200
+Subject: [PATCH] fdo#49517: Revert "fdo#46102: Load Java scripts with class
+ loaders [...]"
+
+This reverts commit dd6c4f4db1d62268d73e09ae52d23f760a967dcc "fdo#46102: Load
+Java scripts with class loaders that actually find them." That commit broke
+support for macros embedded in documents (as
+new java.net.URL("vnd.sun.star.tdoc:...") throws a MalformedURLExcetpion), and
+it looks like that commit was not necessary after all -- or rather that what it
+tried to work around must have been some other problem that has been fixed
+meanwhile. "It is unclear to me how the Java script provider shall ever have
+found the script jars in the past" indicates that something must have been
+fishy, and what I failed to notice back then is that createURL creates
+java.net.URL instances with a UCBStreamHandler that does allow to obtain content
+from weird-looking URLs.
+
+Anyway, with that reverted, all three following scenarios work on both current
+master (towards LO 3.7) and libreoffice-3-6 (towards LO 3.6.4); I haven't yet
+come around to test on libreoffice-3-5:
+
+1 Stock macros, "Tools - Macros - Run Macro... - LibreOffice Macros -
+HelloWorld", running all of the four "helloworld.bsh", "helloworld.js",
+"HelloWorldPyhton", and
+"org.libreoffice.example.java_scripts.HelloWorld.printHW".
+
+2 Per-document macros, loading test.odt attached to fdo#49517, then "Tools -
+Macros - Run Macro... - test.odt - HelloWorld", running
+"org.libreoffice.example.java_scripts.HelloWorld.printHW".
+
+3 Extension macros, installing ScriptDispatch.oxt attached to fdo#46012 as
+shared extension, then loading StartScriptDispatch.odt attached to fdo#46012 and
+pressing the "Start Java via ScriptProvider" button.
+
+Change-Id: I31cd16b3720ffeb1058722d4d1fdffb773f8a067
+---
+ .../script/framework/container/ScriptMetaData.java | 46 ++--------------------
+ .../framework/provider/ClassLoaderFactory.java | 6 +--
+ .../beanshell/ScriptEditorForBeanShell.java | 3 +-
+ .../beanshell/ScriptProviderForBeanShell.java | 3 +-
+ .../provider/java/ScriptProviderForJava.java | 2 +-
+ .../javascript/ScriptProviderForJavaScript.java | 3 +-
+ 6 files changed, 9 insertions(+), 54 deletions(-)
+
+diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
+index f39e8b9..eb1e560 100644
+--- a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
++++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
+@@ -41,14 +41,7 @@ import com.sun.star.script.framework.io.UCBStreamHandler;
+
+ import com.sun.star.ucb.XSimpleFileAccess2;
+
+-import com.sun.star.uno.AnyConverter;
+ import com.sun.star.uno.UnoRuntime;
+-import com.sun.star.uno.XComponentContext;
+-
+-import com.sun.star.uri.UriReferenceFactory;
+-import com.sun.star.uri.XVndSunStarExpandUrl;
+-
+-import com.sun.star.util.XMacroExpander;
+
+ public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ private boolean hasSource = false;
+@@ -244,8 +237,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ return "\nParcelLocation = " + getParcelLocation() + "\nLocationPlaceHolder = " + locationPlaceHolder + super.toString();
+ }
+
+- public URL[] getClassPath(XComponentContext context)
+- throws java.net.MalformedURLException
++ public URL[] getClassPath() throws java.net.MalformedURLException
+ {
+ try
+ {
+@@ -272,7 +264,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ {
+ String relativeClasspath = stk.nextToken();
+ String pathToProcess = PathUtils.make_url( parcelPath, relativeClasspath);
+- URL url = expandURL( context, pathToProcess );
++ URL url = createURL( pathToProcess );
+ if ( url != null )
+ {
+ classPathVec.add ( url );
+@@ -281,7 +273,7 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ }
+ if ( classPathVec.size() == 0)
+ {
+- URL url = expandURL( context, parcelPath );
++ URL url = createURL( parcelPath );
+ if ( url != null )
+ {
+ classPathVec.add(url);
+@@ -298,38 +290,6 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ }
+
+ }
+-
+- private URL expandURL(XComponentContext context, String url)
+- throws java.net.MalformedURLException
+- {
+- XVndSunStarExpandUrl exp = UnoRuntime.queryInterface(
+- XVndSunStarExpandUrl.class,
+- UriReferenceFactory.create(context).parse(url));
+- String expurl;
+- if (exp == null) {
+- expurl = url;
+- } else {
+- XMacroExpander expander;
+- try {
+- expander = (XMacroExpander) AnyConverter.toObject(
+- XMacroExpander.class,
+- context.getValueByName(
+- "/singletons/com.sun.star.util.theMacroExpander"));
+- } catch (com.sun.star.lang.IllegalArgumentException e) {
+- throw new RuntimeException(e);
+- }
+- try {
+- expurl = exp.expand(expander);
+- } catch (com.sun.star.lang.IllegalArgumentException e) {
+- java.net.MalformedURLException e2 =
+- new java.net.MalformedURLException(e.toString());
+- e2.initCause(e);
+- throw e2;
+- }
+- }
+- return new URL(expurl);
+- }
+-
+ private URL createURL( String path ) throws java.net.MalformedURLException
+ {
+ URL url = null;
+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 a831919..4086a3c 100644
+--- a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
++++ b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
+@@ -22,7 +22,6 @@ import java.net.*;
+
+ import com.sun.star.script.framework.log.LogUtils;
+ import com.sun.star.script.framework.container.ScriptMetaData;
+-import com.sun.star.uno.XComponentContext;
+
+ /**
+ * Class Loader Factory
+@@ -31,12 +30,11 @@ public class ClassLoaderFactory
+ {
+ private ClassLoaderFactory() {}
+
+- public static ClassLoader getURLClassLoader(
+- XComponentContext context, ScriptMetaData scriptData )
++ public static ClassLoader getURLClassLoader( ScriptMetaData scriptData )
+ throws NoSuitableClassLoaderException, MalformedURLException
+ {
+ ClassLoader parent = scriptData.getClass().getClassLoader();
+- URL[] classPath = scriptData.getClassPath(context);
++ URL[] classPath = scriptData.getClassPath();
+ LogUtils.DEBUG("Classpath has length " + classPath.length );
+ for ( int i=0; i < classPath.length; i++ )
+ {
+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 4fd6a94..0497bd9 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
+@@ -192,8 +192,7 @@ public class ScriptEditorForBeanShell
+ try {
+ ClassLoader cl = null;
+ try {
+- cl = ClassLoaderFactory.getURLClassLoader(
+- context.getComponentContext(), entry );
++ cl = ClassLoaderFactory.getURLClassLoader( entry );
+ }
+ catch (Exception ignore) // TODO re-examine error handling
+ {
+diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
+index bed3c7a..ea23768 100644
+--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
++++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
+@@ -187,8 +187,7 @@ class ScriptImpl implements XScript
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+ try {
+- cl = ClassLoaderFactory.getURLClassLoader(
+- m_xContext, metaData );
++ cl = ClassLoaderFactory.getURLClassLoader( metaData );
+ sourceUrl = metaData.getSourceURL();
+ }
+ catch ( java.net.MalformedURLException mfu )
+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 6c5024b..090f162 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
+@@ -191,7 +191,7 @@ class ScriptImpl implements XScript
+ try {
+ LogUtils.DEBUG( "Classloader starting..." );
+ scriptLoader = ClassLoaderFactory.getURLClassLoader(
+- m_xContext, metaData );
++ metaData );
+ LogUtils.DEBUG( "Classloader finished..." );
+ }
+ catch (MalformedURLException mfe )
+diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
+index aa36af8..73ce9c5 100644
+--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
++++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
+@@ -186,8 +186,7 @@ class ScriptImpl implements XScript
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+ try {
+- cl = ClassLoaderFactory.getURLClassLoader(
+- m_xContext, metaData );
++ cl = ClassLoaderFactory.getURLClassLoader( metaData );
+ sourceUrl = metaData.getSourceURL();
+ }
+ catch ( java.net.MalformedURLException mfu )
+--
+1.7.11.7
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 98a0ee6..9713656 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -35,7 +35,7 @@ Summary: Free Software Productivity Suite
Name: libreoffice
Epoch: 1
Version: %{libo_version}.2
-Release: 4%{?dist}
+Release: 5%{?dist}
License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic
Group: Applications/Productivity
URL: http://www.documentfoundation.org/develop
@@ -164,6 +164,7 @@ Patch46: 0004-rhbz-827695-sw-prevent-crashes-after-incomplete-prin.patch
Patch47: 0001-fdo-49819-fdo-54609-Do-not-consider-timestamp-differ.patch
Patch48: 0001-Resolves-rhbz-868479-fdo-56281-doubled-in-German-ok-.patch
Patch49: 0001-rhbz-868953-fdo-45084-When-the-caller-specifies-filt.patch
+Patch50: 0001-fdo-49517-Revert-fdo-46102-Load-Java-scripts-with-cl.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -1043,6 +1044,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch47 -p1 -b .fdo-49819-fdo-54609-Do-not-consider-timestamp-differ.patch
%patch48 -p1 -b .rhbz-868479-fdo-56281-doubled-in-German-ok-.patch
%patch49 -p1 -b .rhbz-868953-fdo-45084-When-the-caller-specifies-filt.patch
+%patch50 -p1 -b .fdo-49517-Revert-fdo-46102-Load-Java-scripts-with-cl.patch
# TODO: check this
# these are horribly incomplete--empty translations and copied english
@@ -2329,6 +2331,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%endif
%changelog
+* Mon Oct 29 2012 Stephan Bergmann <sbergman at redhat.com> - 1:3.5.7.2-5-UNBUILT
+- Resolves: fdo#49517 Java macro embedded in document will not run
+
* Wed Oct 24 2012 Eike Rathke <erack at redhat.com> - 1:3.5.7.2-4
- Resolves: rhbz#868953 Calc: open HTML documents from file dialog
More information about the scm-commits
mailing list