From 90a19aeac6cad56e33574685219a85ef98469513 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 3 Nov 2013 20:35:47 +0200 Subject: fdo#70393: move rhino to a subdir of external Change-Id: I7d7858d84a62568d9b0c61403645da13658e78d2 Reviewed-on: https://gerrit.libreoffice.org/6552 Reviewed-by: David Tardon Tested-by: David Tardon --- RepositoryModule_host.mk | 1 - external/Module_external.mk | 1 + external/rhino/ExternalPackage_rhino.mk | 16 + external/rhino/ExternalProject_rhino.mk | 32 + external/rhino/Makefile | 7 + external/rhino/Module_rhino.mk | 22 + external/rhino/OfficeScriptInfo.java | 118 +++ external/rhino/README | 14 + external/rhino/UnpackedTarball_rhino.mk | 24 + external/rhino/rhino1_5R5-find_swing.patch | 19 + external/rhino/rhino1_5R5-updateToolTip.patch | 23 + external/rhino/rhino1_5R5.patch | 1071 +++++++++++++++++++++++++ rhino/ExternalPackage_rhino.mk | 16 - rhino/ExternalProject_rhino.mk | 32 - rhino/Makefile | 7 - rhino/Module_rhino.mk | 22 - rhino/OfficeScriptInfo.java | 118 --- rhino/README | 14 - rhino/UnpackedTarball_rhino.mk | 24 - rhino/rhino1_5R5-find_swing.patch | 19 - rhino/rhino1_5R5-updateToolTip.patch | 23 - rhino/rhino1_5R5.patch | 1071 ------------------------- 22 files changed, 1347 insertions(+), 1347 deletions(-) create mode 100644 external/rhino/ExternalPackage_rhino.mk create mode 100644 external/rhino/ExternalProject_rhino.mk create mode 100644 external/rhino/Makefile create mode 100644 external/rhino/Module_rhino.mk create mode 100644 external/rhino/OfficeScriptInfo.java create mode 100644 external/rhino/README create mode 100644 external/rhino/UnpackedTarball_rhino.mk create mode 100644 external/rhino/rhino1_5R5-find_swing.patch create mode 100644 external/rhino/rhino1_5R5-updateToolTip.patch create mode 100644 external/rhino/rhino1_5R5.patch delete mode 100644 rhino/ExternalPackage_rhino.mk delete mode 100644 rhino/ExternalProject_rhino.mk delete mode 100644 rhino/Makefile delete mode 100644 rhino/Module_rhino.mk delete mode 100644 rhino/OfficeScriptInfo.java delete mode 100644 rhino/README delete mode 100644 rhino/UnpackedTarball_rhino.mk delete mode 100644 rhino/rhino1_5R5-find_swing.patch delete mode 100644 rhino/rhino1_5R5-updateToolTip.patch delete mode 100644 rhino/rhino1_5R5.patch diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk index 1f60a3031695..a878824005cb 100644 --- a/RepositoryModule_host.mk +++ b/RepositoryModule_host.mk @@ -94,7 +94,6 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\ remotebridges \ reportbuilder \ $(call gb_Helper_optional,DBCONNECTIVITY,reportdesign) \ - $(call gb_Helper_optional,RHINO,rhino) \ ridljar \ rsc \ sal \ diff --git a/external/Module_external.mk b/external/Module_external.mk index aeba824032e7..2a6977fdd753 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -72,6 +72,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,POSTGRESQL,postgresql) \ $(call gb_Helper_optional,PYTHON,python3) \ $(call gb_Helper_optional,REDLAND,redland) \ + $(call gb_Helper_optional,RHINO,rhino) \ $(call gb_Helper_optional,VISIO,libvisio) \ $(call gb_Helper_optional,WPD,libwpd) \ $(call gb_Helper_optional,WPG,libwpg) \ diff --git a/external/rhino/ExternalPackage_rhino.mk b/external/rhino/ExternalPackage_rhino.mk new file mode 100644 index 000000000000..0ee1d60e309d --- /dev/null +++ b/external/rhino/ExternalPackage_rhino.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_ExternalPackage_ExternalPackage,rhino,rhino)) + +$(eval $(call gb_ExternalPackage_use_external_project,rhino,rhino)) + +$(eval $(call gb_ExternalPackage_add_file,rhino,$(LIBO_SHARE_JAVA_FOLDER)/js.jar,build/rhino1_5R5/js.jar)) + +# vim: set noet sw=4 ts=4: diff --git a/external/rhino/ExternalProject_rhino.mk b/external/rhino/ExternalProject_rhino.mk new file mode 100644 index 000000000000..3243ad93d538 --- /dev/null +++ b/external/rhino/ExternalProject_rhino.mk @@ -0,0 +1,32 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_ExternalProject_ExternalProject,rhino)) + +$(eval $(call gb_ExternalProject_register_targets,rhino,\ + build \ +)) + +$(call gb_ExternalProject_get_state_target,rhino,build) : + $(call gb_ExternalProject_run,build,\ + $(ICECREAM_RUN) "$(ANT)" \ + -q \ + -f build.xml \ + -Dbuild.label="build-$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)" \ + -DTARFILE_LOCATION="$(if $(findstring -cygwin,$(BUILD_PLATFORM)),$(shell cygpath -m $(TARFILE_LOCATION)),$(TARFILE_LOCATION))" \ + $(if $(filter yes,$(JAVACISGCJ))\ + ,-Dbuild.compiler=gcj \ + ,-Dant.build.javac.source=$(JAVA_SOURCE_VER) \ + -Dant.build.javac.target=$(JAVA_TARGET_VER) \ + ) \ + $(if $(debug),-Dbuild.debug="on") \ + jar \ + ) + +# vim: set noet sw=4 ts=4: diff --git a/external/rhino/Makefile b/external/rhino/Makefile new file mode 100644 index 000000000000..e4968cf85fb6 --- /dev/null +++ b/external/rhino/Makefile @@ -0,0 +1,7 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/external/rhino/Module_rhino.mk b/external/rhino/Module_rhino.mk new file mode 100644 index 000000000000..201d3ba9fc90 --- /dev/null +++ b/external/rhino/Module_rhino.mk @@ -0,0 +1,22 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Module_Module,rhino)) + +ifneq ($(ENABLE_JAVA),) +ifneq ($(filter RHINO,$(BUILD_TYPE)),) +$(eval $(call gb_Module_add_targets,rhino,\ + ExternalPackage_rhino \ + ExternalProject_rhino \ + UnpackedTarball_rhino \ +)) +endif +endif + +# vim: set noet sw=4 ts=4: diff --git a/external/rhino/OfficeScriptInfo.java b/external/rhino/OfficeScriptInfo.java new file mode 100644 index 000000000000..eb1d78641d23 --- /dev/null +++ b/external/rhino/OfficeScriptInfo.java @@ -0,0 +1,118 @@ +/* + * 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 org.mozilla.javascript.tools.debugger; +import java.net.URL; +import java.util.HashMap; +import org.mozilla.javascript.Scriptable; + +public class OfficeScriptInfo +{ + private HashMap loadedSFScripts = new HashMap(); + + public void addScript( URL url, Scriptable scope, Runnable closeCallback ) + { + addScript( url.toString(), url, scope, closeCallback ); + } + + public void addScript( String key, URL url, Scriptable scope, Runnable closeCallback ) + { + SFScriptInfo si = loadedSFScripts.get( key ); + if ( si == null ) + { + si = new SFScriptInfo(); + si.url = url; + si.scope = scope; + si.closeCallback = closeCallback; + loadedSFScripts.put( key, si ); + } + } + + public void deleteScript( String key ) + { + SFScriptInfo info = loadedSFScripts.remove( key ); + if ( info != null ) + { + if ( info.closeCallback != null ) + { + System.out.println("** In removeSFScriptInfo have callback for " + key ); + info.closeCallback.run(); // really need to do this in separate thread???? + } + } + } + + public Scriptable getScriptScope( String key ) + { + Scriptable result = null; + SFScriptInfo info = loadedSFScripts.get( key ); + if ( info != null ) + { + result = info.scope; + } + return result; + } + + public URL getScriptUrl( String key ) + { + URL result = null; + SFScriptInfo info = loadedSFScripts.get( key ); + if ( info != null ) + { + result = info.url; + } + return result; + } + public boolean hasScript( String key ) + { + boolean result = true; + SFScriptInfo info = loadedSFScripts.get( key ); + if ( info == null ) + { + result = false; + } + return result; + } + + public void setScriptRunning( String key, boolean running ) + { + SFScriptInfo info = loadedSFScripts.get( key ); + if ( info != null ) + { + info.isExecuting = running; + } + } + + public boolean isScriptRunning( String key ) + { + boolean result = false; + SFScriptInfo info = loadedSFScripts.get( key ); + if ( info != null ) + { + result = info.isExecuting; + } + return result; + } + + class SFScriptInfo + { + Scriptable scope; + boolean isExecuting; + URL url; + Runnable closeCallback; + } +} diff --git a/external/rhino/README b/external/rhino/README new file mode 100644 index 000000000000..83e4135d0b89 --- /dev/null +++ b/external/rhino/README @@ -0,0 +1,14 @@ +JavaScript engine/interpreter written in Java, used to provide JavaScript extensions. + +The Scripting Framework makes use of the Rhino ([http://www.mozilla.org/rhino/]) +JavaScript interpreter, available under the Mozilla Public License +([http://www.mozilla.org/MPL/MPL-1.1.html]). + +In addition, to support the debugging of scripts contained in OpenOffice.org +documents, we have modified the Java source file Main.java. + +The Rhino source tarball is unpacked and patched with the modified code. The +Rhino Jar file (js.jar) is then built (download/swingExSrc.zip is unpacked and +built as part of this procesS) and delivered to the solver. The file +rhino1_5R5.patch contains the changes made in order to build Rhino. The patch +was generated using the command: diff -wurN diff --git a/external/rhino/UnpackedTarball_rhino.mk b/external/rhino/UnpackedTarball_rhino.mk new file mode 100644 index 000000000000..0a1492b88da6 --- /dev/null +++ b/external/rhino/UnpackedTarball_rhino.mk @@ -0,0 +1,24 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_UnpackedTarball_UnpackedTarball,rhino)) + +$(eval $(call gb_UnpackedTarball_set_tarball,rhino,$(RHINO_TARBALL),,rhino)) + +$(eval $(call gb_UnpackedTarball_set_patchlevel,rhino,2)) + +$(eval $(call gb_UnpackedTarball_add_patches,rhino,\ + external/rhino/rhino1_5R5.patch \ + external/rhino/rhino1_5R5-find_swing.patch \ + external/rhino/rhino1_5R5-updateToolTip.patch \ +)) + +$(eval $(call gb_UnpackedTarball_add_file,rhino,toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java,external/rhino/OfficeScriptInfo.java)) + +# vim: set noet sw=4 ts=4: diff --git a/external/rhino/rhino1_5R5-find_swing.patch b/external/rhino/rhino1_5R5-find_swing.patch new file mode 100644 index 000000000000..f074fa845490 --- /dev/null +++ b/external/rhino/rhino1_5R5-find_swing.patch @@ -0,0 +1,19 @@ +--- misc/rhino1_5R5/toolsrc/build.xml 2009-10-29 18:29:46.605524507 +0100 ++++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-10-29 18:29:26.536908810 +0100 +@@ -12,6 +12,7 @@ + + + ++ + + + +@@ -38,7 +42,7 @@ + +- ++ + + + diff --git a/external/rhino/rhino1_5R5-updateToolTip.patch b/external/rhino/rhino1_5R5-updateToolTip.patch new file mode 100644 index 000000000000..16857d35fca6 --- /dev/null +++ b/external/rhino/rhino1_5R5-updateToolTip.patch @@ -0,0 +1,23 @@ +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Wed Feb 23 10:25:09 2011 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Wed Feb 23 10:25:01 2011 +@@ -1045,9 +1045,18 @@ + } ); + } + ++ // Fix taken from ++ // toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java: + private void updateToolTip() { +- // in case fileName is very long, try to set tool tip on frame +- Component c = getComponent(1); ++ // Try to set tool tip on frame. On Mac OS X 10.5, ++ // the number of components is different, so try to be safe. ++ int n = getComponentCount() - 1; ++ if (n > 1) { ++ n = 1; ++ } else if (n < 0) { ++ return; ++ } ++ Component c = getComponent(n); + // this will work at least for Metal L&F + if (c != null && c instanceof JComponent) { + ((JComponent)c).setToolTipText(getUrl()); diff --git a/external/rhino/rhino1_5R5.patch b/external/rhino/rhino1_5R5.patch new file mode 100644 index 000000000000..5b10c320d015 --- /dev/null +++ b/external/rhino/rhino1_5R5.patch @@ -0,0 +1,1071 @@ +--- misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Fri Mar 28 17:24:23 2008 +@@ -38,6 +38,7 @@ + package org.mozilla.javascript; + + import java.lang.reflect.Method; ++import java.lang.reflect.InvocationTargetException; + + /** + * Load generated classes. +@@ -48,11 +49,34 @@ + implements GeneratedClassLoader + { + public DefiningClassLoader() { +- this.parentLoader = getClass().getClassLoader(); ++ init(getClass().getClassLoader()); + } + + public DefiningClassLoader(ClassLoader parentLoader) { ++ ++ init(parentLoader); ++ } ++ ++ private void init(ClassLoader parentLoader) { ++ + this.parentLoader = parentLoader; ++ ++ this.contextLoader = null; ++ if (method_getContextClassLoader != null) { ++ try { ++ this.contextLoader = (ClassLoader) ++ method_getContextClassLoader.invoke( ++ Thread.currentThread(), ++ ScriptRuntime.emptyArgs); ++ } catch (IllegalAccessException ex) { ++ } catch (InvocationTargetException ex) { ++ } catch (SecurityException ex) { ++ } ++ if (this.contextLoader == this.parentLoader) { ++ this.contextLoader = null; ++ } ++ } ++ + } + + public Class defineClass(String name, byte[] data) { +@@ -68,10 +92,20 @@ + { + Class cl = findLoadedClass(name); + if (cl == null) { +- if (parentLoader != null) { +- cl = parentLoader.loadClass(name); ++ // First try parent class loader and if that does not work, try ++ // contextLoader, but that will be null if ++ // Thread.getContextClassLoader() == parentLoader ++ // or on JDK 1.1 due to lack Thread.getContextClassLoader(). ++ // To avoid catching and rethrowing ClassNotFoundException ++ // in this cases, use try/catch check only if contextLoader != null. ++ if (contextLoader == null) { ++ cl = loadFromParent(name); + } else { +- cl = findSystemClass(name); ++ try { ++ cl = loadFromParent(name); ++ } catch (ClassNotFoundException ex) { ++ cl = contextLoader.loadClass(name); ++ } + } + } + if (resolve) { +@@ -80,5 +114,37 @@ + return cl; + } + ++ private Class loadFromParent(String name) ++ throws ClassNotFoundException ++ { ++ if (parentLoader != null) { ++ return parentLoader.loadClass(name); ++ } else { ++ return findSystemClass(name); ++ } ++ ++ } ++ + private ClassLoader parentLoader; ++ ++ private ClassLoader contextLoader; ++ ++ // We'd like to use "Thread.getContextClassLoader", but ++ // that's only available on Java2. ++ private static Method method_getContextClassLoader; ++ ++ static { ++ try { ++ // Don't use "Thread.class": that performs the lookup ++ // in the class initializer, which doesn't allow us to ++ // catch possible security exceptions. ++ Class threadClass = Class.forName("java.lang.Thread"); ++ method_getContextClassLoader = ++ threadClass.getDeclaredMethod("getContextClassLoader", ++ new Class[0]); ++ } catch (ClassNotFoundException e) { ++ } catch (NoSuchMethodException e) { ++ } catch (SecurityException e) { ++ } ++ } + } +--- misc/rhino1_5R5/toolsrc/build.xml 2004-03-25 21:54:34.000000000 +0100 ++++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-01-17 20:46:44.000000000 +0100 +@@ -6,6 +6,24 @@ + --> + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +@@ -20,46 +38,10 @@ + +- +- ++ + + + +- +- import java.awt.Component; +- +- package org.mozilla.javascript.tools.debugger; +- import java.awt.Component; +- +- +- +- import javax.swing.tree.*; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.tree.*; +- +- +- +- import javax.swing.*; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.*; +- +- +- +- import javax.swing.tree.TreeModel; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.tree.TreeModel; +- +- +- +- import javax.swing.JTree; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.JTree; +- +- + + + +@@ -68,6 +50,7 @@ + includes="org/**/*.java" + deprecation="on" + debug="${debug}"> ++ + + + +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2004-03-25 21:54:34.000000000 +0100 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2009-01-17 20:44:22.000000000 +0100 +@@ -470,15 +470,21 @@ + case KeyEvent.VK_BACK_SPACE: + case KeyEvent.VK_ENTER: + case KeyEvent.VK_DELETE: ++ if (w.isEditable() == false) { + e.consume(); ++ } + break; + } + } + public void keyTyped(KeyEvent e) { ++ if (w.isEditable() == false) { + e.consume(); ++ } + } + public void keyReleased(KeyEvent e) { ++ if (w.isEditable() == false) { + e.consume(); ++ } + } + } + +@@ -879,7 +885,7 @@ + } + }; + +-class FileWindow extends JInternalFrame implements ActionListener { ++class FileWindow extends JInternalFrame implements ActionListener, DocumentListener { + + Main db; + SourceInfo sourceInfo; +@@ -888,15 +894,16 @@ + JScrollPane p; + int currentPos; + JLabel statusBar; ++ boolean isModified = false; + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("Cut")) { +- // textArea.cut(); ++ textArea.cut(); + } else if (cmd.equals("Copy")) { + textArea.copy(); + } else if (cmd.equals("Paste")) { +- // textArea.paste(); ++ textArea.paste(); + } + } + +@@ -910,17 +917,73 @@ + } + + void load() { +- Scriptable scope = db.getScope(); ++ //Scriptable scope = db.getScope(); ++ Scriptable scope = db.officeScripts.getScriptScope( getUrl() ); ++ if ( scope == null ) ++ { ++ scope = db.getScope(); ++ } + if (scope == null) { + MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); + } else { + String url = getUrl(); + if (url != null) { +- new Thread(new LoadFile(db,scope,url)).start(); ++ new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start(); + } + } + } + ++ void save() { ++ if (getUrl() != null) { ++ OutputStream os = null; ++ try { ++ if ( getUrl().startsWith("vnd.sun.star") ) ++ { ++ URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() ); ++ if ( scriptUrl == null ) ++ { ++ throw new IOException("Can't optain stream for " + getUrl() ); ++ } ++ os = scriptUrl.openConnection().getOutputStream(); ++ } ++ else ++ { ++ os = new FileOutputStream( getUrl() ); ++ } ++ String s = textArea.getText(); ++ os.write(s.getBytes(), 0, s.length()); ++ ++ this.isModified = false; ++ } ++ catch (IOException ioe) { ++ JOptionPane.showMessageDialog(this, ++ "Error saving file: " + ioe.getMessage(), ++ "Error", JOptionPane.ERROR_MESSAGE); ++ } ++ finally ++ { ++ if ( os != null ) ++ { ++ try ++ { ++ os.close(); ++ os = null; ++ } ++ catch( IOException ioe ) ++ { ++ System.err.println("Error closing stream: " + ioe.getMessage() ); ++ ioe.printStackTrace(); ++ } ++ } ++ } ++ } ++ } ++ ++ public boolean isEditable() { ++ return db.isSourceEditingEnabled(); ++ } ++ ++ + public int getPosition(int line) { + int result = -1; + try { +@@ -953,7 +1016,7 @@ + fileHeader.repaint(); + } + } +- ++ public Main getDB() { return db; } + FileWindow(Main db, SourceInfo sourceInfo) { + super(SourceInfo.getShortName(sourceInfo.getUrl()), + true, true, true, true); +@@ -972,6 +1035,14 @@ + pack(); + updateText(); + textArea.select(0); ++ addInternalFrameListener( new InternalFrameAdapter() { ++ public void internalFrameClosed(InternalFrameEvent e) { ++ // clean up scriptItems and sourceNames hashes ++ getDB().removeScript( getUrl() ); ++ // remove scripts for officeScripts ++ getDB().officeScripts.deleteScript( getUrl() ); ++ } ++ } ); + } + + private void updateToolTip() { +@@ -990,7 +1061,10 @@ + void updateText() { + String newText = sourceInfo.getSource(); + if (!textArea.getText().equals(newText)) { ++ textArea.getDocument().removeDocumentListener(this); + textArea.setText(newText); ++ this.isModified = false; ++ textArea.getDocument().addDocumentListener(this); + int pos = 0; + if (currentPos != -1) { + pos = currentPos; +@@ -1001,6 +1075,31 @@ + fileHeader.repaint(); + } + ++ /* Implementation of DocumentListener interface */ ++ public void insertUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void removeUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void changedUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void doChanged(DocumentEvent e) { ++ this.isModified = true; ++ } ++ ++ public boolean isModified() { ++ return this.isModified; ++ } ++ ++ public String getText() { ++ return textArea.getText(); ++ } ++ + void setPosition(int pos) { + textArea.select(pos); + currentPos = pos; +@@ -1618,7 +1717,7 @@ + if (line != -1) { + db.currentWindow = w; + } +- db.menubar.addFile(url); ++ // db.menubar.addFile(url); + w.setVisible(true); + if (activate) { + try { +@@ -1752,8 +1851,10 @@ + Menubar(Main db) { + super(); + this.db = db; +- String[] fileItems = {"Open...", "Run...", "", "Exit"}; +- String[] fileCmds = {"Open", "Load", "", "Exit"}; ++ // String[] fileItems = {"Open...", "Run...", "", "Exit"}; ++ // String[] fileCmds = {"Open", "Load", "", "Exit"}; ++ String[] fileItems = {"Run", "Save", "", "Exit"}; ++ String[] fileCmds = {"Run", "Save", "", "Exit"}; + char[] fileShortCuts = {'0', 'N', '\0', 'X'}; + int[] fileAccelerators = {KeyEvent.VK_O, + KeyEvent.VK_N, +@@ -1795,6 +1896,9 @@ + KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK); + item.setAccelerator(k); + } ++ if (fileItems[i].equals("Save")) { ++ saveItem = item; ++ } + } + } + for (int i = 0; i < editItems.length; ++i) { +@@ -1849,9 +1953,9 @@ + item.addActionListener(this); + windowMenu.add(item = new JMenuItem("Tile", 'T')); + item.addActionListener(this); +- windowMenu.addSeparator(); +- windowMenu.add(item = new JMenuItem("Console", 'C')); +- item.addActionListener(this); ++// windowMenu.addSeparator(); ++// windowMenu.add(item = new JMenuItem("Console", 'C')); ++// item.addActionListener(this); + add(windowMenu); + + } +@@ -1925,11 +2029,16 @@ + item.addActionListener(this); + } + ++ public void setSaveEnabled(boolean state) { ++ saveItem.setEnabled(state); ++ } ++ + Main db; + JMenu windowMenu; + JCheckBoxMenuItem breakOnExceptions; + JCheckBoxMenuItem breakOnEnter; + JCheckBoxMenuItem breakOnReturn; ++ JMenuItem saveItem; + }; + + class EnterInterrupt implements Runnable { +@@ -1942,6 +2051,13 @@ + public void run() { + JMenu menu = db.getJMenuBar().getMenu(0); + //menu.getItem(0).setEnabled(false); // File->Load ++ ++ // disable Edit menu Cut, Copy, Paste items ++ menu = db.getJMenuBar().getMenu(1); ++ for (int i = 0; i < 3; i++) { ++ menu.getItem(i).setEnabled(false); ++ } ++ + menu = db.getJMenuBar().getMenu(2); + menu.getItem(0).setEnabled(false); // Debug->Break + int count = menu.getItemCount(); +@@ -1954,6 +2070,10 @@ + b = true; + } + db.toolBar.setEnabled(true); ++ ++ // set flag to disable source editing ++ db.setSourceEditingEnabled(false); ++ + // raise the debugger window + db.toFront(); + } +@@ -1967,6 +2087,13 @@ + public void run() { + JMenu menu = db.getJMenuBar().getMenu(0); + menu.getItem(0).setEnabled(true); // File->Load ++ ++ // enable Edit menu items ++ menu = db.getJMenuBar().getMenu(1); ++ for (int i = 0; i < 3; i++) { ++ menu.getItem(i).setEnabled(true); ++ } ++ + menu = db.getJMenuBar().getMenu(2); + menu.getItem(0).setEnabled(true); // Debug->Break + int count = menu.getItemCount() - 1; +@@ -1980,6 +2107,10 @@ + db.toolBar.getComponent(ci).setEnabled(b); + b = false; + } ++ ++ // set flag to enable source editing ++ db.setSourceEditingEnabled(true); ++ + //db.console.consoleTextArea.requestFocus(); + } + }; +@@ -1988,17 +2119,24 @@ + { + String fileName; + Main db; ++ Reader reader = null; + OpenFile(Main db, String fileName) + { + this.fileName = fileName; + this.db = db; + } ++ OpenFile(Main db, String fileName, Reader reader) { ++ this(db, fileName); ++ this.reader = reader; ++ } + public void run() { + Context cx = Context.enter(); + ContextData contextData = ContextData.get(cx); + contextData.breakNextLine = true; + try { +- cx.compileReader(new FileReader(fileName), fileName, 1, null); ++ cx.compileReader( ++ reader == null ? new FileReader(fileName) : reader, ++ fileName, 1, null); + } catch (Exception exc) { + String msg = exc.getMessage(); + if (exc instanceof EcmaError) { +@@ -2019,29 +2157,79 @@ + Scriptable scope; + String fileName; + Main db; ++ Reader reader = null; ++ Object result = null; ++ Exception exception = null; ++ int lineNum = -1; ++ boolean sfExecute = false; ++ + LoadFile(Main db, Scriptable scope, String fileName) { + this.scope = scope; + this.fileName = fileName; + this.db = db; + } ++ ++ LoadFile(Main db, Scriptable scope, String fileName, Reader reader) { ++ this(db, scope, fileName); ++ this.reader = reader; ++ } ++ LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) { ++ this(db, scope, fileName); ++ this.reader = reader; ++ this.sfExecute = sfExecute; ++ } ++ + public void run() { ++ if ( db.officeScripts.isScriptRunning( fileName ) ) ++ { ++ exception = new Exception("The script is already executing"); ++ if ( !sfExecute ) { ++ MessageDialogWrapper.showMessageDialog(db, ++ "Script already executing", ++ "Run", ++ JOptionPane.ERROR_MESSAGE); ++ } ++ return; ++ } ++ db.officeScripts.setScriptRunning( fileName, true ); + Context cx = Context.enter(); + ContextData contextData = ContextData.get(cx); ++ if ( sfExecute ) ++ { ++ contextData.breakNextLine = false; ++ } ++ else ++ { + contextData.breakNextLine = true; ++ } ++ /* ++ FileWindow w = (FileWindow)db.getSelectedFrame(); ++ if ( sfExecute ) ++ { ++ db.swingInvoke(new SetFilePosition(db, w, -1 ) ); ++ }*/ + try { +- cx.evaluateReader(scope, new FileReader(fileName), ++ result = cx.evaluateReader(scope, ++ reader == null ? new FileReader(fileName) : reader, + fileName, 1, null); + } catch (Exception exc) { ++ exception = exc; + String msg = exc.getMessage(); + if (exc instanceof EcmaError) { + EcmaError err = (EcmaError)exc; + msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg; +- } ++ ++ int lineNum = err.getLineNumber() ; ++ //db.swingInvoke(new SetFilePosition(db, w, lineNum ) ); ++ if ( !sfExecute ) { + MessageDialogWrapper.showMessageDialog(db, + msg, + "Run", + JOptionPane.ERROR_MESSAGE); ++ } ++ } + } finally { ++ db.officeScripts.setScriptRunning( fileName, false ); + cx.exit(); + } + } +@@ -2416,13 +2604,13 @@ + super.setVisible(b); + if (b) { + // this needs to be done after the window is visible +- console.consoleTextArea.requestFocus(); ++ // console.consoleTextArea.requestFocus(); + context.split.setDividerLocation(0.5); + try { +- console.setMaximum(true); +- console.setSelected(true); +- console.show(); +- console.consoleTextArea.requestFocus(); ++ // console.setMaximum(true); ++ // console.setSelected(true); ++ // console.show(); ++ // console.consoleTextArea.requestFocus(); + } catch (Exception exc) { + } + } +@@ -2449,35 +2637,6 @@ + + Hashtable functionNames = new Hashtable(); + +- ScriptItem getScriptItem(DebuggableScript fnOrScript) { +- ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); +- if (item == null) { +- String url = getNormilizedUrl(fnOrScript); +- SourceInfo si = (SourceInfo)sourceNames.get(url); +- if (si == null) { +- if (!fnOrScript.isGeneratedScript()) { +- // Not eval or Function, try to load it from URL +- String source = null; +- try { +- InputStream is = openSource(url); +- try { source = readSource(is); } +- finally { is.close(); } +- } catch (IOException ex) { +- System.err.println +- ("Failed to load source from "+url+": "+ ex); +- } +- if (source != null) { +- si = registerSource(url, source); +- } +- } +- } +- if (si != null) { +- item = registerScript(si, fnOrScript); +- } +- } +- return item; +- } +- + /* Debugger Interface */ + + public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, +@@ -2490,7 +2649,7 @@ + + String getNormilizedUrl(DebuggableScript fnOrScript) { + String url = fnOrScript.getSourceName(); +- if (url == null) { url = ""; } ++ if (url == null) { url = "document"; } + else { + // Not to produce window for eval from different lines, + // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval) +@@ -2601,7 +2760,7 @@ + if (si == null) { + si = new SourceInfo(sourceUrl, source); + sourceNames.put(sourceUrl, si); +- } else { ++ } else if (!source.equals(si.getSource())) { + si.setSource(source); + } + } +@@ -2762,7 +2921,7 @@ + desk = new JDesktopPane(); + desk.setPreferredSize(new Dimension(600, 300)); + desk.setMinimumSize(new Dimension(150, 50)); +- desk.add(console = new JSInternalConsole("JavaScript Console")); ++ // desk.add(console = new JSInternalConsole("JavaScript Console")); + context = new ContextWindow(this); + context.setPreferredSize(new Dimension(600, 120)); + context.setMinimumSize(new Dimension(50, 50)); +@@ -2871,7 +3030,7 @@ + FrameHelper frame = contextData.getFrame(frameIndex); + String sourceName = frame.getUrl(); + if (sourceName == null || sourceName.equals("")) { +- console.show(); ++ // console.show(); + helper.reset(); + return; + } +@@ -2895,6 +3054,19 @@ + int dispatcherIsWaiting = 0; + Context currentContext = null; + ++ // Flag used to establish whether source code editing is allowed in ++ // the debugger, switched on and off depending on whether a debug session ++ // is active ++ boolean sourceEditingEnabled = true; ++ ++ public boolean isSourceEditingEnabled() { ++ return sourceEditingEnabled; ++ } ++ ++ void setSourceEditingEnabled(boolean b) { ++ sourceEditingEnabled = b; ++ } ++ + Context getCurrentContext() { + return currentContext; + } +@@ -3028,14 +3200,14 @@ + swingInvoke(CreateFileWindow.action(this, si, line)); + } + } else { +- if (console.isVisible()) { ++ /* if (console.isVisible()) { + final JSInternalConsole finalConsole = console; + swingInvoke(new Runnable() { + public void run() { + finalConsole.show(); + } + }); +- } ++ } */ + } + swingInvoke(new EnterInterrupt(this, cx)); + swingInvoke(new UpdateContext(this, cx)); +@@ -3217,6 +3389,14 @@ + fileName)).start(); + } + } ++ } else if (cmd.equals("Run")) { ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ w.load(); ++ } else if (cmd.equals("Save")) { ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ w.save(); + } else if (cmd.equals("More Windows...")) { + MoreWindows dlg = new MoreWindows(this, fileWindows, + "Window", "Files"); +@@ -3509,6 +3689,60 @@ + } + } + ++ JInternalFrame getFrameForUrl( URL url ) ++ { ++ JInternalFrame[] frames = desk.getAllFrames(); ++ for (int i = 0; i < frames.length; i++) { ++ FileWindow w = (FileWindow)frames[i]; ++ if ( url.toString().equals( w.getUrl() ) ) { ++ return w; ++ } ++ } ++ return null; ++ } ++ public void highlighLineInSelectedWindow(URL url, int lineNum ){ ++ //FileWindow w = (FileWindow)getFrameForUrl( url ); ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ { ++ if ( lineNum > -1 ) ++ swingInvoke(new SetFilePosition(this, w, lineNum ) ); ++ } ++ } ++ public Object runSelectedWindow( URL scriptUrl ) throws Exception ++ { ++ Object result = null; ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl ); ++ w.toFront(); ++ if (w != null) ++ { ++ Scriptable scope = w.db.getScope(); ++ if (scope == null) ++ { ++ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); ++ result = null; ++ } ++ else ++ { ++ String url = w.getUrl(); ++ Thread executorThread = null; ++ if (url != null) ++ { ++ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); ++ executor.run(); ++ result = executor.result; ++ if ( executor.exception != null ) ++ { ++ throw executor.exception; ++ } ++ } ++ } ++ } ++ return result; ++ ++ } ++ + // + // public interface + // +@@ -3604,6 +3838,69 @@ + return console.getErr(); + } + ++ public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) { ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (scriptUrl != null) { ++ try ++ { ++ InputStreamReader reader = new InputStreamReader(scriptUrl.openStream()); ++ String fileName = null; ++ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") ) ++ { ++ fileName = scriptUrl.toString(); ++ } ++ else ++ { ++ fileName = scriptUrl.getPath(); ++ } ++ officeScripts.addScript( fileName, scriptUrl, scope, closeCallback ); ++ //new Thread(new OpenFile(this, scope, fileName, reader )).start(); ++ swingInvoke( new OpenFile(this, fileName, reader )); ++ } ++ catch ( IOException e ) ++ { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't open stream for script: " + e.toString(), ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } ++ } ++ } ++ split1.setDividerLocation(1.0); ++ } ++ ++ public void openFile(String fileName) { ++ Scriptable scope = getScope(); ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (fileName != null) { ++ new Thread(new OpenFile(this, fileName)).start(); ++ } ++ } ++ split1.setDividerLocation(1.0); ++ } ++ ++ public void openStream(InputStream in) { ++ Scriptable scope = getScope(); ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (in != null) { ++ new Thread(new OpenFile(this, null, new InputStreamReader(in))).start(); ++ } ++ } ++ split1.setDividerLocation(1.0); ++ menubar.setSaveEnabled(false); ++ } ++ + public static void main(String[] args) { + try { + mainThread = Thread.currentThread(); +@@ -3635,5 +3932,162 @@ + } + } + ++ // patched Office specific interface ++ ++ OfficeScriptInfo officeScripts = new OfficeScriptInfo(); ++ ++ void removeScript( String url ) ++ { ++ // Remove the FileWindow from list of open sources ++ fileWindows.remove( url ); ++ ++ // Remove sourceInfo from sourceNames, ensures that ++ // breakpoints etc are deleted ++ synchronized (sourceNames) { ++ sourceNames.remove( url ); ++ } ++ // Removes scriptItems for the script, ensures that a new open ( from openFile ) ++ // will succeed, openFile should open file but fails due to fact that ++ synchronized ( scriptItems ) ++ { ++ Iterator iter = scriptItems.entrySet().iterator(); ++ while ( iter.hasNext() ) ++ { ++ Map.Entry me = ( Map.Entry )iter.next(); ++ ScriptItem item = (ScriptItem)me.getValue(); ++ SourceInfo si = item.getSourceInfo(); ++ if ( si.getUrl().equals( url ) ) ++ { ++ //match ++ scriptItems.remove( me.getKey() ); ++ break; ++ } ++ } ++ } ++ officeScripts.deleteScript( url ); ++ } ++ ++ ++ ScriptItem getScriptItem(DebuggableScript fnOrScript) { ++ ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); ++ if (item == null) { ++ String url = getNormilizedUrl(fnOrScript); ++ SourceInfo si = (SourceInfo)sourceNames.get(url); ++ if (si == null) { ++ if (!fnOrScript.isGeneratedScript()) { ++ // Not eval or Function, try to load it from URL ++ String source = null; ++ try { ++ InputStream is = openSource(url); ++ try { source = readSource(is); } ++ finally { is.close(); } ++ } catch (IOException ex) { ++ System.err.println ++ ("Failed to load source from "+url+": "+ ex); ++ } ++ if (source != null) { ++ si = registerSource(url, source); ++ } ++ } ++ } ++ if (si != null) { ++ item = registerScript(si, fnOrScript); ++ } ++ } ++ ++ return item; ++ } ++ ++ public void showScriptWindow(URL url ){ ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ if ( w != null ) ++ { ++ //w.maximize(); ++ desk.getDesktopManager().deiconifyFrame(w); ++ desk.getDesktopManager().activateFrame(w); ++ w.show(); ++ w.toFront(); ++ } ++ } ++ ++ public void highlighLineInScriptWindow(URL url, int lineNum ){ ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.getPath(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ if (w != null) ++ { ++ if ( lineNum > -1 ) ++ swingInvoke(new SetFilePosition(this, w, lineNum ) ); ++ } ++ } ++ public Object runScriptWindow( URL scriptUrl ) throws Exception ++ { ++ String key = scriptUrl.getPath(); ++ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = scriptUrl.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ Object result = null; ++ w.toFront(); ++ if (w != null) ++ { ++ //Scriptable scope = w.db.getScope(); ++ Scriptable scope = w.db.officeScripts.getScriptScope( key ); ++ if (scope == null) ++ { ++ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); ++ result = null; ++ } ++ else ++ { ++ String url = w.getUrl(); ++ Thread executorThread = null; ++ if (url != null) ++ { ++ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); ++ executor.run(); ++ result = executor.result; ++ if ( executor.exception != null ) ++ { ++ throw executor.exception; ++ } ++ } ++ } ++ } ++ return result; ++ ++ } ++ ++ public boolean isModified( URL url ) ++ { ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ return w.isModified(); ++ } ++ ++ public String getText( URL url ) ++ { ++ String key = url.toString(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ return w.getText(); ++ } ++ + } + +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008 +@@ -36,6 +36,7 @@ + package org.mozilla.javascript.tools.shell; + + import java.security.*; ++import java.security.cert.Certificate; + import java.net.MalformedURLException; + import java.net.URL; + import java.util.Hashtable; +@@ -124,7 +125,7 @@ + + public JavaPolicySecurity() { + // To trigger error on jdk-1.1 with lazy load +- new CodeSource(null, null); ++ new CodeSource(null, (Certificate [])null); + } + + protected void callProcessFileSecure(final Context cx, +@@ -167,7 +168,7 @@ + } + + private ProtectionDomain getUrlDomain(URL url) { +- CodeSource cs = new CodeSource(url, null); ++ CodeSource cs = new CodeSource(url, (Certificate [])null); + PermissionCollection pc = Policy.getPolicy().getPermissions(cs); + return new ProtectionDomain(cs, pc); + } diff --git a/rhino/ExternalPackage_rhino.mk b/rhino/ExternalPackage_rhino.mk deleted file mode 100644 index 0ee1d60e309d..000000000000 --- a/rhino/ExternalPackage_rhino.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_ExternalPackage_ExternalPackage,rhino,rhino)) - -$(eval $(call gb_ExternalPackage_use_external_project,rhino,rhino)) - -$(eval $(call gb_ExternalPackage_add_file,rhino,$(LIBO_SHARE_JAVA_FOLDER)/js.jar,build/rhino1_5R5/js.jar)) - -# vim: set noet sw=4 ts=4: diff --git a/rhino/ExternalProject_rhino.mk b/rhino/ExternalProject_rhino.mk deleted file mode 100644 index 3243ad93d538..000000000000 --- a/rhino/ExternalProject_rhino.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_ExternalProject_ExternalProject,rhino)) - -$(eval $(call gb_ExternalProject_register_targets,rhino,\ - build \ -)) - -$(call gb_ExternalProject_get_state_target,rhino,build) : - $(call gb_ExternalProject_run,build,\ - $(ICECREAM_RUN) "$(ANT)" \ - -q \ - -f build.xml \ - -Dbuild.label="build-$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)" \ - -DTARFILE_LOCATION="$(if $(findstring -cygwin,$(BUILD_PLATFORM)),$(shell cygpath -m $(TARFILE_LOCATION)),$(TARFILE_LOCATION))" \ - $(if $(filter yes,$(JAVACISGCJ))\ - ,-Dbuild.compiler=gcj \ - ,-Dant.build.javac.source=$(JAVA_SOURCE_VER) \ - -Dant.build.javac.target=$(JAVA_TARGET_VER) \ - ) \ - $(if $(debug),-Dbuild.debug="on") \ - jar \ - ) - -# vim: set noet sw=4 ts=4: diff --git a/rhino/Makefile b/rhino/Makefile deleted file mode 100644 index ccb1c85a04da..000000000000 --- a/rhino/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- - -module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) - -include $(module_directory)/../solenv/gbuild/partial_build.mk - -# vim: set noet sw=4 ts=4: diff --git a/rhino/Module_rhino.mk b/rhino/Module_rhino.mk deleted file mode 100644 index 201d3ba9fc90..000000000000 --- a/rhino/Module_rhino.mk +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_Module_Module,rhino)) - -ifneq ($(ENABLE_JAVA),) -ifneq ($(filter RHINO,$(BUILD_TYPE)),) -$(eval $(call gb_Module_add_targets,rhino,\ - ExternalPackage_rhino \ - ExternalProject_rhino \ - UnpackedTarball_rhino \ -)) -endif -endif - -# vim: set noet sw=4 ts=4: diff --git a/rhino/OfficeScriptInfo.java b/rhino/OfficeScriptInfo.java deleted file mode 100644 index eb1d78641d23..000000000000 --- a/rhino/OfficeScriptInfo.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 org.mozilla.javascript.tools.debugger; -import java.net.URL; -import java.util.HashMap; -import org.mozilla.javascript.Scriptable; - -public class OfficeScriptInfo -{ - private HashMap loadedSFScripts = new HashMap(); - - public void addScript( URL url, Scriptable scope, Runnable closeCallback ) - { - addScript( url.toString(), url, scope, closeCallback ); - } - - public void addScript( String key, URL url, Scriptable scope, Runnable closeCallback ) - { - SFScriptInfo si = loadedSFScripts.get( key ); - if ( si == null ) - { - si = new SFScriptInfo(); - si.url = url; - si.scope = scope; - si.closeCallback = closeCallback; - loadedSFScripts.put( key, si ); - } - } - - public void deleteScript( String key ) - { - SFScriptInfo info = loadedSFScripts.remove( key ); - if ( info != null ) - { - if ( info.closeCallback != null ) - { - System.out.println("** In removeSFScriptInfo have callback for " + key ); - info.closeCallback.run(); // really need to do this in separate thread???? - } - } - } - - public Scriptable getScriptScope( String key ) - { - Scriptable result = null; - SFScriptInfo info = loadedSFScripts.get( key ); - if ( info != null ) - { - result = info.scope; - } - return result; - } - - public URL getScriptUrl( String key ) - { - URL result = null; - SFScriptInfo info = loadedSFScripts.get( key ); - if ( info != null ) - { - result = info.url; - } - return result; - } - public boolean hasScript( String key ) - { - boolean result = true; - SFScriptInfo info = loadedSFScripts.get( key ); - if ( info == null ) - { - result = false; - } - return result; - } - - public void setScriptRunning( String key, boolean running ) - { - SFScriptInfo info = loadedSFScripts.get( key ); - if ( info != null ) - { - info.isExecuting = running; - } - } - - public boolean isScriptRunning( String key ) - { - boolean result = false; - SFScriptInfo info = loadedSFScripts.get( key ); - if ( info != null ) - { - result = info.isExecuting; - } - return result; - } - - class SFScriptInfo - { - Scriptable scope; - boolean isExecuting; - URL url; - Runnable closeCallback; - } -} diff --git a/rhino/README b/rhino/README deleted file mode 100644 index 83e4135d0b89..000000000000 --- a/rhino/README +++ /dev/null @@ -1,14 +0,0 @@ -JavaScript engine/interpreter written in Java, used to provide JavaScript extensions. - -The Scripting Framework makes use of the Rhino ([http://www.mozilla.org/rhino/]) -JavaScript interpreter, available under the Mozilla Public License -([http://www.mozilla.org/MPL/MPL-1.1.html]). - -In addition, to support the debugging of scripts contained in OpenOffice.org -documents, we have modified the Java source file Main.java. - -The Rhino source tarball is unpacked and patched with the modified code. The -Rhino Jar file (js.jar) is then built (download/swingExSrc.zip is unpacked and -built as part of this procesS) and delivered to the solver. The file -rhino1_5R5.patch contains the changes made in order to build Rhino. The patch -was generated using the command: diff -wurN diff --git a/rhino/UnpackedTarball_rhino.mk b/rhino/UnpackedTarball_rhino.mk deleted file mode 100644 index 4ee92d2bade9..000000000000 --- a/rhino/UnpackedTarball_rhino.mk +++ /dev/null @@ -1,24 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_UnpackedTarball_UnpackedTarball,rhino)) - -$(eval $(call gb_UnpackedTarball_set_tarball,rhino,$(RHINO_TARBALL),,rhino)) - -$(eval $(call gb_UnpackedTarball_set_patchlevel,rhino,2)) - -$(eval $(call gb_UnpackedTarball_add_patches,rhino,\ - rhino/rhino1_5R5.patch \ - rhino/rhino1_5R5-find_swing.patch \ - rhino/rhino1_5R5-updateToolTip.patch \ -)) - -$(eval $(call gb_UnpackedTarball_add_file,rhino,toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java,rhino/OfficeScriptInfo.java)) - -# vim: set noet sw=4 ts=4: diff --git a/rhino/rhino1_5R5-find_swing.patch b/rhino/rhino1_5R5-find_swing.patch deleted file mode 100644 index f074fa845490..000000000000 --- a/rhino/rhino1_5R5-find_swing.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- misc/rhino1_5R5/toolsrc/build.xml 2009-10-29 18:29:46.605524507 +0100 -+++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-10-29 18:29:26.536908810 +0100 -@@ -12,6 +12,7 @@ - - - -+ - - - -@@ -38,7 +42,7 @@ - -- -+ - - - diff --git a/rhino/rhino1_5R5-updateToolTip.patch b/rhino/rhino1_5R5-updateToolTip.patch deleted file mode 100644 index 16857d35fca6..000000000000 --- a/rhino/rhino1_5R5-updateToolTip.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Wed Feb 23 10:25:09 2011 -+++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Wed Feb 23 10:25:01 2011 -@@ -1045,9 +1045,18 @@ - } ); - } - -+ // Fix taken from -+ // toolsrc/org/mozilla/javascript/tools/debugger/SwingGui.java: - private void updateToolTip() { -- // in case fileName is very long, try to set tool tip on frame -- Component c = getComponent(1); -+ // Try to set tool tip on frame. On Mac OS X 10.5, -+ // the number of components is different, so try to be safe. -+ int n = getComponentCount() - 1; -+ if (n > 1) { -+ n = 1; -+ } else if (n < 0) { -+ return; -+ } -+ Component c = getComponent(n); - // this will work at least for Metal L&F - if (c != null && c instanceof JComponent) { - ((JComponent)c).setToolTipText(getUrl()); diff --git a/rhino/rhino1_5R5.patch b/rhino/rhino1_5R5.patch deleted file mode 100644 index 5b10c320d015..000000000000 --- a/rhino/rhino1_5R5.patch +++ /dev/null @@ -1,1071 +0,0 @@ ---- misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Thu Mar 25 21:54:34 2004 -+++ misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Fri Mar 28 17:24:23 2008 -@@ -38,6 +38,7 @@ - package org.mozilla.javascript; - - import java.lang.reflect.Method; -+import java.lang.reflect.InvocationTargetException; - - /** - * Load generated classes. -@@ -48,11 +49,34 @@ - implements GeneratedClassLoader - { - public DefiningClassLoader() { -- this.parentLoader = getClass().getClassLoader(); -+ init(getClass().getClassLoader()); - } - - public DefiningClassLoader(ClassLoader parentLoader) { -+ -+ init(parentLoader); -+ } -+ -+ private void init(ClassLoader parentLoader) { -+ - this.parentLoader = parentLoader; -+ -+ this.contextLoader = null; -+ if (method_getContextClassLoader != null) { -+ try { -+ this.contextLoader = (ClassLoader) -+ method_getContextClassLoader.invoke( -+ Thread.currentThread(), -+ ScriptRuntime.emptyArgs); -+ } catch (IllegalAccessException ex) { -+ } catch (InvocationTargetException ex) { -+ } catch (SecurityException ex) { -+ } -+ if (this.contextLoader == this.parentLoader) { -+ this.contextLoader = null; -+ } -+ } -+ - } - - public Class defineClass(String name, byte[] data) { -@@ -68,10 +92,20 @@ - { - Class cl = findLoadedClass(name); - if (cl == null) { -- if (parentLoader != null) { -- cl = parentLoader.loadClass(name); -+ // First try parent class loader and if that does not work, try -+ // contextLoader, but that will be null if -+ // Thread.getContextClassLoader() == parentLoader -+ // or on JDK 1.1 due to lack Thread.getContextClassLoader(). -+ // To avoid catching and rethrowing ClassNotFoundException -+ // in this cases, use try/catch check only if contextLoader != null. -+ if (contextLoader == null) { -+ cl = loadFromParent(name); - } else { -- cl = findSystemClass(name); -+ try { -+ cl = loadFromParent(name); -+ } catch (ClassNotFoundException ex) { -+ cl = contextLoader.loadClass(name); -+ } - } - } - if (resolve) { -@@ -80,5 +114,37 @@ - return cl; - } - -+ private Class loadFromParent(String name) -+ throws ClassNotFoundException -+ { -+ if (parentLoader != null) { -+ return parentLoader.loadClass(name); -+ } else { -+ return findSystemClass(name); -+ } -+ -+ } -+ - private ClassLoader parentLoader; -+ -+ private ClassLoader contextLoader; -+ -+ // We'd like to use "Thread.getContextClassLoader", but -+ // that's only available on Java2. -+ private static Method method_getContextClassLoader; -+ -+ static { -+ try { -+ // Don't use "Thread.class": that performs the lookup -+ // in the class initializer, which doesn't allow us to -+ // catch possible security exceptions. -+ Class threadClass = Class.forName("java.lang.Thread"); -+ method_getContextClassLoader = -+ threadClass.getDeclaredMethod("getContextClassLoader", -+ new Class[0]); -+ } catch (ClassNotFoundException e) { -+ } catch (NoSuchMethodException e) { -+ } catch (SecurityException e) { -+ } -+ } - } ---- misc/rhino1_5R5/toolsrc/build.xml 2004-03-25 21:54:34.000000000 +0100 -+++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-01-17 20:46:44.000000000 +0100 -@@ -6,6 +6,24 @@ - --> - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -@@ -20,46 +38,10 @@ - -- -- -+ - - - -- -- import java.awt.Component; -- -- package org.mozilla.javascript.tools.debugger; -- import java.awt.Component; -- -- -- -- import javax.swing.tree.*; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.tree.*; -- -- -- -- import javax.swing.*; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.*; -- -- -- -- import javax.swing.tree.TreeModel; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.tree.TreeModel; -- -- -- -- import javax.swing.JTree; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.JTree; -- -- - - - -@@ -68,6 +50,7 @@ - includes="org/**/*.java" - deprecation="on" - debug="${debug}"> -+ - - - ---- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2004-03-25 21:54:34.000000000 +0100 -+++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2009-01-17 20:44:22.000000000 +0100 -@@ -470,15 +470,21 @@ - case KeyEvent.VK_BACK_SPACE: - case KeyEvent.VK_ENTER: - case KeyEvent.VK_DELETE: -+ if (w.isEditable() == false) { - e.consume(); -+ } - break; - } - } - public void keyTyped(KeyEvent e) { -+ if (w.isEditable() == false) { - e.consume(); -+ } - } - public void keyReleased(KeyEvent e) { -+ if (w.isEditable() == false) { - e.consume(); -+ } - } - } - -@@ -879,7 +885,7 @@ - } - }; - --class FileWindow extends JInternalFrame implements ActionListener { -+class FileWindow extends JInternalFrame implements ActionListener, DocumentListener { - - Main db; - SourceInfo sourceInfo; -@@ -888,15 +894,16 @@ - JScrollPane p; - int currentPos; - JLabel statusBar; -+ boolean isModified = false; - - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - if (cmd.equals("Cut")) { -- // textArea.cut(); -+ textArea.cut(); - } else if (cmd.equals("Copy")) { - textArea.copy(); - } else if (cmd.equals("Paste")) { -- // textArea.paste(); -+ textArea.paste(); - } - } - -@@ -910,17 +917,73 @@ - } - - void load() { -- Scriptable scope = db.getScope(); -+ //Scriptable scope = db.getScope(); -+ Scriptable scope = db.officeScripts.getScriptScope( getUrl() ); -+ if ( scope == null ) -+ { -+ scope = db.getScope(); -+ } - if (scope == null) { - MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); - } else { - String url = getUrl(); - if (url != null) { -- new Thread(new LoadFile(db,scope,url)).start(); -+ new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start(); - } - } - } - -+ void save() { -+ if (getUrl() != null) { -+ OutputStream os = null; -+ try { -+ if ( getUrl().startsWith("vnd.sun.star") ) -+ { -+ URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() ); -+ if ( scriptUrl == null ) -+ { -+ throw new IOException("Can't optain stream for " + getUrl() ); -+ } -+ os = scriptUrl.openConnection().getOutputStream(); -+ } -+ else -+ { -+ os = new FileOutputStream( getUrl() ); -+ } -+ String s = textArea.getText(); -+ os.write(s.getBytes(), 0, s.length()); -+ -+ this.isModified = false; -+ } -+ catch (IOException ioe) { -+ JOptionPane.showMessageDialog(this, -+ "Error saving file: " + ioe.getMessage(), -+ "Error", JOptionPane.ERROR_MESSAGE); -+ } -+ finally -+ { -+ if ( os != null ) -+ { -+ try -+ { -+ os.close(); -+ os = null; -+ } -+ catch( IOException ioe ) -+ { -+ System.err.println("Error closing stream: " + ioe.getMessage() ); -+ ioe.printStackTrace(); -+ } -+ } -+ } -+ } -+ } -+ -+ public boolean isEditable() { -+ return db.isSourceEditingEnabled(); -+ } -+ -+ - public int getPosition(int line) { - int result = -1; - try { -@@ -953,7 +1016,7 @@ - fileHeader.repaint(); - } - } -- -+ public Main getDB() { return db; } - FileWindow(Main db, SourceInfo sourceInfo) { - super(SourceInfo.getShortName(sourceInfo.getUrl()), - true, true, true, true); -@@ -972,6 +1035,14 @@ - pack(); - updateText(); - textArea.select(0); -+ addInternalFrameListener( new InternalFrameAdapter() { -+ public void internalFrameClosed(InternalFrameEvent e) { -+ // clean up scriptItems and sourceNames hashes -+ getDB().removeScript( getUrl() ); -+ // remove scripts for officeScripts -+ getDB().officeScripts.deleteScript( getUrl() ); -+ } -+ } ); - } - - private void updateToolTip() { -@@ -990,7 +1061,10 @@ - void updateText() { - String newText = sourceInfo.getSource(); - if (!textArea.getText().equals(newText)) { -+ textArea.getDocument().removeDocumentListener(this); - textArea.setText(newText); -+ this.isModified = false; -+ textArea.getDocument().addDocumentListener(this); - int pos = 0; - if (currentPos != -1) { - pos = currentPos; -@@ -1001,6 +1075,31 @@ - fileHeader.repaint(); - } - -+ /* Implementation of DocumentListener interface */ -+ public void insertUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void removeUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void changedUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void doChanged(DocumentEvent e) { -+ this.isModified = true; -+ } -+ -+ public boolean isModified() { -+ return this.isModified; -+ } -+ -+ public String getText() { -+ return textArea.getText(); -+ } -+ - void setPosition(int pos) { - textArea.select(pos); - currentPos = pos; -@@ -1618,7 +1717,7 @@ - if (line != -1) { - db.currentWindow = w; - } -- db.menubar.addFile(url); -+ // db.menubar.addFile(url); - w.setVisible(true); - if (activate) { - try { -@@ -1752,8 +1851,10 @@ - Menubar(Main db) { - super(); - this.db = db; -- String[] fileItems = {"Open...", "Run...", "", "Exit"}; -- String[] fileCmds = {"Open", "Load", "", "Exit"}; -+ // String[] fileItems = {"Open...", "Run...", "", "Exit"}; -+ // String[] fileCmds = {"Open", "Load", "", "Exit"}; -+ String[] fileItems = {"Run", "Save", "", "Exit"}; -+ String[] fileCmds = {"Run", "Save", "", "Exit"}; - char[] fileShortCuts = {'0', 'N', '\0', 'X'}; - int[] fileAccelerators = {KeyEvent.VK_O, - KeyEvent.VK_N, -@@ -1795,6 +1896,9 @@ - KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK); - item.setAccelerator(k); - } -+ if (fileItems[i].equals("Save")) { -+ saveItem = item; -+ } - } - } - for (int i = 0; i < editItems.length; ++i) { -@@ -1849,9 +1953,9 @@ - item.addActionListener(this); - windowMenu.add(item = new JMenuItem("Tile", 'T')); - item.addActionListener(this); -- windowMenu.addSeparator(); -- windowMenu.add(item = new JMenuItem("Console", 'C')); -- item.addActionListener(this); -+// windowMenu.addSeparator(); -+// windowMenu.add(item = new JMenuItem("Console", 'C')); -+// item.addActionListener(this); - add(windowMenu); - - } -@@ -1925,11 +2029,16 @@ - item.addActionListener(this); - } - -+ public void setSaveEnabled(boolean state) { -+ saveItem.setEnabled(state); -+ } -+ - Main db; - JMenu windowMenu; - JCheckBoxMenuItem breakOnExceptions; - JCheckBoxMenuItem breakOnEnter; - JCheckBoxMenuItem breakOnReturn; -+ JMenuItem saveItem; - }; - - class EnterInterrupt implements Runnable { -@@ -1942,6 +2051,13 @@ - public void run() { - JMenu menu = db.getJMenuBar().getMenu(0); - //menu.getItem(0).setEnabled(false); // File->Load -+ -+ // disable Edit menu Cut, Copy, Paste items -+ menu = db.getJMenuBar().getMenu(1); -+ for (int i = 0; i < 3; i++) { -+ menu.getItem(i).setEnabled(false); -+ } -+ - menu = db.getJMenuBar().getMenu(2); - menu.getItem(0).setEnabled(false); // Debug->Break - int count = menu.getItemCount(); -@@ -1954,6 +2070,10 @@ - b = true; - } - db.toolBar.setEnabled(true); -+ -+ // set flag to disable source editing -+ db.setSourceEditingEnabled(false); -+ - // raise the debugger window - db.toFront(); - } -@@ -1967,6 +2087,13 @@ - public void run() { - JMenu menu = db.getJMenuBar().getMenu(0); - menu.getItem(0).setEnabled(true); // File->Load -+ -+ // enable Edit menu items -+ menu = db.getJMenuBar().getMenu(1); -+ for (int i = 0; i < 3; i++) { -+ menu.getItem(i).setEnabled(true); -+ } -+ - menu = db.getJMenuBar().getMenu(2); - menu.getItem(0).setEnabled(true); // Debug->Break - int count = menu.getItemCount() - 1; -@@ -1980,6 +2107,10 @@ - db.toolBar.getComponent(ci).setEnabled(b); - b = false; - } -+ -+ // set flag to enable source editing -+ db.setSourceEditingEnabled(true); -+ - //db.console.consoleTextArea.requestFocus(); - } - }; -@@ -1988,17 +2119,24 @@ - { - String fileName; - Main db; -+ Reader reader = null; - OpenFile(Main db, String fileName) - { - this.fileName = fileName; - this.db = db; - } -+ OpenFile(Main db, String fileName, Reader reader) { -+ this(db, fileName); -+ this.reader = reader; -+ } - public void run() { - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); - contextData.breakNextLine = true; - try { -- cx.compileReader(new FileReader(fileName), fileName, 1, null); -+ cx.compileReader( -+ reader == null ? new FileReader(fileName) : reader, -+ fileName, 1, null); - } catch (Exception exc) { - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { -@@ -2019,29 +2157,79 @@ - Scriptable scope; - String fileName; - Main db; -+ Reader reader = null; -+ Object result = null; -+ Exception exception = null; -+ int lineNum = -1; -+ boolean sfExecute = false; -+ - LoadFile(Main db, Scriptable scope, String fileName) { - this.scope = scope; - this.fileName = fileName; - this.db = db; - } -+ -+ LoadFile(Main db, Scriptable scope, String fileName, Reader reader) { -+ this(db, scope, fileName); -+ this.reader = reader; -+ } -+ LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) { -+ this(db, scope, fileName); -+ this.reader = reader; -+ this.sfExecute = sfExecute; -+ } -+ - public void run() { -+ if ( db.officeScripts.isScriptRunning( fileName ) ) -+ { -+ exception = new Exception("The script is already executing"); -+ if ( !sfExecute ) { -+ MessageDialogWrapper.showMessageDialog(db, -+ "Script already executing", -+ "Run", -+ JOptionPane.ERROR_MESSAGE); -+ } -+ return; -+ } -+ db.officeScripts.setScriptRunning( fileName, true ); - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); -+ if ( sfExecute ) -+ { -+ contextData.breakNextLine = false; -+ } -+ else -+ { - contextData.breakNextLine = true; -+ } -+ /* -+ FileWindow w = (FileWindow)db.getSelectedFrame(); -+ if ( sfExecute ) -+ { -+ db.swingInvoke(new SetFilePosition(db, w, -1 ) ); -+ }*/ - try { -- cx.evaluateReader(scope, new FileReader(fileName), -+ result = cx.evaluateReader(scope, -+ reader == null ? new FileReader(fileName) : reader, - fileName, 1, null); - } catch (Exception exc) { -+ exception = exc; - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { - EcmaError err = (EcmaError)exc; - msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg; -- } -+ -+ int lineNum = err.getLineNumber() ; -+ //db.swingInvoke(new SetFilePosition(db, w, lineNum ) ); -+ if ( !sfExecute ) { - MessageDialogWrapper.showMessageDialog(db, - msg, - "Run", - JOptionPane.ERROR_MESSAGE); -+ } -+ } - } finally { -+ db.officeScripts.setScriptRunning( fileName, false ); - cx.exit(); - } - } -@@ -2416,13 +2604,13 @@ - super.setVisible(b); - if (b) { - // this needs to be done after the window is visible -- console.consoleTextArea.requestFocus(); -+ // console.consoleTextArea.requestFocus(); - context.split.setDividerLocation(0.5); - try { -- console.setMaximum(true); -- console.setSelected(true); -- console.show(); -- console.consoleTextArea.requestFocus(); -+ // console.setMaximum(true); -+ // console.setSelected(true); -+ // console.show(); -+ // console.consoleTextArea.requestFocus(); - } catch (Exception exc) { - } - } -@@ -2449,35 +2637,6 @@ - - Hashtable functionNames = new Hashtable(); - -- ScriptItem getScriptItem(DebuggableScript fnOrScript) { -- ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); -- if (item == null) { -- String url = getNormilizedUrl(fnOrScript); -- SourceInfo si = (SourceInfo)sourceNames.get(url); -- if (si == null) { -- if (!fnOrScript.isGeneratedScript()) { -- // Not eval or Function, try to load it from URL -- String source = null; -- try { -- InputStream is = openSource(url); -- try { source = readSource(is); } -- finally { is.close(); } -- } catch (IOException ex) { -- System.err.println -- ("Failed to load source from "+url+": "+ ex); -- } -- if (source != null) { -- si = registerSource(url, source); -- } -- } -- } -- if (si != null) { -- item = registerScript(si, fnOrScript); -- } -- } -- return item; -- } -- - /* Debugger Interface */ - - public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, -@@ -2490,7 +2649,7 @@ - - String getNormilizedUrl(DebuggableScript fnOrScript) { - String url = fnOrScript.getSourceName(); -- if (url == null) { url = ""; } -+ if (url == null) { url = "document"; } - else { - // Not to produce window for eval from different lines, - // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval) -@@ -2601,7 +2760,7 @@ - if (si == null) { - si = new SourceInfo(sourceUrl, source); - sourceNames.put(sourceUrl, si); -- } else { -+ } else if (!source.equals(si.getSource())) { - si.setSource(source); - } - } -@@ -2762,7 +2921,7 @@ - desk = new JDesktopPane(); - desk.setPreferredSize(new Dimension(600, 300)); - desk.setMinimumSize(new Dimension(150, 50)); -- desk.add(console = new JSInternalConsole("JavaScript Console")); -+ // desk.add(console = new JSInternalConsole("JavaScript Console")); - context = new ContextWindow(this); - context.setPreferredSize(new Dimension(600, 120)); - context.setMinimumSize(new Dimension(50, 50)); -@@ -2871,7 +3030,7 @@ - FrameHelper frame = contextData.getFrame(frameIndex); - String sourceName = frame.getUrl(); - if (sourceName == null || sourceName.equals("")) { -- console.show(); -+ // console.show(); - helper.reset(); - return; - } -@@ -2895,6 +3054,19 @@ - int dispatcherIsWaiting = 0; - Context currentContext = null; - -+ // Flag used to establish whether source code editing is allowed in -+ // the debugger, switched on and off depending on whether a debug session -+ // is active -+ boolean sourceEditingEnabled = true; -+ -+ public boolean isSourceEditingEnabled() { -+ return sourceEditingEnabled; -+ } -+ -+ void setSourceEditingEnabled(boolean b) { -+ sourceEditingEnabled = b; -+ } -+ - Context getCurrentContext() { - return currentContext; - } -@@ -3028,14 +3200,14 @@ - swingInvoke(CreateFileWindow.action(this, si, line)); - } - } else { -- if (console.isVisible()) { -+ /* if (console.isVisible()) { - final JSInternalConsole finalConsole = console; - swingInvoke(new Runnable() { - public void run() { - finalConsole.show(); - } - }); -- } -+ } */ - } - swingInvoke(new EnterInterrupt(this, cx)); - swingInvoke(new UpdateContext(this, cx)); -@@ -3217,6 +3389,14 @@ - fileName)).start(); - } - } -+ } else if (cmd.equals("Run")) { -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ w.load(); -+ } else if (cmd.equals("Save")) { -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ w.save(); - } else if (cmd.equals("More Windows...")) { - MoreWindows dlg = new MoreWindows(this, fileWindows, - "Window", "Files"); -@@ -3509,6 +3689,60 @@ - } - } - -+ JInternalFrame getFrameForUrl( URL url ) -+ { -+ JInternalFrame[] frames = desk.getAllFrames(); -+ for (int i = 0; i < frames.length; i++) { -+ FileWindow w = (FileWindow)frames[i]; -+ if ( url.toString().equals( w.getUrl() ) ) { -+ return w; -+ } -+ } -+ return null; -+ } -+ public void highlighLineInSelectedWindow(URL url, int lineNum ){ -+ //FileWindow w = (FileWindow)getFrameForUrl( url ); -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ { -+ if ( lineNum > -1 ) -+ swingInvoke(new SetFilePosition(this, w, lineNum ) ); -+ } -+ } -+ public Object runSelectedWindow( URL scriptUrl ) throws Exception -+ { -+ Object result = null; -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl ); -+ w.toFront(); -+ if (w != null) -+ { -+ Scriptable scope = w.db.getScope(); -+ if (scope == null) -+ { -+ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); -+ result = null; -+ } -+ else -+ { -+ String url = w.getUrl(); -+ Thread executorThread = null; -+ if (url != null) -+ { -+ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); -+ executor.run(); -+ result = executor.result; -+ if ( executor.exception != null ) -+ { -+ throw executor.exception; -+ } -+ } -+ } -+ } -+ return result; -+ -+ } -+ - // - // public interface - // -@@ -3604,6 +3838,69 @@ - return console.getErr(); - } - -+ public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) { -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (scriptUrl != null) { -+ try -+ { -+ InputStreamReader reader = new InputStreamReader(scriptUrl.openStream()); -+ String fileName = null; -+ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") ) -+ { -+ fileName = scriptUrl.toString(); -+ } -+ else -+ { -+ fileName = scriptUrl.getPath(); -+ } -+ officeScripts.addScript( fileName, scriptUrl, scope, closeCallback ); -+ //new Thread(new OpenFile(this, scope, fileName, reader )).start(); -+ swingInvoke( new OpenFile(this, fileName, reader )); -+ } -+ catch ( IOException e ) -+ { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't open stream for script: " + e.toString(), -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } -+ } -+ } -+ split1.setDividerLocation(1.0); -+ } -+ -+ public void openFile(String fileName) { -+ Scriptable scope = getScope(); -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (fileName != null) { -+ new Thread(new OpenFile(this, fileName)).start(); -+ } -+ } -+ split1.setDividerLocation(1.0); -+ } -+ -+ public void openStream(InputStream in) { -+ Scriptable scope = getScope(); -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (in != null) { -+ new Thread(new OpenFile(this, null, new InputStreamReader(in))).start(); -+ } -+ } -+ split1.setDividerLocation(1.0); -+ menubar.setSaveEnabled(false); -+ } -+ - public static void main(String[] args) { - try { - mainThread = Thread.currentThread(); -@@ -3635,5 +3932,162 @@ - } - } - -+ // patched Office specific interface -+ -+ OfficeScriptInfo officeScripts = new OfficeScriptInfo(); -+ -+ void removeScript( String url ) -+ { -+ // Remove the FileWindow from list of open sources -+ fileWindows.remove( url ); -+ -+ // Remove sourceInfo from sourceNames, ensures that -+ // breakpoints etc are deleted -+ synchronized (sourceNames) { -+ sourceNames.remove( url ); -+ } -+ // Removes scriptItems for the script, ensures that a new open ( from openFile ) -+ // will succeed, openFile should open file but fails due to fact that -+ synchronized ( scriptItems ) -+ { -+ Iterator iter = scriptItems.entrySet().iterator(); -+ while ( iter.hasNext() ) -+ { -+ Map.Entry me = ( Map.Entry )iter.next(); -+ ScriptItem item = (ScriptItem)me.getValue(); -+ SourceInfo si = item.getSourceInfo(); -+ if ( si.getUrl().equals( url ) ) -+ { -+ //match -+ scriptItems.remove( me.getKey() ); -+ break; -+ } -+ } -+ } -+ officeScripts.deleteScript( url ); -+ } -+ -+ -+ ScriptItem getScriptItem(DebuggableScript fnOrScript) { -+ ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); -+ if (item == null) { -+ String url = getNormilizedUrl(fnOrScript); -+ SourceInfo si = (SourceInfo)sourceNames.get(url); -+ if (si == null) { -+ if (!fnOrScript.isGeneratedScript()) { -+ // Not eval or Function, try to load it from URL -+ String source = null; -+ try { -+ InputStream is = openSource(url); -+ try { source = readSource(is); } -+ finally { is.close(); } -+ } catch (IOException ex) { -+ System.err.println -+ ("Failed to load source from "+url+": "+ ex); -+ } -+ if (source != null) { -+ si = registerSource(url, source); -+ } -+ } -+ } -+ if (si != null) { -+ item = registerScript(si, fnOrScript); -+ } -+ } -+ -+ return item; -+ } -+ -+ public void showScriptWindow(URL url ){ -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ if ( w != null ) -+ { -+ //w.maximize(); -+ desk.getDesktopManager().deiconifyFrame(w); -+ desk.getDesktopManager().activateFrame(w); -+ w.show(); -+ w.toFront(); -+ } -+ } -+ -+ public void highlighLineInScriptWindow(URL url, int lineNum ){ -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.getPath(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ if (w != null) -+ { -+ if ( lineNum > -1 ) -+ swingInvoke(new SetFilePosition(this, w, lineNum ) ); -+ } -+ } -+ public Object runScriptWindow( URL scriptUrl ) throws Exception -+ { -+ String key = scriptUrl.getPath(); -+ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = scriptUrl.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ Object result = null; -+ w.toFront(); -+ if (w != null) -+ { -+ //Scriptable scope = w.db.getScope(); -+ Scriptable scope = w.db.officeScripts.getScriptScope( key ); -+ if (scope == null) -+ { -+ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); -+ result = null; -+ } -+ else -+ { -+ String url = w.getUrl(); -+ Thread executorThread = null; -+ if (url != null) -+ { -+ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); -+ executor.run(); -+ result = executor.result; -+ if ( executor.exception != null ) -+ { -+ throw executor.exception; -+ } -+ } -+ } -+ } -+ return result; -+ -+ } -+ -+ public boolean isModified( URL url ) -+ { -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ return w.isModified(); -+ } -+ -+ public String getText( URL url ) -+ { -+ String key = url.toString(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ return w.getText(); -+ } -+ - } - ---- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004 -+++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008 -@@ -36,6 +36,7 @@ - package org.mozilla.javascript.tools.shell; - - import java.security.*; -+import java.security.cert.Certificate; - import java.net.MalformedURLException; - import java.net.URL; - import java.util.Hashtable; -@@ -124,7 +125,7 @@ - - public JavaPolicySecurity() { - // To trigger error on jdk-1.1 with lazy load -- new CodeSource(null, null); -+ new CodeSource(null, (Certificate [])null); - } - - protected void callProcessFileSecure(final Context cx, -@@ -167,7 +168,7 @@ - } - - private ProtectionDomain getUrlDomain(URL url) { -- CodeSource cs = new CodeSource(url, null); -+ CodeSource cs = new CodeSource(url, (Certificate [])null); - PermissionCollection pc = Policy.getPolicy().getPermissions(cs); - return new ProtectionDomain(cs, pc); - } -- cgit