summaryrefslogtreecommitdiff
path: root/scripting/java
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/java')
-rw-r--r--scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java541
-rw-r--r--scripting/java/ScriptFramework.component34
-rw-r--r--scripting/java/ScriptProviderForBeanShell.component37
-rw-r--r--scripting/java/ScriptProviderForJava.component37
-rw-r--r--scripting/java/ScriptProviderForJavaScript.component37
-rw-r--r--scripting/java/build.env3
-rwxr-xr-xscripting/java/build.xml285
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/DialogFactory.java423
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java376
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java65
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java291
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java335
-rw-r--r--scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java231
-rw-r--r--scripting/java/com/sun/star/script/framework/container/Parcel.java308
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParcelContainer.java746
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java450
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java36
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ScriptEntry.java128
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java410
-rw-r--r--scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java438
-rw-r--r--scripting/java/com/sun/star/script/framework/container/XMLParser.java38
-rw-r--r--scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java180
-rw-r--r--scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java281
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java119
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java102
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java128
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XStorageHelper.java278
-rw-r--r--scripting/java/com/sun/star/script/framework/log/LogUtils.java68
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java74
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java100
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java53
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/PathUtils.java87
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptContext.java165
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java13
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/ScriptProvider.java745
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java247
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java412
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java383
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java141
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceView.java35
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/template.bsh48
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/Resolver.java50
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java212
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java364
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java92
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java128
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java376
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java358
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/template.js37
-rwxr-xr-xscripting/java/makefile.mk72
-rw-r--r--scripting/java/manifest.mf26
-rw-r--r--scripting/java/org/openoffice/idesupport/CommandLineTools.java350
-rw-r--r--scripting/java/org/openoffice/idesupport/ExtensionFinder.java60
-rw-r--r--scripting/java/org/openoffice/idesupport/JavaFinder.java227
-rw-r--r--scripting/java/org/openoffice/idesupport/LocalOffice.java109
-rw-r--r--scripting/java/org/openoffice/idesupport/MethodFinder.java8
-rw-r--r--scripting/java/org/openoffice/idesupport/OfficeDocument.java120
-rw-r--r--scripting/java/org/openoffice/idesupport/OfficeInstallation.java110
-rw-r--r--scripting/java/org/openoffice/idesupport/SVersionRCFile.java237
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/AllFilesFilter.java47
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java58
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java59
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/FileFilter.java32
-rw-r--r--scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java154
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java236
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/MethodPanel.java186
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java206
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/add.gifbin0 -> 103 bytes
-rw-r--r--scripting/java/org/openoffice/idesupport/xml/Manifest.java171
-rw-r--r--scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java600
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/JavaKit.java248
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java209
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/OOo.jcb5
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/OOo.jcs21
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/Bundle.properties0
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/Bundle_en_US.properties0
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java69
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java44
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java70
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java244
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java85
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java84
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java42
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java143
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java42
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java141
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java42
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java121
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java42
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java257
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java191
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties44
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle_en_US.properties0
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java1192
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java125
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties13
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java112
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoaderBeanInfo.java72
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java120
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java58
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java137
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java82
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoaderBeanInfo.java76
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java89
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoaderBeanInfo.java76
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java114
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java77
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java91
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoaderBeanInfo.java76
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataNode.java81
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java83
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java303
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java112
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoaderBeanInfo.java76
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java147
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java91
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java209
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties14
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java133
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java147
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon.gifbin0 -> 145 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon32.gifbin0 -> 253 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.html11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.settings7
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties24
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/EmptyParcel.html11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gifbin0 -> 588 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon32.gifbin0 -> 759 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeSettings.settings9
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.html11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.settings7
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon.pngbin0 -> 702 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon32.pngbin0 -> 1533 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/ParcelIcon.gifbin0 -> 576 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcel.html11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcelDescriptor.html11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/layer.xml98
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/mime-resolver.xml16
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/office-scripting.url1
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.bsh_24
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.java_27
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/templates/EmptyParcelDescriptor.xml_4
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_41
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/resources/templates/ParcelDescriptor.xml_8
-rwxr-xr-xscripting/java/org/openoffice/netbeans/modules/office/resources/webLink.gifbin0 -> 969 bytes
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java140
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java97
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java127
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java68
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java106
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java92
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties27
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle_en_US.properties0
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java72
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java136
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java250
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java254
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java117
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form74
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java157
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java123
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form82
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java196
163 files changed, 22082 insertions, 0 deletions
diff --git a/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java b/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java
new file mode 100644
index 000000000000..242c800b48db
--- /dev/null
+++ b/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java
@@ -0,0 +1,541 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.security;
+
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.script.framework.log.LogUtils;
+
+public class SecurityDialog extends WeakBase implements XComponent, XServiceInfo, XDialog,
+XInitialization {
+
+ static final String __serviceName = "com.sun.star.script.framework.security.SecurityDialog";
+
+ private static final String _label1Name = "Label1";
+ private static final String _label1String = "This document contains macros. Do you want to allow these macros to be run?";
+
+ private static final String _label2Name = "Label2";
+ private static final String _label2String = "This document contains macros. According to the security settings, the";
+ private static final String _label3Name = "Label3";
+ private static final String _label3String = "macros in this document should not be run. Do you want to run them";
+ private static final String _label4Name = "Label4";
+ private static final String _label4String = "anyway?";
+
+ private static final String _checkBoxName = "CheckBox";
+ private static final String _checkBoxString = "Add this directory to the list of secure paths: ";
+ private static final String _label5Name = "Label5";
+
+ private static final String _title = "Run Macro";
+ private static final String _runMacro = "Run";
+ private static final String _runButtonName = "Run";
+ private static final String _doNotRunMacro = "Do Not Run";
+ private static final String _doNotRunButtonName = "DoNotRun";
+
+ private static final int dialogX = 100;
+ private static final int dialogY = 100;
+ private static final int dialogW = 235;
+ private static final int dialogH = 47;
+
+ private int cbIncrW = -20;
+ private int cbIncrH = 19;
+
+ private static final int runButtonW = 40;
+ private static final int runButtonH = 13;
+ private static final int doNotRunButtonW = 40;
+ private static final int doNotRunButtonH = 13;
+
+ // label for warning dialog
+ private static final int label1X = 20;
+ private static final int label1Y = 9;
+ private static final int label1W = 210;
+ private static final int label1H = 10;
+
+ // labels for confirmation dialog
+ private static final int label2X = 22;
+ private static final int label2Y = 7;
+ private static final int label2W = 210;
+ private static final int label2H = 8;
+ private static final int label3X = 22;
+ private static final int label3Y = 15;
+ private static final int label3W = 210;
+ private static final int label3H = 8;
+ private static final int label4X = 22;
+ private static final int label4Y = 23;
+ private static final int label4W = 210;
+ private static final int label4H = 8;
+
+ // checkbox for confirmation dialog
+ private static final int checkBoxX = 22;
+ private static final int checkBoxY = 40;
+ private static final int checkBoxW = 210;
+ private static final int checkBoxH = 9;
+ // extra label if path longer than 21 chars
+ private static final int label5X = 22;
+ private static final int label5Y = 48;
+ private static final int label5W = 210;
+ private static final int label5H = 9;
+
+ private boolean checkBoxDialog;
+ private short _checkBoxState = 0;
+ private boolean extraPathLine=false;
+ private String checkBoxPath="";
+ private String checkBoxPath2="";
+ private static final int lineWrapLength = 21;
+ private static final int lineWrapH = 12;
+ private String _pushed = _doNotRunButtonName;
+
+ private XComponentContext _xComponentContext;
+ private XDialog _xDialog;
+
+ public SecurityDialog( XComponentContext xComponentContext )
+ {
+ LogUtils.DEBUG( "SecurityDialog ctor" );
+ _xComponentContext = xComponentContext;
+ }
+
+ public void initialize( Object[] args ) throws RuntimeException
+ {
+ LogUtils.DEBUG( "SecurityDialog init" );
+ // figure out if we need a checkbox
+ if ( args.length == 1 && AnyConverter.isString( args[0] ) )
+ {
+ //check args is a path
+ // set checkBoxPath with the arg
+ LogUtils.DEBUG( "checkbox" );
+ try
+ {
+ checkBoxPath = AnyConverter.toString( args[0] );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ throw new RuntimeException( "SecurityDialog::initialize: " + e.getMessage() );
+ }
+ LogUtils.DEBUG( "path: " + checkBoxPath );
+ checkBoxDialog = true;
+ if( checkBoxPath.length() > lineWrapLength )
+ {
+ extraPathLine = true;
+ cbIncrH += lineWrapH;
+ checkBoxPath2 = checkBoxPath.substring( lineWrapLength );
+ checkBoxPath = checkBoxPath.substring( 0, lineWrapLength );
+ }
+
+ }
+ else
+ {
+ LogUtils.DEBUG( "no checkbox: # of args=" +
+ args.length );
+ cbIncrW = 0;
+ cbIncrH = 0;
+ checkBoxDialog = false;
+ }
+
+ // now try and create the dialog
+ try
+ {
+ _xDialog = createDialog();
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG( "Couldn't create dialog" );
+ LogUtils.DEBUG( "uno message: " + e.getMessage());
+ throw new RuntimeException( e.getMessage() );
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( "Couldn't create dialog" );
+ LogUtils.DEBUG( "message: " + e.getMessage());
+ throw new RuntimeException( e.getMessage() );
+ }
+
+ }
+
+ // static component operations
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey ) {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if ( implName.equals( SecurityDialog.class.getName() ) ) {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ SecurityDialog.class, SecurityDialog.__serviceName, multiFactory, regKey );
+ }
+ return xSingleServiceFactory;
+ }
+
+ // XServiceInfo
+ public String getImplementationName( ) {
+ return getClass().getName();
+ }
+
+ // XServiceInfo
+ public boolean supportsService( /*IN*/String serviceName ) {
+ if ( serviceName.equals( __serviceName))
+ return true;
+ return false;
+ }
+
+ // XServiceInfo
+ public String[] getSupportedServiceNames( ) {
+ String[] retValue= new String[0];
+ retValue[0] = __serviceName;
+ return retValue;
+ }
+
+
+ /** method for creating a dialog at runtime
+ */
+ private XDialog createDialog() throws com.sun.star.uno.Exception {
+
+ // get the service manager from the component context
+ XMultiComponentFactory xMultiComponentFactory = _xComponentContext.getServiceManager();
+
+ // create the dialog model and set the properties
+ Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", _xComponentContext );
+ XPropertySet xPSetDialog = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, dialogModel );
+ xPSetDialog.setPropertyValue( "PositionX", new Integer( dialogX) );
+ xPSetDialog.setPropertyValue( "PositionY", new Integer( dialogY));
+ xPSetDialog.setPropertyValue( "Width", new Integer( dialogW+cbIncrW ));
+ xPSetDialog.setPropertyValue( "Height", new Integer( dialogH+cbIncrH ));
+ xPSetDialog.setPropertyValue( "Title", _title );
+
+ // get the service manager from the dialog model
+ XMultiServiceFactory xMultiServiceFactory = ( XMultiServiceFactory )UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, dialogModel );
+
+ // create the Run Macro button model and set the properties
+ Object runButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel" );
+ XPropertySet xPSetButton = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, runButtonModel );
+ LogUtils.DEBUG("run: x="+(((dialogW+cbIncrW)/2)-runButtonW -1) );
+ LogUtils.DEBUG("run: y="+(dialogH+cbIncrH-runButtonH-1));
+ xPSetButton.setPropertyValue( "PositionX", new Integer( (((dialogW+cbIncrW)/2)-runButtonW -1) ));
+ xPSetButton.setPropertyValue( "PositionY", new Integer( dialogH+cbIncrH-runButtonH-1));
+ xPSetButton.setPropertyValue( "Width", new Integer( runButtonW ));
+ xPSetButton.setPropertyValue( "Height", new Integer( runButtonH ));
+ xPSetButton.setPropertyValue( "Name", _runButtonName );
+ xPSetButton.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetButton.setPropertyValue( "Label", _runMacro );
+
+ // create the Dont Run Macro button model and set the properties
+ Object doNotRunButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel" );
+ xPSetButton = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, doNotRunButtonModel );
+ LogUtils.DEBUG("dontrun: x="+(((dialogW+cbIncrW)/2)-1) );
+ LogUtils.DEBUG("dontrun: y="+(dialogH+cbIncrH-doNotRunButtonH-1 ));
+ xPSetButton.setPropertyValue( "PositionX", new Integer( (((dialogW+cbIncrW)/2) + 1) ));
+ xPSetButton.setPropertyValue( "PositionY", new Integer( (dialogH+cbIncrH-doNotRunButtonH-1 ) ));
+ xPSetButton.setPropertyValue( "Width", new Integer( doNotRunButtonW ));
+ xPSetButton.setPropertyValue( "Height", new Integer( doNotRunButtonH ));
+ xPSetButton.setPropertyValue( "Name", _doNotRunButtonName );
+ xPSetButton.setPropertyValue( "TabIndex", new Short( (short)0 ) );
+ xPSetButton.setPropertyValue( "Label", _doNotRunMacro );
+
+ // insert the control models into the dialog model
+ XNameContainer xNameCont = ( XNameContainer )UnoRuntime.queryInterface(
+ XNameContainer.class, dialogModel );
+ xNameCont.insertByName( _runButtonName, runButtonModel );
+ xNameCont.insertByName( _doNotRunButtonName, doNotRunButtonModel );
+
+ if ( checkBoxDialog )
+ {
+ LogUtils.DEBUG("creating label & checkbox");
+ // create the label model and set the properties
+ Object label2Model = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, label2Model );
+ xPSetLabel.setPropertyValue( "PositionX", new Integer( label2X ));
+ xPSetLabel.setPropertyValue( "PositionY", new Integer( label2Y ));
+ xPSetLabel.setPropertyValue( "Width", new Integer( label2W ));
+ xPSetLabel.setPropertyValue( "Height", new Integer( label2H ));
+ xPSetLabel.setPropertyValue( "Name", _label2Name );
+ xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetLabel.setPropertyValue( "Label", _label2String );
+
+ // create the label model and set the properties
+ Object label3Model = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel3 = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, label3Model );
+ xPSetLabel3.setPropertyValue( "PositionX", new Integer( label3X ));
+ xPSetLabel3.setPropertyValue( "PositionY", new Integer( label3Y ));
+ xPSetLabel3.setPropertyValue( "Width", new Integer( label3W ));
+ xPSetLabel3.setPropertyValue( "Height", new Integer( label3H ));
+ xPSetLabel3.setPropertyValue( "Name", _label3Name );
+ xPSetLabel3.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetLabel3.setPropertyValue( "Label", _label3String );
+
+ // create the label model and set the properties
+ Object label4Model = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel4 = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, label4Model );
+ xPSetLabel4.setPropertyValue( "PositionX", new Integer( label4X ));
+ xPSetLabel4.setPropertyValue( "PositionY", new Integer( label4Y ));
+ xPSetLabel4.setPropertyValue( "Width", new Integer( label4W ));
+ xPSetLabel4.setPropertyValue( "Height", new Integer( label4H ));
+ xPSetLabel4.setPropertyValue( "Name", _label4Name );
+ xPSetLabel4.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetLabel4.setPropertyValue( "Label", _label4String );
+
+ // create the checkbox model and set the properties
+ Object checkBoxModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlCheckBoxModel" );
+ XPropertySet xPSetCheckBox = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, checkBoxModel );
+ xPSetCheckBox.setPropertyValue( "PositionX", new Integer( checkBoxX ));
+ xPSetCheckBox.setPropertyValue( "PositionY", new Integer( checkBoxY ));
+ xPSetCheckBox.setPropertyValue( "Width", new Integer( checkBoxW ));
+ xPSetCheckBox.setPropertyValue( "Height", new Integer( checkBoxH ));
+ xPSetCheckBox.setPropertyValue( "State", new Short((short)0) );
+ xPSetCheckBox.setPropertyValue( "Name", _checkBoxName );
+ xPSetCheckBox.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetCheckBox.setPropertyValue( "Label", new String(_checkBoxString +checkBoxPath) );
+
+ // insert the control models into the dialog model
+ xNameCont.insertByName( _label2Name, label2Model );
+ xNameCont.insertByName( _label3Name, label3Model );
+ xNameCont.insertByName( _label4Name, label4Model );
+ xNameCont.insertByName( _checkBoxName, checkBoxModel );
+
+ if ( extraPathLine == true )
+ {
+ // create the label model and set the properties
+ Object label5Model = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel5 = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, label5Model );
+ xPSetLabel5.setPropertyValue( "PositionX", new Integer( label5X ));
+ xPSetLabel5.setPropertyValue( "PositionY", new Integer( label5Y ));
+ xPSetLabel5.setPropertyValue( "Width", new Integer( label5W ));
+ xPSetLabel5.setPropertyValue( "Height", new Integer( label5H ));
+ xPSetLabel5.setPropertyValue( "Name", _label5Name );
+ xPSetLabel5.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetLabel5.setPropertyValue( "Label", checkBoxPath2 );
+ xNameCont.insertByName( _label5Name, label5Model );
+ }
+ }
+ else
+ {
+ // create the label model and set the properties
+ Object labelModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, labelModel );
+ xPSetLabel.setPropertyValue( "PositionX", new Integer( label1X ));
+ xPSetLabel.setPropertyValue( "PositionY", new Integer( label1Y ));
+ xPSetLabel.setPropertyValue( "Width", new Integer( label1W ));
+ xPSetLabel.setPropertyValue( "Height", new Integer( label1H ));
+ xPSetLabel.setPropertyValue( "Name", _label1Name );
+ xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) );
+ xPSetLabel.setPropertyValue( "Label", _label1String );
+
+ // insert the control models into the dialog model
+ xNameCont.insertByName( _label1Name, labelModel );
+ }
+
+ // create the dialog control and set the model
+ Object dialog = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialog", _xComponentContext );
+ XControl xControl = ( XControl )UnoRuntime.queryInterface(
+ XControl.class, dialog );
+ XControlModel xControlModel = ( XControlModel )UnoRuntime.queryInterface(
+ XControlModel.class, dialogModel );
+ xControl.setModel( xControlModel );
+
+ // add an action listener to the button control
+ XControlContainer xControlCont = ( XControlContainer )UnoRuntime.queryInterface(
+ XControlContainer.class, dialog );
+
+ // Add to yes button
+ Object objectButton = xControlCont.getControl( _runButtonName );
+ XButton xButton = ( XButton )UnoRuntime.queryInterface(
+ XButton.class, objectButton );
+ xButton.addActionListener( new ActionListenerImpl( xControlCont, _runButtonName ) );
+
+ // add to no button
+ objectButton = xControlCont.getControl( _doNotRunButtonName );
+ xButton = ( XButton )UnoRuntime.queryInterface(
+ XButton.class, objectButton );
+ xButton.addActionListener( new ActionListenerImpl( xControlCont, _doNotRunButtonName ) );
+
+ if ( checkBoxDialog )
+ {
+ // add to checkbox
+ Object objectCheckBox = xControlCont.getControl( _checkBoxName );
+ XCheckBox xCheckBox = ( XCheckBox )UnoRuntime.queryInterface(
+ XCheckBox.class, objectCheckBox );
+ xCheckBox.addItemListener((XItemListener) new ItemListenerImpl( xControlCont ) );
+ }
+
+ // create a peer
+ Object toolkit = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.ExtToolkit", _xComponentContext );
+ XToolkit xToolkit = ( XToolkit )UnoRuntime.queryInterface(
+ XToolkit.class, toolkit );
+ XWindow xWindow = ( XWindow )UnoRuntime.queryInterface(
+ XWindow.class, xControl );
+ xWindow.setVisible( false );
+ xControl.createPeer( xToolkit, null );
+
+ // return the dialog
+ XDialog xDialog = ( XDialog )UnoRuntime.queryInterface(
+ XDialog.class, dialog );
+ return xDialog;
+ }
+ public short execute()
+ {
+
+ short result = 0;
+ _pushed = _doNotRunButtonName;
+ LogUtils.DEBUG("*DF* Before execute " );
+ _xDialog.execute();
+ LogUtils.DEBUG("*DF* After execute " );
+
+ if ( _pushed.equals( _runButtonName ) )
+ {
+ result += 1;
+ }
+ if ( _checkBoxState == 1 )
+ {
+ result +=2;
+ }
+ return result;
+ }
+
+ public void endExecute()
+ {
+ _xDialog.endExecute();
+ }
+
+ public String getTitle()
+ {
+ return _xDialog.getTitle();
+ }
+
+ public void setTitle( String Title )
+ {
+ _xDialog.setTitle( Title );
+ }
+
+ public void dispose ()
+ {
+ XComponent xComponent = ( XComponent )UnoRuntime.queryInterface(
+ XComponent.class, _xDialog );
+ xComponent.dispose();
+ }
+
+ public void addEventListener ( com.sun.star.lang.XEventListener xListener )
+ {
+ XComponent xComponent = ( XComponent )UnoRuntime.queryInterface(
+ XComponent.class, _xDialog );
+ xComponent.addEventListener( xListener );
+ }
+
+
+ public void removeEventListener ( com.sun.star.lang.XEventListener aListener )
+ {
+ XComponent xComponent = ( XComponent )UnoRuntime.queryInterface(
+ XComponent.class, _xDialog );
+ xComponent.removeEventListener( aListener );
+ }
+
+ public class ActionListenerImpl implements com.sun.star.awt.XActionListener {
+ private XControlContainer _xControlCont;
+ private String _buttonName;
+ public ActionListenerImpl( XControlContainer xControlCont, String buttonName ) {
+ _xControlCont = xControlCont;
+ _buttonName = buttonName;
+ }
+
+ // XEventListener
+ public void disposing( EventObject eventObject ) {
+ _xControlCont = null;
+ }
+
+ // XActionListener
+ public void actionPerformed( ActionEvent actionEvent ) {
+ _pushed = _buttonName;
+ LogUtils.DEBUG("** Button pushed ->" + _pushed );
+
+ _xDialog.endExecute();
+ }
+ }
+
+ public class ItemListenerImpl implements com.sun.star.awt.XItemListener {
+ private XCheckBox _xCheckBox;
+ public ItemListenerImpl( XControlContainer xControlCont ) {
+ Object objectCheckBox = xControlCont.getControl( _checkBoxName );
+ _xCheckBox = ( XCheckBox )UnoRuntime.queryInterface(
+ XCheckBox.class, objectCheckBox );
+ }
+
+ // XEventListener
+ public void disposing( EventObject eventObject ) {
+ _xCheckBox = null;
+ }
+
+ // XAdjustmentListener
+ public void itemStateChanged( ItemEvent itemEvent ) {
+ _checkBoxState = _xCheckBox.getState();
+ LogUtils.DEBUG("** checkbox state ->" + _checkBoxState );
+ }
+ }
+}
diff --git a/scripting/java/ScriptFramework.component b/scripting/java/ScriptFramework.component
new file mode 100644
index 000000000000..d6f9a8f62bf4
--- /dev/null
+++ b/scripting/java/ScriptFramework.component
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.script.framework.security.SecurityDialog">
+ <service name="com.sun.star.script.framework.security.SecurityDialog"/>
+ </implementation>
+</component>
diff --git a/scripting/java/ScriptProviderForBeanShell.component b/scripting/java/ScriptProviderForBeanShell.component
new file mode 100644
index 000000000000..fe040d71d90d
--- /dev/null
+++ b/scripting/java/ScriptProviderForBeanShell.component
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.script.framework.provider.beanshell.ScriptProviderForBeanShell$_ScriptProviderForBeanShell">
+ <service name="com.sun.star.script.browse.BrowseNode"/>
+ <service name="com.sun.star.script.provider.LanguageScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProviderForBeanShell"/>
+ </implementation>
+</component>
diff --git a/scripting/java/ScriptProviderForJava.component b/scripting/java/ScriptProviderForJava.component
new file mode 100644
index 000000000000..4ea6ea8a1086
--- /dev/null
+++ b/scripting/java/ScriptProviderForJava.component
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.script.framework.provider.java.ScriptProviderForJava$_ScriptProviderForJava">
+ <service name="com.sun.star.script.browse.BrowseNode"/>
+ <service name="com.sun.star.script.provider.LanguageScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProviderForJava"/>
+ </implementation>
+</component>
diff --git a/scripting/java/ScriptProviderForJavaScript.component b/scripting/java/ScriptProviderForJavaScript.component
new file mode 100644
index 000000000000..e9725d865983
--- /dev/null
+++ b/scripting/java/ScriptProviderForJavaScript.component
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.script.framework.provider.javascript.ScriptProviderForJavaScript$_ScriptProviderForJavaScript">
+ <service name="com.sun.star.script.browse.BrowseNode"/>
+ <service name="com.sun.star.script.provider.LanguageScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProvider"/>
+ <service name="com.sun.star.script.provider.ScriptProviderForJavaScript"/>
+ </implementation>
+</component>
diff --git a/scripting/java/build.env b/scripting/java/build.env
new file mode 100644
index 000000000000..5b055e0b8452
--- /dev/null
+++ b/scripting/java/build.env
@@ -0,0 +1,3 @@
+jedit.install.dir=/scde/soperm/projects/scripting/build-dependencies
+install.dir=/scde/soperm/projects/scripting/build-dependencies
+netbeans.home=/scde/soperm/projects/scripting/build-dependencies
diff --git a/scripting/java/build.xml b/scripting/java/build.xml
new file mode 100755
index 000000000000..e068237d4618
--- /dev/null
+++ b/scripting/java/build.xml
@@ -0,0 +1,285 @@
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+-->
+<project name="Scipting Framework" default="all" basedir=".">
+
+ <!-- =================== Environmental Properties ======================= -->
+
+ <property name="prj" value=".."/>
+ <property name="build.compiler" value="classic"/>
+ <property name="optimize" value="off"/>
+ <property name="debug" value="on"/>
+ <property name="jardir" value="${out}/class"/>
+ <property name="bindir" value="${out}/bin"/>
+ <property name="idesupport.dir" value="org/openoffice/idesupport"/>
+ <property name="netbeans.dir" value="org/openoffice/netbeans/modules/office"/>
+ <property name="framework.dir" value="Framework/com/sun/star/script/framework/security"/>
+
+ <!-- Change this property if you are building NetBeans editor support jar.
+ Not needed in default build -->
+ <property name="netbeans.install.path" value="/export/home/netbeans"/>
+
+ <property environment="env"/>
+ <property name="env.BSH_JAR" value="${solar.jar}/bsh.jar"/>
+
+ <!-- ==================== classpath setting ============================ -->
+ <path id="idlclasspath">
+ <pathelement location="${solar.jar}/jurt.jar"/>
+ <pathelement location="${solar.jar}/unoil.jar"/>
+ <pathelement location="${solar.jar}/juh.jar"/>
+ <pathelement location="${solar.jar}/java_uno.jar"/>
+ <pathelement location="${solar.jar}/ridl.jar"/>
+ <pathelement location="${env.BSH_JAR}"/>
+ <pathelement location="${solar.jar}/js.jar"/>
+ <pathelement location="${jardir}"/>
+ </path>
+
+ <path id="idesupport.class.path">
+ <pathelement path="${jardir}"/>
+ </path>
+
+ <path id="openide.class.path">
+ <pathelement path="${jardir}"/>
+ <pathelement path="${solar.jar}/openide.jar"/>
+ </path>
+
+ <path id="netbeans.editor.support.classpath">
+ <pathelement path="${jardir}"/>
+ <pathelement path="${netbeans.install.path}/modules/ext/nb-editor.jar"/>
+ </path>
+
+ <condition property="boot_refID" value="macPath" else="nonMacPath">
+ <and>
+ <os family="mac"/>
+ <os family="unix"/>
+ </and>
+ </condition>
+ <path id="macPath" location="${java.home}/../Classes/classes.jar"/>
+ <!-- rhino.jar from OpenJDK breaks build -->
+ <path id="nonMacPath">
+ <fileset dir="${java.home}/">
+ <include name="jre/lib/*.jar"/>
+ <include name="lib/*.jar"/>
+ <exclude name="jre/lib/rhino.jar"/>
+ <exclude name="lib/rhino.jar"/>
+ </fileset>
+ </path>
+ <path id="my.bootstrap.classpath" refID="${boot_refID}"/>
+
+ <!-- ===================== Prepare Directories ========================= -->
+ <target name="prepare">
+ <mkdir dir="${jardir}"/>
+ </target>
+
+ <!-- ======================== Compile Classes ========================== -->
+ <target name="compile" depends="prepare">
+ <javac srcdir="com" destdir="${jardir}"
+ includes="**/*.java" classpathref="idlclasspath"
+ debug="${debug}" optimize="${optimize}" deprecation="off">
+ <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
+ </javac>
+ <javac srcdir="Framework/" destdir="${jardir}"
+ includes="**/*.java" classpathref="idlclasspath" debug="${debug}"
+ optimize="${optimize}" deprecation="off">
+ <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
+ </javac>
+ </target>
+
+ <target name="idesupport.compile" depends="compile, prepare">
+ <javac srcdir="." destdir="${jardir}"
+ debug="${debug}" deprecation="on">
+ <classpath refid="idesupport.class.path"/>
+ <exclude name="${idesupport.dir}/**/.*/*"/>
+ <exclude name="${idesupport.dir}/localoffice/**/*"/>
+ <exclude name="${idesupport.dir}/LocalOffice.java"/>
+ <include name="${idesupport.dir}/*.java"/>
+ <include name="${idesupport.dir}/*/*.java"/>
+ </javac>
+ </target>
+
+ <target name="localoffice.compile" depends="prepare">
+ <javac srcdir="." destdir="${jardir}"
+ debug="${debug}" deprecation="on">
+ <classpath refid="idlclasspath"/>
+ <exclude name="${idesupport.dir}/localoffice/.*/*"/>
+ <include name="${idesupport.dir}/localoffice/*.java"/>
+ </javac>
+ </target>
+
+ <target name="netbeans.compile" depends="idesupport.compile, prepare">
+ <javac srcdir="." destdir="${jardir}"
+ debug="${debug}" deprecation="on">
+ <classpath refid="openide.class.path"/>
+ <exclude name="${netbeans.dir}/**/.*/*"/>
+ <include name="${netbeans.dir}/**/*.java"/>
+ </javac>
+ </target>
+
+ <target name="netbeans.editor.support" depends="prepare">
+ <javac srcdir="." destdir="${jardir}"
+ debug="${debug}" deprecation="on">
+ <classpath refid="netbeans.editor.support.classpath"/>
+ <include name="org/openoffice/netbeans/editor/*.java"/>
+ </javac>
+ <jar jarfile="${jardir}/nb-editorsupport.jar">
+ <fileset dir="${jardir}">
+ <include name="org/openoffice/netbeans/editor/*.class"/>
+ </fileset>
+ <fileset dir=".">
+ <include name="org/openoffice/netbeans/editor/OOo.jcs"/>
+ <include name="org/openoffice/netbeans/editor/OOo.jcb"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- ===================== jar ========================= -->
+ <target name="jar" depends="compile">
+ <jar jarfile="${jardir}/ScriptProviderForJava.jar"
+ basedir="${jardir}">
+ <manifest>
+ <attribute name="Built-By" value="Sun Microsystems"/>
+ <attribute name="RegistrationClassName"
+ value="com.sun.star.script.framework.provider.java.ScriptProviderForJava"/>
+ <attribute name="Class-Path" value="ScriptFramework.jar"/>
+ <attribute name="UNO-Type-Path" value=""/>
+ </manifest>
+ <include name="**/provider/java/*.class"/>
+ </jar>
+
+ <jar jarfile="${jardir}/ScriptProviderForBeanShell.jar"
+ basedir="${jardir}">
+ <manifest>
+ <attribute name="Built-By" value="Sun Microsystems"/>
+ <attribute name="RegistrationClassName"
+ value="com.sun.star.script.framework.provider.beanshell.ScriptProviderForBeanShell"/>
+ <attribute name="Class-Path" value="ScriptFramework.jar bsh.jar"/>
+ <attribute name="UNO-Type-Path" value=""/>
+ </manifest>
+ <include name="**/provider/beanshell/*.class"/>
+ <fileset dir=".">
+ <include name="**/provider/beanshell/*.bsh"/>
+ </fileset>
+ </jar>
+
+ <jar jarfile="${jardir}/ScriptProviderForJavaScript.jar"
+ basedir="${jardir}">
+ <manifest>
+ <attribute name="Built-By" value="Sun Microsystems"/>
+ <attribute name="RegistrationClassName"
+ value="com.sun.star.script.framework.provider.javascript.ScriptProviderForJavaScript"/>
+ <attribute name="Class-Path" value="ScriptFramework.jar js.jar"/>
+ <attribute name="UNO-Type-Path" value=""/>
+ </manifest>
+ <include name="**/provider/javascript/*.class"/>
+ <fileset dir=".">
+ <include name="**/provider/javascript/*.js"/>
+ </fileset>
+ </jar>
+
+ <jar jarfile="${jardir}/ScriptFramework.jar"
+ basedir="${jardir}">
+ <manifest>
+ <attribute name="Built-By" value="Sun Microsystems"/>
+ <attribute name="RegistrationClassName"
+ value="com.sun.star.script.framework.security.SecurityDialog"/>
+ <attribute name="UNO-Type-Path" value=""/>
+ </manifest>
+ <include name="**/security/*"/>
+ <include name="**/log/*.class"/>
+ <include name="**/provider/*.class"/>
+ <include name="**/browse/*.class"/>
+ <include name="**/container/*.class"/>
+ <include name="**/io/*.class"/>
+ </jar>
+
+ </target>
+
+ <target name="idesupport.jar" depends="idesupport.compile">
+ <jar jarfile="${jardir}/idesupport.jar">
+ <fileset dir="${jardir}">
+ <include name="${idesupport.dir}/**/*.class"/>
+ <include name="CommandLineTools*"/>
+ <exclude name="${idesupport.dir}/localoffice/*.class"/>
+ </fileset>
+ <fileset dir=".">
+ <include name="${idesupport.dir}/ui/add.gif"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="localoffice.jar" depends="localoffice.compile">
+ <unjar
+ src="${solar.jar}/unoil.jar"
+ dest="${jardir}"/>
+ <jar jarfile="${jardir}/localoffice.jar">
+ <fileset dir="${jardir}">
+ <include name="${idesupport.dir}/localoffice/*.class"/>
+ <include name="drafts/com/sun/star/script/framework/storage/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="netbeans.jar" depends="netbeans.compile">
+ <jar jarfile="${jardir}/office.jar" manifest="manifest.mf">
+ <fileset dir="${jardir}">
+ <include name="${netbeans.dir}/**/*.class"/>
+ <exclude name="${netbeans.dir}/**/ParcelDescriptorChildren.class"/>
+ <exclude name="${netbeans.dir}/**/ScriptNode.class"/>
+ <include name="${idesupport.dir}/**/*.class"/>
+ <include name="CommandLineTools*"/>
+ </fileset>
+ <fileset dir=".">
+ <include name="${idesupport.dir}/ui/add.gif"/>
+ <include name="${netbeans.dir}/resources/*"/>
+ <include name="${netbeans.dir}/resources/templates/*"/>
+ <include name="${netbeans.dir}/**/Bundle*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- Uncomment this target when building within NetBeans to reinstall the
+ module.
+ <target name="netbeans.install" depends="netbeans.package">
+ <copy file="${jardir}/localoffice.jar"
+ tofile="${netbeans.home}/modules/ext/localoffice.jar"/>
+ <nbinstaller action="reinstall" module="${jardir}/office.jar"/>
+ </target>
+ -->
+
+ <!-- ====================== Clean Generated Files ===================== -->
+ <target name="clean">
+ <delete file="${jardir}/ScriptProviderForJava.jar"/>
+ <delete file="${jardir}/ScriptProviderForJavaScript.jar"/>
+ <delete file="${jardir}/ScriptProviderForBeanShell.jar"/>
+ <delete file="${jardir}/ScriptFramework.jar"/>
+ <delete file="${jardir}/office.jar"/>
+ <delete file="${jardir}/localoffice.jar"/>
+ <delete file="${jardir}/idesupport.jar"/>
+ </target>
+
+ <!-- ========================= All In One Build ======================= -->
+ <target name="all" depends="jar"/>
+</project>
diff --git a/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java
new file mode 100644
index 000000000000..de7986e9ab02
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.browse;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.EventObject;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameContainer;
+
+import com.sun.star.awt.*;
+
+
+public class DialogFactory
+{
+ private static DialogFactory factory;
+ private XComponentContext xComponentContext;
+
+ // singleton
+ private DialogFactory(XComponentContext xComponentContext)
+ {
+ this.xComponentContext = xComponentContext;
+ factory = this;
+ }
+
+ public static void createDialogFactory(XComponentContext xComponentContext)
+ {
+ if (factory == null)
+ {
+ synchronized(DialogFactory.class)
+ {
+ if (factory == null)
+ {
+ factory = new DialogFactory(xComponentContext);
+ }
+ }
+ }
+ }
+
+ public static DialogFactory getDialogFactory()
+ throws java.lang.Exception
+ {
+ if (factory == null)
+ {
+ throw new java.lang.Exception("DialogFactory not initialized");
+ }
+ return factory;
+ }
+
+ public boolean showConfirmDialog(String title, String prompt)
+ {
+ final XDialog xDialog;
+ try
+ {
+ xDialog = createConfirmDialog(title, prompt);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ return false;
+ }
+
+ // add an action listener to the button controls
+ XControlContainer controls = (XControlContainer)
+ UnoRuntime.queryInterface(XControlContainer.class, xDialog);
+
+ XButton okButton = (XButton) UnoRuntime.queryInterface(
+ XButton.class, controls.getControl("Ok"));
+ okButton.setActionCommand("Ok");
+
+ XButton cancelButton = (XButton) UnoRuntime.queryInterface(
+ XButton.class, controls.getControl("Cancel"));
+ cancelButton.setActionCommand("Cancel");
+
+ final ResultHolder resultHolder = new ResultHolder();
+
+ com.sun.star.awt.XActionListener listener =
+ new com.sun.star.awt.XActionListener()
+ {
+ public void actionPerformed(com.sun.star.awt.ActionEvent e) {
+ if (e.ActionCommand.equals("Cancel"))
+ {
+ resultHolder.setResult(Boolean.FALSE);
+ xDialog.endExecute();
+ }
+ else
+ {
+ resultHolder.setResult(Boolean.TRUE);
+ xDialog.endExecute();
+ }
+ }
+
+ public void disposing(EventObject o) {
+ // does nothing
+ }
+ };
+
+ okButton.addActionListener(listener);
+ cancelButton.addActionListener(listener);
+
+ xDialog.execute();
+
+ Boolean result = (Boolean)resultHolder.getResult();
+
+ return result == null ? false : result.booleanValue();
+ }
+
+ public String showInputDialog(String title, String prompt)
+ {
+ final XDialog xDialog;
+ try
+ {
+ xDialog = createInputDialog(title, prompt);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ return null;
+ }
+
+ // add an action listener to the button controls
+ XControlContainer controls = (XControlContainer)
+ UnoRuntime.queryInterface(XControlContainer.class, xDialog);
+
+ XButton okButton = (XButton) UnoRuntime.queryInterface(
+ XButton.class, controls.getControl("Ok"));
+ okButton.setActionCommand("Ok");
+
+ XButton cancelButton = (XButton) UnoRuntime.queryInterface(
+ XButton.class, controls.getControl("Cancel"));
+ cancelButton.setActionCommand("Cancel");
+
+ final XTextComponent textField = (XTextComponent)
+ UnoRuntime.queryInterface(
+ XTextComponent.class, controls.getControl("NameField"));
+
+ final ResultHolder resultHolder = new ResultHolder();
+
+ com.sun.star.awt.XActionListener listener =
+ new com.sun.star.awt.XActionListener()
+ {
+ public void actionPerformed(com.sun.star.awt.ActionEvent e) {
+ if (e.ActionCommand.equals("Cancel"))
+ {
+ resultHolder.setResult(null);
+ xDialog.endExecute();
+ }
+ else
+ {
+ resultHolder.setResult(textField.getText());
+ xDialog.endExecute();
+ }
+ }
+
+ public void disposing(EventObject o) {
+ // does nothing
+ }
+ };
+
+ okButton.addActionListener(listener);
+ cancelButton.addActionListener(listener);
+
+ xDialog.execute();
+
+ return (String)resultHolder.getResult();
+ }
+
+ private XDialog createConfirmDialog(String title, String prompt)
+ throws com.sun.star.uno.Exception
+ {
+ if (title == null || title.equals(""))
+ {
+ title = "Scripting Framework";
+ }
+
+ if (prompt == null || prompt.equals(""))
+ {
+ prompt = "Enter name";
+ }
+
+ // get the service manager from the component context
+ XMultiComponentFactory xMultiComponentFactory =
+ xComponentContext.getServiceManager();
+
+ // create the dialog model and set the properties
+ Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", xComponentContext);
+
+ XPropertySet props = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, dialogModel);
+
+ props.setPropertyValue("Title", title);
+ setDimensions(dialogModel, 100, 100, 157, 37);
+
+ // get the service manager from the dialog model
+ XMultiServiceFactory xMultiServiceFactory =
+ (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, dialogModel);
+
+ // create the label model and set the properties
+ Object label = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel");
+
+ setDimensions(label, 15, 5, 134, 12);
+
+ XPropertySet labelProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, label);
+ labelProps.setPropertyValue("Name", "PromptLabel");
+ labelProps.setPropertyValue("Label", prompt);
+
+ // create the Run Macro button model and set the properties
+ Object okButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel");
+
+ setDimensions(okButtonModel, 40, 18, 38, 15);
+
+ XPropertySet buttonProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, okButtonModel);
+ buttonProps.setPropertyValue("Name", "Ok");
+ buttonProps.setPropertyValue("Label", "Ok");
+
+ // create the Dont Run Macro button model and set the properties
+ Object cancelButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel");
+
+ setDimensions(cancelButtonModel, 83, 18, 38, 15);
+
+ buttonProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, cancelButtonModel);
+ buttonProps.setPropertyValue("Name", "Cancel");
+ buttonProps.setPropertyValue("Label", "Cancel");
+
+ // insert the control models into the dialog model
+ XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, dialogModel);
+
+ xNameCont.insertByName("PromptLabel", label);
+ xNameCont.insertByName("Ok", okButtonModel);
+ xNameCont.insertByName("Cancel", cancelButtonModel);
+
+ // create the dialog control and set the model
+ Object dialog = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialog", xComponentContext);
+ XControl xControl = (XControl) UnoRuntime.queryInterface(
+ XControl.class, dialog);
+
+ XControlModel xControlModel = (XControlModel)
+ UnoRuntime.queryInterface(XControlModel.class, dialogModel);
+ xControl.setModel(xControlModel);
+
+ // create a peer
+ Object toolkit = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.ExtToolkit", xComponentContext);
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(
+ XToolkit.class, toolkit);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(
+ XWindow.class, xControl);
+ xWindow.setVisible(false);
+ xControl.createPeer(xToolkit, null);
+
+ return (XDialog) UnoRuntime.queryInterface(XDialog.class, dialog);
+ }
+
+ private void setDimensions(Object o, int x, int y, int width, int height)
+ throws com.sun.star.uno.Exception
+ {
+ XPropertySet props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, o);
+
+ props.setPropertyValue("PositionX", new Integer(x));
+ props.setPropertyValue("PositionY", new Integer(y));
+ props.setPropertyValue("Height", new Integer(height));
+ props.setPropertyValue("Width", new Integer(width));
+ }
+
+ private XDialog createInputDialog(String title, String prompt)
+ throws com.sun.star.uno.Exception
+ {
+ if (title == null || title.equals(""))
+ {
+ title = "Scripting Framework";
+ }
+
+ if (prompt == null || prompt.equals(""))
+ {
+ prompt = "Enter name";
+ }
+
+ // get the service manager from the component context
+ XMultiComponentFactory xMultiComponentFactory =
+ xComponentContext.getServiceManager();
+
+ // create the dialog model and set the properties
+ Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", xComponentContext);
+
+ setDimensions(dialogModel, 100, 100, 157, 58);
+
+ XPropertySet props = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, dialogModel);
+ props.setPropertyValue("Title", title);
+
+ // get the service manager from the dialog model
+ XMultiServiceFactory xMultiServiceFactory =
+ (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, dialogModel);
+
+ // create the label model and set the properties
+ Object label = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel");
+
+ setDimensions(label, 15, 5, 134, 12);
+
+ XPropertySet labelProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, label);
+ labelProps.setPropertyValue("Name", "PromptLabel");
+ labelProps.setPropertyValue("Label", prompt);
+
+ // create the text field
+ Object edit = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlEditModel");
+
+ setDimensions(edit, 15, 18, 134, 12);
+
+ XPropertySet editProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, edit);
+ editProps.setPropertyValue("Name", "NameField");
+
+ // create the OK button
+ Object okButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel");
+
+ setDimensions(okButtonModel, 40, 39, 38, 15);
+
+ XPropertySet buttonProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, okButtonModel);
+ buttonProps.setPropertyValue("Name", "Ok");
+ buttonProps.setPropertyValue("Label", "Ok");
+
+ // create the Cancel button
+ Object cancelButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel");
+
+ setDimensions(cancelButtonModel, 83, 39, 38, 15);
+
+ buttonProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, cancelButtonModel);
+ buttonProps.setPropertyValue("Name", "Cancel");
+ buttonProps.setPropertyValue("Label", "Cancel");
+
+ // insert the control models into the dialog model
+ XNameContainer xNameCont = (XNameContainer)
+ UnoRuntime.queryInterface(XNameContainer.class, dialogModel);
+
+ xNameCont.insertByName("PromptLabel", label);
+ xNameCont.insertByName("NameField", edit);
+ xNameCont.insertByName("Ok", okButtonModel);
+ xNameCont.insertByName("Cancel", cancelButtonModel);
+
+ // create the dialog control and set the model
+ Object dialog = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialog", xComponentContext);
+ XControl xControl = (XControl) UnoRuntime.queryInterface(
+ XControl.class, dialog);
+
+ XControlModel xControlModel = (XControlModel)
+ UnoRuntime.queryInterface(XControlModel.class, dialogModel);
+ xControl.setModel(xControlModel);
+
+ // create a peer
+ Object toolkit = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.ExtToolkit", xComponentContext);
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(
+ XToolkit.class, toolkit);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(
+ XWindow.class, xControl);
+ xWindow.setVisible(false);
+ xControl.createPeer(xToolkit, null);
+
+ return (XDialog) UnoRuntime.queryInterface(XDialog.class, dialog);
+ }
+
+ private static class ResultHolder {
+ private Object result = null;
+
+ public Object getResult()
+ {
+ return result;
+ }
+
+ public void setResult(Object result)
+ {
+ this.result = result;
+ }
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
new file mode 100644
index 000000000000..974b001d5d35
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.browse;
+
+import com.sun.star.beans.XIntrospectionAccess;
+
+import com.sun.star.lib.uno.helper.PropertySet;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+
+
+import com.sun.star.lang.XMultiComponentFactory;
+
+
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.ucb.XSimpleFileAccess;
+
+import com.sun.star.script.browse.XBrowseNode;
+import com.sun.star.script.browse.BrowseNodeTypes;
+
+import com.sun.star.script.framework.provider.ScriptProvider;
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.container.ScriptMetaData;
+import com.sun.star.script.framework.container.ScriptEntry;
+import com.sun.star.script.framework.container.Parcel;
+import com.sun.star.script.framework.container.ParcelContainer;
+import com.sun.star.script.framework.browse.DialogFactory;
+
+import java.util.*;
+import javax.swing.JOptionPane;
+
+public class ParcelBrowseNode extends PropertySet
+ implements XBrowseNode, XInvocation
+{
+ private ScriptProvider provider;
+ //private RootBrowseNode parent;
+ private Collection browsenodes;
+ private String name;
+ private ParcelContainer container;
+ private Parcel parcel;
+ public boolean deletable = true;
+ public boolean editable = false;
+ public boolean creatable = false;
+ public boolean renamable = true;
+
+ public ParcelBrowseNode( ScriptProvider provider, ParcelContainer container, String parcelName ) {
+ this.provider = provider;
+ this.name = parcelName;
+ this.container = container;
+
+ // TODO decide whether exception is propagated out or not
+ try
+ {
+ this.parcel = (Parcel)this.container.getByName( parcelName );
+ }
+ catch ( Exception e )
+ {
+
+ LogUtils.DEBUG("** Exception: " + e );
+ LogUtils.DEBUG(" ** Failed to get parcel named " +
+ parcelName + " from container" );
+ }
+ registerProperty("Deletable", new Type(boolean.class),
+ (short)0, "deletable");
+ registerProperty("Editable", new Type(boolean.class),
+ (short)0, "editable");
+ registerProperty("Creatable", new Type(boolean.class),
+ (short)0, "creatable");
+ registerProperty("Renamable", new Type(boolean.class),
+ (short)0, "renamable");
+ if (provider.hasScriptEditor() == true)
+ {
+ this.creatable = true;
+ }
+
+ String parcelDirUrl = parcel.getPathToParcel();
+ XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
+ XMultiComponentFactory xFac = xCtx.getServiceManager();
+ try
+ {
+ XSimpleFileAccess xSFA = ( XSimpleFileAccess)
+ UnoRuntime.queryInterface( XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx ) );
+ if ( xSFA != null && ( xSFA.isReadOnly( parcelDirUrl ) ||
+ container.isUnoPkg() ) )
+ {
+ deletable = false;
+ editable = false;
+ creatable = false;
+ renamable = false;
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ // TODO propagate potential errors
+ // Pthrow new com.sun.star.uno.RuntimeException( e.toString() );
+ LogUtils.DEBUG( "Caught exception creating ParcelBrowseNode " + e );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ }
+
+ }
+
+ public String getName() {
+ return parcel.getName();
+ }
+
+ public XBrowseNode[] getChildNodes() {
+ try
+ {
+
+ if ( hasChildNodes() )
+ {
+ String[] names = parcel.getElementNames();
+ browsenodes = new ArrayList( names.length );
+
+ for ( int index = 0; index < names.length; index++ )
+ {
+ browsenodes.add( new ScriptBrowseNode( provider, parcel, names[ index ] ));
+ }
+ }
+ else
+ {
+ LogUtils.DEBUG("ParcelBrowseNode.getChildeNodes no children " );
+ return new XBrowseNode[0];
+ }
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("Failed to getChildeNodes, exception: " + e );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ return new XBrowseNode[0];
+ }
+ return (XBrowseNode[])browsenodes.toArray(new XBrowseNode[0]);
+ }
+
+ public boolean hasChildNodes() {
+ if ( container != null && container.hasByName( getName() ) && parcel != null )
+ {
+ return parcel.hasElements();
+ }
+
+ return false;
+ }
+
+ public short getType() {
+ return BrowseNodeTypes.CONTAINER;
+ }
+
+ public String toString()
+ {
+ return getName();
+ }
+
+ // implementation of XInvocation interface
+ public XIntrospectionAccess getIntrospection() {
+ return null;
+ }
+
+ public Object invoke(String aFunctionName, Object[] aParams,
+ short[][] aOutParamIndex, Object[][] aOutParam)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ LogUtils.DEBUG("ParcelBrowseNode invoke for " + aFunctionName );
+ // Initialise the out paramters - not used but prevents error in
+ // UNO bridge
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+ Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
+
+ if (aFunctionName.equals("Creatable"))
+ {
+ try
+ {
+ String newName;
+
+ if (aParams == null || aParams.length < 1 ||
+ AnyConverter.isString(aParams[0]) == false)
+ {
+ String prompt = "Enter name for new Script";
+ String title = "Create Script";
+
+ // try to get a DialogFactory instance, if it fails
+ // just use a Swing JOptionPane to prompt for the name
+ try
+ {
+ DialogFactory dialogFactory =
+ DialogFactory.getDialogFactory();
+
+ newName = dialogFactory.showInputDialog(title, prompt);
+ }
+ catch (Exception e)
+ {
+ newName = JOptionPane.showInputDialog(null, prompt, title,
+ JOptionPane.QUESTION_MESSAGE);
+ }
+ }
+ else {
+ newName = (String) AnyConverter.toString(aParams[0]);
+ }
+
+ if ( newName == null || newName.equals(""))
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+ }
+ else
+ {
+ String source = new String(provider.getScriptEditor().getTemplate().getBytes());
+ String languageName = newName + "." + provider.getScriptEditor().getExtension();
+ String language = container.getLanguage();
+
+ ScriptEntry entry = new ScriptEntry( language, languageName, languageName, "", new HashMap() );
+
+ Parcel parcel = (Parcel)container.getByName( getName() );
+ ScriptMetaData data = new ScriptMetaData( parcel, entry, source );
+ parcel.insertByName( languageName, data );
+
+ ScriptBrowseNode sbn = new ScriptBrowseNode( provider, parcel, languageName );
+
+ if(browsenodes==null)
+ {
+ LogUtils.DEBUG("browsenodes null!!");
+ browsenodes = new ArrayList(4);
+ }
+ browsenodes.add(sbn);
+
+ result = new Any(new Type(XBrowseNode.class), sbn);
+ }
+ }
+ catch (Exception e)
+ {
+ LogUtils.DEBUG("ParcelBrowseNode[create] failed with: " + e );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+
+ // throw new com.sun.star.reflection.InvocationTargetException(
+ // "Error creating script: " + e.getMessage());
+ }
+ }
+ else if (aFunctionName.equals("Deletable"))
+ {
+ try
+ {
+ if ( container.deleteParcel(getName()) )
+ {
+ result = new Any(new Type(Boolean.class), Boolean.TRUE);
+ }
+ else
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+ }
+ }
+ catch (Exception e)
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+
+ // throw new com.sun.star.reflection.InvocationTargetException(
+ // "Error deleting parcel: " + e.getMessage());
+ }
+ }
+ else if (aFunctionName.equals("Renamable"))
+ {
+ String newName = null;
+ try
+ {
+
+ if (aParams == null || aParams.length < 1 ||
+ AnyConverter.isString(aParams[0]) == false)
+ {
+ String prompt = "Enter new name for Library";
+ String title = "Rename Library";
+
+ // try to get a DialogFactory instance, if it fails
+ // just use a Swing JOptionPane to prompt for the name
+ try
+ {
+ DialogFactory dialogFactory =
+ DialogFactory.getDialogFactory();
+
+ newName = dialogFactory.showInputDialog(title, prompt);
+ }
+ catch (Exception e)
+ {
+ newName = JOptionPane.showInputDialog(null, prompt, title,
+ JOptionPane.QUESTION_MESSAGE);
+ }
+ }
+ else {
+ newName = (String) AnyConverter.toString(aParams[0]);
+ }
+ container.renameParcel( getName(), newName );
+ Parcel p = (Parcel)container.getByName( newName );
+ if(browsenodes == null )
+ {
+ getChildNodes();
+ }
+ ScriptBrowseNode[] childNodes = (ScriptBrowseNode[])browsenodes.toArray(new ScriptBrowseNode[0]);
+
+ for ( int index = 0; index < childNodes.length; index++ )
+ {
+ childNodes[ index ].updateURI( p );
+ }
+ result = new Any(new Type(XBrowseNode.class), this);
+ }
+ catch (Exception e)
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+
+ // throw new com.sun.star.reflection.InvocationTargetException(
+ // "Error renaming parcel: " + e.getMessage());
+ }
+ }
+
+ else {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Function " + aFunctionName + " not supported.");
+ }
+
+ return result;
+ }
+
+ public void setValue(String aPropertyName, Object aValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ }
+
+ public Object getValue(String aPropertyName)
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ return null;
+ }
+
+ public boolean hasMethod(String aName) {
+ return false;
+ }
+
+ public boolean hasProperty(String aName) {
+ return false;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
new file mode 100644
index 000000000000..7d3ef23a94be
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.browse;
+
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.script.browse.XBrowseNode;
+
+import com.sun.star.script.framework.provider.ScriptProvider;
+import com.sun.star.script.framework.log.*;
+import com.sun.star.script.framework.container.*;
+
+
+public class PkgProviderBrowseNode extends ProviderBrowseNode
+ implements XBrowseNode, XInvocation
+{
+
+ public PkgProviderBrowseNode( ScriptProvider provider, ParcelContainer container, XComponentContext xCtx ) {
+ super( provider, container, xCtx );
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container name = " + container.getName());
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container path = " + container.getParcelContainerDir());
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor, container has num parcels = " + container.getElementNames().length);
+ deletable = false;
+ editable = false;
+ creatable = false;
+
+ }
+
+ public String getName() {
+ String name = "Unknown";
+ if ( container != null )
+ {
+ name = container.getName();
+ }
+ return name;
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
new file mode 100644
index 000000000000..99aa4e44e91a
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.browse;
+
+import com.sun.star.lib.uno.helper.PropertySet;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.ucb.XSimpleFileAccess;
+
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.script.browse.XBrowseNode;
+import com.sun.star.script.browse.BrowseNodeTypes;
+
+import com.sun.star.script.framework.provider.ScriptProvider;
+import com.sun.star.script.framework.log.*;
+import com.sun.star.script.framework.container.*;
+import com.sun.star.script.framework.browse.DialogFactory;
+
+import java.util.*;
+import javax.swing.JOptionPane;
+
+public class ProviderBrowseNode extends PropertySet
+ implements XBrowseNode, XInvocation
+{
+ protected ScriptProvider provider;
+ protected Collection browsenodes;
+ protected String name;
+ protected ParcelContainer container;
+ protected Parcel parcel;
+ protected XComponentContext m_xCtx;
+
+ public boolean deletable = true;
+ public boolean creatable = true;
+ public boolean editable = false;
+
+ public ProviderBrowseNode( ScriptProvider provider, ParcelContainer container, XComponentContext xCtx ) {
+ LogUtils.DEBUG("*** ProviderBrowseNode ctor");
+ this.container = container;
+ this.name = this.container.getLanguage();
+ this.provider = provider;
+ this.m_xCtx = xCtx;
+
+ registerProperty("Deletable", new Type(boolean.class),
+ (short)0, "deletable");
+ registerProperty("Creatable", new Type(boolean.class),
+ (short)0, "creatable");
+ registerProperty("Editable", new Type(boolean.class),
+ (short)0, "editable");
+ XSimpleFileAccess xSFA = null;
+ XMultiComponentFactory xFac = m_xCtx.getServiceManager();
+ try
+ {
+ xSFA = ( XSimpleFileAccess)
+ UnoRuntime.queryInterface( XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx ) );
+ if ( container.isUnoPkg() || xSFA.isReadOnly( container.getParcelContainerDir() ) )
+ {
+ deletable = false;
+ creatable = false;
+ }
+ }
+ // TODO propage errors
+ catch( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG("Caught exception in creation of ProviderBrowseNode ");
+ LogUtils.DEBUG( LogUtils.getTrace(e));
+
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public XBrowseNode[] getChildNodes() {
+ LogUtils.DEBUG("***** ProviderBrowseNode.getChildNodes()");
+ if ( hasChildNodes() )
+ {
+ // needs initialisation?
+ LogUtils.DEBUG("** ProviderBrowseNode.getChildNodes(), container is " + container );
+ String[] parcels = container.getElementNames();
+ browsenodes = new ArrayList( parcels.length );
+ for ( int index = 0; index < parcels.length; index++ )
+ {
+ try
+ {
+ XBrowseNode node = new ParcelBrowseNode( provider, container, parcels[ index ] );
+ browsenodes.add( node );
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("*** Failed to create parcel node for " + parcels[ index ] );
+ LogUtils.DEBUG( e.toString() );
+ }
+ }
+ ParcelContainer[] packageContainers = container.getChildContainers();
+ LogUtils.DEBUG("**** For container named " + container.getName() + " with root path " + container.getParcelContainerDir() + " has " + packageContainers.length + " child containers " );
+
+ for ( int i = 0; i < packageContainers.length; i++ )
+ {
+ XBrowseNode node = new PkgProviderBrowseNode( provider, packageContainers[ i ], m_xCtx );
+ browsenodes.add( node );
+ }
+ }
+ else
+ {
+ LogUtils.DEBUG("*** No container available");
+ return new XBrowseNode[0];
+ }
+ return ( XBrowseNode[] )browsenodes.toArray( new XBrowseNode[0] );
+ }
+
+ public boolean hasChildNodes() {
+ boolean result = true;
+
+ if ( container == null ||
+ ( !container.hasElements() &&
+ container.getChildContainers().length == 0 ) )
+ {
+ result = false;
+ }
+
+ LogUtils.DEBUG("***** ProviderBrowseNode.hasChildNodes(): " +
+ "name=" + name +
+ ", path=" + container.getParcelContainerDir() +
+ ", result=" + result );
+
+ return result;
+ }
+
+ public short getType() {
+ return BrowseNodeTypes.CONTAINER;
+ }
+
+ public String toString()
+ {
+ return getName();
+ }
+
+ // implementation of XInvocation interface
+ public XIntrospectionAccess getIntrospection() {
+ return null;
+ }
+
+ public Object invoke(String aFunctionName, Object[] aParams,
+ short[][] aOutParamIndex, Object[][] aOutParam)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ // Initialise the out paramters - not used but prevents error in
+ // UNO bridge
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+ Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
+
+ if (aFunctionName.equals("Creatable"))
+ {
+ try
+ {
+ String name;
+
+ if (aParams == null || aParams.length < 1 ||
+ AnyConverter.isString(aParams[0]) == false)
+ {
+ String prompt = "Enter name for new Parcel";
+ String title = "Create Parcel";
+
+ // try to get a DialogFactory instance, if it fails
+ // just use a Swing JOptionPane to prompt for the name
+ try
+ {
+ DialogFactory dialogFactory =
+ DialogFactory.getDialogFactory();
+
+ name = dialogFactory.showInputDialog(title, prompt);
+ }
+ catch (Exception e)
+ {
+ name = JOptionPane.showInputDialog(null, prompt, title,
+ JOptionPane.QUESTION_MESSAGE);
+ }
+ }
+ else {
+ name = (String) AnyConverter.toString(aParams[0]);
+ }
+
+ if (name == null || name.equals(""))
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+ }
+ else
+ {
+
+ Object newParcel = container.createParcel( name );
+ LogUtils.DEBUG("Parcel created " + name + " " + newParcel );
+ if ( newParcel == null )
+ {
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+ }
+ else
+ {
+ ParcelBrowseNode parcel = new ParcelBrowseNode( provider, container, name );
+ LogUtils.DEBUG("created parcel node ");
+ if ( browsenodes == null )
+ {
+ browsenodes = new ArrayList( 5 );
+ }
+
+ browsenodes.add(parcel);
+
+
+ result = new Any(new Type(XBrowseNode.class), parcel);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LogUtils.DEBUG("ProviderBrowseNode[create] failed with: " + e );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ result = new Any(new Type(Boolean.class), Boolean.FALSE);
+
+ // throw new com.sun.star.reflection.InvocationTargetException(
+ // "Error creating script: " + e.getMessage());
+ }
+ }
+ else {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Function " + aFunctionName + " not supported.");
+ }
+
+ return result;
+ }
+
+ public void setValue(String aPropertyName, Object aValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ }
+
+ public Object getValue(String aPropertyName)
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ return null;
+ }
+
+ public boolean hasMethod(String aName) {
+ return false;
+ }
+
+ public boolean hasProperty(String aName) {
+ return false;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
new file mode 100644
index 000000000000..30c35105a9a0
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -0,0 +1,335 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.browse;
+
+import com.sun.star.script.browse.XBrowseNode;
+import com.sun.star.script.browse.BrowseNodeTypes;
+import com.sun.star.script.provider.XScriptContext;
+
+import com.sun.star.lib.uno.helper.PropertySet;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.lang.NoSupportException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.reflection.InvocationTargetException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.ElementExistException;
+
+import java.util.*;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.provider.ScriptProvider;
+import com.sun.star.script.framework.container.*;
+
+public class ScriptBrowseNode extends PropertySet
+ implements XBrowseNode, XInvocation
+{
+ private ScriptProvider provider;
+
+ private Parcel parent;
+ private String name;
+ public String uri;
+ public String description;
+ public boolean editable = false;
+ public boolean deletable = false;
+ public boolean renamable = false;
+
+ public ScriptBrowseNode( ScriptProvider provider, Parcel parent,
+ String name )
+ {
+ this.provider = provider;
+ this.name = name;
+ this.parent = parent;
+ ScriptMetaData data = null;
+ XSimpleFileAccess xSFA = null;
+ XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
+ XMultiComponentFactory xFac = xCtx.getServiceManager();
+ try
+ {
+ data = (ScriptMetaData)parent.getByName( name );
+ xSFA = ( XSimpleFileAccess)
+ UnoRuntime.queryInterface( XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx ) );
+ }
+
+ // TODO fix exception types to be caught here, should we rethrow?
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() );
+ }
+
+ uri = data.getShortFormScriptURL();
+ description = data.getDescription();
+
+ if (provider.hasScriptEditor() == true)
+ {
+
+ this.editable = true;
+ try
+ {
+ if ( !parent.isUnoPkg() &&
+ !xSFA.isReadOnly( parent.getPathToParcel() ) )
+ {
+ this.deletable = true;
+ this.renamable = true;
+ }
+ }
+ // TODO propagate errors
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
+ LogUtils.DEBUG( LogUtils.getTrace(e));
+ }
+
+ }
+
+ registerProperty("Deletable", new Type(boolean.class),
+ (short)0, "deletable");
+ registerProperty("Editable", new Type(boolean.class),
+ (short)0, "editable");
+ registerProperty("Renamable", new Type(boolean.class),
+ (short)0, "renamable");
+ registerProperty("URI", new Type(String.class),
+ (short)0, "uri");
+ registerProperty("Description", new Type(String.class),
+ (short)0, "description");
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public XBrowseNode[] getChildNodes() {
+ return new XBrowseNode[0];
+ }
+
+ public boolean hasChildNodes() {
+ return false;
+ }
+
+ public short getType() {
+ return BrowseNodeTypes.SCRIPT;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public void updateURI( Parcel p ) {
+ parent = p;
+ ScriptMetaData data = null;
+ try
+ {
+ data = (ScriptMetaData)parent.getByName( name );
+ }
+
+ // TODO fix exception types to be caught here, should we rethrow?
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() );
+ }
+ uri = data.getShortFormScriptURL();
+ }
+ // implementation of XInvocation interface
+ public XIntrospectionAccess getIntrospection() {
+ return null;
+ }
+
+ public Object invoke(String aFunctionName, Object[] aParams,
+ short[][] aOutParamIndex, Object[][] aOutParam)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ // Initialise the out paramters - not used but prevents error in
+ // UNO bridge
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+ Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
+
+ if (aFunctionName.equals("Editable"))
+ {
+ if (!editable)
+ {
+ NoSupportException nse = new NoSupportException(
+ aFunctionName + " is not editable " );
+
+ throw new InvocationTargetException(
+ "Scripting framework error editing script", null, nse );
+ }
+
+ XScriptContext ctxt = provider.getScriptingContext();
+ ScriptMetaData data = null;
+ try
+ {
+ data = (ScriptMetaData)parent.getByName( name );
+ }
+ catch ( NoSuchElementException nse )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ name + " does not exist or can't be found " );
+ }
+ catch ( com.sun.star.lang.WrappedTargetException wte )
+ {
+ // rethrow
+ throw new InvocationTargetException(
+ "Scripting framework editing script ",
+ null, wte.TargetException );
+ }
+
+ provider.getScriptEditor().edit(ctxt, data);
+ }
+ else if (aFunctionName.equals("Deletable"))
+ {
+ if (!deletable)
+ {
+ NoSupportException nse = new NoSupportException(
+ aFunctionName + " is not supported for this node" );
+
+ throw new InvocationTargetException(
+ "Scripting framework error deleting script", null, nse );
+ }
+ try
+ {
+ parent.removeByName( name );
+ result = new Any(new Type(Boolean.class), Boolean.TRUE);
+ }
+ catch ( NoSuchElementException nse )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ name + " does not exist or can't be found " );
+ }
+ catch ( WrappedTargetException wte )
+ {
+ // rethrow
+ throw new InvocationTargetException(
+ "Scripting framework deleting script ",
+ null, wte.TargetException );
+ }
+
+ }
+ else if (aFunctionName.equals("Renamable"))
+ {
+ result = new Any(new Type(XBrowseNode.class), new XBrowseNode[0]);
+ if (!renamable)
+ {
+ NoSupportException nse = new NoSupportException(
+ aFunctionName + " is not supported for this node" );
+
+ throw new InvocationTargetException(
+ "Scripting framework error renaming script", null, nse );
+ }
+
+ try
+ {
+ String newName = (String) AnyConverter.toString(aParams[0]);
+ ScriptMetaData oldData = (ScriptMetaData)parent.getByName( name );
+ oldData.loadSource();
+ String oldSource = oldData.getSource();
+
+ LogUtils.DEBUG("Create renamed script");
+ String languageName =
+ newName + "." + provider.getScriptEditor().getExtension();
+ String language = provider.getName();
+
+ ScriptEntry entry = new ScriptEntry(
+ language, languageName, languageName, "", new HashMap() );
+
+ ScriptMetaData data = new ScriptMetaData(
+ parent, entry, oldSource );
+
+ parent.insertByName( languageName, data );
+
+ LogUtils.DEBUG("Now remove old script");
+ parent.removeByName( name );
+
+ uri = data.getShortFormScriptURL();
+ name = languageName;
+ result = new Any(new Type(XBrowseNode.class), this);
+ }
+ catch ( NoSuchElementException nse )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ name + " does not exist or can't be found " );
+ }
+ catch ( ElementExistException eee )
+ {
+ // rethrow
+ throw new InvocationTargetException(
+ "Scripting framework error renaming script ",
+ null, eee );
+ }
+ catch ( WrappedTargetException wte )
+ {
+ // rethrow
+ throw new InvocationTargetException(
+ "Scripting framework rename script ",
+ null, wte.TargetException );
+ }
+ }
+ else {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Function " + aFunctionName + " not supported.");
+ }
+
+ return result;
+ }
+
+ public void setValue(String aPropertyName, Object aValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ }
+
+ public Object getValue(String aPropertyName)
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ return null;
+ }
+
+ public boolean hasMethod(String aName) {
+ return false;
+ }
+
+ public boolean hasProperty(String aName) {
+ return false;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java
new file mode 100644
index 000000000000..abc28fb36b4f
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+
+import java.util.ArrayList;
+
+// import javax.xml.parsers.DocumentBuilderFactory;
+// import javax.xml.parsers.DocumentBuilder;
+// import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.*;
+
+public class DeployedUnoPackagesDB {
+
+ // File name to be used for parcel descriptor files
+ private static final String
+ PARCEL_DESCRIPTOR_NAME = "unopkg-desc.xml";
+
+ // This is the default contents of a parcel descriptor to be used when
+ // creating empty descriptors
+ private static final byte[] EMPTY_DOCUMENT =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<unopackages xmlns:unopackages=\"unopackages.dtd\">\n" +
+ "</unopackages>").getBytes();
+
+ private File file = null;
+ private Document document = null;
+
+ public DeployedUnoPackagesDB() throws IOException {
+ ByteArrayInputStream bis = null;
+ try {
+ bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
+ this.document = XMLParserFactory.getParser().parse(bis);
+ }
+ finally {
+ if (bis != null)
+ bis.close();
+ }
+ }
+
+ public DeployedUnoPackagesDB(Document document) {
+ this.document = document;
+ }
+
+ public DeployedUnoPackagesDB(InputStream is) throws IOException {
+ this(XMLParserFactory.getParser().parse(is));
+ }
+
+ public String[] getDeployedPackages( String language )
+ {
+ ArrayList packageUrls = new ArrayList(4);
+ Element main = document.getDocumentElement();
+ Element root = null;
+ Element item;
+ int len = 0;
+ NodeList langNodes = null;
+
+ if ((langNodes = main.getElementsByTagName("language")) != null &&
+ (len = langNodes.getLength()) != 0)
+ {
+ for ( int i=0; i<len; i++ )
+ {
+ Element e = (Element)langNodes.item( i );
+ if ( e.getAttribute("value").equals(language) )
+ {
+ root = e;
+ break;
+ }
+ }
+ }
+ if ( root != null )
+ {
+ len = 0;
+ NodeList packages = null;
+ if ((packages = root.getElementsByTagName("package")) != null &&
+ (len = packages.getLength()) != 0)
+ {
+
+ for ( int i=0; i<len; i++ )
+ {
+
+ Element e = (Element)packages.item( i );
+ packageUrls.add( e.getAttribute("value") );
+ }
+ }
+ }
+ if ( !packageUrls.isEmpty() )
+ {
+ return (String[])packageUrls.toArray( new String[0] );
+ }
+ return new String[0];
+ }
+
+ public void write(OutputStream out) throws IOException {
+ XMLParserFactory.getParser().write(document, out);
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+
+
+ private void clearEntries() {
+ NodeList langNodes;
+ Element main = document.getDocumentElement();
+ int len;
+
+ if ((langNodes = document.getElementsByTagName("language")) != null &&
+ (len = langNodes.getLength()) != 0)
+ {
+ for (int i = len - 1; i >= 0; i--) {
+ try {
+ main.removeChild(langNodes.item(i));
+ }
+ catch (DOMException de) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public boolean removePackage( String language, String url )
+ {
+ Element main = document.getDocumentElement();
+ Element langNode = null;
+ int len = 0;
+ NodeList langNodes = null;
+ boolean result = false;
+ if ((langNodes = main.getElementsByTagName("language")) != null &&
+ (len = langNodes.getLength()) != 0)
+ {
+ for ( int i=0; i<len; i++ )
+ {
+ Element e = (Element)langNodes.item( i );
+ if ( e.getAttribute("value").equals(language) )
+ {
+ langNode = e;
+ break;
+ }
+ }
+ }
+ if ( langNode != null )
+ {
+ len = 0;
+ NodeList packages = null;
+ if ((packages = langNode.getElementsByTagName("package")) != null &&
+ (len = packages.getLength()) != 0)
+ {
+ for ( int i=0; i<len; i++ )
+ {
+
+ Element e = (Element)packages.item( i );
+ String value = e.getAttribute("value");
+
+ if ( value.equals(url) )
+ {
+ langNode.removeChild( e );
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public void addPackage(String language, String url ) {
+ Element main = document.getDocumentElement();
+ Element langNode = null;
+ Element pkgNode = null;
+
+ int len = 0;
+ NodeList langNodes = null;
+
+ if ((langNodes = document.getElementsByTagName("language")) != null &&
+ (len = langNodes.getLength()) != 0)
+ {
+ for ( int i=0; i<len; i++ )
+ {
+ Element e = (Element)langNodes.item( i );
+ if ( e.getAttribute("value").equals(language) )
+ {
+ langNode = e;
+ break;
+ }
+ }
+ }
+ if ( langNode == null )
+ {
+ langNode = document.createElement("language");
+ langNode.setAttribute( "value", language );
+ }
+ pkgNode = document.createElement("package");
+ pkgNode.setAttribute( "value", url );
+
+ langNode.appendChild(pkgNode);
+ //add to the Top Element
+ main.appendChild(langNode);
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/Parcel.java b/scripting/java/com/sun/star/script/framework/container/Parcel.java
new file mode 100644
index 000000000000..40790eae6b28
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/Parcel.java
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.container;
+import com.sun.star.script.framework.log.*;
+import com.sun.star.script.framework.io.*;
+import com.sun.star.script.framework.provider.PathUtils;
+
+import com.sun.star.container.*;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.ucb.XSimpleFileAccess2;
+import java.io.*;
+
+public class Parcel implements XNameContainer
+{
+ protected ParcelDescriptor m_descriptor;
+ protected String name;
+ protected ParcelContainer parent;
+ protected XSimpleFileAccess m_xSFA;
+ public Parcel( XSimpleFileAccess xSFA, ParcelContainer parent, ParcelDescriptor desc, String parcelName )
+ {
+ this( parent, desc, parcelName );
+ this.m_xSFA = xSFA;
+ }
+
+ public Parcel( ParcelContainer parent, ParcelDescriptor desc, String parcelName )
+ {
+ this.parent = parent;
+ this.m_descriptor = desc;
+ this.name = parcelName;
+ }
+
+ /**
+ * Tests if this <tt>Parcel</tt> is in an UNO package
+ * or within a sub package within an UNO package
+ *
+ * @return <tt>true</tt> if has parent <tt>false</tt> otherwise
+ */
+ public boolean isUnoPkg() { return parent.isUnoPkg(); }
+
+ public String getName()
+ {
+ return name;
+ }
+ public java.lang.Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG("** Parcel.getByName for " + aName );
+ ScriptEntry script = null;
+ try
+ {
+ if ( m_descriptor != null && hasElements() )
+ {
+ ScriptEntry[] scripts = m_descriptor.getScriptEntries();
+ if ( scripts.length != 0 )
+ {
+ for ( int index = 0; index < scripts.length; index++ )
+ {
+ if ( scripts[ index ].getLanguageName().equals( aName ) )
+ {
+ script = scripts[ index ];
+ break;
+ }
+ }
+ }
+ }
+ }
+ // catch unknown or un-checked exceptions
+ catch ( Exception e )
+ {
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ if ( script == null )
+ {
+ LogUtils.DEBUG("No script for " + aName );
+ throw new com.sun.star.container.NoSuchElementException("No script named " + aName );
+ }
+ ScriptMetaData data = new ScriptMetaData( this, script, null );
+
+ LogUtils.DEBUG("returning date for " + aName );
+ return data;
+ }
+ public String[] getElementNames()
+ {
+ String[] results = new String[0];
+ if ( m_descriptor != null )
+ {
+ ScriptEntry[] scripts = m_descriptor.getScriptEntries();
+ results = new String[ scripts.length ];
+ for ( int index = 0; index < scripts.length; index++ )
+ {
+ results[ index ] = scripts[ index ].getLanguageName();
+ }
+ }
+ return results;
+ }
+ public boolean hasByName( String aName )
+ {
+
+ boolean result = true;
+ Object containee = null;
+ try
+ {
+ containee = getByName( aName );
+ if ( containee != null )
+ {
+ result = true;
+ }
+ }
+ catch( Exception e )
+ {
+ result = false;
+ }
+ return result;
+ }
+
+ public com.sun.star.uno.Type getElementType() {
+ // TODO at the moment this returns void indicating
+ // type is unknown ( from UNO point of view this is correct )
+ // but, maybe we want to have a private UNO interface
+ //
+ return new Type();
+ }
+
+ public boolean hasElements()
+ {
+ if ( m_descriptor != null && m_descriptor.getScriptEntries().length > 0 )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void replaceByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ // TODO check type of aElement
+ // if not ok, throw IllegalArgument
+ if ( m_descriptor != null )
+ {
+ try
+ {
+ ScriptEntry script = (ScriptEntry)getByName( aName );
+ if ( script != null )
+ {
+ //m_descriptor.removeScriptEntry( script );
+ // TODO needs to create source file ( if there is one )
+ //m_descriptor.write();
+ }
+ else
+ {
+ throw new com.sun.star.container.NoSuchElementException("No script named " + aName );
+ }
+
+
+ }
+ // TO DO should catch specified exceptions
+ catch ( Exception e )
+ {
+ throw new com.sun.star.lang.WrappedTargetException();
+ }
+
+ }
+ }
+
+ // create
+ public void insertByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, ElementExistException, com.sun.star.lang.WrappedTargetException
+ {
+ // TODO check the type of aElement and throw#
+ // if not appropriate
+ try
+ {
+ if ( hasByName( aName ) )
+ {
+ throw new ElementExistException( aName );
+ }
+ ScriptMetaData script = (ScriptMetaData)aElement;
+
+ if ( script.hasSource() )
+ {
+ LogUtils.DEBUG("Inserting source: " + script.getSource());
+ if ( !script.writeSourceFile() )
+ {
+ throw new com.sun.star.lang.WrappedTargetException( "Failed to create source file " + script.getLanguageName() );
+ }
+ }
+ m_descriptor.addScriptEntry( script );
+ writeParcelDescriptor();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("Failed to insert entry " + aName + ": " + e.getMessage());
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ }
+
+
+ private void writeParcelDescriptor()
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception, java.io.IOException
+ {
+ String pathToDescriptor = PathUtils.make_url(
+ getPathToParcel(), ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
+
+ XSimpleFileAccess2 xSFA2 = ( XSimpleFileAccess2 )
+ UnoRuntime.queryInterface( XSimpleFileAccess2.class, m_xSFA );
+
+ if ( xSFA2 != null )
+ {
+ ByteArrayOutputStream bos = null;
+ ByteArrayInputStream bis = null;
+ XInputStreamImpl xis = null;
+ try
+ {
+ bos = new ByteArrayOutputStream( 1024 );
+ m_descriptor.write( bos );
+ bis = new ByteArrayInputStream( bos.toByteArray() );
+
+ xis = new XInputStreamImpl( bis );
+ xSFA2.writeFile( pathToDescriptor, xis );
+ }
+ finally
+ {
+ if (bos != null) bos.close();
+ if (bis != null) bis.close();
+ if (xis != null) xis.closeInput();
+ }
+ }
+ }
+
+ // delete
+ public void removeByName( String Name ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ try
+ {
+ ScriptMetaData script = null;
+ if ( ( script = (ScriptMetaData)getByName( Name ) ) != null )
+ {
+// if ( script.hasSource() )
+ {
+ if ( !script.removeSourceFile() )
+ {
+ LogUtils.DEBUG("** Parcel.removeByName Failed to remove script " + Name );
+ throw new com.sun.star.lang.WrappedTargetException("Failed to remove script " + Name );
+ }
+ LogUtils.DEBUG("** Parcel.removeByName have removed script source file " + Name );
+ }
+ m_descriptor.removeScriptEntry( script );
+ writeParcelDescriptor();
+
+ }
+ else
+ {
+ throw new com.sun.star.container.NoSuchElementException( "No script named " + Name );
+ }
+
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("** Parcel.removeByName Exception: " + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+
+ }
+ // rename parcel
+ public void rename( String name ) throws com.sun.star.lang.WrappedTargetException
+ {
+ this.name = name;
+ }
+ public ParcelContainer getParent() { return parent; }
+ /**
+ * Returns the path of this <tt>Parcel</tt>
+ *
+ * @return <tt>String</tt> path to parcel
+ */
+ public String getPathToParcel()
+ {
+ String path = parent.getParcelContainerDir() + "/" + name;
+ return path;
+ }
+
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
new file mode 100644
index 000000000000..018f8baee687
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
@@ -0,0 +1,746 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+
+import com.sun.star.script.framework.log.*;
+import com.sun.star.script.framework.io.*;
+import com.sun.star.script.framework.provider.PathUtils;
+
+import com.sun.star.container.*;
+import com.sun.star.uno.Type;
+import com.sun.star.lang.*;
+import com.sun.star.io.*;
+import java.io.*;
+import java.util.*;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.ucb.XSimpleFileAccess2;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.uri.XUriReference;
+import com.sun.star.uri.XUriReferenceFactory;
+import com.sun.star.uri.XVndSunStarScriptUrl;
+
+/**
+ * The <code>ParcelContainer</code> object is used to store the
+ * ScripingFramework specific Libraries.
+ *
+ * @author
+ * @created
+ */
+
+public class ParcelContainer implements XNameAccess
+{
+ protected String language;
+ protected String containerUrl;
+ protected Collection parcels = new ArrayList(10);
+ static protected XSimpleFileAccess m_xSFA;
+ protected XComponentContext m_xCtx;
+ private ParcelContainer parent = null;
+ private Collection childContainers = new ArrayList(10);;
+ private boolean isPkgContainer = false;
+
+ /**
+ * Tests if this <tt>ParcelContainer</tt> represents an UNO package
+ * or sub package within an UNO package
+ *
+ * @return <tt>true</tt> if has parent <tt>false</tt> otherwise
+ */
+ public boolean isUnoPkg() { return isPkgContainer; }
+ /**
+ * Tests if this <tt>ParcelContainer</tt> has a parent
+ * a parent.
+ *
+ * @return <tt>true</tt> if has parent <tt>false</tt> otherwise
+ */
+ public boolean hasParent()
+ {
+ if ( parent == null )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns this <tt>ParcelContainer</tt>'s parent
+ *
+ * @return <tt>ParcelContainer</tt> if has parent null otherwise
+ */
+ public ParcelContainer parent()
+ {
+ return parent;
+ }
+
+ /**
+ * Returns all child <tt>ParcelContainer</tt>
+ * this instance of <tt>ParcelContainer</tt>
+ *
+ * @return a new array of ParcelContainers. A zero
+ * length array is returned if no child ParcelContainers.
+ */
+ public ParcelContainer[] getChildContainers()
+ {
+ if ( childContainers.isEmpty() )
+ {
+ return new ParcelContainer[0];
+ }
+ return (ParcelContainer[]) childContainers.toArray( new ParcelContainer[0] );
+
+ }
+ /**
+ * Removes a child <tt>ParcelContainer</tt>
+ * from this instance.
+ * @param child <tt>ParcelContainer</tt> to be added.
+ *
+ * @return <tt>true</tt> if child successfully removed
+ */
+ public boolean removeChildContainer( ParcelContainer child )
+ {
+ return childContainers.remove( child );
+ }
+
+ /**
+ * Adds a new child <tt>ParcelContainer</tt>
+ * to this instance.
+ * @param child <tt>ParcelContainer</tt> to be added.
+ *
+ */
+ public void addChildContainer( ParcelContainer child )
+ {
+ childContainers.add( child );
+ }
+
+ /**
+ * Returns a child <tt>ParcelContainer</tt> whose location
+ * matches the <tt>location</tt> argument passed to this method.
+ * @param key the <tt>location</tt> which is to
+ * be matched.
+ *
+ * @return child <tt>ParcelContainer</tt> or <null> if none
+ * found.
+ */
+
+ public ParcelContainer getChildContainer( String key )
+ {
+ ParcelContainer result = null;
+ Iterator iter = childContainers.iterator();
+ while ( iter.hasNext() )
+ {
+ ParcelContainer c = (ParcelContainer) iter.next();
+ String location = ScriptMetaData.getLocationPlaceHolder(
+ c.containerUrl, c.getName());
+
+ if ( key.equals( location ) )
+ {
+ result = c;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns a child <tt>ParcelContainer</tt> whose member
+ * <tt>containerUrl</tt> matches the <tt>containerUrl</tt>
+ * argument passed to this method.
+ * @param containerUrl the <tt>containerUrl</tt> which is to
+ * be matched.
+ *
+ * @return child <tt>ParcelContainer</tt> or <null> if none
+ * found.
+ */
+
+ public ParcelContainer getChildContainerForURL( String containerUrl )
+ {
+ ParcelContainer result = null;
+ Iterator iter = childContainers.iterator();
+ while ( iter.hasNext() )
+ {
+ ParcelContainer c = (ParcelContainer) iter.next();
+ if ( containerUrl.equals( c.containerUrl ) )
+ {
+ result = c;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns Name of this container. Name of this <tt>ParcelContainer</tt>
+ * is determined from the <tt>containerUrl</tt> as the last portion
+ * of the URL after the last forward slash.
+ * @return name of <tt>ParcelContainer</tt>
+ * found.
+ */
+ public String getName()
+ {
+ String name = null;
+ // TODO handler package ParcelContainer?
+ if ( !containerUrl.startsWith( "vnd.sun.star.tdoc:" ) )
+ {
+ // return name
+ String decodedUrl = java.net.URLDecoder.decode( containerUrl );
+ int indexOfSlash = decodedUrl.lastIndexOf( "/" );
+ if ( indexOfSlash != -1 )
+ {
+ name = decodedUrl.substring( indexOfSlash + 1 );
+ }
+ }
+ else
+ {
+ name = "document";
+ }
+ return name;
+ }
+
+ /**
+ * Initializes a newly created <code>ParcelContainer</code> object.
+ * @param xCtx UNO component context
+ * @param containerUrl location of this container.
+ * @param language language for which entries are stored
+ * @return name of <tt>ParcelContainer</tt>
+ * @throws IllegalArgumentException
+ * @throws WrappedTargetException
+ */
+
+ public ParcelContainer( XComponentContext xCtx, String containerUrl, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+
+ {
+ this( null, xCtx, containerUrl, language, true );
+ }
+
+ /**
+ * Initializes a newly created <code>ParcelContainer</code> object.
+ * @param xCtx UNO component context
+ * @param containerUrl location of this container.
+ * @param language language for which entries are stored
+ * @param loadParcels set to <tt>true</tt> if parcels are to be loaded
+ * on construction.
+ * @return name of <tt>ParcelContainer</tt>
+ * @throws IllegalArgumentException
+ * @throws WrappedTargetException
+ */
+ public ParcelContainer( XComponentContext xCtx, String containerUrl, String language, boolean loadParcels ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ {
+ this( null, xCtx, containerUrl, language, loadParcels );
+ }
+
+ /**
+ * Initializes a newly created <code>ParcelContainer</code> object.
+ * @param parent parent ParcelContainer
+ * @param xCtx UNO component context
+ * @param containerUrl location of this container.
+ * @param language language for which entries are stored
+ * @param loadParcels set to <tt>true</tt> if parcels are to be loaded
+ * on construction.
+ * @return name of <tt>ParcelContainer</tt>
+ * @throws IllegalArgumentException
+ */
+
+ public ParcelContainer( ParcelContainer parent, XComponentContext xCtx, String containerUrl, String language, boolean loadParcels ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+
+ {
+ LogUtils.DEBUG("Creating ParcelContainer for " + containerUrl + " loadParcels = " + loadParcels + " language = " + language );
+ this.m_xCtx = xCtx;
+ this.language = language;
+ this.parent = parent;
+ this.containerUrl = containerUrl;
+
+ initSimpleFileAccess();
+ boolean parentIsPkgContainer = false;
+
+ if ( parent != null )
+ {
+ parentIsPkgContainer = parent.isUnoPkg();
+ }
+
+ if ( containerUrl.endsWith("uno_packages") || parentIsPkgContainer )
+ {
+ isPkgContainer = true;
+ }
+
+ if ( loadParcels )
+ {
+ loadParcels();
+ }
+ }
+
+
+ public String getContainerURL() { return this.containerUrl; }
+
+ private synchronized void initSimpleFileAccess()
+ {
+ if ( m_xSFA != null )
+ {
+ return;
+ }
+ try
+ {
+ m_xSFA = ( XSimpleFileAccess )UnoRuntime.queryInterface(
+ XSimpleFileAccess.class,
+ m_xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess", m_xCtx ) );
+ }
+ catch ( Exception e )
+ {
+ // TODO should throw
+ LogUtils.DEBUG("Error instantiating simplefile access ");
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ }
+ }
+
+ public String getParcelContainerDir()
+ {
+ // If this container does not represent an uno-package
+ // then then it is a document, user or share
+ // in each case the convention is to have a Scripts/[language]
+ // dir where scripts reside
+ if ( !isUnoPkg() )
+ {
+ return PathUtils.make_url( containerUrl , "Scripts/" + language.toLowerCase() );
+ }
+ return containerUrl;
+ }
+ public Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, WrappedTargetException
+ {
+ Parcel parcel = null;
+ try
+ {
+ if ( hasElements() )
+ {
+ Iterator iter = parcels.iterator();
+ while ( iter.hasNext() )
+ {
+ Parcel parcelToCheck = (Parcel)iter.next();
+
+ if ( parcelToCheck.getName().equals( aName ) )
+ {
+ parcel = parcelToCheck;
+ break;
+ }
+ }
+ }
+ }
+ catch ( Exception e)
+ {
+ throw new WrappedTargetException( e.toString() );
+ }
+ if ( parcel == null )
+ {
+ throw new com.sun.star.container.NoSuchElementException( "Macro Library " + aName + " not found" );
+ }
+ return parcel;
+ }
+ public String[] getElementNames()
+ {
+ if ( hasElements() )
+ {
+ Parcel[] theParcels = (Parcel[])parcels.toArray( new Parcel[0] );
+ String[] names = new String[ theParcels.length ];
+ for ( int count = 0; count < names.length; count++ )
+ {
+ names[count] = theParcels[ count ].getName();
+ }
+ return names;
+ }
+
+ return new String[0];
+ }
+ public boolean hasByName( String aName )
+ {
+ boolean isFound = false;
+ try
+ {
+ if ( getByName( aName ) != null )
+ {
+ isFound = true;
+ }
+
+ }
+ catch ( Exception e )
+ {
+ //TODO - handle trace
+ }
+ return isFound;
+ }
+ public Type getElementType()
+ {
+ return new Type();
+ }
+ public boolean hasElements()
+ {
+ if ( parcels == null || parcels.isEmpty() )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private void loadParcels() throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ {
+ try
+ {
+ LogUtils.DEBUG("About to load parcels from " + containerUrl );
+ if ( m_xSFA.isFolder( getParcelContainerDir() ) )
+ {
+ LogUtils.DEBUG( getParcelContainerDir() + " is a folder " );
+ String[] children = m_xSFA.getFolderContents( getParcelContainerDir(), true );
+ parcels = new ArrayList(children.length);
+ for ( int i = 0; i < children.length; i++)
+ {
+ LogUtils.DEBUG("Processing " + children[ i ] );
+ try
+ {
+ loadParcel( children[ i ] );
+ }
+ catch (java.lang.Exception e)
+ {
+ // print an error message and move on to
+ // the next parcel
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught " + e.getClass().getName() + " exception loading parcel " + children[i] + ": " + e.getMessage() );
+ }
+ }
+ }
+ else
+ {
+ LogUtils.DEBUG(" ParcelCOntainer.loadParcels " + getParcelContainerDir() + " is not a folder ");
+ }
+
+ }
+ catch ( com.sun.star.ucb.CommandAbortedException e )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
+ LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
+ LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ }
+
+ public XNameContainer createParcel(String name) throws ElementExistException, com.sun.star.lang.WrappedTargetException
+ {
+ Parcel p = null;
+ if ( hasByName( name ) )
+ {
+ throw new ElementExistException( "Parcel " + name + " already exists" );
+ }
+ String pathToParcel = PathUtils.make_url( getParcelContainerDir() , name );
+
+ try
+ {
+ LogUtils.DEBUG("ParcelContainer.createParcel, creating folder " + pathToParcel );
+ m_xSFA.createFolder( pathToParcel );
+
+ LogUtils.DEBUG("ParcelContainer.createParcel, folder " + pathToParcel + " created ");
+
+ ParcelDescriptor pd = new ParcelDescriptor();
+ pd.setLanguage( language );
+ String parcelDesc = PathUtils.make_url( pathToParcel, ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
+ XSimpleFileAccess2 xSFA2 = ( XSimpleFileAccess2 )
+ UnoRuntime.queryInterface( XSimpleFileAccess2.class, m_xSFA );
+ if ( xSFA2 != null )
+ {
+ LogUtils.DEBUG("createParcel() Using XSIMPLEFILEACCESS2 " + parcelDesc );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream( 1024 );
+ pd.write( bos );
+ bos.close();
+ ByteArrayInputStream bis = new ByteArrayInputStream( bos.toByteArray() );
+ XInputStreamImpl xis = new XInputStreamImpl( bis );
+ xSFA2.writeFile( parcelDesc, xis );
+ xis.closeInput();
+ p = loadParcel( pathToParcel );
+ }
+ }
+ catch ( Exception e )
+ {
+
+ LogUtils.DEBUG("createParcel() Exception while attempting to create = " + name );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ return p;
+ }
+
+ public Parcel loadParcel( String parcelUrl ) throws com.sun.star.lang.WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ {
+
+ String name = null;
+
+ String parcelDescUrl = PathUtils.make_url( parcelUrl, ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
+ Parcel parcel = null;
+
+ XInputStream xis = null;
+ InputStream is = null;
+
+ try
+ {
+ if ( m_xSFA.exists( parcelDescUrl ) )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcel opening " + parcelDescUrl );
+ xis = m_xSFA.openFileRead( parcelDescUrl );
+ is = new XInputStreamWrapper( xis );
+
+ ParcelDescriptor pd = new ParcelDescriptor(is) ;
+ try
+ {
+ is.close();
+ is = null;
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcel Exception when closing stream for " + parcelDescUrl + " :" + e );
+ }
+ LogUtils.DEBUG("ParcelContainer.loadParcel closed " + parcelDescUrl );
+ if ( !pd.getLanguage().equals( language ) )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcel Language of Parcel does not match this container ");
+ return null;
+ }
+ LogUtils.DEBUG("Processing " + parcelDescUrl + " closed " );
+
+ int indexOfSlash = parcelUrl.lastIndexOf("/");
+ name = parcelUrl.substring( indexOfSlash + 1 );
+
+ parcel = new Parcel( m_xSFA, this, pd, name );
+
+ LogUtils.DEBUG(" ParcelContainer.loadParcel created parcel for " + parcelDescUrl + " for language " + language );
+ parcels.add( parcel );
+ }
+ else
+ {
+ throw new java.io.IOException( parcelDescUrl + " does NOT exist!");
+ }
+ }
+ catch ( com.sun.star.ucb.CommandAbortedException e )
+ {
+
+ LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ catch ( java.io.IOException e )
+ {
+ LogUtils.DEBUG("ParcelContainer.loadParcel() caught IOException while accessing " + parcelDescUrl + ": " + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+
+ LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+
+ finally
+ {
+ if ( is != null )
+ {
+ try
+ {
+ is.close(); // is will close xis
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ else if ( xis != null )
+ {
+ try
+ {
+ xis.closeInput();
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ }
+ return parcel;
+ }
+ public void renameParcel(String oldName, String newName) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming parcel " + oldName + " to " + newName );
+ LogUtils.DEBUG(" ** ParcelContainer is " + this );
+ Parcel p = (Parcel)getByName( oldName );
+ if ( p == null )
+ {
+ throw new com.sun.star.container.NoSuchElementException( "No parcel named " + oldName );
+ }
+ String oldParcelDirUrl = PathUtils.make_url( getParcelContainerDir(),
+ oldName );
+ String newParcelDirUrl = PathUtils.make_url( getParcelContainerDir(),
+ newName );
+ try
+ {
+ if (!m_xSFA.isFolder( oldParcelDirUrl ) )
+ {
+ Exception e = new com.sun.star.io.IOException("Invalid Parcel directory: " + oldName );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+ LogUtils.DEBUG(" ** ParcelContainer Renaming folder " + oldParcelDirUrl + " to " + newParcelDirUrl );
+ m_xSFA.move( oldParcelDirUrl, newParcelDirUrl );
+ }
+ catch ( com.sun.star.ucb.CommandAbortedException ce )
+ {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + ce );
+ throw new com.sun.star.lang.WrappedTargetException( ce.toString() );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+
+ p.rename( newName );
+ }
+ // removes but doesn't physically delele parcel from container
+ public boolean removeParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ boolean result = false;
+ Parcel p = (Parcel)getByName( name );
+ if ( p == null )
+ {
+ throw new com.sun.star.container.NoSuchElementException("No parcel named " + name );
+ }
+
+ result = parcels.remove( p );
+ return result;
+ }
+ public boolean deleteParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG( "deleteParcel for containerURL " + containerUrl + " name = " + name + " Langueg = " + language );
+ boolean result = false;
+
+ Parcel p = (Parcel)getByName( name );
+ if ( p == null )
+ {
+ throw new com.sun.star.container.NoSuchElementException("No parcel named " + name );
+ }
+
+ try
+ {
+ String pathToParcel = PathUtils.make_url( getParcelContainerDir(), name );
+ m_xSFA.kill( pathToParcel );
+ }
+ catch( Exception e )
+ {
+ LogUtils.DEBUG("Error deleteing parcel " + name );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString() );
+ }
+
+ result = parcels.remove( p );
+ return result;
+ }
+
+ public String getLanguage() { return language; }
+
+ public ScriptMetaData findScript( ParsedScriptUri parsedUri ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ ScriptMetaData scriptData = null;
+ Parcel p = null;
+ p = (Parcel)getByName( parsedUri.parcel);
+ scriptData = (ScriptMetaData)p.getByName( parsedUri.function);
+ LogUtils.DEBUG("** found script data for " + parsedUri.function + " script is " + scriptData );
+ return scriptData;
+
+ }
+public ParsedScriptUri parseScriptUri( String scriptURI ) throws com.sun.star.lang.IllegalArgumentException
+{
+
+ XMultiComponentFactory xMcFac = null;
+ XUriReferenceFactory xFac = null;
+
+ try
+ {
+ xMcFac = m_xCtx.getServiceManager();
+ xFac = ( XUriReferenceFactory )
+ UnoRuntime.queryInterface( XUriReferenceFactory.class,
+ xMcFac.createInstanceWithContext(
+ "com.sun.star.uri.UriReferenceFactory", m_xCtx ) );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG("Problems parsing URL:" + e.toString() );
+ throw new com.sun.star.lang.IllegalArgumentException( "Problems parsing URL reason: " + e.toString() );
+ }
+ if ( xFac == null )
+ {
+ LogUtils.DEBUG("Failed to create UrlReference factory");
+ throw new com.sun.star.lang.IllegalArgumentException( "Failed to create UrlReference factory for url " + scriptURI );
+ }
+
+ XUriReference uriRef = xFac.parse( scriptURI );
+ XVndSunStarScriptUrl sfUri = ( XVndSunStarScriptUrl )
+ UnoRuntime.queryInterface( XVndSunStarScriptUrl.class, uriRef );
+
+ if ( sfUri == null )
+ {
+ LogUtils.DEBUG("Failed to parse url");
+ throw new com.sun.star.lang.IllegalArgumentException( "Failed to parse url " + scriptURI );
+ }
+
+ ParsedScriptUri parsedUri = new ParsedScriptUri();
+ // parse language
+ parsedUri.language = sfUri.getParameter("language");
+ parsedUri.function= sfUri.getName();
+ parsedUri.parcel = "";
+
+ // parse parcel name;
+ StringTokenizer tokenizer = new StringTokenizer( parsedUri.function, "." );
+
+ if ( tokenizer.hasMoreElements() )
+ {
+ parsedUri.parcel = (String)tokenizer.nextElement();
+ LogUtils.DEBUG("** parcelName = " + parsedUri.parcel );
+ }
+
+ if ( parsedUri.function != null && ( parsedUri.function.length() > 0 ) )
+ {
+ // strip out parcel name
+ parsedUri.function = parsedUri.function.substring( parsedUri.parcel.length() + 1);
+ }
+
+ // parse location
+ parsedUri.location = sfUri.getParameter("location");
+
+ // TODO basic sanity check on language, location, functioname, parcel
+ // should be correct e.g. verified by MSP and LangProvider by the
+ // time its got to here
+
+ LogUtils.DEBUG("** location = " + parsedUri.location +
+ "\nfunction = " + parsedUri.function +
+ "\nparcel = " + parsedUri.parcel +
+ "\nlocation = " + parsedUri.location );
+ return parsedUri;
+}
+
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
new file mode 100644
index 000000000000..b78f07079f0c
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
@@ -0,0 +1,450 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.container;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.ByteArrayInputStream;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+// import javax.xml.parsers.DocumentBuilderFactory;
+// import javax.xml.parsers.DocumentBuilder;
+// import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.*;
+
+public class ParcelDescriptor {
+
+ // File name to be used for parcel descriptor files
+ public static final String
+ PARCEL_DESCRIPTOR_NAME = "parcel-descriptor.xml";
+
+ // Collection of all ParcelDescriptor created for files
+ private static final Map PARCEL_DESCRIPTOR_MAP = new HashMap(5);
+
+ // This is the default contents of a parcel descriptor to be used when
+ // creating empty descriptors
+ private static final byte[] EMPTY_DOCUMENT =
+ ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<parcel xmlns:parcel=\"scripting.dtd\" language=\"Java\">\n" +
+ "</parcel>").getBytes();
+
+ private File file = null;
+ private Document document = null;
+ private String language = null;
+ private Map languagedepprops = new Hashtable(3);
+
+ public static synchronized void removeParcelDescriptor(File parent) {
+ File path = new File(parent, PARCEL_DESCRIPTOR_NAME);
+ PARCEL_DESCRIPTOR_MAP.remove(path);
+ }
+
+ public static synchronized void renameParcelDescriptor(File oldFile, File newFile) {
+ File oldPath = new File(oldFile, PARCEL_DESCRIPTOR_NAME);
+ ParcelDescriptor pd = (ParcelDescriptor)PARCEL_DESCRIPTOR_MAP.get(oldPath);
+ if(pd != null) {
+ PARCEL_DESCRIPTOR_MAP.remove(oldPath);
+ File newPath = new File(newFile, PARCEL_DESCRIPTOR_NAME);
+ pd.file = newPath;
+ PARCEL_DESCRIPTOR_MAP.put(newPath, pd);
+ }
+ }
+
+ // returns the ParcelDescriptor in the corresponding directory
+ // returns null if no ParcelDescriptor is found in the directory
+ public static synchronized ParcelDescriptor
+ getParcelDescriptor(File parent) {
+
+ File path = new File(parent, PARCEL_DESCRIPTOR_NAME);
+ ParcelDescriptor pd = (ParcelDescriptor)PARCEL_DESCRIPTOR_MAP.get(path);
+
+ if (pd == null && path.exists()) {
+ try {
+ pd = new ParcelDescriptor(path);
+ }
+ catch (IOException ioe) {
+ return null;
+ }
+ PARCEL_DESCRIPTOR_MAP.put(path, pd);
+ }
+ return pd;
+ }
+
+ // returns a ParcelDescriptor for the corresponding directory
+ // if no ParcelDescriptor exists, one is created
+ public static synchronized ParcelDescriptor
+ createParcelDescriptor(File parent) throws IOException {
+
+ ParcelDescriptor pd = getParcelDescriptor(parent);
+
+ if (pd == null) {
+ if (parent == null || !parent.exists() || !parent.isDirectory()) {
+ throw new IOException("Cannot create Parcel Descriptor");
+ }
+
+ File path = new File(parent, PARCEL_DESCRIPTOR_NAME);
+ pd = new ParcelDescriptor(path);
+ PARCEL_DESCRIPTOR_MAP.put(path, pd);
+ }
+ return pd;
+ }
+
+ public ParcelDescriptor() throws IOException {
+ ByteArrayInputStream bis = null;
+ try {
+ bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
+ this.document = XMLParserFactory.getParser().parse(bis);
+ }
+ finally {
+ if (bis != null)
+ bis.close();
+ }
+ }
+
+ public ParcelDescriptor(Document document) {
+ this.document = document;
+ initLanguageProperties();
+ }
+
+ public ParcelDescriptor(InputStream is) throws IOException {
+ this(XMLParserFactory.getParser().parse(is));
+ }
+
+ public ParcelDescriptor(File file) throws IOException {
+ this(file, "Java");
+ }
+
+ public ParcelDescriptor(File file, String language) throws IOException {
+ this.file = file;
+
+ if (file.exists()) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
+ this.document = XMLParserFactory.getParser().parse(fis);
+ }
+ finally {
+ if (fis != null)
+ fis.close();
+ }
+ }
+ else {
+ ByteArrayInputStream bis = null;
+ try {
+ bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
+ this.document = XMLParserFactory.getParser().parse(bis);
+ }
+ finally {
+ if (bis != null)
+ bis.close();
+ }
+ setLanguage(language);
+ }
+ initLanguageProperties();
+ }
+
+ public void write(File file) throws IOException {
+ FileOutputStream fos = new FileOutputStream(file);
+ XMLParserFactory.getParser().write(document, fos);
+ fos.close();
+ }
+
+ public void write() throws IOException {
+ if (file == null)
+ throw new FileNotFoundException("No file specified");
+
+ write(file);
+ }
+
+ public void write(OutputStream out) throws IOException {
+ XMLParserFactory.getParser().write(document, out);
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public String getLanguage() {
+ if (language == null) {
+ if (document != null) {
+ Element e = document.getDocumentElement();
+ language = e.getAttribute("language");
+ }
+ }
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+
+ if (document != null) {
+ try {
+ Element e = document.getDocumentElement();
+ e.setAttribute("language", language);
+ }
+ catch (DOMException de) {
+ }
+ }
+ }
+
+ public ScriptEntry[] getScriptEntries() {
+ ArrayList scripts = new ArrayList();
+ NodeList scriptNodes;
+ int len;
+
+ if (document == null ||
+ (scriptNodes = document.getElementsByTagName("script")) == null ||
+ (len = scriptNodes.getLength()) == 0)
+ return new ScriptEntry[0];
+
+ for (int i = 0; i < len; i++) {
+ String language, languagename, logicalname, description = "";
+ Map langProps = new HashMap();
+ NodeList nl;
+ Element tmp;
+
+ Element scriptElement = (Element)scriptNodes.item(i);
+ language = scriptElement.getAttribute("language");
+
+ nl = scriptElement.getElementsByTagName("logicalname");
+ if (nl == null)
+ logicalname = "";
+ else {
+ tmp = (Element)nl.item(0);
+ logicalname = tmp.getAttribute("value");
+ }
+
+ // get the text of the description element
+ nl = scriptElement.getElementsByTagName("locale");
+ if (nl != null)
+ {
+ nl = nl.item(0).getChildNodes();
+ if (nl != null)
+ {
+ for (int j = 0 ; j < nl.getLength(); j++)
+ {
+ if (nl.item(j).getNodeName().equals("description"))
+ {
+ CharacterData cd =
+ (CharacterData)nl.item(j).getFirstChild();
+ description = cd.getData().trim();
+ }
+ }
+ }
+ }
+
+ nl = scriptElement.getElementsByTagName("functionname");
+ if (nl == null) {
+ languagename = "";
+ } else {
+ tmp = (Element)nl.item(0);
+ languagename = tmp.getAttribute("value");
+ }
+ nl = scriptElement.getElementsByTagName("languagedepprops");
+ if ( nl != null && nl.getLength() > 0 )
+ {
+
+ NodeList props = ((Element)nl.item(0)).getElementsByTagName("prop");
+ if ( props != null )
+ {
+ for ( int j=0; j < props.getLength(); j++ )
+ {
+ tmp = (Element)props.item(j);
+ String key = tmp.getAttribute("name");
+ String val = tmp.getAttribute("value");
+ langProps.put( key,val );
+ }
+ }
+ }
+ ScriptEntry entry = new ScriptEntry(language, languagename, logicalname, "",langProps, description);
+ scripts.add(entry);
+ }
+ return (ScriptEntry[])scripts.toArray(new ScriptEntry[0]);
+ }
+
+ public void setScriptEntries(ScriptEntry[] scripts) {
+ clearEntries();
+ for (int i = 0; i < scripts.length; i++)
+ addScriptEntry(scripts[i]);
+ }
+
+ public void setScriptEntries(Enumeration scripts) {
+ clearEntries();
+ while (scripts.hasMoreElements())
+ addScriptEntry((ScriptEntry) scripts.nextElement());
+ }
+
+ public String getLanguageProperty(String name) {
+ return (String)languagedepprops.get(name);
+ }
+
+ public void setLanguageProperty(String name, String value) {
+ languagedepprops.put(name, value);
+ setScriptEntries(getScriptEntries());
+ }
+
+ private void initLanguageProperties() {
+ NodeList nl = document.getElementsByTagName("languagedepprops");
+ int len;
+
+ if (nl != null && (len = nl.getLength()) != 0) {
+
+ for (int i = 0; i < len; i++) {
+ Element e = (Element)nl.item(i);
+ NodeList nl2 = e.getElementsByTagName("prop");
+ int len2;
+
+ if (nl2 != null && (len2 = nl2.getLength()) != 0) {
+ for (int j = 0; j < len2; j++) {
+ Element e2 = (Element)nl2.item(j);
+
+ String name = e2.getAttribute("name");
+ String value = e2.getAttribute("value");
+
+ if (getLanguageProperty(name) == null) {
+ languagedepprops.put(name, value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void clearEntries() {
+ NodeList scriptNodes;
+ Element main = document.getDocumentElement();
+ int len;
+
+ if ((scriptNodes = document.getElementsByTagName("script")) != null &&
+ (len = scriptNodes.getLength()) != 0)
+ {
+ for (int i = len - 1; i >= 0; i--) {
+ try {
+ main.removeChild(scriptNodes.item(i));
+ }
+ catch (DOMException de) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public void removeScriptEntry(ScriptEntry script) {
+ NodeList scriptNodes;
+ Element main = document.getDocumentElement();
+ int len;
+
+ if ((scriptNodes = document.getElementsByTagName("script")) != null &&
+ (len = scriptNodes.getLength()) != 0)
+ {
+ for (int i = len - 1; i >= 0; i--) {
+ try {
+ Element scriptElement = (Element)scriptNodes.item(i);
+ String languagename = "";
+
+ NodeList nl =
+ scriptElement.getElementsByTagName("functionname");
+ if (nl == null) {
+ continue;
+ } else {
+ Element tmp = (Element)nl.item(0);
+ languagename = tmp.getAttribute("value");
+ }
+
+ if (languagename.equals(script.getLanguageName())) {
+ main.removeChild(scriptElement);
+ }
+ }
+ catch (DOMException de) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public void addScriptEntry(ScriptEntry script) {
+ Element main = document.getDocumentElement();
+ Element root, item, tempitem;
+
+ root = document.createElement("script");
+ root.setAttribute("language", script.getLanguage());
+
+ item = document.createElement("locale");
+ item.setAttribute("lang", "en");
+ tempitem = document.createElement("displayname");
+ tempitem.setAttribute("value", script.getLogicalName());
+ item.appendChild(tempitem);
+
+ tempitem = document.createElement("description");
+ String description = script.getDescription();
+ if (description == null || description.equals(""))
+ {
+ description = script.getLogicalName();
+ }
+ tempitem.appendChild(document.createTextNode(description));
+ item.appendChild(tempitem);
+
+ root.appendChild(item);
+
+ item = document.createElement("logicalname");
+ item.setAttribute("value", script.getLogicalName());
+ root.appendChild(item);
+
+ item = document.createElement("functionname");
+ item.setAttribute("value", script.getLanguageName());
+ root.appendChild(item);
+
+ if (languagedepprops != null && languagedepprops.size() != 0) {
+ String key;
+ item = document.createElement("languagedepprops");
+
+ Iterator iter = languagedepprops.keySet().iterator();
+ while (iter.hasNext()) {
+ tempitem = document.createElement("prop");
+ key = (String)iter.next();
+ tempitem.setAttribute("name", key);
+ tempitem.setAttribute("value", (String)languagedepprops.get(key));
+ item.appendChild(tempitem);
+ }
+ root.appendChild(item);
+ }
+
+ //add to the Top Element
+ main.appendChild(root);
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java b/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java
new file mode 100644
index 000000000000..0a8febd8cdc6
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java
@@ -0,0 +1,36 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.container;
+
+public class ParsedScriptUri
+{
+ public String language;
+ public String location;
+ public String function;
+ public String parcel;
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
new file mode 100644
index 000000000000..a888a73c8f3b
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+import java.util.Map;
+import java.util.HashMap;
+public class ScriptEntry implements Cloneable {
+
+ private String language;
+ private String languagename;
+ private String location;
+ private String logicalname = "";
+ private String description = "";
+
+ private Map languagedepprops;
+
+ public ScriptEntry(String language, String languagename,
+ String logicalname, String location) {
+ this.language = language;
+ this.languagename = languagename;
+ // logical name/ function name concept
+ // needs to be reworked, in meantime
+ // function name ( from xml ) will be used
+ // as logical name also
+ this.logicalname = languagename;
+ this.location = location;
+ this.languagedepprops = new HashMap();
+ }
+
+ public ScriptEntry(ScriptEntry entry)
+ {
+ this.language = entry.language;
+ this.languagename = entry.languagename;
+ this.logicalname = entry.languagename;
+ this.location = entry.location;
+ this.languagedepprops = entry.languagedepprops;
+ this.description = entry.description;
+ }
+
+ public ScriptEntry(String language, String languagename,
+ String logicalname, String location, Map languagedepprops) {
+ this( language, languagename, logicalname, location );
+ this.languagedepprops = languagedepprops;
+ }
+
+ public ScriptEntry(String language, String languagename,
+ String logicalname, String location,
+ Map languagedepprops, String description) {
+ this( language, languagename, logicalname, location );
+ this.languagedepprops = languagedepprops;
+ this.description = description;
+ }
+
+ public ScriptEntry(String languagename, String location) {
+ this("Java", languagename, languagename, location);
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean equals(ScriptEntry other) {
+ if (language.equals(other.getLanguage()) &&
+ languagename.equals(other.getLanguageName()) &&
+ logicalname.equals(other.getLogicalName()) &&
+ languagedepprops.equals(other.getLanguageProperties()) &&
+ location.equals(other.getLocation()))
+ return true;
+ return false;
+ }
+
+ public Map getLanguageProperties()
+ {
+ return languagedepprops;
+ }
+
+ public String getLanguageName() {
+ return languagename;
+ }
+
+ public String getLogicalName() {
+ return logicalname;
+ }
+
+ public void setLogicalName(String name) {
+ logicalname = name;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String toString() {
+ return "\nLogicalName = " + logicalname + "\nLanguageName = " + languagename + "\nLocation = " + location + "\nLanguaguageProperties = " + languagedepprops;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
new file mode 100644
index 000000000000..e7007972936b
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+
+import java.net.URL;
+
+import java.io.ByteArrayInputStream;
+
+import java.util.Vector;
+import java.util.StringTokenizer;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import com.sun.star.script.framework.log.LogUtils;
+
+import com.sun.star.script.framework.provider.PathUtils;
+
+import com.sun.star.script.framework.io.XInputStreamImpl;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+import com.sun.star.script.framework.container.Parcel;
+
+import com.sun.star.script.framework.io.UCBStreamHandler;
+
+import com.sun.star.ucb.XSimpleFileAccess2;
+
+import com.sun.star.uno.UnoRuntime;
+
+public class ScriptMetaData extends ScriptEntry implements Cloneable {
+ private boolean hasSource = false;
+ private String locationPlaceHolder = "";
+ private String source;
+ private Parcel parent;
+
+
+ public ScriptMetaData( Parcel parent, ScriptEntry entry,
+ String source )
+ {
+ super( entry );
+ this.parent = parent;
+ if ( source != null )
+ {
+ this.hasSource = true;
+ this.source = source;
+ }
+
+ }
+
+ public boolean hasSource()
+ {
+ return hasSource;
+ }
+ public String getSource()
+ {
+
+ if ( source !=null && hasSource )
+ {
+ return source;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public byte[] getSourceBytes()
+ {
+ if ( source !=null && hasSource )
+ {
+ return source.getBytes();
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean equals(ScriptMetaData other) {
+ if (super.equals(other) &&
+ hasSource == other.hasSource() )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public String getScriptFullURL()
+ {
+ String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName() +
+ "?" + "language=" + getLanguage() +
+ "&location=" + getParcelLocation();
+ return url;
+ }
+
+ public String getShortFormScriptURL()
+ {
+ String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName() +
+ "?" + "language=" + getLanguage() +
+ "&location=" + getLocationPlaceHolder();
+ return url;
+ }
+
+ // TODO probably should be private should not be necessary
+ // to be exposed at all
+
+ private static final String SHARE =
+ "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" +
+ PathUtils.BOOTSTRAP_NAME +
+ "::BaseInstallation}/share";
+
+ private static final String USER =
+ "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" +
+ PathUtils.BOOTSTRAP_NAME +
+ "::UserInstallation}/user";
+
+ private static final String UNO_USER_PACKAGES1 =
+ "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE";
+
+ private static final String UNO_USER_PACKAGES2 =
+ USER + "/uno_packages";
+
+ private static final String UNO_SHARED_PACKAGES1 =
+ "$UNO_SHARED_PACKAGES_CACHE";
+
+ private static final String UNO_SHARED_PACKAGES2 =
+ SHARE + "/uno_packages";
+
+ public static String getLocationPlaceHolder(String url, String pkgname)
+ {
+ String result = "Unknown";
+
+ if ( url.indexOf(UNO_USER_PACKAGES1) > -1 ||
+ url.indexOf(UNO_USER_PACKAGES2) > -1 )
+ {
+ result = PathUtils.make_url( "user:uno_packages", pkgname );
+ }
+ else if ( url.indexOf(UNO_SHARED_PACKAGES1) > -1 ||
+ url.indexOf(UNO_SHARED_PACKAGES2) > -1 )
+ {
+ result = PathUtils.make_url( "share:uno_packages", pkgname );
+ }
+ else if ( url.indexOf(SHARE) == 0 )
+ {
+ result = "share";
+ }
+ else if ( url.indexOf(USER) == 0 )
+ {
+ result = "user";
+ }
+ else if ( url.indexOf("vnd.sun.star.tdoc:") == 0 )
+ {
+ result = "document";
+ }
+ return result;
+ }
+
+ public String getLocationPlaceHolder()
+ {
+ String placeHolder = "Unknown";
+ String pathToParcel = parent.getPathToParcel();
+
+ if ( pathToParcel.indexOf(UNO_USER_PACKAGES1) > -1 ||
+ pathToParcel.indexOf(UNO_USER_PACKAGES2) > -1 )
+ {
+ // its a package
+ placeHolder = "user:uno_packages";
+ String unoPkg = parent.parent.getName();
+ if ( unoPkg != null )
+ {
+ placeHolder = PathUtils.make_url( placeHolder, unoPkg );
+ }
+ }
+ else if ( pathToParcel.indexOf(UNO_SHARED_PACKAGES1) > -1 ||
+ pathToParcel.indexOf(UNO_SHARED_PACKAGES2) > -1 )
+ {
+ //its a package
+ placeHolder = "share:uno_packages";
+ String unoPkg = parent.parent.getName();
+ if ( unoPkg != null )
+ {
+ placeHolder = PathUtils.make_url( placeHolder, unoPkg );
+ }
+ }
+ else if ( pathToParcel.indexOf(SHARE) == 0 )
+ {
+ placeHolder = "share";
+ }
+ else if ( pathToParcel.indexOf(USER) == 0 )
+ {
+ placeHolder = "user";
+ }
+ else if ( pathToParcel.indexOf("vnd.sun.star.tdoc:") == 0 )
+ {
+ placeHolder = "document";
+ }
+ // TODO handling document packages ??? not really sure of package url
+/* else
+ {
+ } */
+ return placeHolder;
+ }
+
+ // TODO probably should be private should not be necessary
+ // to be exposed at all only used in lang providers at the moment
+ // to generate URL for script, editors should use a model of script
+ // source and not interact with the URL
+ // Also if it is to remain needs to be renamed to getParcelLocationURL
+
+ // return URL string to parcel
+ public String getParcelLocation()
+ {
+ return parent.getPathToParcel();
+ }
+
+
+ public String toString()
+ {
+ return "\nParcelLocation = " + getParcelLocation() + "\nLocationPlaceHolder = " + locationPlaceHolder + super.toString();
+ }
+
+ public URL[] getClassPath() throws java.net.MalformedURLException
+ {
+ try
+ {
+ String classpath = (String)getLanguageProperties().get("classpath");
+ Vector paths = null;
+
+ if ( classpath == null )
+ {
+ classpath = "";
+ }
+
+ String parcelPath = getParcelLocation();
+ // make sure path ends with /
+ if ( !parcelPath.endsWith("/") )
+ {
+ parcelPath += "/";
+ }
+
+ // replace \ with /
+ parcelPath = parcelPath.replace( '\\', '/' );
+
+ Vector classPathVec = new Vector();
+ StringTokenizer stk = new StringTokenizer(classpath, ":");
+ while ( stk.hasMoreElements() )
+ {
+ String relativeClasspath = (String)stk.nextElement();
+ String pathToProcess = PathUtils.make_url( parcelPath, relativeClasspath);
+ URL url = createURL( pathToProcess );
+ if ( url != null )
+ {
+ classPathVec.add ( url );
+ }
+
+ }
+ if ( classPathVec.size() == 0)
+ {
+ URL url = createURL( parcelPath );
+ if ( url != null )
+ {
+ classPathVec.add(url);
+ }
+ }
+
+ return (URL[])classPathVec.toArray( new URL[0]);
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("Failed to build class path " + e.toString() );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ return new URL[0];
+ }
+
+ }
+ private URL createURL( String path ) throws java.net.MalformedURLException
+ {
+ URL url = null;
+ int indexOfColon = path.indexOf(":");
+ String scheme = path.substring( 0, indexOfColon );
+ UCBStreamHandler handler = new UCBStreamHandler( parent.parent.m_xCtx, scheme, parent.m_xSFA);
+
+ path += UCBStreamHandler.separator;
+ url = new URL(null, path, handler);
+ return url;
+ }
+
+ // TODO should decide whether this should throw or not
+ // decide whether it should be public or protected ( final ? )
+ public void loadSource()
+ {
+ try
+ {
+ URL sourceUrl = getSourceURL();
+ LogUtils.DEBUG("** In load source BUT not loading yet for " + sourceUrl );
+
+ if ( sourceUrl != null )
+ {
+ StringBuffer buf = new StringBuffer();
+ InputStream in = sourceUrl.openStream();
+
+ byte[] contents = new byte[1024];
+ int len = 0;
+
+ while ((len = in.read(contents, 0, 1024)) != -1) {
+ buf.append(new String(contents, 0, len));
+ }
+
+ try {
+ in.close();
+ }
+ catch (java.io.IOException ignore ) {
+ LogUtils.DEBUG("** Failed to read scriot from url " + ignore.toString() );
+ }
+
+ source = buf.toString();
+ hasSource = true;
+ }
+ }
+ catch (java.io.IOException e) {
+ LogUtils.DEBUG("** Failed to read scriot from url " + e.toString());
+ }
+
+ }
+ protected boolean writeSourceFile()
+ {
+ String parcelLocation = parent.getPathToParcel();
+ String sourceFilePath = parent.getPathToParcel() + "/" + getLanguageName();
+ boolean result = false;
+ OutputStream os = null;
+ try
+ {
+ XSimpleFileAccess2 xSFA2 = ( XSimpleFileAccess2 )
+ UnoRuntime.queryInterface( XSimpleFileAccess2.class,
+ parent.m_xSFA );
+ if ( xSFA2 != null )
+ {
+ ByteArrayInputStream bis = new ByteArrayInputStream( getSourceBytes() );
+ XInputStreamImpl xis = new XInputStreamImpl( bis );
+ xSFA2.writeFile( sourceFilePath, xis );
+ xis.closeInput();
+ result = true;
+ }
+ }
+ // TODO re-examine exception processing should probably throw
+ // exceptions back to caller
+ catch ( Exception ignore )
+
+ {
+ }
+ return result;
+ }
+ protected boolean removeSourceFile()
+ {
+ String parcelLocation = parent.getPathToParcel();
+ String sourceFilePath = parcelLocation + "/" + getLanguageName();
+ boolean result = false;
+ try
+ {
+ parent.m_xSFA.kill( sourceFilePath );
+ result = true;
+ }
+ // TODO reexamine exception handling
+ catch ( Exception e )
+ {
+ }
+ return result;
+ }
+
+ public URL getSourceURL() throws java.net.MalformedURLException
+ {
+ String sUrl = null;
+ URL scriptURL = null;
+
+ sUrl = getParcelLocation();
+ sUrl = PathUtils.make_url( sUrl, getLanguageName() );
+ LogUtils.DEBUG("Creating script url for " + sUrl );
+ scriptURL = createURL( sUrl );
+ return scriptURL;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
new file mode 100644
index 000000000000..edf6a2d806b7
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
@@ -0,0 +1,438 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.container;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.provider.PathUtils;
+import com.sun.star.script.framework.io.XOutputStreamWrapper;
+import com.sun.star.script.framework.io.XInputStreamWrapper;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.OutputStream;
+import java.io.InputStream;
+
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XTruncate;
+
+import com.sun.star.deployment.XPackage;
+import com.sun.star.deployment.ExtensionRemovedException;
+
+public class UnoPkgContainer extends ParcelContainer
+{
+
+ private Map registeredPackages = new HashMap();
+ protected String extensionDb;
+ protected String extensionRepository;
+
+ public UnoPkgContainer( XComponentContext xCtx, String locationURL,
+ String _extensionDb, String _extensionRepository, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ {
+ super( xCtx, locationURL, language, false );
+ extensionDb = _extensionDb;
+ extensionRepository = _extensionRepository;
+ init();
+ }
+
+ // gets the ParcelContainer for persisted uno packages
+ public ParcelContainer getRegisteredUnoPkgContainer( String url )
+ {
+ if (!url.endsWith("/"))
+ {
+ url += "/";
+ }
+
+ LogUtils.DEBUG("** getRegisterPackage ctx = " + containerUrl );
+ LogUtils.DEBUG("** getRegisterPackage for uri " + url );
+ LogUtils.DEBUG("** getRegisterPackage for langugage " + language );
+ ParcelContainer result = (ParcelContainer)registeredPackages.get( url );
+ LogUtils.DEBUG("getRegisterPackage result is " + result );
+ return result;
+ }
+
+ public boolean hasRegisteredUnoPkgContainer( String url )
+ {
+ boolean result = false;
+ if ( getRegisteredUnoPkgContainer( url ) != null )
+ {
+ result = true;
+ }
+ return result;
+ }
+
+ private void registerPackageContainer( String url, ParcelContainer c )
+ {
+ if (!url.endsWith("/"))
+ {
+ url += "/";
+ }
+
+ LogUtils.DEBUG("RegisterPackage ctx = " + containerUrl );
+ LogUtils.DEBUG("RegisterPackage language = " + language );
+ LogUtils.DEBUG("RegisterPackage " + c + " for url " + url );
+ registeredPackages.put( url, c );
+ }
+
+ public void deRegisterPackageContainer( String url )
+ {
+ if (!url.endsWith("/"))
+ {
+ url += "/";
+ }
+
+ LogUtils.DEBUG("In deRegisterPackageContainer for " + url );
+ if ( hasRegisteredUnoPkgContainer( url ) )
+ {
+ try
+ {
+ DeployedUnoPackagesDB db = getUnoPackagesDB();
+ if ( db != null )
+ {
+ if ( db.removePackage( language, url ) )
+ {
+ writeUnoPackageDB( db );
+ ParcelContainer container =
+ ( ParcelContainer ) registeredPackages.get( url );
+ if ( !container.hasElements() )
+ {
+ // When all libraries within a package bundle
+ // ( for this language ) are removed also
+ // remove the container from its parent
+ // Otherwise, a container ( with no containees )
+ // representing the uno package bundle will
+ // still exist and so will get displayed
+ if ( container.parent() != null )
+ {
+ container.parent().removeChildContainer( container );
+ }
+ }
+ registeredPackages.remove( url );
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ //TODO revisit exception handling and exception here
+ //means something very wrong
+ LogUtils.DEBUG("***** deRegisterPackageContainer() got exception " + e );
+ }
+ }
+ LogUtils.DEBUG("Leaving deRegisterPackageContainer for " + url );
+ }
+
+ private void init() throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG("getting container for " + containerUrl );
+ DeployedUnoPackagesDB db = null;
+ try
+ {
+ db = getUnoPackagesDB();
+ if ( db != null )
+ {
+ String[] packages = db.getDeployedPackages( language );
+
+ for ( int i=0; i<packages.length;i++)
+ {
+ try
+ {
+ processUnoPackage( packages[i], language );
+ }
+ catch ( com.sun.star.lang.IllegalArgumentException ila)
+ {
+ LogUtils.DEBUG("Failed to process " + packages[i] + " for " + language);
+ LogUtils.DEBUG(" Reason: " + ila );
+ }
+ catch( Exception e )
+ {
+ // TODO proper exception or do we wish
+ // to ignore errors here
+ LogUtils.DEBUG("Something very wrong!!!!!");
+ LogUtils.DEBUG("Failed to process " + packages[i] + " for " + language);
+ LogUtils.DEBUG(" Reason: " + e );
+ }
+ }
+ }
+ }
+ catch ( com.sun.star.lang.WrappedTargetException e )
+ {
+ // no deployed packages
+ LogUtils.DEBUG("No deployed uno-packages for " + containerUrl );
+ }
+ }
+
+
+ public ScriptMetaData findScript( ParsedScriptUri psu ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+
+ {
+ ScriptMetaData scriptData = null;
+
+ String language = psu.language;
+ String functionName = psu.function;
+ String parcelName = psu.parcel;
+ String location = psu.location;
+
+ LogUtils.DEBUG("*** UnoPkgContainer.findScript() ***" +
+ "\ncontainerUrl = " + containerUrl +
+ "\nfunction = " + functionName +
+ "\nlocation = " + location +
+ "\nparcel = " + parcelName );
+
+ ParcelContainer pc = getChildContainer( location );
+
+ if ( pc == null )
+ {
+ throw new com.sun.star.lang.WrappedTargetException( "Failed to resolve script " , null, new com.sun.star.lang.IllegalArgumentException( "Cannot resolve script location for script = " + functionName ) );
+ }
+
+ scriptData = pc.findScript( psu );
+ return scriptData;
+
+ }
+
+ private DeployedUnoPackagesDB getUnoPackagesDB() throws com.sun.star.lang.WrappedTargetException
+ {
+ InputStream is = null;
+ DeployedUnoPackagesDB dp = null;
+ try
+ {
+// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
+ String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
+ LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl );
+ if ( m_xSFA.exists( packagesUrl ) )
+ {
+ if ( packagesUrl.startsWith( "vnd.sun.star.tdoc" ) )
+ {
+ // handles using XStorage directly
+ throw new com.sun.star.lang.WrappedTargetException("Can't handle documents yet");
+ }
+
+ is = new XInputStreamWrapper( m_xSFA.openFileRead( packagesUrl ) );
+ dp = new DeployedUnoPackagesDB( is );
+ try
+ {
+ is.close();
+ is = null;
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ else
+ {
+ LogUtils.DEBUG("getUnoPackagesDB() " + packagesUrl + " does not exist");
+ }
+ }
+ catch( Exception e )
+ {
+ LogUtils.DEBUG("getUnoPackagesDB() caught Exception: " + e );
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString());
+ }
+ finally
+ {
+ if ( is != null )
+ {
+ try
+ {
+ is.close();
+ is = null;
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ }
+
+ return dp;
+ }
+
+ private void writeUnoPackageDB( DeployedUnoPackagesDB dp ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG("In writeUnoPackageDB() ");
+
+ XOutputStream xos = null;
+ OutputStream os = null;
+ try
+ {
+// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
+ String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
+ xos = m_xSFA.openFileWrite( packagesUrl );
+ XTruncate xTrc = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xos );
+ if ( xTrc != null )
+ {
+ LogUtils.DEBUG("In writeUnoPackageDB() Truncating...." );
+ xTrc.truncate();
+ }
+ else
+ {
+ LogUtils.DEBUG("In writeUnoPackageDB() CANT Truncate...." );
+ }
+ os = new XOutputStreamWrapper( xos );
+ dp.write( os );
+ try
+ {
+ os.close(); // will close xos
+ os = null;
+ }
+ catch( Exception ignore )
+ {
+ }
+ }
+ catch( Exception e )
+ {
+ LogUtils.DEBUG("In writeUnoPackageDB() Exception: " + e );
+ throw new com.sun.star.lang.WrappedTargetException( e.toString());
+ }
+ finally
+ {
+ if ( os != null )
+ {
+ try
+ {
+ os.close(); // will close xos
+ os = null;
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ }
+ }
+
+ public void processUnoPackage( XPackage dPackage, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.container.ElementExistException
+ {
+ LogUtils.DEBUG("** in processUnoPackage " );
+ String uri = null;
+ DeployedUnoPackagesDB db = null;
+ uri = dPackage.getURL();
+
+ if ( !uri.endsWith( "/" ) )
+ {
+ uri += "/";
+ }
+
+ LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri );
+ LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName() );
+ LogUtils.DEBUG("** processUnoPackage getMediaType() -> " + dPackage.getPackageType().getMediaType() );
+ try
+ {
+ LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() );
+ }
+ catch (com.sun.star.deployment.ExtensionRemovedException e)
+ {
+ throw new com.sun.star.lang.WrappedTargetException(e.toString(), this, e);
+ }
+
+ processUnoPackage( uri, language );
+
+ db = getUnoPackagesDB();
+ if ( db == null )
+ {
+ try
+ {
+ db = new DeployedUnoPackagesDB();
+ }
+ catch ( java.io.IOException ioe )
+ {
+ throw new com.sun.star.lang.WrappedTargetException( ioe.toString());
+ }
+ }
+ db.addPackage( language, uri );
+ writeUnoPackageDB( db );
+ }
+
+ private void processUnoPackage( String uri, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.container.ElementExistException
+ {
+ if ( hasRegisteredUnoPkgContainer( uri ) )
+ {
+ throw new com.sun.star.container.ElementExistException( "Already a registered uno package " + uri + " for language " + language );
+ }
+ LogUtils.DEBUG("processUnoPackage - URL = " + uri );
+ LogUtils.DEBUG("processUnoPackage - script library package");
+ String parentUrl = uri;
+
+ if ( uri.indexOf( "%2Funo_packages%2F" ) > -1 ||
+ uri.indexOf( "/uno_packages/" ) > -1 ||
+ uri.indexOf("$UNO_USER_PACKAGES_CACHE/") > -1 ||
+ uri.indexOf("$UNO_SHARED_PACKAGES_CACHE/") > -1 ||
+ uri.indexOf("$BUNDLED_EXTENSIONS/") > -1 )
+ {
+ //its in a bundle need to determine the uno-package file its in
+ LogUtils.DEBUG("processUnoPackage - is part of a uno bundle");
+
+ int index = uri.lastIndexOf("/");
+ if ( uri.endsWith("/") )
+ {
+ uri = uri.substring( 0, index );
+ index = uri.lastIndexOf("/");
+ }
+
+ if ( index > -1 )
+ {
+ parentUrl = uri.substring( 0, index );
+ LogUtils.DEBUG("processUnoPackage - composition is contained in " + parentUrl);
+ }
+
+ ParcelContainer pkgContainer = getChildContainerForURL( parentUrl );
+ if ( pkgContainer == null )
+ {
+ pkgContainer = new ParcelContainer( this, m_xCtx, parentUrl, language, false );
+ if ( pkgContainer.loadParcel( uri ) == null )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library from composition package " + uri + " for language " + language );
+
+ }
+ addChildContainer( pkgContainer );
+ }
+ else
+ {
+ if ( pkgContainer.loadParcel( uri ) == null )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library from composition package " + uri + " for language " + language );
+ }
+
+ }
+ registerPackageContainer( uri, pkgContainer );
+ }
+ else
+ {
+ // stand-alone library package, e.g. not contained in
+ // an uno package
+ if ( loadParcel( uri ) == null )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library package " + uri + " for language " + language );
+ }
+ registerPackageContainer( uri, this );
+ }
+
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/XMLParser.java b/scripting/java/com/sun/star/script/framework/container/XMLParser.java
new file mode 100644
index 000000000000..5e5bd00fac0e
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/XMLParser.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import org.w3c.dom.Document;
+
+public interface XMLParser {
+ public Document parse(InputStream inputStream) throws IOException;
+ public void write(Document doc, OutputStream out) throws IOException;
+}
diff --git a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
new file mode 100644
index 000000000000..52405fe0ea7c
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.container;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import javax.xml.parsers.*;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class XMLParserFactory {
+
+ private static XMLParser parser = null;
+ private static String officedtdurl = null;
+
+ private XMLParserFactory() {}
+
+ public static XMLParser getParser() {
+ if (parser == null) {
+ synchronized (XMLParserFactory.class) {
+ if (parser == null)
+ parser = new DefaultParser();
+ }
+ }
+ return parser;
+ }
+
+ public static void setParser(XMLParser p) {
+ parser = p;
+ }
+
+ public static void setOfficeDTDURL(String url) {
+ officedtdurl = url;
+ }
+
+ private static class DefaultParser implements XMLParser {
+
+ private DocumentBuilderFactory factory;
+
+ public DefaultParser() {
+ factory = DocumentBuilderFactory.newInstance();
+ }
+
+ public Document parse(InputStream inputStream) throws IOException {
+ Document result = null;
+ InputSource is = null;
+
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ is = new InputSource(inputStream);
+
+ if (officedtdurl != null) {
+ is.setSystemId(officedtdurl);
+ }
+
+ result = builder.parse(is);
+ }
+ catch (SAXParseException spe) {
+ throw new IOException(spe.getMessage());
+ }
+ catch (SAXException se) {
+ throw new IOException(se.getMessage());
+ }
+ catch (ParserConfigurationException pce) {
+ throw new IOException(pce.getMessage());
+ }
+ return result;
+ }
+
+ public void write(Document doc, OutputStream out) throws IOException {
+ Class clazz = doc.getClass();
+ String name = clazz.getName();
+
+ // depending on the class of the Document object use introspection
+ // to invoke the appropriate methods for writing the XML
+ // this code is based on the code used by the NetBeans
+ // class XMLUtilImpl in the openide module
+ try {
+ if (name.equals("com.sun.xml.tree.XmlDocument") ||
+ name.equals("org.apache.crimson.tree.XmlDocument")) {
+
+ // these DOM implementations are self writing
+ Method write;
+ write = clazz.getDeclaredMethod("write",
+ new Class[] {OutputStream.class});
+ write.invoke(doc, new Object[] {out});
+ }
+ else {
+ // try xerces serialize package using introspection
+ ClassLoader cl = this.getClass().getClassLoader();
+
+ Class serializerClass = null;
+ Class formatterClass = null;
+
+ try {
+ serializerClass = Class.forName(
+ "org.apache.xml.serialize.XMLSerializer", true, cl);
+ formatterClass = Class.forName(
+ "org.apache.xml.serialize.OutputFormat", true, cl);
+ } catch (ClassNotFoundException cnfe) {
+ String prefix = "com.sun.org.apache.xml.internal.";
+
+ serializerClass = Class.forName(
+ prefix + "serialize.XMLSerializer" , true, cl);
+ formatterClass = Class.forName(
+ prefix + "serialize.OutputFormat", true, cl);
+ }
+
+ Object serializerObject = serializerClass.newInstance();
+ Object formatterObject = formatterClass.newInstance();
+
+ // improve output readability using the OutputFormat class
+ Method method = null;
+ method = formatterClass.getMethod("setMethod",
+ new Class[] {String.class});
+ method.invoke(formatterObject, new Object[] {"xml"});
+ method = formatterClass.getMethod("setIndenting",
+ new Class[] {Boolean.TYPE});
+ method.invoke(formatterObject, new Object[] {Boolean.TRUE});
+
+ // now set up an instance of XMLSerializer with our
+ // OutputStream and serialize our Document
+ method = serializerClass.getMethod("setOutputByteStream",
+ new Class[] {OutputStream.class});
+ method.invoke(serializerObject, new Object[] {out});
+ method = serializerClass.getMethod("setOutputFormat",
+ new Class[] {formatterClass});
+ method.invoke(serializerObject,
+ new Object[] {formatterObject});
+
+ method = serializerClass.getMethod("asDOMSerializer",
+ new Class[0]);
+ Object impl = method.invoke(serializerObject,
+ new Object[0]);
+
+ method = impl.getClass().getMethod("serialize",
+ new Class[] {Document.class});
+ method.invoke(impl, new Object[] {doc});
+ }
+ } catch (NoSuchMethodException ex) {
+ throw new IOException(ex.getMessage());
+ } catch (ClassNotFoundException ex) {
+ throw new IOException(ex.getMessage());
+ } catch (Exception ex) {
+ throw new IOException(ex.getMessage());
+ }
+ }
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
new file mode 100644
index 000000000000..6ca6fabff260
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
@@ -0,0 +1,281 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.io;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XTruncate;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.provider.PathUtils;
+
+public class UCBStreamHandler extends URLStreamHandler {
+
+ public final static String separator = "/ucb/";
+
+ private XComponentContext m_xContext = null;
+ private XMultiComponentFactory m_xMultiComponentFactory = null;
+ private XSimpleFileAccess m_xSimpleFileAccess = null;
+ private HashMap m_jarStreamMap = new HashMap(12);
+ public static String m_ucbscheme;
+
+ public UCBStreamHandler( XComponentContext ctxt, String scheme, XSimpleFileAccess xSFA )
+ {
+ LogUtils.DEBUG( "UCBStreamHandler ctor, scheme = " + scheme );
+ this.m_xContext = ctxt;
+ this.m_ucbscheme = scheme;
+ this.m_xSimpleFileAccess = xSFA;
+ }
+
+ public void parseURL(URL url, String spec, int start, int limit) {
+ LogUtils.DEBUG("**XUCBStreamHandler, parseURL: " + url + " spec: " + spec + " start: " + start + " limit: " + limit );
+
+ String file = url.getFile();
+ if (file == null)
+ file = spec.substring(start, limit);
+ else
+ file += spec.substring(start, limit);
+
+ LogUtils.DEBUG("**For scheme = " + m_ucbscheme );
+ LogUtils.DEBUG("**Setting path = " + file );
+ setURL(url, m_ucbscheme, null, -1, null, null, file, null, null);
+ }
+
+ public URLConnection openConnection(URL u) throws IOException {
+ return new UCBConnection(u);
+ }
+
+ private class UCBConnection extends URLConnection {
+
+ public UCBConnection(URL url) {
+ super(url);
+ }
+
+ public void connect() {
+ }
+
+ public InputStream getInputStream() throws IOException {
+ LogUtils.DEBUG("UCBConnectionHandler GetInputStream on " + url );
+ String sUrl = url.toString();
+ if (sUrl.lastIndexOf(separator) == -1) {
+ LogUtils.DEBUG("getInputStream straight file load" );
+ return getFileStreamFromUCB(sUrl);
+ }
+ else {
+ String path = sUrl.substring(0, sUrl.lastIndexOf(separator) );
+ String file = sUrl.substring(
+ sUrl.lastIndexOf(separator) + separator.length());
+ LogUtils.DEBUG("getInputStream, load of file from another file eg. " + file + " from " + path );
+ return getUCBStream(file, path);
+ }
+ }
+ public OutputStream getOutputStream() throws IOException {
+ LogUtils.DEBUG("UCBConnectionHandler getOutputStream on " + url );
+ OutputStream os = null;
+ try
+ {
+ String sUrl = url.toString();
+ if ( !( sUrl.lastIndexOf(separator) == -1) ) {
+ String path = sUrl.substring(0, sUrl.lastIndexOf(separator));
+ String file = sUrl.substring(
+ sUrl.lastIndexOf(separator) + separator.length());
+
+ if ( m_xSimpleFileAccess.isReadOnly( path ) )
+ {
+ throw new java.io.IOException("File is read only");
+ }
+
+ LogUtils.DEBUG("getOutputStream, create o/p stream for file eg. " + path );
+
+ // we will only deal with simple file write
+ XOutputStream xos = m_xSimpleFileAccess.openFileWrite( path );
+ XTruncate xtrunc = ( XTruncate ) UnoRuntime.queryInterface( XTruncate.class, xos );
+ if ( xtrunc != null )
+ {
+ xtrunc.truncate();
+ }
+ os = new XOutputStreamWrapper( xos );
+ }
+ if ( os == null )
+ {
+ throw new IOException("Failed to get OutputStream for " + sUrl );
+ }
+ }
+ catch ( com.sun.star.ucb.CommandAbortedException cae )
+ {
+ LogUtils.DEBUG("caught exception: " + cae.toString() + " getting writable stream from " + url );
+ throw new IOException( cae.toString() );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ LogUtils.DEBUG("caught unknown exception: " + e.toString() + " getting writable stream from " + url );
+ throw new IOException( e.toString() );
+ }
+ return os;
+ }
+ }
+
+
+ private InputStream getUCBStream(String file, String path)
+ throws IOException
+ {
+ InputStream is = null;
+ InputStream result = null;
+
+ try {
+ if (path.endsWith(".jar")) {
+ is = (InputStream)m_jarStreamMap.get(path);
+
+ if (is == null) {
+ is = getFileStreamFromUCB(path);
+ m_jarStreamMap.put(path, is);
+ }
+ else {
+ try {
+ is.reset();
+ }
+ catch (IOException e) {
+ is.close();
+ is = getFileStreamFromUCB(path);
+ m_jarStreamMap.put(path, is);
+ }
+ }
+ result = getFileStreamFromJarStream(file, is);
+ }
+ else
+ {
+ String fileUrl = PathUtils.make_url(path,file);
+ result = getFileStreamFromUCB(fileUrl);
+ }
+ }
+ finally {
+ if (is != null) {
+ try {
+ is.close();
+ }
+ catch (IOException ioe) {
+ LogUtils.DEBUG("Caught exception closing stream: " +
+ ioe.getMessage());
+ }
+ }
+ }
+ return result;
+ }
+
+ private InputStream getFileStreamFromJarStream(String file, InputStream is)
+ throws IOException
+ {
+ ZipInputStream zis = null;
+ ZipEntry entry = null;
+ boolean found = false;
+
+ zis = new ZipInputStream(is);
+
+ while (zis.available() != 0) {
+ entry = (ZipEntry)zis.getNextEntry();
+
+ if (entry.getName().equals(file)) {
+ return zis;
+ }
+ }
+ return null;
+ }
+
+ private InputStream getFileStreamFromUCB(String path)
+ throws IOException
+ {
+ InputStream result = null;
+ XInputStream xInputStream = null;
+
+ try {
+ LogUtils.DEBUG("Trying to read from " + path );
+ xInputStream = m_xSimpleFileAccess.openFileRead(path);
+ LogUtils.DEBUG("sfa appeared to read file " );
+ byte[][] inputBytes = new byte[1][];
+
+ int ln = 0;
+ int sz = m_xSimpleFileAccess.getSize(path);
+ // TODO don't depend on result of available() or size()
+ // just read stream 'till complete
+ if ( sz == 0 )
+ {
+ if ( xInputStream.available() > 0 )
+ {
+ sz = xInputStream.available();
+ }
+ }
+ LogUtils.DEBUG("size of file " + path + " is " + sz );
+ LogUtils.DEBUG("available = " + xInputStream.available() );
+ inputBytes[0] = new byte[sz];
+
+ ln = xInputStream.readBytes(inputBytes, sz);
+
+ if (ln != sz) {
+ throw new IOException(
+ "Failed to read " + sz + " bytes from XInputStream");
+ }
+
+ result = new ByteArrayInputStream(inputBytes[0]);
+ }
+ catch (com.sun.star.io.IOException ioe) {
+ LogUtils.DEBUG("caught exception " + ioe );
+ throw new IOException(ioe.getMessage());
+ }
+ catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("caught exception " + e );
+ throw new IOException(e.getMessage());
+ }
+ finally
+ {
+ if (xInputStream != null) {
+ try {
+ xInputStream.closeInput();
+ }
+ catch (Exception e2) {
+ LogUtils.DEBUG(
+ "Error closing XInputStream:" + e2.getMessage());
+ }
+ }
+ }
+ return result;
+ }
+
+ private String convertClassNameToFileName(String name) {
+ return name.replace('.', File.separatorChar) + ".class";
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
new file mode 100644
index 000000000000..c83c030662a4
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.io;
+
+import com.sun.star.io.XInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+
+public class XInputStreamImpl implements XInputStream
+{
+ InputStream is;
+ public XInputStreamImpl( InputStream is )
+ {
+ this.is = is;
+ }
+
+ public int readBytes( /*OUT*/byte[][] aData, /*IN*/int nBytesToRead ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
+ {
+ aData[ 0 ] = new byte[ nBytesToRead ];
+
+ int totalBytesRead = 0;
+
+ try
+ {
+ int bytesRead = 0;
+ while ( ( bytesRead = is.read( aData[ 0 ], totalBytesRead, nBytesToRead ) ) > 0 && ( totalBytesRead < nBytesToRead ) )
+ {
+ totalBytesRead += bytesRead;
+ nBytesToRead -= bytesRead;
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new com.sun.star.io.IOException( e.toString() );
+ }
+ catch ( IndexOutOfBoundsException aie )
+ {
+ throw new com.sun.star.io.BufferSizeExceededException( aie.toString() );
+ }
+ return totalBytesRead;
+ }
+
+ public int readSomeBytes( /*OUT*/byte[][] aData, /*IN*/int nMaxBytesToRead ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
+ {
+ int bytesToRead = nMaxBytesToRead;
+ int availableBytes = available();
+ if ( availableBytes < nMaxBytesToRead )
+ {
+ bytesToRead = availableBytes;
+ }
+ int read = readBytes( aData, bytesToRead );
+ return read;
+ }
+
+ public void skipBytes( /*IN*/int nBytesToSkip ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
+ {
+ long bytesSkipped = 0;
+ try
+ {
+ bytesSkipped = is.skip( (long)nBytesToSkip );
+ }
+ catch ( IOException e )
+ {
+ throw new com.sun.star.io.IOException( e.toString() );
+ }
+ }
+
+ public int available( ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException
+ {
+ int bytesAvail = 0;
+ try
+ {
+ bytesAvail = is.available();
+ }
+ catch ( IOException e )
+ {
+ throw new com.sun.star.io.IOException( e.toString() );
+ }
+ return bytesAvail;
+ }
+
+ public void closeInput( ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException
+ {
+ try
+ {
+ is.close();
+ }
+ catch( IOException e )
+ {
+ throw new com.sun.star.io.IOException( e.toString() );
+ }
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java
new file mode 100644
index 000000000000..cfc1b8489739
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.io;
+
+import java.io.InputStream;
+import com.sun.star.io.XInputStream;
+
+public class XInputStreamWrapper extends InputStream {
+ private XInputStream m_xInputStream;
+
+ public XInputStreamWrapper(XInputStream xInputStream) {
+ m_xInputStream = xInputStream;
+ }
+
+ public int read() throws java.io.IOException
+ {
+ byte[][] byteRet = new byte[1][0];
+ long numRead;
+
+ try {
+ numRead = m_xInputStream.readBytes(byteRet, 1);
+ }
+ catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+
+ if (numRead != 1) {
+ return -1;
+ }
+ return byteRet[0][0];
+ }
+
+ public int read( byte[] b ) throws java.io.IOException
+ {
+ byte[][] byteRet = new byte[1][];
+ byteRet[0] = b;
+ try
+ {
+ return m_xInputStream.readBytes( byteRet, b.length );
+ }
+ catch ( com.sun.star.io.IOException ioe)
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+ public long skip(long n) throws java.io.IOException
+ {
+ try {
+ m_xInputStream.skipBytes((int)n);
+ return n;
+ }
+ catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+ public int available() throws java.io.IOException
+ {
+ try {
+ return m_xInputStream.available();
+ }
+ catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+ public void close() throws java.io.IOException
+ {
+ try {
+ m_xInputStream.closeInput();
+ }
+ catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java b/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java
new file mode 100644
index 000000000000..dc2c7233708d
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.script.framework.io;
+import java.io.*;
+import com.sun.star.io.XOutputStream;
+
+
+public class XOutputStreamWrapper extends OutputStream {
+ XOutputStream m_xOutputStream;
+ public XOutputStreamWrapper(XOutputStream xOs ) {
+ this.m_xOutputStream = xOs;
+ }
+ public void write(int b)
+ throws java.io.IOException
+ {
+ if ( m_xOutputStream == null )
+ {
+ throw new java.io.IOException("Stream is null");
+ }
+ byte[] bytes = new byte[1];
+ bytes[0] = (byte) b;
+ try
+ {
+ m_xOutputStream.writeBytes( bytes );
+ }
+ catch ( com.sun.star.io.IOException ioe )
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+ public void write(byte[] b)
+ throws java.io.IOException
+ {
+
+ if ( m_xOutputStream == null )
+ {
+ throw new java.io.IOException( "Stream is null" );
+ }
+ try
+ {
+ m_xOutputStream.writeBytes( b );
+ }
+ catch ( com.sun.star.io.IOException ioe )
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+ public void write( byte[] b, int off, int len )
+ throws java.io.IOException
+ {
+ if ( m_xOutputStream == null )
+ {
+ throw new java.io.IOException( "Stream is null" );
+ }
+ byte[] bytes = new byte[len];
+ for ( int i=off; i< off+len; i++ )
+ {
+ bytes[i] = b[i];
+ }
+ try
+ {
+ m_xOutputStream.writeBytes(bytes);
+ }
+ catch ( com.sun.star.io.IOException ioe )
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+ public void flush()
+ throws java.io.IOException
+ {
+ if ( m_xOutputStream == null )
+ {
+ throw new java.io.IOException( "Stream is null" );
+ }
+ try
+ {
+ m_xOutputStream.flush();
+ }
+ catch ( com.sun.star.io.IOException ioe )
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+ public void close()
+ throws java.io.IOException
+ {
+ if ( m_xOutputStream == null )
+ {
+ throw new java.io.IOException( "Stream is null" );
+ }
+ try
+ {
+ m_xOutputStream.closeOutput();
+ }
+ catch ( com.sun.star.io.IOException ioe )
+ {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+
+ }
+
diff --git a/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java
new file mode 100644
index 000000000000..7043438bc87e
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.io;
+
+import com.sun.star.frame.XModel;
+
+import com.sun.star.container.XNameAccess;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.io.XStream;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+
+import com.sun.star.embed.XStorage;
+import com.sun.star.embed.XTransactedObject;
+
+import com.sun.star.document.XDocumentSubStorageSupplier;
+
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.EventObject;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.provider.PathUtils;
+
+import java.util.*;
+import java.io.*;
+
+
+public class XStorageHelper implements XEventListener
+{
+ XStorage[] xStorages;
+ XStream xStream;
+ XInputStream xIs = null;
+ XOutputStream xOs = null;
+ static Map modelMap = new HashMap();
+ XModel xModel = null;
+ private static XStorageHelper listener = new XStorageHelper();
+
+ private XStorageHelper() {}
+ public XStorageHelper( String path, int mode, boolean create ) throws IOException
+ {
+ String modelUrl = null;
+ int indexOfScriptsDir = path.lastIndexOf( "Scripts" );
+ if ( indexOfScriptsDir > -1 )
+ {
+ modelUrl = path.substring( 0, indexOfScriptsDir - 1 );
+ path = path.substring( indexOfScriptsDir, path.length());
+ }
+
+ LogUtils.DEBUG("XStorageHelper ctor, path: " + path);
+ this.xModel = getModelForURL( modelUrl );
+
+ try
+ {
+ StringTokenizer tokens = new StringTokenizer(path, "/");
+
+ if (tokens.countTokens() == 0)
+ {
+ throw new IOException("Invalid path");
+ }
+ XDocumentSubStorageSupplier xDocumentSubStorageSupplier =
+ (XDocumentSubStorageSupplier) UnoRuntime.queryInterface(
+ XDocumentSubStorageSupplier.class, xModel);
+ xStorages = new XStorage[tokens.countTokens() ];
+ LogUtils.DEBUG("XStorageHelper ctor, path chunks length: " + xStorages.length );
+
+ for ( int i = 0; i < xStorages.length; i++ )
+ {
+ LogUtils.DEBUG("XStorageHelper, processing index " + i );
+ String name = tokens.nextToken();
+ LogUtils.DEBUG("XStorageHelper, getting: " + name);
+ XStorage storage = null;
+ if ( i == 0 )
+ {
+ storage = xDocumentSubStorageSupplier.getDocumentSubStorage( name, mode );
+ if ( storage == null )
+ {
+ LogUtils.DEBUG("** boo hoo Storage is null " );
+ }
+ XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,storage );
+ if ( xProps != null )
+ {
+ String mediaType = AnyConverter.toString( xProps.getPropertyValue( "MediaType" ) );
+ LogUtils.DEBUG("***** media type is " + mediaType );
+ if ( !mediaType.equals("scripts") )
+ {
+ xProps.setPropertyValue("MediaType","scripts");
+ }
+ }
+ }
+ else
+ {
+ XNameAccess xNameAccess = (XNameAccess)
+ UnoRuntime.queryInterface(XNameAccess.class, xStorages[i-1]);
+ if (xNameAccess == null )
+ {
+ disposeObject();
+ throw new IOException("No name access " + name);
+ }
+ else if ( !xNameAccess.hasByName(name) || !xStorages[i-1].isStorageElement(name) )
+ {
+ if ( !create )
+ {
+ disposeObject();
+ throw new IOException("No subdir: " + name);
+ }
+ else
+ {
+ // attempt to create new storage
+ LogUtils.DEBUG("Attempt to create new storage for " + name );
+ }
+ }
+
+ storage = xStorages[i-1].openStorageElement(
+ name, mode );
+ }
+ if ( storage == null )
+ {
+ disposeObject();
+ throw new IOException("storage not found: " + name);
+ }
+ xStorages[ i ] = storage;
+
+ }
+ }
+ catch ( com.sun.star.io.IOException ioe)
+ {
+ disposeObject();
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ disposeObject();
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public synchronized static void addNewModel( XModel model )
+ {
+ // TODO needs to cater for model for untitled document
+ modelMap.put( PathUtils.getOidForModel( model ), model );
+ XComponent xComp = (XComponent)
+ UnoRuntime.queryInterface(XComponent.class, model);
+
+ if ( xComp != null )
+ {
+ try
+ {
+ xComp.addEventListener( listener );
+ }
+ catch ( Exception e )
+ {
+ // What TODO here ?
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ }
+ }
+ }
+
+ public void disposing( EventObject Source )
+ {
+ XModel model = (XModel)
+ UnoRuntime.queryInterface(XModel.class,Source.Source );
+
+ if ( model != null )
+ {
+ LogUtils.DEBUG(" Disposing doc " + model.getURL() );
+ Object result = modelMap.remove( model );
+ result = null;
+ }
+ }
+ public XStorage getStorage()
+ {
+ return xStorages[ xStorages.length - 1 ];
+ }
+ public XModel getModel()
+ {
+ return xModel;
+ }
+ public void disposeObject()
+ {
+ disposeObject( false );
+ }
+ public void disposeObject( boolean shouldCommit )
+ {
+ LogUtils.DEBUG("In disposeObject");
+
+ for ( int i = xStorages.length -1 ; i > -1; i-- )
+ {
+ LogUtils.DEBUG("In disposeObject disposing storage " + i );
+ try
+ {
+ XStorage xStorage = xStorages[i];
+ if ( shouldCommit )
+ {
+ commit(xStorage);
+ }
+ disposeObject(xStorage);
+ LogUtils.DEBUG("In disposeObject disposed storage " + i );
+ }
+ catch( Exception ignore )
+ {
+ LogUtils.DEBUG("Exception disposing storage " + i );
+ }
+
+ }
+
+ }
+ static public void disposeObject( XInterface xInterface )
+ {
+ if (xInterface == null) {
+ return;
+ }
+
+ XComponent xComponent = (XComponent)
+ UnoRuntime.queryInterface(XComponent.class, xInterface);
+
+ if (xComponent == null) {
+ return;
+ }
+ xComponent.dispose();
+ }
+ static public void commit( XInterface xInterface )
+ {
+ XTransactedObject xTrans = (XTransactedObject)
+ UnoRuntime.queryInterface(XTransactedObject.class, xInterface);
+ if ( xTrans != null )
+ {
+ try
+ {
+ xTrans.commit();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG("Something went bellyup exception: " + e );
+ }
+ }
+ }
+
+ public XModel getModelForURL( String url )
+ {
+ //TODO does not cater for untitled documents
+ return (XModel)modelMap.get( url );
+ }
+
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/log/LogUtils.java b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
new file mode 100644
index 000000000000..ef4b1f9a56ec
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
@@ -0,0 +1,68 @@
+package com.sun.star.script.framework.log;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+public class LogUtils {
+
+ private static boolean m_bDebugEnabled = false;
+
+ static
+ {
+ String debugFlag =
+ System.getProperties().getProperty("ScriptJavaRuntimeDebug");
+
+ if (debugFlag != null && debugFlag.length() > 0)
+ {
+ m_bDebugEnabled = debugFlag.equalsIgnoreCase("true");
+ }
+ }
+
+ // Ensure that instances of this class cannot be created
+ private LogUtils() {
+ }
+
+ /**
+ * Print Debug Output
+ *
+ * @param msg message to be displayed
+ */
+ public static void DEBUG(String msg)
+ {
+ if (m_bDebugEnabled)
+ {
+ System.out.println(msg);
+ }
+ }
+
+ public static String getTrace( Exception e )
+ {
+ ByteArrayOutputStream baos = null;
+ PrintStream ps = null;
+ String result = "";
+ try
+ {
+ baos = new ByteArrayOutputStream( );
+ ps = new PrintStream( baos );
+ e.printStackTrace( ps );
+ }
+ finally
+ {
+ try
+ {
+ if ( baos != null )
+ {
+ baos.close();
+ }
+ if ( ps != null )
+ {
+ ps.close();
+ }
+ }
+ catch ( Exception excp )
+ {
+ }
+ }
+ return result;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
new file mode 100755
index 000000000000..641ca589d9a5
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
@@ -0,0 +1,74 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider;
+
+import java.net.*;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+/**
+ * Class Loader Factory
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+public class ClassLoaderFactory
+{
+ private ClassLoaderFactory() {}
+
+ public static ClassLoader getURLClassLoader( ScriptMetaData scriptData )
+ throws NoSuitableClassLoaderException, MalformedURLException
+ {
+ ClassLoader parent = scriptData.getClass().getClassLoader();
+ URL[] classPath = scriptData.getClassPath();
+ LogUtils.DEBUG("Classpath has length " + classPath.length );
+ for ( int i=0; i < classPath.length; i++ )
+ {
+ LogUtils.DEBUG("ClassPath " + i + "} is " + classPath[ i ].toString() );
+ }
+ return getURLClassLoader( parent, classPath );
+ }
+ public static ClassLoader getURLClassLoader( ClassLoader parent, URL[] classpath)
+ throws NoSuitableClassLoaderException
+ {
+ ClassLoader loader =
+ new URLClassLoader( classpath, parent);
+
+ if (loader != null)
+ {
+ return loader;
+ }
+ else
+ {
+ throw new NoSuitableClassLoaderException(
+ "Unable to create URLClassLoader");
+ }
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java b/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java
new file mode 100644
index 000000000000..a311669fdb38
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.document.XScriptInvocationContext;
+
+import com.sun.star.script.provider.XScriptContext;
+
+
+/**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+public class EditorScriptContext implements XScriptContext
+{
+ private XDesktop m_xDeskTop;
+ private XComponentContext m_xComponentContext;
+ private XDesktop m_xCtx;
+ public EditorScriptContext( XComponentContext xmComponentContext,
+ XDesktop xDesktop )
+ {
+ this.m_xComponentContext = xmComponentContext;
+ this.m_xDeskTop = xDesktop;
+ }
+
+ //----------------------------------------------------------------------
+ /**
+ Obtain the document reference on which the script can operate
+
+ @returns
+ XModel interface
+ */
+ public XModel getDocument()
+ {
+ XModel xModel = ( XModel ) UnoRuntime.queryInterface( XModel.class,
+ m_xDeskTop.getCurrentComponent() );
+
+ return xModel;
+ }
+
+ public XScriptInvocationContext getInvocationContext()
+ {
+ XScriptInvocationContext xContext = ( XScriptInvocationContext ) UnoRuntime.queryInterface(
+ XScriptInvocationContext.class, getDocument() );
+ return xContext;
+ }
+
+ /**
+ Obtain the desktop reference on which the script can operate
+
+ @returns
+ XDesktop interface
+ */
+ public XDesktop getDesktop()
+ {
+ return m_xDeskTop;
+ }
+
+ /**
+ Obtain the component context which the script can use to create other uno components
+
+ @returns
+ XComponentContext interface
+ */
+ public XComponentContext getComponentContext()
+ {
+ return m_xComponentContext;
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java b/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java
new file mode 100755
index 000000000000..9b8613cf97cd
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.provider;
+
+public class NoSuitableClassLoaderException extends Exception
+{
+ /**
+ * Constructs an <code>NoSuitableClassLoaderException</code> with <code>null</code>
+ * as its error detail message.
+ */
+ public NoSuitableClassLoaderException()
+ {
+ super();
+ }
+ /**
+ * Constructs an <code>NoSuitBaleClassLoaderException</code> with the specified detail
+ * message. The error message string <code>s</code> can later be
+ * retrieved by the <code>{@link java.lang.Throwable#getMessage}</code>
+ * method of class <code>java.lang.Throwable</code>.
+ *
+ * @param s the detail message.
+ */
+ public NoSuitableClassLoaderException(String s)
+ {
+ super(s);
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/PathUtils.java b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java
new file mode 100644
index 000000000000..2084425979fc
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.provider;
+
+import java.util.StringTokenizer;
+
+import java.lang.reflect.Method;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.IQueryInterface;
+
+public class PathUtils {
+
+ public static String FILE_URL_PREFIX;
+ public static String BOOTSTRAP_NAME;
+ private static boolean m_windows = false;
+
+ static {
+ // detect if windows platform
+ if (System.getProperty("os.name").startsWith("Windows"))
+ m_windows = true;
+
+ FILE_URL_PREFIX = m_windows ? "file:///" : "file://";
+ BOOTSTRAP_NAME = m_windows ? "bootstrap.ini" : "bootstraprc";
+ }
+ public static String getOidForModel( XModel xModel )
+ {
+ String oid = new String("");
+ if ( xModel != null )
+ {
+ try
+ {
+ Method getOid = IQueryInterface.class.getMethod("getOid", (java.lang.Class[])null);
+ if ( getOid != null )
+ {
+ oid = (String)getOid.invoke( xModel, new Object[0] );
+ }
+
+ }
+ catch ( Exception ignore )
+ {
+ }
+ }
+ return oid;
+ }
+ static public String make_url( String baseUrl, String url )
+ {
+ StringBuffer buff = new StringBuffer( baseUrl.length() + url.length() ); buff.append( baseUrl );
+ StringTokenizer t = new StringTokenizer( url, "/");
+ while ( t.hasMoreElements() )
+ {
+ if ( buff.charAt( buff.length() - 1 ) != '/' )
+ {
+ buff.append('/');
+ }
+ buff.append( java.net.URLEncoder.encode( (String)t.nextElement() ) ); }
+ return buff.toString();
+ }
+
+ private PathUtils() {
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
new file mode 100644
index 000000000000..544bebb6ea9f
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
@@ -0,0 +1,165 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider;
+
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.lib.uno.helper.PropertySet;
+import com.sun.star.uno.Type;
+
+import com.sun.star.script.provider.XScriptContext;
+
+import com.sun.star.script.framework.log.LogUtils;
+
+
+/**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+public class ScriptContext extends PropertySet implements XScriptContext
+{
+ /**
+ * Description of the Class
+ *
+ * @author John Rice
+ * @created 18/09/02
+ */
+
+ public final static String HM_DOC_REF = "DocumentReference";
+ public final static String HM_DESKTOP = "Desktop";
+ public final static String HM_COMPONENT_CONTEXT = "ComponentContext";
+
+ private final static String DOC_REF = "SCRIPTING_DOC_REF";
+ private final static String DOC_URI = "SCRIPTING_DOC_URI";
+
+
+ public XModel m_xModel = null;
+ public XScriptInvocationContext m_xInvocationContext = null;
+ public String m_sDocURI = null;
+ public XDesktop m_xDeskTop = null;
+ public Integer m_iStorageID = null;
+ public XComponentContext m_xComponentContext = null;
+
+ public ScriptContext( XComponentContext xmComponentContext,
+ XDesktop xDesktop, XModel xModel, XScriptInvocationContext xInvocContext)
+ {
+ this.m_xDeskTop = xDesktop;
+ this.m_xComponentContext = xmComponentContext;
+ this.m_xModel = xModel;
+ this.m_xInvocationContext = xInvocContext;
+
+ if ( m_xModel != null )
+ {
+ registerProperty( DOC_URI, new Type(String.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_sDocURI");
+ }
+
+ registerProperty( HM_DOC_REF, new Type(XModel.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xModel");
+ registerProperty( HM_DESKTOP, new Type(XDesktop.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xDeskTop");
+ registerProperty( HM_COMPONENT_CONTEXT, new Type(XDesktop.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xComponentContext");
+ }
+
+ public static XScriptContext createContext( XModel xModel, XScriptInvocationContext xInvocContext,
+ XComponentContext xCtxt, XMultiComponentFactory xMCF)
+ {
+ XScriptContext sc = null;
+
+ try {
+
+ Object xInterface = null;
+ XDesktop xDesktop = null;
+
+ xInterface = xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtxt);
+ xDesktop = (XDesktop)
+ UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ if ( xModel != null )
+ {
+ sc = new ScriptContext(xCtxt, xDesktop, xModel, xInvocContext);
+ }
+ else
+ {
+ sc = new EditorScriptContext(xCtxt, xDesktop );
+ }
+
+ }
+ catch ( Exception e ) {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ }
+ return sc;
+ }
+
+ //----------------------------------------------------------------------
+ /**
+ Obtain the document reference on which the script can operate
+
+ @returns
+ XModel interface
+ */
+ public XModel getDocument()
+ {
+ return m_xModel;
+ }
+
+ public XScriptInvocationContext getInvocationContext()
+ {
+ return m_xInvocationContext;
+ }
+
+ /**
+ Obtain the desktop reference on which the script can operate
+
+ @returns
+ XDesktop interface
+ */
+ public XDesktop getDesktop()
+ {
+ return m_xDeskTop;
+ }
+
+ /**
+ Obtain the component context which the script can use to create other uno components
+
+ @returns
+ XComponentContext interface
+ */
+ public XComponentContext getComponentContext()
+ {
+ return m_xComponentContext;
+ }
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
new file mode 100644
index 000000000000..e6654d2bd83f
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
@@ -0,0 +1,13 @@
+package com.sun.star.script.framework.provider;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+public interface ScriptEditor
+{
+ public Object execute() throws Exception;
+ public void indicateErrorLine( int lineNum );
+ public void edit(XScriptContext context, ScriptMetaData entry);
+ public String getTemplate();
+ public String getExtension();
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
new file mode 100755
index 000000000000..e83410f3f35c
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
@@ -0,0 +1,745 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider;
+
+import com.sun.star.container.XNameContainer;
+
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XModel;
+
+import com.sun.star.util.XMacroExpander;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XVetoableChangeListener;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.beans.Property;
+
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.provider.XScriptProvider;
+import com.sun.star.script.provider.XScript;
+import com.sun.star.script.provider.ScriptFrameworkErrorException;
+import com.sun.star.script.provider.ScriptFrameworkErrorType;
+
+import com.sun.star.script.browse.XBrowseNode;
+import com.sun.star.script.browse.BrowseNodeTypes;
+
+import com.sun.star.script.framework.log.LogUtils;
+
+import com.sun.star.script.framework.container.ScriptMetaData;
+import com.sun.star.script.framework.container.XMLParserFactory;
+import com.sun.star.script.framework.container.ParcelContainer;
+import com.sun.star.script.framework.container.ParsedScriptUri;
+import com.sun.star.script.framework.container.UnoPkgContainer;
+
+import com.sun.star.ucb.Command;
+import com.sun.star.ucb.XContentProvider;
+import com.sun.star.ucb.XContent;
+import com.sun.star.ucb.XCommandProcessor;
+import com.sun.star.ucb.XContentIdentifier;
+import com.sun.star.ucb.XContentIdentifierFactory;
+
+import com.sun.star.sdbc.XRow;
+
+import com.sun.star.script.framework.browse.ProviderBrowseNode;
+import com.sun.star.script.framework.browse.DialogFactory;
+
+import com.sun.star.deployment.XPackage;
+
+
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.frame.XTransientDocumentsDocumentContentFactory;
+import com.sun.star.uno.TypeClass;
+
+public abstract class ScriptProvider
+ implements XScriptProvider, XBrowseNode, XPropertySet, XInvocation,
+ XInitialization, XTypeProvider, XServiceInfo, XNameContainer
+{
+ private final String[] __serviceNames = {
+ "com.sun.star.script.provider.ScriptProviderFor",
+ "com.sun.star.script.provider.LanguageScriptProvider"
+ };
+
+ public final static String CLASSPATH = "classpath";
+
+ protected String language;
+
+ protected XComponentContext m_xContext;
+ protected XMultiComponentFactory m_xMultiComponentFactory;
+ protected XModel m_xModel;
+ protected XScriptInvocationContext m_xInvocContext;
+ protected ParcelContainer m_container;
+
+ // proxies to helper objects which implement interfaces
+ private XPropertySet m_xPropertySetProxy;
+ private XInvocation m_xInvocationProxy;
+ // TODO should this be implemented in this class
+ private XBrowseNode m_xBrowseNodeProxy;
+ private XScriptContext m_xScriptContext;
+
+ public ScriptProvider( XComponentContext ctx, String language )
+ {
+ this.language = language;
+ __serviceNames[0] += language;
+
+ LogUtils.DEBUG( "ScriptProvider: constructor - start. " + language );
+
+ m_xContext = ctx;
+
+ // Initialize DialogFactory class in case dialogs are required
+ DialogFactory.createDialogFactory(m_xContext);
+
+ try
+ {
+ m_xMultiComponentFactory = m_xContext.getServiceManager();
+
+ if ( m_xMultiComponentFactory == null )
+ {
+ throw new Exception( "Error could not obtain a " +
+ "multicomponent factory - rethrowing Exception." );
+ }
+
+ Object serviceObj = m_xContext.getValueByName(
+ "/singletons/com.sun.star.util.theMacroExpander");
+
+ XMacroExpander me = (XMacroExpander) AnyConverter.toObject(
+ new Type(XMacroExpander.class), serviceObj);
+
+ XMLParserFactory.setOfficeDTDURL(me.expandMacros(
+ "${$BRAND_BASE_DIR/program/bootstraprc::BaseInstallation}/share/dtd/officedocument/1_0/"));
+
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Error constructing ScriptProvider: "
+ + e.getMessage() );
+ }
+
+ LogUtils.DEBUG( "ScriptProvider: constructor - finished." );
+ }
+
+ synchronized public XScriptContext getScriptingContext()
+ {
+ if ( m_xScriptContext == null )
+ {
+ m_xScriptContext = ScriptContext.createContext( m_xModel, m_xInvocContext, m_xContext, m_xMultiComponentFactory );
+ }
+ return m_xScriptContext;
+ }
+ public void initialize( Object[] aArguments )
+ throws com.sun.star.uno.Exception
+ {
+ LogUtils.DEBUG( "entering XInit for language " + language);
+ boolean isPkgProvider = false;
+ if( aArguments.length == 1 )
+ {
+ String contextUrl = null;
+ if ( AnyConverter.getType(aArguments[0]).getTypeClass().equals(TypeClass.INTERFACE) )
+ {
+ // try whether it denotes a XScriptInvocationContext
+ m_xInvocContext = (XScriptInvocationContext)UnoRuntime.queryInterface(
+ XScriptInvocationContext.class, aArguments[0]);
+ if ( m_xInvocContext != null )
+ {
+ // if so, obtain the document - by definition, this must be
+ // the ScriptContainer
+ m_xModel = (XModel)UnoRuntime.queryInterface( XModel.class,
+ m_xInvocContext.getScriptContainer() );
+ }
+ else
+ {
+ // otherwise, check whether it's an XModel
+ m_xModel = (XModel)UnoRuntime.queryInterface( XModel.class,
+ m_xInvocContext.getScriptContainer() );
+ }
+ if ( m_xModel == null )
+ {
+ throw new com.sun.star.uno.Exception(
+ "ScriptProvider argument must be either a string, a valid XScriptInvocationContext, " +
+ "or an XModel", this);
+ }
+
+ contextUrl = getDocUrlFromModel( m_xModel );
+ m_container = new ParcelContainer( m_xContext, contextUrl, language );
+ }
+ else if (AnyConverter.isString(aArguments[0]) == true)
+ {
+ String originalContextURL = AnyConverter.toString(aArguments[0]);
+ LogUtils.DEBUG("creating Application, path: " + originalContextURL );
+ contextUrl = originalContextURL;
+ // TODO no support for packages in documents yet
+ if ( originalContextURL.startsWith( "vnd.sun.star.tdoc" ) )
+ {
+ m_container = new ParcelContainer( m_xContext, contextUrl, language );
+ m_xModel = getModelFromDocUrl( originalContextURL );
+ }
+ else
+ {
+ String extensionDb = null;
+ String extensionRepository = null;
+ if ( originalContextURL.startsWith( "bundled" ) )
+ {
+ contextUrl = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "bundled";
+ }
+
+ if ( originalContextURL.startsWith( "share" ) )
+ {
+ contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "shared";
+ }
+ else if ( originalContextURL.startsWith( "user" ) )
+ {
+ contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "user";
+ }
+
+ if ( originalContextURL.endsWith( "uno_packages") )
+ {
+ isPkgProvider = true;
+ }
+ if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl )
+ && !extensionRepository.equals("bundled"))
+ {
+ contextUrl = PathUtils.make_url( contextUrl, "uno_packages" );
+ }
+ if ( isPkgProvider )
+ {
+ m_container = new UnoPkgContainer( m_xContext, contextUrl, extensionDb, extensionRepository, language );
+ }
+ else
+ {
+ m_container = new ParcelContainer( m_xContext, contextUrl, language );
+ }
+ }
+ }
+ else
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "ScriptProvider created with invalid argument");
+ }
+
+ LogUtils.DEBUG("Modified Application path is: " + contextUrl );
+ LogUtils.DEBUG("isPkgProvider is: " + isPkgProvider );
+
+ // TODO should all be done in this class instead of
+ // deleagation????
+ m_xBrowseNodeProxy = new ProviderBrowseNode( this,
+ m_container, m_xContext );
+
+ m_xInvocationProxy = (XInvocation)UnoRuntime.queryInterface(XInvocation.class, m_xBrowseNodeProxy);
+ m_xPropertySetProxy = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, m_xBrowseNodeProxy);
+ }
+ else
+ {
+ // this is ok, for example when executing a script from the
+ // command line
+ LogUtils.DEBUG( "ScriptProviderFor" + language +
+ " initialized without a context");
+ }
+ LogUtils.DEBUG( "leaving XInit" );
+ }
+
+ /**
+ * Gets the types attribute of the ScriptProvider object
+ *
+ * @return The types value
+ */
+ public com.sun.star.uno.Type[] getTypes()
+ {
+ Type[] retValue = new Type[ 8 ];
+ retValue[ 0 ] = new Type( XScriptProvider.class );
+ retValue[ 1 ] = new Type( XBrowseNode.class );
+ retValue[ 2 ] = new Type( XInitialization.class );
+ retValue[ 3 ] = new Type( XTypeProvider.class );
+ retValue[ 4 ] = new Type( XServiceInfo.class );
+ retValue[ 5 ] = new Type( XPropertySet.class );
+ retValue[ 6 ] = new Type( XInvocation.class );
+ retValue[ 7 ] = new Type( com.sun.star.container.XNameContainer.class );
+ return retValue;
+ }
+
+ /**
+ * Gets the implementationId attribute of the ScriptProvider object
+ *
+ * @return The implementationId value
+ */
+ public byte[] getImplementationId()
+ {
+ return this.getClass().getName().getBytes();
+ }
+
+ /**
+ * Gets the implementationName attribute of the ScriptProvider object
+ *
+ * @return The implementationName value
+ */
+ public String getImplementationName()
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Description of the Method
+ *
+ * @param serviceName Description of the Parameter
+ * @return Description of the Return Value
+ */
+ public boolean supportsService( String serviceName )
+ {
+ for ( int index = __serviceNames.length; index-- > 0; )
+ {
+ if ( serviceName.equals( __serviceNames[ index ] ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Gets the supportedServiceNames attribute of the ScriptProvider object
+ *
+ * @return The supportedServiceNames value
+ */
+ public String[] getSupportedServiceNames()
+ {
+ return __serviceNames;
+ }
+
+
+
+ public abstract XScript getScript( /*IN*/String scriptURI )
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException;
+
+ // TODO need to encapsulate this better,
+ // Some factory concept for creating/accessing Editor
+ // How this is passed down or how it is accessable by BrowseNode
+ // implementations needs thinking about
+ // This method is used to determine whether the ScriptProvider
+ // has a ScriptEditor
+ public abstract boolean hasScriptEditor();
+ // TODO see above
+ // This method is used to get the ScriptEditor for this ScriptProvider
+ public abstract ScriptEditor getScriptEditor();
+
+ public ScriptMetaData getScriptData( /*IN*/String scriptURI ) throws ScriptFrameworkErrorException
+
+ {
+ ParsedScriptUri details = null;
+ try
+ {
+ details = m_container.parseScriptUri( scriptURI );
+ ScriptMetaData scriptData = m_container.findScript( details );
+ if ( scriptData == null )
+ {
+ throw new ScriptFrameworkErrorException( details.function + " does not exist",
+ null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+ return scriptData;
+ }
+ catch ( com.sun.star.lang.IllegalArgumentException ila )
+ {
+ // TODO specify the correct error Type
+ throw new ScriptFrameworkErrorException( ila.getMessage(),
+ null, scriptURI, language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+ catch ( com.sun.star.container.NoSuchElementException nse )
+ {
+ throw new ScriptFrameworkErrorException( nse.getMessage(),
+ null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+ catch ( com.sun.star.lang.WrappedTargetException wta )
+ {
+ // TODO specify the correct error Type
+ Exception wrapped = (Exception)wta.TargetException;
+ String message = wta.getMessage();
+ if ( wrapped != null )
+ {
+ message = wrapped.getMessage();
+ }
+ throw new ScriptFrameworkErrorException( message,
+ null, details.function, language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ }
+
+
+ // Implementation of XBrowseNode interface
+ public String getName()
+ {
+ return language;
+ }
+
+ public XBrowseNode[] getChildNodes()
+ {
+ if ( m_xBrowseNodeProxy == null )
+ {
+ LogUtils.DEBUG("No Nodes available ");
+ return new XBrowseNode[0];
+ }
+ return m_xBrowseNodeProxy .getChildNodes();
+ }
+
+ public boolean hasChildNodes()
+ {
+ if ( m_xBrowseNodeProxy == null )
+ {
+ LogUtils.DEBUG("No Nodes available ");
+ return false;
+ }
+ return m_xBrowseNodeProxy.hasChildNodes();
+ }
+
+ public short getType()
+ {
+ return BrowseNodeTypes.CONTAINER;
+ }
+
+ public String toString()
+ {
+ return getName();
+ }
+
+ // implementation of XInvocation interface
+ public XIntrospectionAccess getIntrospection() {
+ return m_xInvocationProxy.getIntrospection();
+ }
+
+ public Object invoke(String aFunctionName, Object[] aParams,
+ short[][] aOutParamIndex, Object[][] aOutParam)
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ return m_xInvocationProxy.invoke(
+ aFunctionName, aParams, aOutParamIndex, aOutParam);
+ }
+
+ public void setValue(String aPropertyName, Object aValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException
+ {
+ m_xInvocationProxy.setValue(aPropertyName, aValue);
+ }
+
+ public Object getValue(String aPropertyName)
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ return m_xInvocationProxy.getValue(aPropertyName);
+ }
+
+ public boolean hasMethod(String aName) {
+ return m_xInvocationProxy.hasMethod(aName);
+ }
+
+ public boolean hasProperty(String aName) {
+ return m_xInvocationProxy.hasProperty(aName);
+ }
+
+ public XPropertySetInfo getPropertySetInfo()
+ {
+ return m_xPropertySetProxy.getPropertySetInfo();
+ }
+
+ public void setPropertyValue(String aPropertyName, Object aValue)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.beans.PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ m_xPropertySetProxy.setPropertyValue(aPropertyName, aValue);
+ }
+
+ public Object getPropertyValue(String PropertyName)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ return m_xPropertySetProxy.getPropertyValue(PropertyName);
+ }
+
+ public void addPropertyChangeListener(
+ String aPropertyName, XPropertyChangeListener xListener)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ m_xPropertySetProxy.addPropertyChangeListener(aPropertyName, xListener);
+ }
+
+ public void removePropertyChangeListener(
+ String aPropertyName, XPropertyChangeListener aListener)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ m_xPropertySetProxy.removePropertyChangeListener(
+ aPropertyName, aListener);
+ }
+
+ public void addVetoableChangeListener(
+ String PropertyName, XVetoableChangeListener aListener)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ m_xPropertySetProxy.addVetoableChangeListener(PropertyName, aListener);
+ }
+
+ public void removeVetoableChangeListener(
+ String PropertyName, XVetoableChangeListener aListener)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ m_xPropertySetProxy.removeVetoableChangeListener(
+ PropertyName, aListener);
+ }
+ public java.lang.Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ // TODO needs implementing?
+ if ( true )
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "getByName not implemented" );
+ }
+ return new Object();
+ }
+
+ public String[] getElementNames()
+ {
+ // TODO needs implementing?
+ String[] result = new String[0];
+ if ( true )
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "getElementNames not implemented" );
+
+ }
+ return result;
+ }
+
+
+ // Performs the getRegStatus functionality for the PkgMgr
+ public boolean hasByName( String aName )
+ {
+ boolean result = false;
+ if ( ((UnoPkgContainer)m_container).hasRegisteredUnoPkgContainer( aName ) )
+ {
+ result = true;
+ }
+ return result;
+ }
+
+ public com.sun.star.uno.Type getElementType()
+ {
+ // TODO at the moment this returns void indicating
+ // type is unknown should indicate XPackage ? do we implement XPackage
+ return new Type();
+ }
+
+ public boolean hasElements()
+ {
+ // TODO needs implementing?
+ boolean result = false;
+ if ( true )
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "hasElements not implemented" );
+
+ }
+ return result;
+ }
+ public void replaceByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ // TODO needs implementing
+ if ( true )
+ {
+ throw new com.sun.star.uno.RuntimeException(
+ "replaceByName not implemented" );
+
+ }
+ }
+
+ public void insertByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG("Provider for " + language + " received register for package " + aName );
+ XPackage newPackage = ( XPackage ) UnoRuntime.queryInterface( XPackage.class, aElement );
+ if ( aName.length() == 0 )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException( "Empty name" );
+ }
+ if ( newPackage == null )
+ {
+ throw new com.sun.star.lang.IllegalArgumentException( "No package supplied" );
+ }
+
+ ((UnoPkgContainer)m_container).processUnoPackage( newPackage, language );
+ }
+
+ // de-register for library only !!
+ public void removeByName( String Name ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ {
+ LogUtils.DEBUG("In ScriptProvider.removeByName() for " + Name + " this provider = " + language );
+ ParcelContainer c = ((UnoPkgContainer)m_container).getRegisteredUnoPkgContainer( Name );
+ if ( c != null )
+ {
+ String libName;
+ if (Name.endsWith("/"))
+ {
+ String tmp = Name.substring( 0, Name.lastIndexOf( "/" ) );
+ libName = tmp.substring( tmp.lastIndexOf( "/" ) + 1 );
+ }
+ else
+ {
+ libName = Name.substring( Name.lastIndexOf( "/" ) + 1 );
+ }
+ LogUtils.DEBUG("Deregistering library " + libName );
+ if ( c.removeParcel( libName ) )
+ {
+ ((UnoPkgContainer)m_container).deRegisterPackageContainer( Name );
+ }
+ else
+ {
+ throw new com.sun.star.container.NoSuchElementException( libName + " cannot be removed from container." );
+ }
+ }
+ else
+ {
+ throw new com.sun.star.container.NoSuchElementException( Name + " doesn't exist for " + language );
+ }
+ // TODO see if we want to remove the ParcelContainer is no Parcels/Libraries left
+ }
+
+ private String getDocUrlFromModel( XModel document )
+ {
+ XTransientDocumentsDocumentContentFactory factory = null;
+ try
+ {
+ factory = (XTransientDocumentsDocumentContentFactory)UnoRuntime.queryInterface(
+ XTransientDocumentsDocumentContentFactory.class,
+ m_xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.frame.TransientDocumentsDocumentContentFactory",
+ m_xContext
+ )
+ );
+ }
+ catch (Exception ex)
+ {
+ }
+
+ if ( factory == null )
+ throw new com.sun.star.uno.RuntimeException( "ScriptProvider: unable to create a TDOC context factory.", this );
+
+ try
+ {
+ XContent content = factory.createDocumentContent( document );
+ return content.getIdentifier().getContentIdentifier();
+ }
+ catch( Exception ex )
+ {
+ }
+
+ LogUtils.DEBUG("unable to determine the model's TDOC URL");
+ return "";
+ }
+
+ private XModel getModelFromDocUrl( String docUrl )
+ {
+ LogUtils.DEBUG("getModelFromDocUrl - searching for match for ->" + docUrl + "<-" );
+ XModel xModel = null;
+ try
+ {
+ Object[] args = new String[] {"Local", "Office" };
+
+ Object ucb = m_xMultiComponentFactory.createInstanceWithArgumentsAndContext( "com.sun.star.ucb.UniversalContentBroker", args, m_xContext );
+
+
+ XContentIdentifierFactory xFac = ( XContentIdentifierFactory )
+ UnoRuntime.queryInterface( XContentIdentifierFactory.class,
+ ucb );
+
+
+ XContentIdentifier xCntId = xFac.createContentIdentifier( docUrl );
+
+
+ XContentProvider xCntAccess = ( XContentProvider )
+ UnoRuntime.queryInterface( XContentProvider.class,
+ ucb );
+
+
+ XContent xCnt = xCntAccess.queryContent( xCntId );
+
+
+ XCommandProcessor xCmd = ( XCommandProcessor )
+ UnoRuntime.queryInterface( XCommandProcessor.class, xCnt );
+
+
+ Property[] pArgs = new Property[ ] { new Property() };
+ pArgs[ 0 ].Name = "DocumentModel";
+ pArgs[ 0 ].Handle = -1;
+
+ Command command = new Command();
+
+ command.Handle = -1;
+ command.Name = "getPropertyValues";
+ command.Argument = pArgs;
+
+ com.sun.star.ucb.XCommandEnvironment env = null ;
+ Object result = xCmd.execute( command, 0, env ) ;
+
+ XRow values = ( XRow ) UnoRuntime.queryInterface( XRow.class,
+ result );
+
+ xModel = ( XModel ) UnoRuntime.queryInterface( XModel.class,
+ values.getObject( 1, null ) );
+ }
+ catch ( Exception ignore )
+ {
+ LogUtils.DEBUG("Failed to get model exception " + ignore );
+
+ }
+ return xModel;
+ }
+
+
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java
new file mode 100755
index 000000000000..509da1623f53
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java
@@ -0,0 +1,247 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.beanshell;
+
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+import javax.swing.JComponent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.DocumentEvent;
+
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.Dimension;
+
+public class PlainSourceView extends JScrollPane
+ implements ScriptSourceView, DocumentListener {
+
+ private ScriptSourceModel model;
+ private JTextArea ta;
+ private GlyphGutter gg;
+ private int linecount;
+ private boolean isModified = false;
+
+ public PlainSourceView(ScriptSourceModel model) {
+ this.model = model;
+ initUI();
+ model.setView(this);
+ }
+
+ public void clear() {
+ ta.setText("");
+ }
+
+ public void update() {
+ /* Remove ourselves as a DocumentListener while loading the source
+ so we don't get a storm of DocumentEvents during loading */
+ ta.getDocument().removeDocumentListener(this);
+
+ if (isModified == false)
+ {
+ int pos = ta.getCaretPosition();
+ ta.setText(model.getText());
+ try {
+ ta.setCaretPosition(pos);
+ }
+ catch (IllegalArgumentException iae) {
+ // do nothing and allow JTextArea to set it's own position
+ }
+ }
+
+ // scroll to currentPosition of the model
+ try {
+ int line = ta.getLineStartOffset(model.getCurrentPosition());
+ Rectangle rect = ta.modelToView(line);
+ ta.scrollRectToVisible(rect);
+ }
+ catch (Exception e) {
+ // couldn't scroll to line, do nothing
+ }
+
+ gg.repaint();
+
+ // Add back the listener
+ ta.getDocument().addDocumentListener(this);
+ }
+
+ public boolean isModified() {
+ return isModified;
+ }
+
+ public void setModified(boolean value) {
+ isModified = value;
+ }
+
+ private void initUI() {
+ ta = new JTextArea();
+ ta.setRows(15);
+ ta.setColumns(40);
+ ta.setLineWrap(false);
+ ta.insert(model.getText(), 0);
+ linecount = ta.getLineCount();
+
+ gg = new GlyphGutter(this);
+
+ setViewportView(ta);
+ setRowHeaderView(gg);
+
+ ta.getDocument().addDocumentListener(this);
+ }
+
+ /* 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);
+ }
+
+ /* If the number of lines in the JTextArea has changed then update the
+ GlyphGutter */
+ public void doChanged(DocumentEvent e) {
+ isModified = true;
+
+ if (linecount != ta.getLineCount()) {
+ gg.update();
+ linecount = ta.getLineCount();
+ }
+ }
+
+ public String getText() {
+ return ta.getText();
+ }
+
+ public JTextArea getTextArea() {
+ return ta;
+ }
+
+ public int getCurrentPosition() {
+ return model.getCurrentPosition();
+ }
+}
+
+class GlyphGutter extends JComponent {
+
+ private PlainSourceView view;
+ private final String DUMMY_STRING = "99";
+
+ GlyphGutter(PlainSourceView view) {
+ this.view = view;
+ update();
+ }
+
+ public void update() {
+ JTextArea textArea = view.getTextArea();
+ Font font = textArea.getFont();
+ setFont(font);
+
+ FontMetrics metrics = getFontMetrics(font);
+ int h = metrics.getHeight();
+ int lineCount = textArea.getLineCount() + 1;
+
+ String dummy = Integer.toString(lineCount);
+ if (dummy.length() < 2) {
+ dummy = DUMMY_STRING;
+ }
+
+ Dimension d = new Dimension();
+ d.width = metrics.stringWidth(dummy) + 16;
+ d.height = lineCount * h + 100;
+ setPreferredSize(d);
+ setSize(d);
+ }
+
+ public void paintComponent(Graphics g) {
+ JTextArea textArea = view.getTextArea();
+
+ Font font = textArea.getFont();
+ g.setFont(font);
+
+ FontMetrics metrics = getFontMetrics(font);
+ Rectangle clip = g.getClipBounds();
+
+ g.setColor(getBackground());
+ g.fillRect(clip.x, clip.y, clip.width, clip.height);
+
+ int ascent = metrics.getMaxAscent();
+ int h = metrics.getHeight();
+ int lineCount = textArea.getLineCount() + 1;
+
+ int startLine = clip.y / h;
+ int endLine = (clip.y + clip.height) / h + 1;
+ int width = getWidth();
+ if (endLine > lineCount) {
+ endLine = lineCount;
+ }
+
+ for (int i = startLine; i < endLine; i++) {
+ String text;
+ text = Integer.toString(i + 1) + " ";
+ int w = metrics.stringWidth(text);
+ int y = i * h;
+ g.setColor(Color.blue);
+ g.drawString(text, 0, y + ascent);
+ int x = width - ascent;
+
+ // if currentPosition is not -1 then a red arrow will be drawn
+ if (i == view.getCurrentPosition()) {
+ drawArrow(g, ascent, x, y);
+ }
+ }
+ }
+
+ private void drawArrow(Graphics g, int ascent, int x, int y) {
+ Polygon arrow = new Polygon();
+ int dx = x;
+ y += ascent - 10;
+ int dy = y;
+ arrow.addPoint(dx, dy + 3);
+ arrow.addPoint(dx + 5, dy + 3);
+ for (x = dx + 5; x <= dx + 10; x++, y++) {
+ arrow.addPoint(x, y);
+ }
+ for (x = dx + 9; x >= dx + 5; x--, y++) {
+ arrow.addPoint(x, y);
+ }
+ arrow.addPoint(dx + 5, dy + 7);
+ arrow.addPoint(dx, dy + 7);
+
+ g.setColor(Color.red);
+ g.fillPolygon(arrow);
+ g.setColor(Color.black);
+ g.drawPolygon(arrow);
+ }
+};
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
new file mode 100644
index 000000000000..4fd5d85ac28d
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -0,0 +1,412 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.beanshell;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+
+import java.awt.FlowLayout;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import java.util.HashMap;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.framework.provider.ScriptEditor;
+import com.sun.star.script.framework.container.ScriptMetaData;
+import com.sun.star.script.framework.provider.ClassLoaderFactory;
+
+public class ScriptEditorForBeanShell
+ implements ScriptEditor, ActionListener
+{
+ private JFrame frame;
+ private String filename;
+
+ private ScriptSourceModel model;
+ private ScriptSourceView view;
+
+ private XScriptContext context;
+ private URL scriptURL = null;
+ private ClassLoader cl = null;
+
+ // global ScriptEditorForBeanShell returned for getEditor() calls
+ private static ScriptEditorForBeanShell theScriptEditorForBeanShell;
+
+ // global list of ScriptEditors, key is URL of file being edited
+ private static Map BEING_EDITED = new HashMap();
+
+ // template for new BeanShell scripts
+ private static String BSHTEMPLATE;
+
+ // try to load the template for BeanShell scripts
+ static {
+ try {
+ URL url =
+ ScriptEditorForBeanShell.class.getResource("template.bsh");
+
+ InputStream in = url.openStream();
+ StringBuffer buf = new StringBuffer();
+ byte[] b = new byte[1024];
+ int len = 0;
+
+ while ((len = in.read(b)) != -1) {
+ buf.append(new String(b, 0, len));
+ }
+
+ in.close();
+
+ BSHTEMPLATE = buf.toString();
+ }
+ catch (IOException ioe) {
+ BSHTEMPLATE = "// BeanShell script";
+ }
+ catch (Exception e) {
+ BSHTEMPLATE = "// BeanShell script";
+ }
+ }
+
+ /**
+ * Returns the global ScriptEditorForBeanShell instance.
+ */
+ public static ScriptEditorForBeanShell getEditor()
+ {
+ if (theScriptEditorForBeanShell == null)
+ {
+ synchronized(ScriptEditorForBeanShell.class)
+ {
+ if (theScriptEditorForBeanShell == null)
+ {
+ theScriptEditorForBeanShell =
+ new ScriptEditorForBeanShell();
+ }
+ }
+ }
+ return theScriptEditorForBeanShell;
+ }
+
+ /**
+ * Get the ScriptEditorForBeanShell instance for this URL
+ *
+ * @param url The URL of the script source file
+ *
+ * @return The ScriptEditorForBeanShell associated with
+ * the given URL if one exists, otherwise null.
+ */
+ public static ScriptEditorForBeanShell getEditor(URL url)
+ {
+ return (ScriptEditorForBeanShell)BEING_EDITED.get(url);
+ }
+
+ /**
+ * Returns whether or not the script source being edited in this
+ * ScriptEditorForBeanShell has been modified
+ */
+ public boolean isModified()
+ {
+ return view.isModified();
+ }
+
+ /**
+ * Returns the text being displayed in this ScriptEditorForBeanShell
+ *
+ * @return The text displayed in this ScriptEditorForBeanShell
+ */
+ public String getText()
+ {
+ return view.getText();
+ }
+
+ /**
+ * Returns the template text for BeanShell scripts
+ *
+ * @return The template text for BeanShell scripts
+ */
+ public String getTemplate() {
+ return BSHTEMPLATE;
+ }
+
+ /**
+ * Returns the default extension for BeanShell scripts
+ *
+ * @return The default extension for BeanShell scripts
+ */
+ public String getExtension() {
+ return "bsh";
+ }
+
+
+ /**
+ * Indicates the line where error occured
+ *
+ */
+ public void indicateErrorLine( int lineNum )
+ {
+ model.indicateErrorLine( lineNum );
+ }
+ /**
+ * Executes the script edited by the editor
+ *
+ */
+ public Object execute() throws Exception {
+ frame.toFront();
+ return model.execute( context, cl );
+ }
+ /**
+ * Opens an editor window for the specified ScriptMetaData.
+ * If an editor window is already open for that data it will be
+ * moved to the front.
+ *
+ * @param metadata The metadata describing the script
+ * @param context The context in which to execute the script
+ *
+ */
+ public void edit(XScriptContext context, ScriptMetaData entry) {
+
+ if (entry != null ) {
+ try {
+ ClassLoader cl = null;
+ try {
+ cl = ClassLoaderFactory.getURLClassLoader( entry );
+ }
+ catch (Exception ignore) // TODO re-examine error handling
+ {
+ }
+ String sUrl = entry.getParcelLocation();
+ if ( !sUrl.endsWith( "/" ) )
+ {
+ sUrl += "/";
+ }
+ sUrl += entry.getLanguageName();
+ URL url = entry.getSourceURL();
+
+ // check if there is already an editing session for this script
+ if (BEING_EDITED.containsKey(url))
+ {
+ ScriptEditorForBeanShell editor =
+ (ScriptEditorForBeanShell) BEING_EDITED.get(url);
+
+ editor.frame.toFront();
+ }
+ else
+ {
+ new ScriptEditorForBeanShell(context, cl, url);
+ }
+ }
+ catch (IOException ioe) {
+ showErrorMessage( "Error loading file: " + ioe.getMessage() );
+ }
+ }
+ }
+
+ private ScriptEditorForBeanShell() {
+ }
+
+ private ScriptEditorForBeanShell(XScriptContext context, ClassLoader cl,
+ URL url)
+ {
+ this.context = context;
+ this.scriptURL = url;
+ this.model = new ScriptSourceModel(url);
+ this.filename = url.getFile();
+ this.cl = cl;
+ try {
+ Class c = Class.forName(
+ "org.openoffice.netbeans.editor.NetBeansSourceView");
+
+ Class[] types = new Class[] { ScriptSourceModel.class };
+
+ java.lang.reflect.Constructor ctor = c.getConstructor(types);
+
+ if (ctor != null) {
+ Object[] args = new Object[] { this.model };
+ this.view = (ScriptSourceView) ctor.newInstance(args);
+ }
+ else {
+ this.view = new PlainSourceView(model);
+ }
+ }
+ catch (java.lang.Error err) {
+ this.view = new PlainSourceView(model);
+ }
+ catch (Exception e) {
+ this.view = new PlainSourceView(model);
+ }
+
+ this.model.setView(this.view);
+ initUI();
+ frame.show();
+
+ BEING_EDITED.put(url, this);
+ }
+
+ private void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(frame, message,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ private void initUI() {
+ frame = new JFrame("BeanShell Debug Window: " + filename);
+ frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+
+ frame.addWindowListener(
+ new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e) {
+ doClose();
+ }
+ }
+ );
+
+ String[] labels = {"Run", "Clear", "Save", "Close"};
+ JPanel p = new JPanel();
+ p.setLayout(new FlowLayout());
+
+ for (int i = 0; i < labels.length; i++) {
+ JButton b = new JButton(labels[i]);
+ b.addActionListener(this);
+ p.add(b);
+
+ if (labels[i].equals("Save") && filename == null) {
+ b.setEnabled(false);
+ }
+ }
+
+ frame.getContentPane().add((JComponent)view, "Center");
+ frame.getContentPane().add(p, "South");
+ frame.pack();
+ frame.setSize(590, 480);
+ frame.setLocation(300, 200);
+ }
+
+ private void doClose() {
+ if (view.isModified()) {
+ int result = JOptionPane.showConfirmDialog(frame,
+ "The script has been modified. " +
+ "Do you want to save the changes?");
+
+ if (result == JOptionPane.CANCEL_OPTION)
+ {
+ // don't close the window, just return
+ return;
+ }
+ else if (result == JOptionPane.YES_OPTION)
+ {
+ boolean saveSuccess = saveTextArea();
+ if (saveSuccess == false)
+ {
+ return;
+ }
+ }
+ }
+ frame.dispose();
+ shutdown();
+ }
+
+ private boolean saveTextArea() {
+ boolean result = true;
+
+ if (!view.isModified()) {
+ return true;
+ }
+
+ OutputStream fos = null;
+ try {
+ String s = view.getText();
+ fos = scriptURL.openConnection().getOutputStream();
+ if ( fos != null) {
+ fos.write(s.getBytes());
+ }
+ else
+ {
+ showErrorMessage(
+ "Error saving script: Could not open stream for file" );
+ result = false;
+ }
+ view.setModified(false);
+ }
+ catch (IOException ioe) {
+ showErrorMessage( "Error saving script: " + ioe.getMessage() );
+ result = false;
+ }
+ catch (Exception e) {
+ showErrorMessage( "Error saving script: " + e.getMessage() );
+ result = false;
+ }
+ finally {
+ if (fos != null) {
+ try {
+ fos.flush();
+ if ( fos != null )
+ {
+ fos.close();
+ }
+ }
+ catch (IOException ignore) {
+ }
+ }
+ }
+ return result;
+ }
+
+ private void shutdown()
+ {
+ if (BEING_EDITED.containsKey(scriptURL)) {
+ BEING_EDITED.remove(scriptURL);
+ }
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals("Run")) {
+ try
+ {
+ execute();
+ }
+ catch (Exception invokeException ) {
+ showErrorMessage(invokeException.getMessage());
+ }
+ }
+ else if (e.getActionCommand().equals("Close")) {
+ doClose();
+ }
+ else if (e.getActionCommand().equals("Save")) {
+ saveTextArea();
+ }
+ else if (e.getActionCommand().equals("Clear")) {
+ view.clear();
+ }
+ }
+}
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
new file mode 100755
index 000000000000..95c727881427
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
@@ -0,0 +1,383 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.beanshell;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.frame.XModel;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Any;
+
+import com.sun.star.reflection.InvocationTargetException;
+
+import java.util.StringTokenizer;
+
+import java.net.URL;
+
+import bsh.Interpreter;
+
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.script.provider.XScript;
+import com.sun.star.script.provider.ScriptErrorRaisedException;
+import com.sun.star.script.provider.ScriptExceptionRaisedException;
+import com.sun.star.script.provider.ScriptFrameworkErrorException;
+import com.sun.star.script.provider.ScriptFrameworkErrorType;
+
+
+import com.sun.star.script.framework.provider.*;
+import com.sun.star.script.framework.log.*;
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+public class ScriptProviderForBeanShell
+{
+ public static class _ScriptProviderForBeanShell extends ScriptProvider
+ {
+ public _ScriptProviderForBeanShell(XComponentContext ctx)
+ {
+ super (ctx, "BeanShell");
+ }
+
+ public XScript getScript( /*IN*/String scriptURI )
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException
+ {
+ ScriptMetaData scriptData = null;
+ try
+ {
+ scriptData = getScriptData( scriptURI );
+ ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel, m_xInvocContext );
+ return script;
+ }
+ catch ( com.sun.star.uno.RuntimeException re )
+ {
+ throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+ }
+
+ public boolean hasScriptEditor()
+ {
+ return true;
+ }
+
+ public ScriptEditor getScriptEditor()
+ {
+ return ScriptEditorForBeanShell.getEditor();
+ }
+ }
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ *
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @return returns a <code>XSingleServiceFactory</code> for creating
+ * the component
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if ( implName.equals( ScriptProviderForBeanShell._ScriptProviderForBeanShell.class.getName() ) )
+ {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ ScriptProviderForBeanShell._ScriptProviderForBeanShell.class,
+ "com.sun.star.script.ScriptProviderForBeanShell",
+ multiFactory,
+ regKey );
+ }
+
+ return xSingleServiceFactory;
+ }
+}
+
+class ScriptImpl implements XScript
+{
+ private ScriptMetaData metaData;
+ private XComponentContext m_xContext;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private XModel m_xModel;
+ private XScriptInvocationContext m_xInvocContext;
+
+ ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel,
+ XScriptInvocationContext xContext ) throws com.sun.star.uno.RuntimeException
+ {
+ this.metaData = metaData;
+ this.m_xContext = ctx;
+ this.m_xModel = xModel;
+ this.m_xInvocContext = xContext;
+
+ try
+ {
+ this.m_xMultiComponentFactory = m_xContext.getServiceManager();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Error constructing ScriptImpl [beanshell]: "
+ + e.getMessage() );
+ }
+
+ LogUtils.DEBUG("ScriptImpl [beanshell] script data = " + metaData );
+ }
+ /**
+ * documentStorageID and document reference
+ * for use in script name resolving
+ *
+ * @param aParams All parameters; pure, out params are
+ * undefined in sequence, i.e., the value
+ * has to be ignored by the callee
+ *
+ * @param aOutParamIndex Out indices
+ *
+ * @param aOutParam Out parameters
+ *
+ * @returns The value returned from the function
+ * being invoked
+ *
+ * @throws IllegalArgumentException If there is no matching script name
+ *
+ * @throws CannotConvertException If args do not match or cannot
+ * be converted the those of the
+ * invokee
+ *
+ * @throws InvocationTargetException If the running script throws
+ * an exception this information
+ * is captured and rethrown as
+ * this exception type.
+ */
+
+ public Object invoke( /*IN*/Object[] aParams,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam )
+ throws ScriptFrameworkErrorException,
+ InvocationTargetException
+ {
+ // Initialise the out paramters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+ try {
+ cl = ClassLoaderFactory.getURLClassLoader( metaData );
+ sourceUrl = metaData.getSourceURL();
+ }
+ catch ( java.net.MalformedURLException mfu )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ mfu.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL );
+ }
+ catch ( NoSuitableClassLoaderException nsc )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ nsc.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ // Set class loader to be used for class files
+ // and jar files
+ Thread.currentThread().setContextClassLoader(cl);
+ Interpreter interpreter = new Interpreter();
+
+ interpreter.getNameSpace().clear();
+ // Set class loader to be used by interpreter
+ // to look for classes by source e.g. interpreter
+ // will use this classloader to search classpath
+ // for source file ( bla.java ) on import or reference
+ interpreter.setClassLoader(cl);
+ try {
+ interpreter.set("XSCRIPTCONTEXT",
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory));
+
+ interpreter.set("ARGUMENTS", aParams);
+ }
+ catch (bsh.EvalError e) {
+ // Framework error setting up context
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ try {
+ String source = null;
+ Object result = null;
+
+ ScriptEditorForBeanShell editor =
+ ScriptEditorForBeanShell.getEditor(
+ sourceUrl );
+
+ if ( editor != null )
+ {
+ result = editor.execute();
+
+ if (result == null)
+ {
+ return new Any(new Type(), null);
+ }
+ return result;
+ }
+
+ metaData.loadSource();
+ source = metaData.getSource();
+
+ if ( source == null || source.length() == 0 )
+ {
+ throw new ScriptFrameworkErrorException(
+ "Failed to read script", null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+ result = interpreter.eval( source );
+
+ if (result == null)
+ {
+ return new Any(new Type(), null);
+ }
+ return result;
+ }
+ catch ( bsh.ParseException pe )
+ {
+ throw new InvocationTargetException( "Beanshell failed to parse " + metaData.getLanguageName(), null, processBshException( pe, metaData.getLanguageName() ) );
+ }
+ catch ( bsh.TargetError te )
+ {
+ throw new InvocationTargetException( "Beanshell uncaught exception for " + metaData.getLanguageName(), null, processBshException( te, metaData.getLanguageName() ) );
+ }
+ catch ( bsh.EvalError ex )
+ {
+ throw new InvocationTargetException( "Beanshell error for " + metaData.getLanguageName(), null, processBshException( ex, metaData.getLanguageName() ) );
+ }
+ catch ( Exception e )
+ {
+ throw new ScriptFrameworkErrorException(
+ "Failed to read script", null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ }
+ private void raiseEditor( int lineNum )
+ {
+ ScriptEditorForBeanShell editor = null;
+ try
+ {
+ URL sourceUrl = metaData.getSourceURL();
+ editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
+ if ( editor == null )
+ {
+ editor = ScriptEditorForBeanShell.getEditor();
+ editor.edit(
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory), metaData );
+ editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
+ }
+ if ( editor != null )
+ {
+ editor.indicateErrorLine( lineNum );
+ }
+ }
+ catch( Exception ignore )
+ {
+ }
+ }
+
+ private ScriptErrorRaisedException processBshException( bsh.EvalError e, String script )
+ {
+ LogUtils.DEBUG("Beanshell error RAW message " + e.getMessage());
+ String message = e.getMessage();
+ int usefullInfoIndex = message.lastIndexOf("\' :" );
+ int lineNum = e.getErrorLineNumber();
+
+ raiseEditor( lineNum );
+
+ //String stackTrace = te.getScriptStackTrace(); // never seems to have any info??
+ if ( usefullInfoIndex > -1 )
+ {
+ message = message.substring( usefullInfoIndex + 2 );
+ }
+ if ( e instanceof bsh.TargetError )
+ {
+ LogUtils.DEBUG("got instance of TargetError");
+ if ( usefullInfoIndex == -1 )
+ {
+ message = ( ( bsh.TargetError)e ).getTarget().getMessage();
+ }
+ String wrappedException = "";
+ String full = e.toString();
+ int index = full.indexOf( "Target exception:" );
+ if ( index > -1 )
+ {
+ String toParse = full.substring( index );
+ LogUtils.DEBUG("About to parse " + toParse );
+ StringTokenizer tokenizer = new StringTokenizer( full.substring( index ),":" );
+ if ( tokenizer.countTokens() > 2 )
+ {
+ LogUtils.DEBUG("First token = " + (String)tokenizer.nextElement());
+ wrappedException = (String)tokenizer.nextElement();
+ LogUtils.DEBUG("wrapped exception = = " + wrappedException );
+ }
+ }
+ ScriptExceptionRaisedException se = new ScriptExceptionRaisedException( message);
+ se.lineNum = lineNum;
+ se.scriptName = script;
+ se.exceptionType = wrappedException;
+ se.language = "BeanShell";
+ LogUtils.DEBUG("UnCaught Exception error: " );
+ LogUtils.DEBUG("\tscript: " + script );
+ LogUtils.DEBUG("\tline: " + lineNum );
+ LogUtils.DEBUG("\twrapped exception: " + wrappedException );
+ LogUtils.DEBUG("\tmessage: " + message );
+ return se;
+ }
+ else
+ {
+ LogUtils.DEBUG("Error or ParseError Exception error: " );
+ LogUtils.DEBUG("\tscript: " + script );
+ LogUtils.DEBUG("\tline: " + lineNum );
+ LogUtils.DEBUG("\tmessage: " + message );
+ return new ScriptErrorRaisedException( message, null, script, "BeanShell", lineNum );
+ }
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
new file mode 100644
index 000000000000..05b2850f33a8
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.beanshell;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import java.net.URL;
+
+import com.sun.star.script.provider.XScriptContext;
+
+public class ScriptSourceModel {
+
+ private int currentPosition = -1;
+ private URL file = null;
+ private ScriptSourceView view = null;
+
+ public ScriptSourceModel(URL file ) {
+ this.file = file;
+ }
+
+ private String load() throws IOException {
+ StringBuffer buf = new StringBuffer();
+ InputStream in = file.openStream();
+
+ byte[] contents = new byte[1024];
+ int len = 0;
+
+ while ((len = in.read(contents, 0, 1024)) != -1) {
+ buf.append(new String(contents, 0, len));
+ }
+
+ try {
+ in.close();
+ }
+ catch (IOException ignore) {
+ }
+
+ return buf.toString();
+ }
+
+ public String getText() {
+ String result = "";
+
+ try {
+ result = load();
+ }
+ catch (IOException ioe) {
+ // do nothing, empty string will be returned
+ }
+
+ return result;
+ }
+
+ public int getCurrentPosition() {
+ return this.currentPosition;
+ }
+
+ public void setView(ScriptSourceView view) {
+ this.view = view;
+ }
+
+ public Object execute(final XScriptContext context, ClassLoader cl )
+ throws Exception
+ {
+ Object result = null;
+ // Thread execThread = new Thread() {
+ // public void run() {
+ if ( cl != null )
+ {
+ // sets this threads class loader
+ // hopefully any threads spawned by this
+ // will inherit this cl
+ // this enables any class files imported
+ // from the interpreter to be loaded
+ // note: setting the classloader on the
+ // interpreter has a slightly different
+ // meaning in that the classloader for
+ // the interpreter seems only to look for
+ // source files ( bla.java ) in the classpath
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ bsh.Interpreter interpreter = new bsh.Interpreter();
+ if ( cl != null )
+ {
+ // additionally set class loader on the interpreter
+ // to allow it to load java classes defined in source
+ // files e.g. bla.java
+ interpreter.getNameSpace().clear();
+ }
+
+
+ // reset position
+ currentPosition = -1;
+ view.update();
+
+ interpreter.set("XSCRIPTCONTEXT", context);
+ interpreter.set("ARGUMENTS", new Object[0]);
+
+ if (view.isModified()) {
+ result = interpreter.eval(view.getText());
+ }
+ else {
+ result = interpreter.eval(getText());
+ }
+ // }
+ // };
+ // execThread.start();
+ return result;
+ }
+ public void indicateErrorLine( int lineNum )
+ {
+ System.out.println("Beanshell indicateErrorLine " + lineNum );
+ currentPosition = lineNum - 1;
+ view.update();
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceView.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceView.java
new file mode 100644
index 000000000000..22b4e375aa05
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceView.java
@@ -0,0 +1,35 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.beanshell;
+
+public interface ScriptSourceView {
+ public void clear();
+ public void update();
+ public boolean isModified();
+ public void setModified(boolean value);
+ public String getText();
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/template.bsh b/scripting/java/com/sun/star/script/framework/provider/beanshell/template.bsh
new file mode 100644
index 000000000000..03cb114d79b7
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/template.bsh
@@ -0,0 +1,48 @@
+/*
+ Import standard OpenOffice.org API classes. For more information on
+ these classes and the OpenOffice.org API, see the OpenOffice.org
+ Developers Guide at:
+
+ http://api.openoffice.org/
+*/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XModel;
+
+/*
+ Import XScriptContext class. An instance of this class is available
+ to all BeanShell scripts in the global variable "XSCRIPTCONTEXT". This
+ variable can be used to access the document for which this script
+ was invoked.
+
+ Methods available are:
+
+ XSCRIPTCONTEXT.getDocument() returns XModel
+ XSCRIPTCONTEXT.getInvocationContext() returns XScriptInvocationContext or NULL
+ XSCRIPTCONTEXT.getDesktop() returns XDesktop
+ XSCRIPTCONTEXT.getComponentContext() returns XComponentContext
+
+ For more information on using this class see the scripting
+ developer guides at:
+
+ http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml
+*/
+
+// Hello World in BeanShell
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextRange;
+
+oDoc = UnoRuntime.queryInterface(XModel.class,XSCRIPTCONTEXT.getInvocationContext());
+if ( oDoc == null )
+ oDoc = XSCRIPTCONTEXT.getDocument();
+
+xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);
+xText = xTextDoc.getText();
+xTextRange = xText.getEnd();
+xTextRange.setString( "Hello World (in BeanShell)" );
+
+// BeanShell OpenOffice.org scripts should always return 0
+return 0;
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
new file mode 100755
index 000000000000..548425ca3e44
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+/**
+ * The Resolver interface is an interface common to all classes which
+ * want to implement an algorithm for obtaining a ScriptProxy object
+ * for a particular ScriptDescriptor and Class
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+
+public interface Resolver {
+ /**
+ * Returns a ScriptProxy object for the given ScriptDescriptor and Class
+ *
+ * @param sd A script Descriptor
+ * @param c A Class
+ * @return The ScriptProxy value
+ */
+ public ScriptProxy getProxy( ScriptDescriptor sd, Class c )
+ throws NoSuchMethodException;
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
new file mode 100755
index 000000000000..59e9952b5837
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
@@ -0,0 +1,212 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.util.Vector;
+import java.util.StringTokenizer;
+
+/**
+ * The <code>ScriptDescriptor</code> object is used to store the search
+ * criteria that should be used for finding a particular script
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+public class ScriptDescriptor
+{
+ private String m_name;
+ private String m_methodName;
+ private String m_className;
+ private Vector m_classpath;
+ private Vector m_argumentTypes = new Vector( 11 );
+
+
+ /**
+ * Constructs a ScriptDescriptor for the given name
+ *
+ * @param name Script Name
+ * @exception IllegalArgumentException if the given name does not contain a "."
+ */
+ public ScriptDescriptor( String name )
+ throws IllegalArgumentException
+ {
+ int idx = name.lastIndexOf( '.' );
+
+ if ( idx == -1 )
+ {
+ throw new IllegalArgumentException( "Invalid method name" );
+ }
+
+ this.m_name = name;
+ this.m_methodName = name.substring( idx + 1 );
+ this.m_className = name.substring( 0, idx );
+ }
+
+
+ /**
+ * Gets the fully qualified name of this <code>ScriptDescriptor</code>
+ *
+ * @return The Script Name value
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Gets the fully qualified name of this <code>ScriptDescriptor</code>
+ *
+ * @return The Script Name value
+ */
+ public String getClassName()
+ {
+ return m_className;
+ }
+
+
+ /**
+ * Gets the method name of this <code>ScriptDescriptor</code>
+ *
+ * @return The methodName value
+ */
+ public String getMethodName()
+ {
+ return m_methodName;
+ }
+
+
+ /**
+ * Sets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @param classpath The new classpath value
+ */
+ public void setClasspath( String classpath )
+ {
+ StringTokenizer stk = new StringTokenizer( classpath, ":" );
+ while( stk.hasMoreElements() )
+ {
+ this.m_classpath.add( (String) stk.nextElement() );
+ }
+ }
+
+ /**
+ * Sets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @param classpath The new classpath value
+ */
+ public void setClasspath( Vector classpath )
+ {
+ this.m_classpath = classpath;
+ }
+
+
+ /**
+ * Gets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @return The classpath value
+ */
+ public Vector getClasspath()
+ {
+ return m_classpath;
+ }
+
+
+ /**
+ * Adds the given <code>Class</code> to the list of argument types stored in
+ * this ScriptDescriptor
+ *
+ * @param clazz The feature to be added to the ArgumentType attribute
+ */
+ public synchronized void addArgumentType( Class clazz )
+ {
+ m_argumentTypes.addElement( clazz );
+ }
+
+
+ /**
+ * Adds the given array of <code>Class</code> to the list of argument types
+ * stored in this ScriptDescriptor
+ *
+ * @param classes The feature to be added to the ArgumentTypes attribute
+ */
+ public synchronized void addArgumentTypes( Class[] classes )
+ {
+ for ( int i = 0; i < classes.length; i++ )
+ {
+ addArgumentType( classes[ i ] );
+ }
+ }
+
+
+ /**
+ * Gets a list of the types of the arguments stored in this
+ * <code>ScriptDescriptor</code>
+ *
+ * return the argument types as an array of Class
+ *
+ * @return The argumentTypes value
+ */
+ public synchronized Class[]
+ getArgumentTypes()
+ {
+ if ( m_argumentTypes.size() > 0 )
+ return ( Class[] ) m_argumentTypes.toArray( new Class[ 0 ] );
+ else
+ return null;
+ }
+
+
+ /**
+ * Returns a <code>String</code> representation of this
+ * <code>ScriptDescriptor</code>
+ *
+ * @return The scriptName including the parameters.
+ */
+ public String toString()
+ {
+ StringBuffer description = new StringBuffer( m_name );
+ Class[] types = getArgumentTypes();
+
+ description.append( " (" );
+
+ if ( types != null )
+ {
+ for ( int i = 0; i < types.length - 1; i++ )
+ {
+ description.append( types[ i ].getName() );
+ description.append( ", " );
+ }
+
+ description.append( types[ types.length - 1 ].getName() );
+ }
+ description.append( ")" );
+
+ return description.toString();
+ }
+}
+
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
new file mode 100755
index 000000000000..707ea05624d9
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
@@ -0,0 +1,364 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.java;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Any;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.net.MalformedURLException;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.provider.XScript;
+import com.sun.star.script.provider.ScriptExceptionRaisedException;
+import com.sun.star.script.provider.ScriptFrameworkErrorException;
+import com.sun.star.script.provider.ScriptFrameworkErrorType;
+
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+import com.sun.star.script.framework.provider.*;
+import com.sun.star.script.framework.log.LogUtils;
+/**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+public class ScriptProviderForJava
+{
+ /**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+ public static class _ScriptProviderForJava extends ScriptProvider
+ {
+ private Resolver m_resolutionPolicy = new StrictResolver();
+
+ public _ScriptProviderForJava( XComponentContext ctx )
+ {
+ super (ctx, "Java");
+ }
+
+ public XScript getScript( /*IN*/String scriptURI )
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException
+ {
+ ScriptMetaData scriptData = null;
+ scriptData = getScriptData( scriptURI );
+ ScriptImpl script = null;
+ try
+ {
+ script = new ScriptImpl( m_xContext, m_resolutionPolicy, scriptData, m_xModel, m_xInvocContext );
+ return script;
+ }
+ catch ( com.sun.star.uno.RuntimeException re )
+ {
+ throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ }
+
+ public boolean hasScriptEditor()
+ {
+ return false;
+ }
+
+ public ScriptEditor getScriptEditor()
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ *
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @return returns a <code>XSingleServiceFactory</code> for creating
+ * the component
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if ( implName.equals( ScriptProviderForJava._ScriptProviderForJava.class.getName() ) )
+ {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ ScriptProviderForJava._ScriptProviderForJava.class,
+ "com.sun.star.script.provider.ScriptProviderForJava",
+ multiFactory,
+ regKey );
+ }
+
+ return xSingleServiceFactory;
+ }
+}
+
+class ScriptImpl implements XScript
+{
+ private ScriptMetaData metaData;
+ private XComponentContext m_xContext;
+ private XModel m_xModel;
+ private XScriptInvocationContext m_xInvocContext;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private Resolver m_resolutionPolicy;
+ ScriptImpl( XComponentContext ctx, Resolver resolver, ScriptMetaData metaData, XModel xModel, XScriptInvocationContext xInvocContext ) throws com.sun.star.uno.RuntimeException
+ {
+ this.metaData = metaData;
+ this.m_xContext = ctx;
+ this.m_xModel = xModel;
+ this.m_xInvocContext = xInvocContext;
+ this.m_resolutionPolicy = resolver;
+ try
+ {
+ this.m_xMultiComponentFactory = m_xContext.getServiceManager();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Error constructing ScriptProvider: "
+ + e.getMessage() );
+ }
+
+ LogUtils.DEBUG("ScriptImpl [java] script data = " + metaData );
+ }
+ /**
+ * Invoke
+ *
+ *
+ * @param aParams All parameters; pure, out params are undefined in
+ * sequence, i.e., the value has to be ignored by the callee
+ * @param aOutParamIndex Out indices
+ * @param aOutParam Out parameters
+ * @returns The value returned from the function being invoked
+ * @throws IllegalArgumentException If there is no matching script name
+ * @throws CannotConvertException If args do not match or cannot be converted
+ * the those of the invokee
+ * @throws InvocationTargetException If the running script throws an exception
+ * this information is captured and rethrown as this exception type.
+ */
+
+ public Object invoke(
+ /*IN*/Object[] params,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam )
+
+ throws ScriptFrameworkErrorException, com.sun.star.reflection.InvocationTargetException
+ {
+ LogUtils.DEBUG( "** ScriptProviderForJava::invoke: Starting..." );
+
+ // Initialise the out paramters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+
+ Map languageProps = metaData.getLanguageProperties();
+
+ ScriptDescriptor scriptDesc =
+ new ScriptDescriptor( metaData.getLanguageName() );
+
+ ClassLoader scriptLoader = null;
+
+ try {
+ LogUtils.DEBUG( "Classloader starting..." );
+ scriptLoader = ClassLoaderFactory.getURLClassLoader(
+ metaData );
+ LogUtils.DEBUG( "Classloader finished..." );
+ }
+ catch (MalformedURLException mfe )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ mfe.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL );
+ }
+ catch (NoSuitableClassLoaderException ncl )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ ncl.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ catch (ArrayStoreException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ ArrayList invocationArgList = new ArrayList();
+ Object[] invocationArgs = null;
+
+ LogUtils.DEBUG( "Parameter Mapping..." );
+
+ // Setup Context Object
+ XScriptContext xSc = ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory);
+ scriptDesc.addArgumentType( XScriptContext.class );
+ invocationArgList.add( xSc );
+
+ for ( int i = 0; i < params.length; i++ )
+ {
+ scriptDesc.addArgumentType( params[ i ].getClass() );
+ invocationArgList.add( params[ i ] );
+ }
+
+ if ( !invocationArgList.isEmpty() )
+ {
+ invocationArgs = invocationArgList.toArray();
+ }
+
+
+
+ LogUtils.DEBUG( "ScriptProxy starting... " );
+ ScriptProxy script = null;
+ try
+ {
+ 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: " + String.valueOf(end - start) +
+ "milliseconds");
+
+ try
+ {
+ LogUtils.DEBUG( "class loaded ... " );
+ script = m_resolutionPolicy.getProxy( scriptDesc, c );
+ LogUtils.DEBUG( "script resolved ... " );
+ }
+ catch( NoSuchMethodException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+
+ LogUtils.DEBUG( "Starting Invoke on Proxy ..." );
+ Object result = null;
+
+ try
+ {
+ long start = new java.util.Date().getTime();
+ result = script.invoke( invocationArgs );
+ long end = new java.util.Date().getTime();
+
+ LogUtils.DEBUG("invoke took: " +
+ String.valueOf(end - start) + "milliseconds");
+ }
+ catch ( java.lang.IllegalArgumentException iae )
+ {
+ throw new ScriptFrameworkErrorException(
+ iae.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+
+ }
+ catch ( java.lang.IllegalAccessException ia )
+ {
+ throw new ScriptFrameworkErrorException(
+ ia.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ catch ( java.lang.reflect.InvocationTargetException ite )
+ {
+ Throwable targetException = ite.getTargetException();
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ targetException.toString() );
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = targetException.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se );
+ }
+ catch ( Exception unknown )
+ {
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ unknown.toString() );
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = unknown.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se );
+ }
+ if ( result == null )
+ {
+ LogUtils.DEBUG( "Got Nothing Back" );
+ // in the case where there is no return type
+ Any voidAny = new Any(new Type(), null);
+ result = voidAny;
+ }
+ else
+ {
+ LogUtils.DEBUG( "Got object " + result );
+ }
+ return result;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
new file mode 100755
index 000000000000..6cd36c83710f
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A ScriptProxy object acts as a proxy for a Java <code>Method</code>
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ * @see java.lang.reflect.Method
+ */
+public class ScriptProxy
+{
+ private Object m_targetObject;
+ private Method m_method;
+
+
+ /**
+ * Constructs a <code>ScriptProxy</code> object for the given
+ * <code>Method</code>
+ *
+ * @param method Description of the Parameter
+ */
+ public ScriptProxy( Method method )
+ {
+ this.m_method = method;
+ }
+
+
+ /**
+ * Sets the <code>Object</code> on which the ScriptProxy should invoke
+ * the method
+ *
+ * @param obj The new targetObject value
+ */
+ public void setTargetObject( Object obj )
+ {
+ m_targetObject = obj;
+ }
+
+
+ /**
+ * Invokes the method contained in this <code>ScriptProxy</code>,
+ * any exceptions resulting from the invocation will be thrown
+ *
+ * @param args the arguments to be passed when invoking
+ * the method
+ * @return the Object returned from the method
+ * invocation, may be null
+ * @exception IllegalAccessException Description of the Exception
+ * @exception InvocationTargetException Description of the Exception
+ * @exception IllegalArgumentException Description of the Exception
+ * @exception Exception Description of the Exception
+ * @see java.lang.reflect.Method for the exceptions
+ * that may be thrown
+ */
+ public Object invoke( Object[] args )
+ throws IllegalAccessException, InvocationTargetException,
+ IllegalArgumentException
+ {
+ return m_method.invoke( m_targetObject, args );
+ }
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
new file mode 100755
index 000000000000..8adb6e66e5e8
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.lang.reflect.*;
+import com.sun.star.script.framework.log.LogUtils;
+
+/**
+ * A StrictResolver can be used to get a ScriptProxy object for a given
+ * ScriptDescriptor and Class. The StrictResolver is an implementation of
+ * the Resolver strategy. It will only return a ScriptProxy object if a
+ * method accepting all of the arguments specified in the ScriptDescriptor
+ * can be found in the Class.
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+public class StrictResolver implements Resolver
+{
+ /**
+ *Constructor for the StrictResolver object
+ */
+ public StrictResolver()
+ {
+ LogUtils.DEBUG( this.getClass().getName() + " created" );
+ }
+
+
+ /**
+ * Returns a ScriptProxy object for the given ScriptDescriptor and Class.
+ * Only a strict match will be returned ie. where all of the arguments in
+ * the given ScriptDescriptor match the types of the
+ *
+ * @param sd the ScriptDescriptor for which a ScriptProxy is required
+ * @param c the Class file in which to search for the method
+ * @return the ScriptProxy matching the criteria, or null if no match is found
+ */
+ public ScriptProxy getProxy( ScriptDescriptor sd, Class c )
+ throws NoSuchMethodException
+ {
+ Method m = null;
+ ScriptProxy sp = null;
+
+ LogUtils.DEBUG( "StrictResolver.getProxy() for: " + sd.toString() );
+
+ try
+ {
+ m = resolveArguments( sd, c );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new NoSuchMethodException( "StrictResolver.getProxy: Cant find method: "
+ + sd.getMethodName() + ":" + e.getMessage() );
+ }
+ catch ( NoSuchMethodException e )
+ {
+ throw new NoSuchMethodException( "StrictResolver.getProxy: Cant find method: "
+ + sd.getMethodName() + ":" + e.getMessage() );
+ }
+
+ sp = new ScriptProxy( m );
+
+ int modifiers = m.getModifiers();
+ if ( !Modifier.isStatic( modifiers ) )
+ {
+ Object o;
+ try
+ {
+ o = c.newInstance();
+ }
+ catch ( InstantiationException ie )
+ {
+ throw new NoSuchMethodException( "getScriptProxy: Cant instantiate: " +
+ c.getName() );
+ }
+ catch ( IllegalAccessException iae )
+ {
+ throw new NoSuchMethodException( "getScriptProxy: Cant access: "
+ + c.getName() );
+ }
+ sp.setTargetObject( o );
+ }
+
+ return sp;
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ * @param sd Description of the Parameter
+ * @param c Description of the Parameter
+ * @return Description of the Return Value
+ * @exception ClassNotFoundException
+ * @exception NoSuchMethodException
+ */
+ private Method resolveArguments( ScriptDescriptor sd, Class c )
+ throws ClassNotFoundException, NoSuchMethodException
+ {
+ return c.getMethod( sd.getMethodName(), sd.getArgumentTypes() );
+ }
+}
+
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
new file mode 100644
index 000000000000..b9849d1e4e1d
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.provider.javascript;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ImporterTopLevel;
+import org.mozilla.javascript.tools.debugger.Main;
+import org.mozilla.javascript.tools.debugger.ScopeProvider;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.framework.container.ScriptMetaData;
+import com.sun.star.script.framework.provider.ScriptEditor;
+import com.sun.star.script.framework.log.LogUtils;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.swing.SwingUtilities;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+public class ScriptEditorForJavaScript implements ScriptEditor
+{
+ // global ScriptEditorForJavaScript instance
+ private static ScriptEditorForJavaScript theScriptEditorForJavaScript;
+
+ // template for JavaScript scripts
+ private static String JSTEMPLATE;
+
+ static private Main rhinoWindow;
+ private URL scriptURL;
+ // global list of ScriptEditors, key is URL of file being edited
+ private static Map BEING_EDITED = new HashMap();
+
+ static {
+ try {
+ URL url =
+ ScriptEditorForJavaScript.class.getResource("template.js");
+
+ InputStream in = url.openStream();
+ StringBuffer buf = new StringBuffer();
+ byte[] b = new byte[1024];
+ int len = 0;
+
+ while ((len = in.read(b)) != -1) {
+ buf.append(new String(b, 0, len));
+ }
+
+ in.close();
+
+ JSTEMPLATE = buf.toString();
+ }
+ catch (IOException ioe) {
+ JSTEMPLATE = "// JavaScript script";
+ }
+ catch (Exception e) {
+ JSTEMPLATE = "// JavaScript script";
+ }
+ }
+
+ /**
+ * Returns the global ScriptEditorForJavaScript instance.
+ */
+ public static ScriptEditorForJavaScript getEditor()
+ {
+ if (theScriptEditorForJavaScript == null)
+ {
+ synchronized(ScriptEditorForJavaScript.class)
+ {
+ if (theScriptEditorForJavaScript == null)
+ {
+ theScriptEditorForJavaScript =
+ new ScriptEditorForJavaScript();
+ }
+ }
+ }
+ return theScriptEditorForJavaScript;
+ }
+
+ /**
+ * Get the ScriptEditorForJavaScript instance for this URL
+ *
+ * @param url The URL of the script source file
+ *
+ * @return The ScriptEditorForJavaScript associated with
+ * the given URL if one exists, otherwise null.
+ */
+ public static ScriptEditorForJavaScript getEditor(URL url)
+ {
+ return (ScriptEditorForJavaScript)BEING_EDITED.get(url);
+ }
+
+ /**
+ * Returns whether or not the script source being edited in this
+ * ScriptEditorForJavaScript has been modified
+ */
+ public boolean isModified()
+ {
+ return rhinoWindow.isModified( scriptURL );
+ }
+
+ /**
+ * Returns the text being displayed in this ScriptEditorForJavaScript
+ *
+ * @return The text displayed in this ScriptEditorForJavaScript
+ */
+ public String getText()
+ {
+ return rhinoWindow.getText( scriptURL );
+ }
+
+ /**
+ * Returns the Rhino Debugger url of this ScriptEditorForJavaScript
+ *
+ * @return The url of this ScriptEditorForJavaScript
+ */
+ public String getURL()
+ {
+ return scriptURL.toString();
+ }
+
+ /**
+ * Returns the template text for JavaScript scripts
+ *
+ * @return The template text for JavaScript scripts
+ */
+ public String getTemplate()
+ {
+ return JSTEMPLATE;
+ }
+
+ /**
+ * Returns the default extension for JavaScript scripts
+ *
+ * @return The default extension for JavaScript scripts
+ */
+ public String getExtension()
+ {
+ return "js";
+ }
+
+ /**
+ * Opens an editor window for the specified ScriptMetaData.
+ * If an editor window is already open for that data it will be
+ * moved to the front.
+ *
+ * @param metadata The metadata describing the script
+ * @param context The context in which to execute the script
+ *
+ */
+ public void edit(final XScriptContext context, ScriptMetaData entry)
+ {
+ try {
+ String sUrl = entry.getParcelLocation();
+ if ( !sUrl.endsWith( "/" ) )
+ {
+ sUrl += "/";
+ }
+ sUrl += entry.getLanguageName();
+ URL url = entry.getSourceURL();
+
+ // check if there is already an editing session for this script
+ //if (BEING_EDITED.containsKey(url))
+ if ( rhinoWindow != null )
+ {
+ ScriptEditorForJavaScript editor =
+ (ScriptEditorForJavaScript) BEING_EDITED.get(url);
+ if ( editor == null )
+ {
+ editor = new ScriptEditorForJavaScript( context, url );
+ editor.edit( context, entry );
+ }
+ else
+ {
+ rhinoWindow.showScriptWindow( url );
+ }
+ }
+ else
+ {
+ ScriptEditorForJavaScript editor =
+ new ScriptEditorForJavaScript( context, url );
+
+ }
+ rhinoWindow.toFront();
+ }
+ catch ( IOException e )
+ {
+ LogUtils.DEBUG("Caught exception: " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
+ }
+ }
+
+ // Ensures that new instances of this class can only be created using
+ // the factory methods
+ private ScriptEditorForJavaScript()
+ {
+ }
+
+ private ScriptEditorForJavaScript(XScriptContext context, URL url)
+ {
+ initUI();
+ Scriptable scope = getScope( context );
+ this.rhinoWindow.openFile(url, scope, new closeHandler( url ) );
+
+
+ this.scriptURL = url;
+ synchronized( ScriptEditorForJavaScript.class )
+ {
+ BEING_EDITED.put(url, this);
+ }
+
+ }
+
+ /**
+ * Executes the script edited by the editor
+ *
+ */
+
+ public Object execute() throws Exception
+ {
+ rhinoWindow.toFront();
+
+ return this.rhinoWindow.runScriptWindow( scriptURL );
+ }
+
+ /**
+ * Indicates the line where error occured
+ *
+ */
+ public void indicateErrorLine( int lineNum )
+ {
+ this.rhinoWindow.toFront();
+ this.rhinoWindow.highlighLineInScriptWindow( scriptURL, lineNum );
+ }
+ // This code is based on the main method of the Rhino Debugger Main class
+ // We pass in the XScriptContext in the global scope for script execution
+ private void initUI() {
+ try {
+ synchronized ( ScriptEditorForJavaScript.class )
+ {
+ if ( this.rhinoWindow != null )
+ {
+ return;
+ }
+
+ final Main sdb = new Main("Rhino JavaScript Debugger");
+ swingInvoke(new Runnable() {
+ public void run() {
+ sdb.pack();
+ sdb.setSize(640, 640);
+ sdb.setVisible(true);
+ }
+ });
+ sdb.setExitAction(new Runnable() {
+ public void run() {
+ sdb.clearAllBreakpoints();
+ sdb.dispose();
+ shutdown();
+ }
+ });
+ Context.addContextListener(sdb);
+ sdb.setScopeProvider(new ScopeProvider() {
+ public Scriptable getScope() {
+ return org.mozilla.javascript.tools.shell.Main.getScope();
+ }
+ });
+ sdb.addWindowListener( new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ shutdown();
+ }
+ });
+ this.rhinoWindow = sdb;
+ }
+ } catch (Exception exc) {
+ LogUtils.DEBUG( LogUtils.getTrace( exc ) );
+ }
+ }
+
+ private static void swingInvoke(Runnable f) {
+ if (SwingUtilities.isEventDispatchThread()) {
+ f.run();
+ return;
+ }
+ try {
+ SwingUtilities.invokeAndWait(f);
+ } catch (Exception exc) {
+ LogUtils.DEBUG( LogUtils.getTrace( exc ) );
+ }
+ }
+
+ private void shutdown()
+ {
+ // dereference Rhino Debugger window
+ this.rhinoWindow = null;
+ this.scriptURL = null;
+ // remove all scripts from BEING_EDITED
+ synchronized( BEING_EDITED )
+ {
+ java.util.Iterator iter = BEING_EDITED.keySet().iterator();
+ java.util.Vector keysToRemove = new java.util.Vector();
+ while ( iter.hasNext() )
+ {
+
+ URL key = (URL)iter.next();
+ keysToRemove.add( key );
+ }
+ for ( int i=0; i<keysToRemove.size(); i++ )
+ {
+ BEING_EDITED.remove( keysToRemove.elementAt( i ) );
+ }
+ keysToRemove = null;
+ }
+
+ }
+ private Scriptable getScope(XScriptContext xsctxt )
+ {
+ Context ctxt = Context.enter();
+ ImporterTopLevel scope = new ImporterTopLevel(ctxt);
+
+ Scriptable jsCtxt = Context.toObject(xsctxt, scope);
+ scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
+
+ Scriptable jsArgs = Context.toObject(
+ new Object[0], scope);
+ scope.put("ARGUMENTS", scope, jsArgs);
+
+ Context.exit();
+ return scope;
+ }
+
+ class closeHandler implements Runnable
+ {
+ URL url;
+ closeHandler( URL url )
+ {
+ this.url = url;
+ }
+ public void run()
+ {
+ synchronized( BEING_EDITED )
+ {
+ Object o = BEING_EDITED.remove( this.url );
+ }
+ }
+ }
+}
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
new file mode 100755
index 000000000000..9f04d9105374
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
@@ -0,0 +1,358 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.javascript;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.frame.XModel;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.comp.loader.FactoryHelper;
+
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.reflection.InvocationTargetException;
+
+import java.net.URL;
+
+import com.sun.star.script.provider.XScript;
+
+import com.sun.star.script.provider.ScriptExceptionRaisedException;
+import com.sun.star.script.provider.ScriptFrameworkErrorException;
+import com.sun.star.script.provider.ScriptFrameworkErrorType;
+
+import com.sun.star.script.framework.log.LogUtils;
+import com.sun.star.script.framework.provider.ScriptContext;
+import com.sun.star.script.framework.provider.ClassLoaderFactory;
+import com.sun.star.script.framework.provider.ScriptProvider;
+import com.sun.star.script.framework.provider.ScriptEditor;
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ImporterTopLevel;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.JavaScriptException;
+
+public class ScriptProviderForJavaScript
+{
+ public static class _ScriptProviderForJavaScript extends ScriptProvider
+ {
+ public _ScriptProviderForJavaScript(XComponentContext ctx)
+ {
+ super(ctx, "JavaScript");
+ }
+
+ public XScript getScript( /*IN*/String scriptURI )
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException
+ {
+ ScriptMetaData scriptData = null;
+ try
+ {
+ scriptData = getScriptData( scriptURI );
+ ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel, m_xInvocContext );
+ return script;
+ }
+ catch ( com.sun.star.uno.RuntimeException re )
+ {
+ throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+ }
+
+ public boolean hasScriptEditor()
+ {
+ return true;
+ }
+
+ public ScriptEditor getScriptEditor()
+ {
+ return ScriptEditorForJavaScript.getEditor();
+ }
+ }
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ *
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @return returns a <code>XSingleServiceFactory</code> for creating
+ * the component
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if ( implName.equals( ScriptProviderForJavaScript._ScriptProviderForJavaScript.class.getName() ) )
+ {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ ScriptProviderForJavaScript._ScriptProviderForJavaScript.class,
+ "com.sun.star.script.provider.ScriptProviderForJavaScript",
+ multiFactory,
+ regKey );
+ }
+
+ return xSingleServiceFactory;
+ }
+}
+class ScriptImpl implements XScript
+{
+ private ScriptMetaData metaData;
+ private XComponentContext m_xContext;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private XModel m_xModel;
+ private XScriptInvocationContext m_xInvocContext;
+
+ ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel, XScriptInvocationContext xInvocContext ) throws com.sun.star.uno.RuntimeException
+ {
+ this.metaData = metaData;
+ this.m_xContext = ctx;
+ this.m_xModel = xModel;
+ this.m_xInvocContext = xInvocContext;
+ try
+ {
+ this.m_xMultiComponentFactory = m_xContext.getServiceManager();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Error constructing ScriptImpl: [javascript]");
+ }
+ LogUtils.DEBUG("ScriptImpl [javascript] script data = " + metaData );
+ }
+
+ /**
+ * The invoke method of the ScriptProviderForJavaScript runs the
+ * JavaScript script specified in the URI
+ *
+ *
+ *
+ * @param aParams All parameters; pure, out params are
+ * undefined in sequence, i.e., the value
+ * has to be ignored by the callee
+ *
+ * @param aOutParamIndex Out indices
+ *
+ * @param aOutParam Out parameters
+ *
+ * @returns The value returned from the function
+ * being invoked
+ *
+ * @throws ScriptFrameworkErrorException If there is no matching script name
+ *
+ *
+ * @throws InvocationTargetException If the running script throws
+ * an exception this information
+ * is captured and rethrown as
+ * ScriptErrorRaisedException or
+ * ScriptExceptionRaisedException
+ */
+
+ public Object invoke(
+ /*IN*/Object[] params,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam )
+
+ throws ScriptFrameworkErrorException, InvocationTargetException
+ {
+ // Initialise the out paramters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+
+
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+ try {
+ cl = ClassLoaderFactory.getURLClassLoader( metaData );
+ sourceUrl = metaData.getSourceURL();
+ }
+ catch ( java.net.MalformedURLException mfu )
+ {
+ throw new ScriptFrameworkErrorException(
+ mfu.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL );
+ }
+ catch ( com.sun.star.script.framework.provider.NoSuitableClassLoaderException nsc )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ nsc.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ Context ctxt = null;
+
+ try
+ {
+ String editorURL = sourceUrl.toString();
+ Object result = null;
+ String source = null;
+ ScriptEditorForJavaScript editor =
+ ScriptEditorForJavaScript.getEditor(
+ metaData.getSourceURL() );
+
+ if (editor != null)
+ {
+ editorURL = editor.getURL();
+ result = editor.execute();
+ if ( result != null &&
+ result.getClass().getName().equals( "org.mozilla.javascript.Undefined" ) )
+ {
+ // Always return a string
+ // TODO revisit
+ return Context.toString( result );
+ }
+
+ }
+
+ if (editor != null && editor.isModified() == true)
+ {
+ LogUtils.DEBUG("GOT A MODIFIED SOURCE");
+ source = editor.getText();
+ }
+ else
+ {
+ metaData.loadSource();
+ source = metaData.getSource();
+
+ }
+
+ if ( source == null || source.length() == 0 ) {
+ throw new ScriptFrameworkErrorException(
+ "Failed to read source data for script", null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ /* Set the context ClassLoader on the current thread to
+ be our custom ClassLoader. This is the suggested method
+ for setting up a ClassLoader to be used by the Rhino
+ interpreter
+ */
+ if (cl != null) {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ // Initialize a Rhino Context object
+ ctxt = Context.enter();
+
+ /* The ImporterTopLevel ensures that importClass and
+ importPackage statements work in Javascript scripts
+ Make the XScriptContext available as a global variable
+ to the script
+ */
+ ImporterTopLevel scope = new ImporterTopLevel(ctxt);
+
+ Scriptable jsCtxt = Context.toObject(
+ ScriptContext.createContext(
+ m_xModel, m_xInvocContext, m_xContext,
+ m_xMultiComponentFactory), scope);
+ scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
+
+ Scriptable jsArgs = Context.toObject(params, scope);
+ scope.put("ARGUMENTS", scope, jsArgs);
+
+ result = ctxt.evaluateString(scope,
+ source, "<stdin>", 1, null);
+ result = ctxt.toString(result);
+ return result;
+ }
+ catch (JavaScriptException jse) {
+ LogUtils.DEBUG( "Caught JavaScriptException exception for JavaScript type = " + jse.getClass() );
+ String message = jse.getMessage();
+ //int lineNo = jse.getLineNumber();
+ Object wrap = jse.getValue();
+ LogUtils.DEBUG( "\t message " + message );
+ LogUtils.DEBUG( "\t wrapped type " + wrap.getClass() );
+ LogUtils.DEBUG( "\t wrapped toString " + wrap.toString() );
+ ScriptExceptionRaisedException se = new
+ ScriptExceptionRaisedException( message );
+ se.lineNum = -1;
+ se.language = "JavaScript";
+ se.scriptName = metaData.getLanguageName();
+ se.exceptionType = wrap.getClass().getName();
+ se.language = metaData.getLanguage();
+ LogUtils.DEBUG( "ExceptionRaised exception " );
+ LogUtils.DEBUG( "\t message " + se.getMessage() );
+ LogUtils.DEBUG( "\t lineNum " + se.lineNum );
+ LogUtils.DEBUG( "\t language " + se.language );
+ LogUtils.DEBUG( "\t scriptName " + se.scriptName );
+ raiseEditor( se.lineNum );
+ throw new InvocationTargetException( "JavaScript uncaught exception" + metaData.getLanguageName(), null, se );
+ }
+ catch (Exception ex) {
+ LogUtils.DEBUG("Caught Exception " + ex );
+ LogUtils.DEBUG("rethrowing as ScriptFramework error" );
+ throw new ScriptFrameworkErrorException(
+ ex.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ finally {
+ if ( ctxt != null )
+ {
+ Context.exit();
+ }
+ }
+ }
+
+ private void raiseEditor( int lineNum )
+ {
+ ScriptEditorForJavaScript editor = null;
+ try
+ {
+ URL sourceUrl = metaData.getSourceURL();
+ editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
+ if ( editor == null )
+ {
+ editor = ScriptEditorForJavaScript.getEditor();
+ editor.edit(
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory), metaData );
+ editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
+ }
+ if ( editor != null )
+ {
+ System.out.println("** Have raised IDE for JavaScript, calling indicateErrorLine for line " + lineNum );
+ editor.indicateErrorLine( lineNum );
+ }
+ }
+ catch( Exception ignore )
+ {
+ }
+ }
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/template.js b/scripting/java/com/sun/star/script/framework/provider/javascript/template.js
new file mode 100644
index 000000000000..d992791e647c
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/template.js
@@ -0,0 +1,37 @@
+// Hello World in JavaScript
+// Import standard OpenOffice.org API classes. For more information on
+// these classes and the OpenOffice.org API, see the OpenOffice.org
+// Developers Guide at:
+// http://api.openoffice.org/
+
+importClass(Packages.com.sun.star.uno.UnoRuntime);
+importClass(Packages.com.sun.star.text.XTextDocument);
+importClass(Packages.com.sun.star.text.XText);
+importClass(Packages.com.sun.star.text.XTextRange);
+importClass(Packages.com.sun.star.frame.XModel);
+
+// Import XScriptContext class. An instance of this class is available
+// to all JavaScript scripts in the global variable "XSCRIPTCONTEXT". This
+// variable can be used to access the document for which this script
+// was invoked.
+//
+// Methods available are:
+//
+// XSCRIPTCONTEXT.getDocument() returns XModel
+// XSCRIPTCONTEXT.getInvocationContext() returns XScriptInvocationContext or NULL
+// XSCRIPTCONTEXT.getDesktop() returns XDesktop
+// XSCRIPTCONTEXT.getComponentContext() returns XComponentContext
+//
+// For more information on using this class see the scripting
+// developer guides at:
+//
+// http://api.openoffice.org/docs/DevelopersGuide/ScriptingFramework/ScriptingFramework.xhtml
+//
+
+oDoc = UnoRuntime.queryInterface(XModel,XSCRIPTCONTEXT.getInvocationContext());
+if ( !oDoc )
+ oDoc = XSCRIPTCONTEXT.getDocument();
+xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
+xText = xTextDoc.getText();
+xTextRange = xText.getEnd();
+xTextRange.setString( "Hello World (in JavaScript)" );
diff --git a/scripting/java/makefile.mk b/scripting/java/makefile.mk
new file mode 100755
index 000000000000..dc8ee1abdc46
--- /dev/null
+++ b/scripting/java/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+PRJNAME=scripting
+TARGET=scriptruntimeforjava
+
+.INCLUDE : ant.mk
+
+.IF "$(L10N_framework)"==""
+.IF "$(SOLAR_JAVA)"!=""
+ALLTAR : ANTBUILD
+.ENDIF
+.ENDIF
+
+ALLTAR : \
+ $(MISC)/ScriptFramework.component \
+ $(MISC)/ScriptProviderForBeanShell.component \
+ $(MISC)/ScriptProviderForJava.component \
+ $(MISC)/ScriptProviderForJavaScript.component
+
+$(MISC)/ScriptFramework.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt ScriptFramework.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)ScriptFramework.jar' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt ScriptFramework.component
+
+$(MISC)/ScriptProviderForBeanShell.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt \
+ ScriptProviderForBeanShell.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)ScriptProviderForBeanShell.jar' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt \
+ ScriptProviderForBeanShell.component
+
+$(MISC)/ScriptProviderForJava.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt ScriptProviderForJava.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)ScriptProviderForJava.jar' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt ScriptProviderForJava.component
+
+$(MISC)/ScriptProviderForJavaScript.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt \
+ ScriptProviderForJavaScript.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)ScriptProviderForJavaScript.jar' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt \
+ ScriptProviderForJavaScript.component
diff --git a/scripting/java/manifest.mf b/scripting/java/manifest.mf
new file mode 100644
index 000000000000..ba14e301b3eb
--- /dev/null
+++ b/scripting/java/manifest.mf
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.openoffice.netbeans.modules.office/1
+OpenIDE-Module-Name: Office Support
+OpenIDE-Module-Short-Description: Scripting Support for Office Documents
+OpenIDE-Module-Localizing-Bundle: org/openoffice/netbeans/modules/office/Bundle.properties
+OpenIDE-Module-Specification-Version: 0.2
+OpenIDE-Module-Implementation-Version: 0.2
+OpenIDE-Module-Install: org/openoffice/netbeans/modules/office/utils/OfficeModule.class
+OpenIDE-Module-Layer: org/openoffice/netbeans/modules/office/resources/layer.xml
+
+Name: org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.class
+OpenIDE-Module-Class: Loader
+
+Name: org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.class
+OpenIDE-Module-Class: Loader
+
+Name: org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.class
+Install-Before: org.openide.loaders.XMLDataObject, org.netbeans.modules.xml.core.XMLDataObject
+OpenIDE-Module-Class: Loader
+
+Name: org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.class
+Install-Before: org.openoffice.netbeans.modules.office.loader.ParcelDescriptorDataLoader
+OpenIDE-Module-Class: Loader
+
+Name: org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.class
+OpenIDE-Module-Class: Loader
diff --git a/scripting/java/org/openoffice/idesupport/CommandLineTools.java b/scripting/java/org/openoffice/idesupport/CommandLineTools.java
new file mode 100644
index 000000000000..29d3b704f0a6
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/CommandLineTools.java
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+import com.sun.star.script.framework.container.ParcelDescriptor;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.idesupport.filter.AllFilesFilter;
+import com.sun.star.script.framework.container.XMLParserFactory;
+import org.openoffice.idesupport.*;
+
+public class CommandLineTools {
+ private static final String PARCEL_XML_FILE =
+ ParcelZipper.PARCEL_DESCRIPTOR_XML;
+
+ private static String officePath = null;
+
+ public static void main(String[] args) {
+ CommandLineTools driver = new CommandLineTools();
+ Command command = driver.parseArgs(args);
+
+ // Get the URL for the Office DTD directory and pass it to the
+ // XMLParserFactory so that Office xml files can be parsed
+ if (officePath == null)
+ {
+ try {
+ SVersionRCFile sv = SVersionRCFile.createInstance();
+ if (sv.getDefaultVersion() != null)
+ {
+ officePath = sv.getDefaultVersion().getPath();
+ }
+ }
+ catch (IOException ioe) {
+ System.err.println("Error getting Office directory");
+ }
+ }
+
+ if (officePath == null)
+ {
+ driver.fatalUsage("Error: Office Installation path not set");
+ }
+
+ File officeDir = new File(officePath);
+ if (officeDir.exists() == false || officeDir.isDirectory() == false)
+ {
+ driver.fatalUsage(
+ "Error: Office Installation path not valid: " + officePath);
+ }
+
+ OfficeInstallation oi = new OfficeInstallation(officePath);
+ String url = oi.getURL("share/dtd/officedocument/1_0/");
+ XMLParserFactory.setOfficeDTDURL(url);
+
+ if (command == null)
+ driver.printUsage();
+ else {
+ try {
+ command.execute();
+ }
+ catch (Exception e) {
+ driver.fatal("Error: " + e.getMessage());
+ }
+ }
+ }
+
+ private interface Command {
+ public void execute() throws Exception;
+ }
+
+ private void printUsage() {
+ System.out.println("java " + getClass().getName() + " -h " +
+ "prints this message");
+ System.out.println("java " + getClass().getName() +
+ " [-o Path to Office Installation] " +
+ "-d <script parcel zip file> " +
+ "<destination document or directory>");
+ System.out.println("java " + getClass().getName() +
+ " [-o Path to Office Installation] " +
+ "-g [parcel root directory] [options] [script names]");
+ System.out.println("options:");
+ System.out.println("\t[-l language[=supported extension 1[" +
+ File.pathSeparator + "supported extension 2]]]");
+ System.out.println("\t[-p name=value]");
+ System.out.println("\t[-v]");
+ }
+
+ private void fatal(String message) {
+ System.err.println(message);
+ System.exit(-1);
+ }
+
+ private void fatalUsage(String message) {
+ System.err.println(message);
+ System.err.println();
+ printUsage();
+ System.exit(-1);
+ }
+ private Command parseArgs(String[] args) {
+
+ if (args.length < 1) {
+ return null;
+ }
+ else if (args[0].equals("-h")) {
+ return new Command() {
+ public void execute() {
+ printUsage();
+ }
+ };
+ }
+
+ int i = 0;
+
+ if(args[0].equals("-o")) {
+ officePath = args[i+1];
+ i += 2;
+ }
+
+ if(args[i].equals("-d")) {
+ if ((args.length - i) != 3)
+ return null;
+ else
+ return new DeployCommand(args[i+1], args[i+2]);
+ }
+ else if(args[i].equals("-g")) {
+
+ if ((args.length - i) == 1)
+ return new GenerateCommand(System.getProperty("user.dir"));
+
+ GenerateCommand command;
+ i++;
+ if (!args[i].startsWith("-"))
+ command = new GenerateCommand(args[i++]);
+ else
+ command = new GenerateCommand(System.getProperty("user.dir"));
+
+ for (; i < args.length; i++) {
+ if (args[i].equals("-l")) {
+ command.setLanguage(args[++i]);
+ }
+ else if (args[i].equals("-p")) {
+ command.addProperty(args[++i]);
+ }
+ else if (args[i].equals("-v")) {
+ command.setVerbose();
+ }
+ else {
+ command.addScript(args[i]);
+ }
+ }
+ return command;
+ }
+ return null;
+ }
+
+ private static class GenerateCommand implements Command {
+
+ private File basedir, contents, parcelxml;
+ private boolean verbose = false;
+ private String language = null;
+ private MethodFinder finder = null;
+ private ArrayList scripts = null;
+ private Hashtable properties = new Hashtable(3);
+
+ public GenerateCommand(String basedir) {
+ this.basedir = new File(basedir);
+ this.contents = new File(basedir, ParcelZipper.CONTENTS_DIRNAME);
+ this.parcelxml = new File(contents, PARCEL_XML_FILE);
+ }
+
+ public void setLanguage(String language) {
+ StringTokenizer tokenizer = new StringTokenizer(language, "=");
+ this.language = tokenizer.nextToken();
+
+ if (this.language.toLowerCase().equals("java")) {
+ this.finder = JavaFinder.getInstance();
+ return;
+ }
+
+ if (tokenizer.hasMoreTokens()) {
+ String ext = (String)tokenizer.nextToken();
+ String[] extensions;
+
+ if (ext.indexOf(File.pathSeparator) != -1) {
+ tokenizer = new StringTokenizer(ext, File.pathSeparator);
+ extensions = new String[tokenizer.countTokens()];
+ int i = 0;
+
+ while(tokenizer.hasMoreTokens())
+ extensions[i++] = (String)tokenizer.nextToken();
+ }
+ else {
+ extensions = new String[1];
+ extensions[0] = ext;
+ }
+ this.finder = new ExtensionFinder(this.language, extensions);
+ }
+ }
+
+ public void addProperty(String prop) {
+ StringTokenizer tok = new StringTokenizer(prop, "=");
+
+ if (tok.countTokens() != 2)
+ return;
+
+ String name = tok.nextToken();
+ String value = tok.nextToken();
+
+ properties.put(name, value);
+ }
+
+ public void setVerbose() {
+ verbose = true;
+ }
+
+ public void addScript(String script) {
+ if (language == null)
+ return;
+
+ addScript(new ScriptEntry(language, script, script, basedir.getName()));
+ }
+
+ public void addScript(ScriptEntry entry) {
+ if (scripts == null)
+ scripts = new ArrayList(3);
+ scripts.add(entry);
+ }
+
+ public void execute() throws Exception {
+
+ if (basedir.isDirectory() != true) {
+ throw new Exception(basedir.getName() + " is not a directory");
+ }
+ else if (contents.exists() != true) {
+ throw new Exception(basedir.getName() +
+ " does not contain a Contents directory");
+ }
+
+ if (language == null && parcelxml.exists() == false) {
+ throw new Exception(parcelxml.getName() + " not found and language " +
+ "not specified");
+ }
+
+ if (language != null && parcelxml.exists() == true) {
+ ParcelDescriptor desc;
+ String desclang = "";
+
+ desc = new ParcelDescriptor(parcelxml);
+ desclang = desc.getLanguage().toLowerCase();
+
+ if (!desclang.equals(language.toLowerCase()))
+ throw new Exception(parcelxml.getName() + " already exists, " +
+ "and has a different language attribute: " +
+ desc.getLanguage());
+ }
+
+ if (language != null && scripts == null) {
+ if (finder == null)
+ throw new Exception("Extension list not specified for this language");
+
+ log("Searching for " + language + " scripts");
+
+ ScriptEntry[] entries = finder.findMethods(contents);
+ for (int i = 0; i < entries.length; i++) {
+ addScript(entries[i]);
+ log("Found: " + entries[i].getLogicalName());
+ }
+ }
+
+ if (scripts != null) {
+ if (scripts.size() == 0)
+ throw new Exception("No valid scripts found");
+
+ ParcelDescriptor desc = new ParcelDescriptor(parcelxml, language);
+ desc.setScriptEntries((ScriptEntry[])scripts.toArray(new ScriptEntry[0]));
+ if (properties.size() != 0) {
+ Enumeration enumer = properties.keys();
+
+ while (enumer.hasMoreElements()) {
+ String name = (String)enumer.nextElement();
+ String value = (String)properties.get(name);
+ log("Setting property: " + name + " to " + value);
+
+ desc.setLanguageProperty(name, value);
+ }
+ }
+ desc.write();
+ }
+ else {
+ if (parcelxml.exists() == false)
+ throw new Exception("No valid scripts found");
+ }
+
+ contents = new File(contents.getAbsolutePath());
+ String name = ParcelZipper.getParcelZipper().zipParcel(contents, AllFilesFilter.getInstance());
+ System.out.println(name + " generated");
+ }
+
+ private void log(String message) {
+ if (verbose)
+ System.out.println(message);
+ }
+ }
+
+ private static class DeployCommand implements Command {
+
+ File source, target;
+
+ public DeployCommand(String source, String target) {
+ this.source = new File(source);
+ this.target = new File(target);
+ }
+
+ public void execute() throws Exception {
+ ParcelZipper.getParcelZipper().deployParcel(source, target);
+ System.out.println(source.getName() +
+ " successfully deployed to " + target.getAbsolutePath());
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/ExtensionFinder.java b/scripting/java/org/openoffice/idesupport/ExtensionFinder.java
new file mode 100644
index 000000000000..8a0a10196a73
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/ExtensionFinder.java
@@ -0,0 +1,60 @@
+package org.openoffice.idesupport;
+
+import java.io.File;
+import java.util.ArrayList;
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+
+public class ExtensionFinder implements MethodFinder {
+
+ private String[] extensions;
+ private String language;
+
+ public ExtensionFinder(String language, String[] extensions) {
+ this.language = language;
+ this.extensions = extensions;
+ }
+
+ public ScriptEntry[] findMethods(File basedir) {
+ String parcelName;
+ ArrayList files = new ArrayList(10);
+ ScriptEntry[] empty = new ScriptEntry[0];
+
+ if (basedir == null || basedir.exists() == false ||
+ basedir.isDirectory() == false)
+ return empty;
+
+ parcelName = basedir.getName();
+ if (parcelName.equals(ParcelZipper.CONTENTS_DIRNAME))
+ parcelName = basedir.getParentFile().getName();
+
+ findFiles(files, basedir, parcelName);
+
+ if (files.size() != 0)
+ return (ScriptEntry[])files.toArray(empty);
+ return empty;
+ }
+
+ private void findFiles(ArrayList list, File basedir, String parcelName) {
+ File[] children = basedir.listFiles();
+ File f;
+
+ for (int i = 0; i < children.length; i++) {
+ f = children[i];
+
+ if (f.isDirectory())
+ findFiles(list, f, parcelName);
+ else {
+ for (int j = 0; j < extensions.length; j++) {
+ if (f.getName().endsWith(extensions[j])) {
+ ScriptEntry entry = new ScriptEntry(language,
+ f.getName(), f.getName(), parcelName);
+ list.add(entry);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/JavaFinder.java b/scripting/java/org/openoffice/idesupport/JavaFinder.java
new file mode 100644
index 000000000000..cf077b6b2c08
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/JavaFinder.java
@@ -0,0 +1,227 @@
+package org.openoffice.idesupport;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+
+public class JavaFinder implements MethodFinder {
+
+ private static JavaFinder finder;
+ private static final String JAVA_SUFFIX = ".java";
+ private static final String CLASS_SUFFIX = ".class";
+ private static final String LANGUAGE = "Java";
+ private static final String FIRST_PARAM =
+ "drafts.com.sun.star.script.framework.runtime.XScriptContext";
+
+ private Vector classpath = null;
+
+ private JavaFinder() {}
+
+ private JavaFinder(Vector classpath) {
+ this.classpath = classpath;
+ }
+
+ public static JavaFinder getInstance() {
+ if (finder == null) {
+ synchronized(JavaFinder.class) {
+ if (finder == null)
+ finder = new JavaFinder();
+ }
+ }
+ return finder;
+ }
+
+ public static JavaFinder getInstance(Vector classpath) {
+ return new JavaFinder(classpath);
+ }
+
+ public ScriptEntry[] findMethods(File basedir) {
+ String parcelName;
+ ArrayList result = new ArrayList(10);
+ ScriptEntry[] empty = new ScriptEntry[0];
+
+ if (basedir == null || basedir.exists() == false ||
+ basedir.isDirectory() == false)
+ return empty;
+
+ parcelName = basedir.getName();
+ if (parcelName.equals(ParcelZipper.CONTENTS_DIRNAME))
+ parcelName = basedir.getParentFile().getName();
+
+ String[] classNames = findClassNames(basedir);
+ if (classNames != null && classNames.length != 0) {
+
+ ClassLoader classloader;
+
+ if (classpath == null)
+ classloader = getClassLoader(basedir);
+ else
+ classloader = getClassLoader();
+
+ for (int i = 0; i < classNames.length; i++)
+ {
+ try
+ {
+ Class clazz = classloader.loadClass(classNames[i]);
+ Method[] methods = clazz.getDeclaredMethods();
+ for (int k = 0; k < methods.length; k++)
+ {
+ if (Modifier.isPublic(methods[k].getModifiers()))
+ {
+ Class[] params = methods[k].getParameterTypes();
+ if(params.length > 0)
+ {
+ if(params[0].getName().equals(FIRST_PARAM))
+ {
+ ScriptEntry entry =
+ new ScriptEntry(classNames[i] + "." +
+ methods[k].getName(), parcelName);
+ result.add(entry);
+ }
+ }
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ System.err.println("Caught ClassNotFoundException loading: "
+ + classNames[i]);
+ continue;
+ }
+ catch (NoClassDefFoundError nc)
+ {
+ System.err.println("Caught NoClassDefFoundErr loading: " +
+ classNames[i]);
+ continue;
+ }
+ }
+ }
+
+ if (result.size() != 0)
+ return (ScriptEntry[])result.toArray(empty);
+ return empty;
+ }
+
+ private ClassLoader getClassLoader() {
+ int len = classpath.size();
+ ArrayList urls = new ArrayList(len);
+
+ for (int i = 0; i < len; i++) {
+ try {
+ String s = (String)classpath.elementAt(i);
+ s = SVersionRCFile.toFileURL(s);
+
+ if (s != null)
+ urls.add(new URL(s));
+ }
+ catch (MalformedURLException mue) {
+ }
+ }
+
+ return new URLClassLoader((URL[])urls.toArray(new URL[0]));
+ }
+
+ private ClassLoader getClassLoader(File basedir) {
+ ArrayList files = findFiles(basedir, ".jar");
+ files.add(basedir);
+
+ try {
+ Enumeration offices = SVersionRCFile.createInstance().getVersions();
+
+ while (offices.hasMoreElements()) {
+ OfficeInstallation oi = (OfficeInstallation)offices.nextElement();
+ String unoil = SVersionRCFile.getPathForUnoil(oi.getPath());
+
+ if (unoil != null) {
+ files.add(new File(unoil, "unoil.jar"));
+ break;
+ }
+ }
+ }
+ catch (IOException ioe) {
+ return null;
+ }
+
+ URL[] urls = new URL[files.size()];
+ String urlpath;
+ File f;
+ for (int i = 0; i < urls.length; i++) {
+ try {
+ f = (File)files.get(i);
+ urlpath = SVersionRCFile.toFileURL(f.getAbsolutePath());
+
+ if (urlpath != null)
+ urls[i] = new URL(urlpath);
+ }
+ catch (MalformedURLException mue) {
+ // do nothing, go on to next file
+ }
+ }
+
+ return new URLClassLoader(urls);
+ }
+
+ private ArrayList findFiles(File basedir, String suffix) {
+ ArrayList result = new ArrayList();
+ File[] children = basedir.listFiles();
+
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isDirectory())
+ result.addAll(findFiles(children[i], suffix));
+ else if (children[i].getName().endsWith(suffix))
+ result.add(children[i]);
+ }
+ return result;
+ }
+
+ private String[] findClassNames(File basedir)
+ {
+ ArrayList classFiles = findFiles(basedir, CLASS_SUFFIX);
+ if(classFiles == null || classFiles.size() == 0)
+ return null;
+
+ ArrayList javaFiles = findFiles(basedir, JAVA_SUFFIX);
+ if(javaFiles == null || javaFiles.size() == 0)
+ return null;
+
+ ArrayList result = new ArrayList();
+ for (int i = 0; i < classFiles.size(); i++)
+ {
+ File classFile = (File)classFiles.get(i);
+ String className = classFile.getName();
+ className = className.substring(0, className.lastIndexOf(CLASS_SUFFIX));
+ boolean finished = false;
+
+
+ for (int j = 0; j < javaFiles.size() && finished == false; j++)
+ {
+ File javaFile = (File)javaFiles.get(j);
+ String javaName = javaFile.getName();
+ javaName = javaName.substring(0, javaName.lastIndexOf(JAVA_SUFFIX));
+
+ if (javaName.equals(className))
+ {
+ String path = classFile.getAbsolutePath();
+ path = path.substring(basedir.getAbsolutePath().length() + 1);
+ path = path.replace(File.separatorChar, '.');
+ path = path.substring(0, path.lastIndexOf(CLASS_SUFFIX));
+
+ result.add(path);
+ javaFiles.remove(j);
+ finished = true;
+ }
+ }
+ }
+ return (String[])result.toArray(new String[0]);
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/LocalOffice.java b/scripting/java/org/openoffice/idesupport/LocalOffice.java
new file mode 100644
index 000000000000..73f319a87269
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/LocalOffice.java
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport;
+
+import java.io.File;
+import java.net.ConnectException;
+import java.util.Vector;
+
+/**
+ * LocalOffice represents a connection to the local office.
+ *
+ * This class allows to get access to some scripting framework
+ * releated functionality of the locally running office. The
+ * office has to be started with options appropriate for establishing
+ * local connection.
+ *
+ * @author misha <misha@openoffice.org>
+ */
+public class LocalOffice
+{
+ /**
+ * Creates an instance of the local office connection.
+ *
+ * @param parent is an application specific class loader.
+ * @param officePath is a platform specific path string
+ * to the office distribution.
+ * @param port is a communication port.
+ */
+ public static final LocalOffice create(
+ ClassLoader parent, String officePath, int port)
+ {
+ Vector path = new Vector();
+ path.addElement(officePath + "/program/classes/ridl.jar");
+ path.addElement(officePath + "/program/classes/jurt.jar");
+ path.addElement(officePath + "/program/classes/unoil.jar");
+ path.addElement(officePath + "/program/classes/juh.jar");
+ path.addElement(System.getProperties().getProperty("netbeans.home") +
+ File.separator + "modules" +
+ File.separator + "ext" +
+ File.separator + "localoffice.jar");
+ // commented out so code will compile
+ // ClassLoader appcl = new DefaultScriptClassLoader(parent, path);
+ ClassLoader appcl = path.getClass().getClassLoader();
+ Class clazz = null;
+ LocalOffice office = null;
+ try {
+ clazz = appcl.loadClass(
+ "org.openoffice.idesupport.localoffice.LocalOfficeImpl");
+ office = (LocalOffice)clazz.newInstance();
+ office.connect(officePath, port);
+ } catch (java.lang.Exception exp) {
+ office = null;
+ }
+ return office;
+ }
+
+ /**
+ * Connects to the running office.
+ *
+ * @param officePath is a platform specific path string
+ * to the office distribution.
+ * @param port is a communication port.
+ */
+ protected void connect(String officePath, int port)
+ throws ConnectException
+ {
+ }
+
+ /**
+ * Closes the connection to the running office.
+ */
+ public void disconnect()
+ {
+ }
+
+ /**
+ * Refresh the script storage.
+ *
+ * @param uri is an identifier of storage has to be refreshed.
+ */
+ public void refreshStorage(String uri)
+ {
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/MethodFinder.java b/scripting/java/org/openoffice/idesupport/MethodFinder.java
new file mode 100644
index 000000000000..3bf85e323566
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/MethodFinder.java
@@ -0,0 +1,8 @@
+package org.openoffice.idesupport;
+
+import java.io.File;
+import com.sun.star.script.framework.container.ScriptEntry;
+
+public interface MethodFinder {
+ public ScriptEntry[] findMethods(File basedir);
+}
diff --git a/scripting/java/org/openoffice/idesupport/OfficeDocument.java b/scripting/java/org/openoffice/idesupport/OfficeDocument.java
new file mode 100644
index 000000000000..9f75c57be867
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/OfficeDocument.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport;
+
+import java.io.*;
+import java.util.zip.*;
+import java.util.Vector;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+
+import org.openoffice.idesupport.filter.FileFilter;
+import org.openoffice.idesupport.filter.BinaryOnlyFilter;
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+public class OfficeDocument
+{
+ public static final String PARCEL_PREFIX_DIR =
+ ParcelZipper.PARCEL_PREFIX_DIR;
+
+ public static final String[] OFFICE_EXTENSIONS =
+ {".sxc" , ".sxw", ".sxi", ".sxd"};
+ public static final String OFFICE_PRODUCT_NAME = "OpenOffice.org";
+
+ private File file = null;
+
+ public OfficeDocument(File file) throws IllegalArgumentException
+ {
+ if (!file.exists() || file.isDirectory() || !isOfficeFile(file)) {
+ throw new IllegalArgumentException("This is not a valid " +
+ OFFICE_PRODUCT_NAME + " document.");
+ }
+ this.file = file;
+ }
+
+ private boolean isOfficeFile(File file) {
+ for (int i = 0; i < OFFICE_EXTENSIONS.length; i++)
+ if (file.getName().endsWith(OFFICE_EXTENSIONS[i]))
+ return true;
+ return false;
+ }
+
+ public Enumeration getParcels() {
+
+ Vector parcels = new Vector();
+ ZipFile zp = null;
+
+ try
+ {
+ zp = new ZipFile(this.file);
+
+ for (Enumeration enumer = zp.entries(); enumer.hasMoreElements(); )
+ {
+ ZipEntry ze = (ZipEntry)enumer.nextElement();
+ if (ze.getName().endsWith(ParcelZipper.PARCEL_DESCRIPTOR_XML))
+ {
+ String tmp = ze.getName();
+ int end = tmp.lastIndexOf("/");
+ tmp = tmp.substring(0, end);
+
+ String parcelName = ze.getName().substring(0, end);
+ parcels.add(parcelName);
+ }
+ }
+ }
+ catch(ZipException ze) {
+ ze.printStackTrace();
+ }
+ catch(IOException ioe) {
+ ioe.printStackTrace();
+ }
+ finally {
+ if (zp != null) {
+ try {
+ zp.close();
+ }
+ catch (IOException asdf) {
+ }
+ }
+ }
+
+ return parcels.elements();
+ }
+
+ public boolean removeParcel(String parcelName) {
+
+ try {
+ ParcelZipper.getParcelZipper().removeParcel(file, parcelName);
+ }
+ catch (IOException ioe) {
+ ioe.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/OfficeInstallation.java b/scripting/java/org/openoffice/idesupport/OfficeInstallation.java
new file mode 100644
index 000000000000..66bb8a6ccf29
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/OfficeInstallation.java
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package org.openoffice.idesupport;
+
+import java.io.File;
+import java.net.URLDecoder;
+
+public class OfficeInstallation implements java.io.Serializable {
+
+ private String name;
+ private String path;
+ private String url;
+ private boolean hasFW = false;
+ private boolean supportsFW = false;
+
+ public static final String FILE_URL_PREFIX = SVersionRCFile.FILE_URL_PREFIX;
+
+ public OfficeInstallation(String path) {
+ this(path, path);
+ }
+
+ public OfficeInstallation(String name, String path) {
+
+ this.name = name;
+
+ if (path.startsWith(FILE_URL_PREFIX)) {
+ this.url = path;
+ path = URLDecoder.decode(path);
+ path = path.substring(FILE_URL_PREFIX.length());
+
+ if (System.getProperty("os.name").startsWith("Windows"))
+ path = path.replace('/', File.separatorChar);
+
+ this.path = path;
+ }
+ else {
+ this.path = path;
+
+ if (System.getProperty("os.name").startsWith("Windows"))
+ path = path.replace(File.separatorChar, '/');
+
+ this.url = FILE_URL_PREFIX + path;
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getPath(String name) {
+ if (!name.startsWith(File.separator))
+ name = File.separator + name;
+
+ return path + name;
+ }
+
+ public String getURL() {
+ return url;
+ }
+
+ public String getURL(String name) {
+ if (System.getProperty("os.name").startsWith("Windows"))
+ name = name.replace(File.separatorChar, '/');
+
+ if (!name.startsWith("/"))
+ name = "/" + name;
+
+ return url + name;
+ }
+
+ public boolean hasFramework() {
+ return hasFW;
+ }
+
+ public boolean supportsFramework() {
+ return true;
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java
new file mode 100644
index 000000000000..0df5d4a61169
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java
@@ -0,0 +1,237 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport;
+
+import java.io.File;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.util.Vector;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+
+public class SVersionRCFile {
+
+ public static final String DEFAULT_NAME =
+ System.getProperty("os.name").startsWith("Windows") == true ?
+ System.getProperty("user.home") + File.separator +
+ "Application Data" + File.separator + "sversion.ini" :
+ System.getProperty("user.home") + File.separator +
+ ".sversionrc";
+
+ public static final String FILE_URL_PREFIX =
+ System.getProperty("os.name").startsWith("Windows") == true ?
+ "file:///" : "file://";
+
+ public static final String PKGCHK =
+ System.getProperty("os.name").startsWith("Windows") == true ?
+ "pkgchk.exe" : "pkgchk";
+
+ private static final String VERSIONS_LINE = "[Versions]";
+
+ private static final String UNOILJAR =
+ "skip_registration" + File.separator + "unoil.jar";
+
+ private static final String UNOPACKAGEDIR =
+ File.separator + "user" + File.separator + "uno_packages" +
+ File.separator + "cache" + File.separator + "uno_packages";
+
+ /* Make sure this is in LowerCase !!!!! */
+ private static final String SCRIPTF = "scriptf";
+
+ private static final HashMap files = new HashMap(3);
+
+ private File sversionrc = null;
+ private OfficeInstallation defaultversion = null;
+ private Vector versions = null;
+ private long lastModified = 0;
+
+ public SVersionRCFile() {
+ this(DEFAULT_NAME);
+ }
+
+ public SVersionRCFile(String name) {
+ sversionrc = new File(name);
+ versions = new Vector(5);
+ }
+
+ public static SVersionRCFile createInstance() {
+ return(createInstance(DEFAULT_NAME));
+ }
+
+ public static SVersionRCFile createInstance(String name) {
+ SVersionRCFile result = null;
+
+ synchronized(SVersionRCFile.class) {
+ result = (SVersionRCFile)files.get(name);
+
+ if (result == null) {
+ result = new SVersionRCFile(name);
+ files.put(name, result);
+ }
+ }
+ return result;
+ }
+
+ public OfficeInstallation getDefaultVersion() throws IOException {
+ if (defaultversion == null) {
+ getVersions();
+ }
+
+ return defaultversion;
+ }
+
+ public Enumeration getVersions() throws IOException {
+
+ long l = sversionrc.lastModified();
+
+ if (l > lastModified) {
+ BufferedReader br = null;
+
+ try {
+ br = new BufferedReader(new FileReader(sversionrc));
+ load(br);
+ lastModified = l;
+ }
+ catch (FileNotFoundException fnfe) {
+ throw new IOException(fnfe.getMessage());
+ }
+ finally {
+ if (br != null)
+ br.close();
+ }
+ }
+ return versions.elements();
+ }
+
+ private void load(BufferedReader br) throws IOException {
+ String s;
+
+ while ((s = br.readLine()) != null &&
+ (s.equals(VERSIONS_LINE)) != true);
+
+ while ((s = br.readLine()) != null &&
+ (s.equals("")) != true) {
+ StringTokenizer tokens = new StringTokenizer(s, "=");
+ int count = tokens.countTokens();
+
+ if (count != 2)
+ continue;
+
+ String name = tokens.nextToken();
+ String path = tokens.nextToken();
+ OfficeInstallation oi = new OfficeInstallation(name, path);
+ if (oi.supportsFramework()) {
+ versions.add(oi);
+ defaultversion = oi;
+ }
+ }
+ }
+
+ public static String toFileURL(String path) {
+ File f = new File(path);
+
+ if (!f.exists())
+ return null;
+
+ try {
+ path = f.getCanonicalPath();
+ }
+ catch (IOException ioe) {
+ return null;
+ }
+
+ if (System.getProperty("os.name").startsWith("Windows"))
+ path = path.replace(File.separatorChar, '/');
+
+ StringBuffer buf = new StringBuffer(FILE_URL_PREFIX);
+ buf.append(path);
+
+ if (f.isDirectory())
+ buf.append("/");
+
+ return buf.toString();
+ }
+
+ public static String getPathForUnoil(String officeInstall)
+ {
+ File unopkgdir = new File(officeInstall, UNOPACKAGEDIR);
+ if(!unopkgdir.exists())
+ {
+ return null;
+ }
+ File scriptf = null;
+ String[] listunopkg = unopkgdir.list();
+ int size = listunopkg.length;
+ for(int i=0; i<size; i++)
+ {
+ if (listunopkg[i].toLowerCase().indexOf(SCRIPTF)>-1)
+ {
+ scriptf = new File(unopkgdir, listunopkg[i]);
+ }
+ }
+ if(scriptf != null)
+ {
+ File unoil = new File(scriptf, UNOILJAR);
+ if(unoil.exists())
+ {
+ String path = unoil.getParent();
+ path = path.substring(path.indexOf(UNOPACKAGEDIR));
+ return officeInstall + path;
+ }
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ SVersionRCFile ov;
+
+ if (args.length == 0)
+ ov = new SVersionRCFile();
+ else
+ ov = new SVersionRCFile(args[0]);
+
+ Enumeration enumer;
+
+ try {
+ enumer = ov.getVersions();
+ }
+ catch (IOException ioe) {
+ System.err.println("Error getting versions: " + ioe.getMessage());
+ return;
+ }
+
+ while (enumer.hasMoreElements()) {
+ OfficeInstallation oi = (OfficeInstallation)enumer.nextElement();
+ System.out.println("Name: " + oi.getName() + ", Path: " + oi.getPath() +
+ ", URL: " + oi.getURL());
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/filter/AllFilesFilter.java b/scripting/java/org/openoffice/idesupport/filter/AllFilesFilter.java
new file mode 100644
index 000000000000..c27886d8f9c5
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/filter/AllFilesFilter.java
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.filter;
+
+public class AllFilesFilter implements FileFilter {
+ private static final AllFilesFilter filter = new AllFilesFilter();
+
+ private AllFilesFilter() {
+ }
+
+ public static AllFilesFilter getInstance() {
+ return filter;
+ }
+
+ public boolean validate(String name) {
+ return true;
+ }
+
+ public String toString() {
+ return "<all files>";
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java b/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java
new file mode 100644
index 000000000000..ba670705566c
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.filter;
+
+public class BinaryOnlyFilter implements FileFilter {
+ private static final String[] EXTENSIONS = {".class", ".jar", ".bsh"};
+ private static final String DESCRIPTION = "Executable Files Only";
+ private static final BinaryOnlyFilter filter = new BinaryOnlyFilter();
+
+ private BinaryOnlyFilter() {
+ }
+
+ public static BinaryOnlyFilter getInstance() {
+ return filter;
+ }
+ public boolean validate(String name) {
+ for (int i = 0; i < EXTENSIONS.length; i++)
+ if (name.endsWith(EXTENSIONS[i]))
+ return true;
+ return false;
+ }
+
+ public String toString() {
+ /* StringBuffer buf = new StringBuffer(DESCRIPTION + ": ");
+
+ for (int i = 0; i < EXTENSIONS.length - 1; i++)
+ buf.append("<" + EXTENSIONS[i] + "> ");
+ buf.append("<" + EXTENSIONS[EXTENSIONS.length - 1] + ">");
+
+ return buf.toString(); */
+ return DESCRIPTION;
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java b/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java
new file mode 100644
index 000000000000..9de3acfb3ee5
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.filter;
+
+public class ExceptParcelFilter implements FileFilter {
+ private static final String DESCRIPTION = "Remove specified Parcel";
+ private static final ExceptParcelFilter filter = new ExceptParcelFilter();
+ private static String parcelName = null;
+
+ private ExceptParcelFilter() {
+ }
+
+ public void setParcelToRemove(String parcelName)
+ {
+ this.parcelName = parcelName;
+ }
+
+ public static ExceptParcelFilter getInstance() {
+ return filter;
+ }
+ public boolean validate(String name) {
+ if (name.startsWith(this.parcelName))
+ return true;
+ return false;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer(DESCRIPTION + ": ");
+
+ buf.append("<" + this.parcelName + ">");
+
+ return buf.toString();
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/filter/FileFilter.java b/scripting/java/org/openoffice/idesupport/filter/FileFilter.java
new file mode 100644
index 000000000000..52ad72c4753c
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/filter/FileFilter.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.filter;
+
+public interface FileFilter {
+ public boolean validate(String name);
+}
diff --git a/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java b/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java
new file mode 100644
index 000000000000..491aa61cb052
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.localoffice;
+
+import java.net.ConnectException;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Exception;
+
+import drafts.com.sun.star.script.framework.storage.XScriptStorageManager;
+
+import org.openoffice.idesupport.LocalOffice;
+
+/**
+ * LocalOfficeImpl represents a connection to the local office.
+ *
+ * This class is an implementation of LocalOffice ane allows to
+ * get access to some scripting framework releated functionality
+ * of the locally running office. The office has to be started
+ * with options appropriate for establishing local connection.
+ *
+ * @author misha <misha@openoffice.org>
+ */
+public final class LocalOfficeImpl
+ extends LocalOffice
+{
+ private final static String STORAGE_MRG_SINGLETON =
+ "/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager";
+
+ private transient String mOfficePath;
+ private transient XMultiComponentFactory mComponentFactory;
+ private transient XComponentContext mComponentContext;
+ private transient XMultiServiceFactory mServiceFactory;
+ /**
+ * Constructor.
+ */
+ public LocalOfficeImpl()
+ {
+ }
+
+ /**
+ * Connects to the running office.
+ *
+ * @param officePath is a platform specific path string
+ * to the office distribution.
+ * @param port is a communication port.
+ */
+ protected void connect(String officePath, int port)
+ throws ConnectException
+ {
+ mOfficePath = officePath;
+ try {
+ bootstrap(port);
+ } catch (java.lang.Exception ex) {
+ throw new ConnectException(ex.getMessage());
+ }
+ }
+
+ /**
+ * Refresh the script storage.
+ *
+ * @param uri is an identifier of storage has to be refreshed.
+ */
+ public void refreshStorage(String uri)
+ {
+ try {
+ Object object = null;
+ object = mComponentContext.getValueByName(STORAGE_MRG_SINGLETON);
+ XScriptStorageManager storageMgr;
+ storageMgr = (XScriptStorageManager)UnoRuntime.queryInterface(
+ XScriptStorageManager.class, object);
+ storageMgr.refreshScriptStorage(uri);
+ } catch (java.lang.Exception ex) {
+System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " + ex.getMessage());
+System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " + ex.getClass().getName());
+ }
+System.out.println("*** LocalOfficeImpl.refreshStorage: DONE");
+ }
+
+ /**
+ * Closes the connection to the running office.
+ */
+ public void disconnect()
+ {
+/*
+ if(mComponentFactory != null) {
+ XComponent comp = (XComponent)UnoRuntime.queryInterface(
+ XComponent.class, mComponentFactory);
+ comp.dispose();
+ }
+*/
+ }
+
+ /**
+ * Boot straps UNO.
+ *
+ * The office has to be started with following string:
+ * "-accept=socket,host=localhost,port=<PORT>;urp;StarOffice.ServiceManager"
+ *
+ * @param port is a communication port.
+ */
+ private void bootstrap(int port)
+ throws java.lang.Exception
+ {
+ Object object;
+ mComponentContext = Bootstrap.createInitialComponentContext(null);
+ XUnoUrlResolver urlresolver = UnoUrlResolver.create(mComponentContext);
+ object = urlresolver.resolve(
+ "uno:socket,host=localhost,port=" +
+ port +
+ ";urp;StarOffice.ServiceManager");
+ mComponentFactory = (XMultiComponentFactory)UnoRuntime.queryInterface(
+ XMultiComponentFactory.class, object);
+ XPropertySet factoryProps;
+ factoryProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, mComponentFactory);
+ object = factoryProps.getPropertyValue("DefaultContext");
+ mComponentContext = (XComponentContext)UnoRuntime.queryInterface(
+ XComponentContext.class, object);
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java
new file mode 100644
index 000000000000..b4bfd6266dac
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java
@@ -0,0 +1,236 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.ui;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.util.Vector;
+import java.util.Enumeration;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JButton;
+import javax.swing.AbstractButton;
+import javax.swing.ImageIcon;
+import javax.swing.border.LineBorder;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.w3c.dom.Document;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+import com.sun.star.script.framework.container.ParcelDescriptor;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+public class ConfigurePanel extends JPanel {
+
+ private File basedir;
+ private Vector classpath;
+ private ParcelDescriptor descriptor;
+
+ private MethodPanel methodPanel;
+ private ScriptPanel scriptPanel;
+
+ public static final String DIALOG_TITLE =
+ "Choose What to Export as Scripts";
+
+ public ConfigurePanel(String basedir, Vector classpath,
+ ParcelDescriptor descriptor) {
+
+ this.basedir = new File(basedir);
+ this.classpath = classpath;
+ this.descriptor = descriptor;
+ initUI();
+ }
+
+ public ConfigurePanel(String basedir, Vector classpath)
+ throws IOException {
+
+ this.basedir = new File(basedir);
+ this.classpath = classpath;
+ this.descriptor = new ParcelDescriptor(new File(this.basedir,
+ ParcelZipper.PARCEL_DESCRIPTOR_XML));
+ initUI();
+ }
+
+ public void reload(String basedir, Vector classpath,
+ ParcelDescriptor descriptor) {
+
+ if (basedir != null)
+ this.basedir = new File(basedir);
+
+ if (classpath != null)
+ this.classpath = classpath;
+
+ if (descriptor != null) {
+ descriptor = descriptor;
+ }
+
+ methodPanel.reload(this.basedir, this.classpath,
+ descriptor.getLanguage());
+ scriptPanel.reload(descriptor.getScriptEntries());
+ }
+
+ public void reload(String basedir, Vector classpath)
+ throws IOException {
+
+ if (basedir != null)
+ this.basedir = new File(basedir);
+
+ if (classpath != null)
+ this.classpath = classpath;
+
+ this.descriptor = new ParcelDescriptor(new File(this.basedir,
+ ParcelZipper.PARCEL_DESCRIPTOR_XML));
+
+ methodPanel.reload(this.basedir, this.classpath,
+ descriptor.getLanguage());
+ scriptPanel.reload(descriptor.getScriptEntries());
+ }
+
+ public ParcelDescriptor getConfiguration() throws Exception {
+ Enumeration scripts = scriptPanel.getScriptEntries();
+ descriptor.setScriptEntries(scripts);
+ return descriptor;
+ }
+
+ private void initUI() {
+
+ JPanel leftPanel = new JPanel();
+ JPanel methodButtons = initMethodButtons();
+ methodPanel = new MethodPanel(basedir, classpath, descriptor.getLanguage());
+
+ leftPanel.setLayout(new BorderLayout());
+ leftPanel.add(methodPanel, BorderLayout.CENTER);
+
+ JPanel rightPanel = new JPanel();
+ JPanel scriptButtons = initScriptButtons();
+ scriptPanel = new ScriptPanel(descriptor.getScriptEntries());
+
+ rightPanel.setLayout(new BorderLayout());
+ rightPanel.add(scriptPanel, BorderLayout.CENTER);
+ rightPanel.add(scriptButtons, BorderLayout.SOUTH);
+
+ setLayout(new GridBagLayout());
+ setPreferredSize(new java.awt.Dimension(700, 300));
+ setBorder(LineBorder.createBlackLineBorder());
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.fill = java.awt.GridBagConstraints.BOTH;
+ gbc.ipadx = 40;
+ gbc.anchor = java.awt.GridBagConstraints.WEST;
+ gbc.insets = new Insets(10, 5, 5, 5);
+ gbc.weightx = 0.75;
+ add(leftPanel, gbc);
+
+ gbc = new java.awt.GridBagConstraints();
+ gbc.gridx = 1;
+ gbc.gridy = 0;
+ add(methodButtons, gbc);
+
+ gbc = new java.awt.GridBagConstraints();
+ gbc.gridx = 2;
+ gbc.gridy = 0;
+ gbc.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gbc.fill = java.awt.GridBagConstraints.BOTH;
+ gbc.anchor = java.awt.GridBagConstraints.EAST;
+ gbc.insets = new Insets(10, 5, 5, 5);
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ add(rightPanel, gbc);
+ }
+
+ private JPanel initMethodButtons() {
+ JPanel panel = new JPanel();
+ panel.setLayout(new GridBagLayout());
+ ImageIcon icon = new ImageIcon(getClass().getResource("/org/openoffice/idesupport/ui/add.gif"));
+ JButton addButton = new JButton("Add", icon);
+ addButton.setHorizontalTextPosition(AbstractButton.LEFT);
+
+ addButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.addScriptEntries(methodPanel.getSelectedEntries());
+ }
+ }
+ );
+
+ GridBagConstraints gbc = new java.awt.GridBagConstraints();
+ gbc.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gbc.insets = new Insets(5, 5, 5, 5);
+ panel.add(addButton, gbc);
+
+ JPanel dummyPanel = new JPanel();
+ gbc = new java.awt.GridBagConstraints();
+ gbc.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gbc.gridheight = java.awt.GridBagConstraints.REMAINDER;
+ gbc.fill = java.awt.GridBagConstraints.BOTH;
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ panel.add(dummyPanel, gbc);
+
+ return panel;
+ }
+
+ private JPanel initScriptButtons() {
+ JPanel panel = new JPanel();
+ JButton removeButton = new JButton("Remove");
+ JButton removeAllButton = new JButton("Remove All");
+
+ removeButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.removeSelectedRows();
+ }
+ }
+ );
+
+ removeAllButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.removeAllRows();
+ }
+ }
+ );
+
+ panel.add(removeButton);
+ panel.add(removeAllButton);
+
+ return panel;
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java
new file mode 100644
index 000000000000..a65c9556d131
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.ui;
+
+import java.io.File;
+import java.util.Vector;
+import java.util.ArrayList;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JList;
+import javax.swing.JTable;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.JLabel;
+import java.awt.BorderLayout;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+import org.openoffice.idesupport.MethodFinder;
+import org.openoffice.idesupport.ExtensionFinder;
+import org.openoffice.idesupport.JavaFinder;
+
+public class MethodPanel extends JPanel {
+
+ private File basedir;
+ private Vector classpath;
+ private final static String FIRST_PARAM =
+ "drafts.com.sun.star.script.framework.runtime.XScriptContext";
+
+ // private JTable table;
+ // private MethodTableModel model;
+ private JList list;
+ private ScriptEntry[] values;
+
+ public MethodPanel(File basedir, Vector classpath, String language) {
+ this.basedir = basedir;
+ this.classpath = classpath;
+
+ initValues(language);
+ initUI();
+ }
+
+ public void reload(File basedir, Vector classpath, String language) {
+ this.basedir = basedir;
+ this.classpath = classpath;
+
+ initValues(language);
+ list.setListData(values);
+ }
+
+ public ScriptEntry[] getSelectedEntries() {
+ Object[] selections = list.getSelectedValues();
+ ScriptEntry[] entries = new ScriptEntry[selections.length];
+
+ for (int i = 0; i < selections.length; i++) {
+ entries[i] = (ScriptEntry)selections[i];
+ }
+
+ return entries;
+ }
+
+ private void initUI() {
+ JLabel label = new JLabel("Available Methods:");
+ // table = new JTable(model);
+ list = new JList(values);
+
+ JScrollPane pane = new JScrollPane(list);
+ label.setLabelFor(pane);
+
+ BorderLayout layout = new BorderLayout();
+ setLayout(layout);
+ layout.setVgap(5);
+
+ add(label, BorderLayout.NORTH);
+ add(pane, BorderLayout.CENTER);
+ }
+
+ private void initValues(String language) {
+ MethodFinder finder;
+
+ if (language == null)
+ finder = JavaFinder.getInstance(classpath);
+ else if (language.toLowerCase().equals("beanshell"))
+ finder = new ExtensionFinder(language, new String[] {".bsh"});
+ else
+ finder = JavaFinder.getInstance(classpath);
+
+ values = finder.findMethods(basedir);
+ }
+
+ /*
+ private class MethodTableModel extends AbstractTableModel {
+ final String[] columnNames = {"Method",
+ "Language"};
+
+ private Vector methods;
+ private int nextRow;
+
+ public MethodTableModel() {
+ methods = new Vector(11);
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public int getRowCount() {
+ return methods.size();
+ }
+
+ public String getColumnName(int col) {
+ return columnNames[col];
+ }
+
+ public void add(ScriptEntry entry) {
+ methods.addElement(entry);
+ fireTableRowsInserted(nextRow, nextRow);
+ nextRow++;
+ }
+
+ public void remove(int row) {
+ methods.removeElementAt(row);
+ fireTableRowsDeleted(row, row);
+ nextRow--;
+ }
+
+ public void removeAll() {
+ methods.removeAllElements();
+ fireTableRowsDeleted(0, nextRow);
+ nextRow = 0;
+ }
+
+ public Object getValueAt(int row) {
+ return methods.elementAt(row);
+ }
+
+ public Object getValueAt(int row, int col) {
+ String result = "";
+ ScriptEntry entry;
+
+ entry = (ScriptEntry)methods.elementAt(row);
+
+ if (col == 0)
+ result = entry.getLanguageName();
+ else if (col == 1)
+ result = entry.getLanguage();
+
+ return result;
+ }
+
+ public boolean isCellEditable(int row, int col) {
+ return false;
+ }
+ }
+ */
+}
diff --git a/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java
new file mode 100644
index 000000000000..98a6ac50e22d
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.ui;
+
+import java.io.File;
+import java.util.Vector;
+import java.util.Enumeration;
+
+import java.awt.BorderLayout;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusAdapter;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.JTable;
+import javax.swing.DefaultCellEditor;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableColumn;
+import javax.swing.table.AbstractTableModel;
+
+import com.sun.star.script.framework.container.ScriptEntry;
+
+public class ScriptPanel extends JPanel {
+ private ScriptTableModel model;
+ private JTable table;
+
+ public ScriptPanel(ScriptEntry[] scripts) {
+ model = new ScriptTableModel(scripts);
+ initUI();
+ }
+
+ public void reload(ScriptEntry[] entries) {
+ model.removeAll();
+ addScriptEntries(entries);
+ }
+
+ public void addScriptEntries(ScriptEntry[] entries) {
+ for (int i = 0; i < entries.length; i++) {
+ ScriptEntry entry;
+
+ try {
+ entry = (ScriptEntry) entries[i].clone();
+ }
+ catch (CloneNotSupportedException cnse) {
+ entry = new ScriptEntry(entries[i].getLanguage(),
+ entries[i].getLanguageName(),
+ entries[i].getLogicalName(),
+ entries[i].getLocation());
+ }
+
+ model.add(entry);
+ }
+ }
+
+ public void removeSelectedRows() {
+ int[] selections = table.getSelectedRows();
+
+ for (int i = selections.length - 1; i >= 0; i--) {
+ model.remove(selections[i]);
+ }
+ }
+
+ public void removeAllRows() {
+ model.removeAll();
+ }
+
+ public Enumeration getScriptEntries() {
+ return model.getScriptEntries();
+ }
+
+ private void initUI() {
+ table = new JTable(model);
+ TableColumn column = table.getColumnModel().getColumn(1);
+ column.setCellEditor(new DefaultCellEditor(new JTextField()));
+
+ table.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent evt) {
+ tableFocusLost(evt);
+ }
+ });
+
+ JScrollPane pane = new JScrollPane(table);
+ JLabel label = new JLabel("Scripts:");
+ label.setLabelFor(pane);
+
+ BorderLayout layout = new BorderLayout();
+ setLayout(layout);
+ layout.setVgap(5);
+ add(label, BorderLayout.NORTH);
+ add(pane, BorderLayout.CENTER);
+ }
+
+ private void tableFocusLost(FocusEvent evt) {
+ TableCellEditor editor = table.getCellEditor();
+ if (editor != null) {
+ Object value = editor.getCellEditorValue();
+ if (value != null)
+ model.setValueAt(value,
+ table.getEditingRow(), table.getEditingColumn());
+ }
+ }
+
+ private class ScriptTableModel extends AbstractTableModel {
+ final String[] columnNames = {"Exported Method",
+ "Script Name"};
+
+ private Vector scripts;
+ private int nextRow;
+
+ public ScriptTableModel(ScriptEntry[] entries) {
+ scripts = new Vector(entries.length + 11);
+ for (int i = 0; i < entries.length; i++) {
+ scripts.addElement(entries[i]);
+ }
+ nextRow = entries.length;
+ }
+
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ public int getRowCount() {
+ return scripts.size();
+ }
+
+ public String getColumnName(int col) {
+ return columnNames[col];
+ }
+
+ public void add(ScriptEntry entry) {
+ scripts.addElement(entry);
+ fireTableRowsInserted(nextRow, nextRow);
+ nextRow++;
+ }
+
+ public void remove(int row) {
+ scripts.removeElementAt(row);
+ fireTableRowsDeleted(row, row);
+ nextRow--;
+ }
+
+ public void removeAll() {
+ scripts.removeAllElements();
+ fireTableRowsDeleted(0, nextRow);
+ nextRow = 0;
+ }
+
+ public Enumeration getScriptEntries() {
+ return scripts.elements();
+ }
+
+ public Object getValueAt(int row, int col) {
+ String result = "";
+ ScriptEntry entry;
+
+ entry = (ScriptEntry)scripts.elementAt(row);
+
+ if (col == 0)
+ result = entry.getLanguageName();
+ else if (col == 1)
+ result = entry.getLogicalName();
+
+ return result;
+ }
+
+ public boolean isCellEditable(int row, int col) {
+ if (col == 0)
+ return false;
+ else
+ return true;
+ }
+
+ public void setValueAt(Object value, int row, int col) {
+ ScriptEntry entry = (ScriptEntry)scripts.elementAt(row);
+ entry.setLogicalName((String)value);
+ fireTableCellUpdated(row, col);
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/ui/add.gif b/scripting/java/org/openoffice/idesupport/ui/add.gif
new file mode 100644
index 000000000000..e47c986ccf1f
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/ui/add.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/idesupport/xml/Manifest.java b/scripting/java/org/openoffice/idesupport/xml/Manifest.java
new file mode 100644
index 000000000000..74b5bc8f22bc
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/xml/Manifest.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.xml;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+
+import com.sun.star.script.framework.container.XMLParserFactory;
+
+public class Manifest {
+
+ private Document document = null;
+ private boolean baseElementsExist = false;
+
+ public Manifest(InputStream inputStream) throws IOException {
+ document = XMLParserFactory.getParser().parse(inputStream);
+ }
+
+ public void add(String entry) {
+ add(entry, "");
+ }
+
+ private void add(String entry, String type) {
+ Element root, el;
+
+ ensureBaseElementsExist();
+
+ try {
+ root = (Element)
+ document.getElementsByTagName("manifest:manifest").item(0);
+
+ el = document.createElement("manifest:file-entry");
+ el.setAttribute("manifest:media-type", type);
+ el.setAttribute("manifest:full-path", entry);
+ // System.out.println("added: " + el.toString());
+ root.appendChild(el);
+ }
+ catch (Exception e) {
+ System.err.println("Error adding entry: " + e.getMessage());
+ }
+ }
+
+ private void ensureBaseElementsExist() {
+ if (baseElementsExist == false) {
+ baseElementsExist = true;
+ add("Scripts/", "application/script-parcel");
+ }
+ }
+
+ public void remove(String entry) {
+ Element root, el;
+ int len;
+
+ try {
+ root = (Element)
+ document.getElementsByTagName("manifest:manifest").item(0);
+
+ NodeList nl = root.getElementsByTagName("manifest:file-entry");
+ if (nl == null || (len = nl.getLength()) == 0)
+ return;
+
+ ArrayList list = new ArrayList();
+ for (int i = 0; i < len; i++) {
+ el = (Element)nl.item(i);
+ if (el.getAttribute("manifest:full-path").startsWith(entry)) {
+ // System.out.println("found: " + el.toString());
+ list.add(el);
+ }
+ }
+
+ Iterator iter = list.iterator();
+ while (iter.hasNext())
+ root.removeChild((Element)iter.next());
+
+ // System.out.println("and after root is: " + root.toString());
+ }
+ catch (Exception e) {
+ System.err.println("Error removing entry: " + e.getMessage());
+ }
+ }
+
+ public InputStream getInputStream() throws IOException {
+ InputStream result = null;
+ ByteArrayOutputStream out = null;
+
+ try {
+ out = new ByteArrayOutputStream();
+ write(out);
+ result = new ByteArrayInputStream(out.toByteArray());
+ // result = replaceNewlines(out.toByteArray());
+ }
+ finally {
+ if (out != null)
+ out.close();
+ }
+
+ return result;
+ }
+
+ private InputStream replaceNewlines(byte[] bytes) throws IOException {
+ InputStream result;
+ ByteArrayOutputStream out;
+ BufferedReader reader;
+
+ reader = new BufferedReader(new InputStreamReader(
+ new ByteArrayInputStream(bytes)));
+ out = new ByteArrayOutputStream();
+
+ int previous = reader.read();
+ out.write(previous);
+ int current;
+
+ while ((current = reader.read()) != -1) {
+ if (((char)current == '\n' || (char)current == ' ') &&
+ (char)previous == '\n')
+ continue;
+ else {
+ out.write(current);
+ previous = current;
+ }
+ }
+ result = new ByteArrayInputStream(out.toByteArray());
+
+ return result;
+ }
+
+ public void write(OutputStream out) throws IOException {
+ XMLParserFactory.getParser().write(document, out);
+ }
+}
diff --git a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java
new file mode 100644
index 000000000000..f0bfb52ecfe6
--- /dev/null
+++ b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java
@@ -0,0 +1,600 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.idesupport.zip;
+
+import java.io.*;
+import java.util.Enumeration;
+import java.util.zip.*;
+import java.beans.PropertyVetoException;
+
+import org.openoffice.idesupport.filter.FileFilter;
+import org.openoffice.idesupport.filter.BinaryOnlyFilter;
+import org.openoffice.idesupport.filter.ExceptParcelFilter;
+
+import com.sun.star.script.framework.container.ParcelDescriptor;
+import org.openoffice.idesupport.xml.Manifest;
+
+public class ParcelZipper
+{
+ public static final String PARCEL_PREFIX_DIR = "Scripts/";
+ public static final String PARCEL_EXTENSION = "sxp";
+ public static final String CONTENTS_DIRNAME = "Contents";
+ public static final String PARCEL_DESCRIPTOR_XML = "parcel-descriptor.xml";
+
+ private static ParcelZipper zipper = null;
+
+ private static final FileFilter DEFAULT_FILTER =
+ BinaryOnlyFilter.getInstance();
+
+ private ParcelZipper() {
+ }
+
+ public static ParcelZipper getParcelZipper() {
+ if (zipper == null) {
+ synchronized(ParcelZipper.class) {
+ if (zipper == null)
+ zipper = new ParcelZipper();
+ }
+ }
+ return zipper;
+ }
+
+ public String zipParcel(File basedir) throws IOException {
+ File targetfile, targetdir;
+
+ if (basedir.getName().equals(CONTENTS_DIRNAME))
+ targetdir = basedir.getParentFile();
+ else
+ targetdir = basedir;
+
+ targetfile = new File(targetdir, targetdir.getName() + "." + PARCEL_EXTENSION);
+
+ return zipParcel(basedir, targetfile, DEFAULT_FILTER);
+ }
+
+ public String zipParcel(File basedir, File targetfile) throws IOException {
+ return zipParcel(basedir, targetfile, DEFAULT_FILTER);
+ }
+
+ public String zipParcel(File basedir, FileFilter filter) throws IOException {
+ File targetfile, targetdir;
+
+ if (basedir.getName().equals(CONTENTS_DIRNAME))
+ targetdir = basedir.getParentFile();
+ else
+ targetdir = basedir;
+
+ targetfile = new File(targetdir, targetdir.getName() + "." + PARCEL_EXTENSION);
+
+ return zipParcel(basedir, targetfile, filter);
+ }
+
+ public String zipParcel(File basedir, File targetfile, FileFilter filter)
+ throws IOException {
+ String realpath, tmppath;
+
+ realpath = targetfile.getPath();
+ tmppath = realpath + ".tmp";
+
+ File tmpfile = new File(tmppath);
+ ZipOutputStream out = null;
+ try {
+ if (tmpfile.exists() == true)
+ tmpfile.delete();
+
+ out = new ZipOutputStream(new FileOutputStream(tmpfile));
+
+ File[] children = basedir.listFiles();
+ for (int i = 0; i < children.length; i++)
+ addFileToParcel(children[i], "", out, filter);
+ }
+ catch (IOException ioe) {
+ out.close();
+ tmpfile.delete();
+ throw ioe;
+ }
+ finally {
+ if (out != null)
+ out.close();
+ }
+
+ if (targetfile.exists() == true)
+ targetfile.delete();
+ tmpfile.renameTo(targetfile);
+
+ return targetfile.getAbsolutePath();
+ }
+
+ private void addFileToParcel(File root, String path, ZipOutputStream out, FileFilter filter)
+ throws IOException {
+ ZipEntry ze;
+
+ if (root.isDirectory() == true) {
+ ze = new ZipEntry(/* PARCEL_PREFIX_DIR + */ path + root.getName() + "/");
+ out.putNextEntry(ze);
+ out.closeEntry();
+ File[] children = root.listFiles();
+
+ for (int i = 0; i < children.length; i++)
+ addFileToParcel(children[i], path + root.getName() + "/", out, filter);
+ }
+ else {
+ if (filter.validate(root.getName()) == false &&
+ root.getName().equals("parcel-descriptor.xml") == false)
+ return;
+
+ ze = new ZipEntry(/* PARCEL_PREFIX_DIR + */ path + root.getName());
+ out.putNextEntry(ze);
+
+ byte[] bytes = new byte[1024];
+ int len;
+
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(root);
+
+ while ((len = fis.read(bytes)) != -1)
+ out.write(bytes, 0, len);
+ }
+ finally {
+ if (fis != null) fis.close();
+ }
+ out.closeEntry();
+ }
+ }
+
+ public boolean isOverwriteNeeded(File parcel, File target)
+ throws IOException
+ {
+ boolean result;
+
+ if (target.isDirectory())
+ result = isDirectoryOverwriteNeeded(parcel, target);
+ else
+ result = isDocumentOverwriteNeeded(parcel, target);
+
+ return result;
+ }
+
+ private boolean isDirectoryOverwriteNeeded(File parcel, File target) {
+ String parcelDir = getParcelDirFromParcelZip(parcel.getName());
+
+ File langdir;
+ try {
+ langdir = new File(target, getParcelLanguage(parcel));
+ }
+ catch (IOException ioe) {
+ return false;
+ }
+
+ if (langdir.exists() == false)
+ return false;
+
+ File[] children = langdir.listFiles();
+
+ for (int i = 0; i < children.length; i++)
+ if (children[i].getName().equals(parcelDir))
+ return true;
+
+ return false;
+ }
+
+ private boolean isDocumentOverwriteNeeded(File parcel, File document)
+ throws IOException
+ {
+ ZipFile documentZip = null;
+ boolean result = false;
+
+ try {
+ documentZip = new ZipFile(document);
+
+ String name =
+ PARCEL_PREFIX_DIR + getParcelLanguage(parcel) +
+ "/" + getParcelDirFromParcelZip(parcel.getName()) +
+ "/" + PARCEL_DESCRIPTOR_XML;
+
+ if (documentZip.getEntry(name) != null)
+ result = true;
+ }
+ catch (IOException ioe) {
+ return false;
+ }
+ finally {
+ if (documentZip != null) documentZip.close();
+ }
+
+ return result;
+ }
+
+ public String deployParcel(File parcel, File target)
+ throws IOException {
+
+ String output = null;
+ if (target.isDirectory())
+ output = unzipToDirectory(parcel, target);
+ else
+ output = unzipToZip(parcel, target);
+ return output;
+ }
+
+ private String getParcelDirFromParcelZip(String zipname) {
+ String result = zipname.substring(0, zipname.lastIndexOf("."));
+ return result;
+ }
+
+ private String unzipToDirectory(File parcel, File targetDirectory)
+ throws IOException {
+
+ ZipInputStream in = null;
+ File parcelDir = new File(targetDirectory,
+ getParcelLanguage(parcel) + File.separator +
+ getParcelDirFromParcelZip(parcel.getName()));
+
+ if (isDirectoryOverwriteNeeded(parcel, targetDirectory)) {
+ if (deleteDir(parcelDir) == false) {
+ throw new IOException("Could not overwrite: " +
+ parcelDir.getAbsolutePath());
+ }
+ }
+
+ try {
+ in = new ZipInputStream(new FileInputStream(parcel));
+
+ File outFile;
+ ZipEntry inEntry = in.getNextEntry();
+ byte[] bytes = new byte[1024];
+ int len;
+
+ while (inEntry != null) {
+ outFile = new File(parcelDir, inEntry.getName());
+ if (inEntry.isDirectory()) {
+ outFile.mkdir();
+ }
+ else {
+ if (outFile.getParentFile().exists() != true)
+ outFile.getParentFile().mkdirs();
+
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(outFile);
+
+ while ((len = in.read(bytes)) != -1)
+ out.write(bytes, 0, len);
+ }
+ finally {
+ if (out != null) out.close();
+ }
+ }
+ inEntry = in.getNextEntry();
+ }
+ }
+ finally {
+ if (in != null) in.close();
+ }
+
+ return parcelDir.getAbsolutePath();
+ }
+
+ private boolean deleteDir(File basedir) {
+ if (basedir.isDirectory()) {
+ String[] children = basedir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(basedir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return basedir.delete();
+ }
+
+ private String unzipToZip(File parcel, File targetDocument)
+ throws IOException {
+
+ ZipInputStream documentStream = null;
+ ZipInputStream parcelStream = null;
+ ZipOutputStream outStream = null;
+ Manifest manifest;
+
+ String language = getParcelLanguage(parcel);
+
+ if (isDocumentOverwriteNeeded(parcel, targetDocument)) {
+ String parcelName = language + "/" +
+ getParcelDirFromParcelZip(parcel.getName());
+ removeParcel(targetDocument, parcelName);
+ }
+
+ // first write contents of document to tmpfile
+ File tmpfile = new File(targetDocument.getAbsolutePath() + ".tmp");
+
+ manifest = addParcelToManifest(targetDocument, parcel);
+
+ try {
+ documentStream =
+ new ZipInputStream(new FileInputStream(targetDocument));
+ parcelStream = new ZipInputStream(new FileInputStream(parcel));
+ outStream = new ZipOutputStream(new FileOutputStream(tmpfile));
+
+ copyParcelToZip(parcelStream, outStream, PARCEL_PREFIX_DIR +
+ language + "/" + getParcelDirFromParcelZip(parcel.getName()));
+ copyDocumentToZip(documentStream, outStream, manifest);
+ }
+ catch (IOException ioe) {
+ tmpfile.delete();
+ throw ioe;
+ }
+ finally {
+ if (documentStream != null) documentStream.close();
+ if (parcelStream != null) parcelStream.close();
+ if (outStream != null) outStream.close();
+ }
+
+ if (targetDocument.delete() == false) {
+ tmpfile.delete();
+ throw new IOException("Could not overwrite " + targetDocument);
+ }
+ else
+ tmpfile.renameTo(targetDocument);
+
+ return targetDocument.getAbsolutePath();
+ }
+
+ private void copyParcelToZip(ZipInputStream in, ZipOutputStream out,
+ String parcelName) throws IOException {
+
+ ZipEntry outEntry;
+ ZipEntry inEntry = in.getNextEntry();
+ byte[] bytes = new byte[1024];
+ int len;
+
+ while (inEntry != null) {
+ if(parcelName!=null)
+ outEntry = new ZipEntry(parcelName + "/" + inEntry.getName());
+ else
+ outEntry = new ZipEntry(inEntry);
+ out.putNextEntry(outEntry);
+
+ if (inEntry.isDirectory() == false)
+ while ((len = in.read(bytes)) != -1)
+ out.write(bytes, 0, len);
+
+ out.closeEntry();
+ inEntry = in.getNextEntry();
+ }
+ }
+
+ private void copyDocumentToZip(ZipInputStream in, ZipOutputStream out,
+ Manifest manifest) throws IOException {
+
+ ZipEntry outEntry;
+ ZipEntry inEntry;
+ byte[] bytes = new byte[1024];
+ int len;
+
+ while ((inEntry = in.getNextEntry()) != null) {
+
+ outEntry = new ZipEntry(inEntry);
+ out.putNextEntry(outEntry);
+
+ if(inEntry.getName().equals("META-INF/manifest.xml") &&
+ manifest != null) {
+ InputStream manifestStream = null;
+ try {
+ manifestStream = manifest.getInputStream();
+ while ((len = manifestStream.read(bytes)) != -1)
+ out.write(bytes, 0, len);
+ }
+ finally {
+ if (manifestStream != null)
+ manifestStream.close();
+ }
+ }
+ else if (inEntry.isDirectory() == false) {
+ while ((len = in.read(bytes)) != -1)
+ out.write(bytes, 0, len);
+ }
+
+ out.closeEntry();
+ }
+ }
+
+ public String removeParcel(File document, String parcelName)
+ throws IOException {
+
+ ZipInputStream documentStream = null;
+ ZipOutputStream outStream = null;
+ Manifest manifest = null;
+
+ if (!parcelName.startsWith(PARCEL_PREFIX_DIR))
+ parcelName = PARCEL_PREFIX_DIR + parcelName;
+ manifest = removeParcelFromManifest(document, parcelName);
+
+ // first write contents of document to tmpfile
+ File tmpfile = new File(document.getAbsolutePath() + ".tmp");
+
+ try {
+ ZipEntry outEntry;
+ ZipEntry inEntry;
+ byte[] bytes = new byte[1024];
+ int len;
+
+ documentStream = new ZipInputStream(new FileInputStream(document));
+ outStream = new ZipOutputStream(new FileOutputStream(tmpfile));
+
+ while ((inEntry = documentStream.getNextEntry()) != null) {
+
+ if(inEntry.getName().startsWith(parcelName))
+ continue;
+
+ outEntry = new ZipEntry(inEntry);
+ outStream.putNextEntry(outEntry);
+
+ if(inEntry.getName().equals("META-INF/manifest.xml") &&
+ manifest != null) {
+ InputStream manifestStream = null;
+ try {
+ manifestStream = manifest.getInputStream();
+ while ((len = manifestStream.read(bytes)) != -1)
+ outStream.write(bytes, 0, len);
+ }
+ finally {
+ if (manifestStream != null)
+ manifestStream.close();
+ }
+ }
+ else if (inEntry.isDirectory() == false) {
+ while ((len = documentStream.read(bytes)) != -1)
+ outStream.write(bytes, 0, len);
+ }
+
+ outStream.closeEntry();
+ }
+ }
+ catch (IOException ioe) {
+ tmpfile.delete();
+ throw ioe;
+ }
+ finally {
+ if (documentStream != null)
+ documentStream.close();
+
+ if (outStream != null)
+ outStream.close();
+ }
+
+ if (document.delete() == false) {
+ tmpfile.delete();
+ throw new IOException("Could not overwrite " + document);
+ }
+ else
+ tmpfile.renameTo(document);
+
+ return document.getAbsolutePath();
+ }
+
+ private Manifest getManifestFromDocument(File document) {
+ ZipFile documentZip = null;
+ Manifest result = null;
+
+ try {
+ documentZip = new ZipFile(document);
+ ZipEntry original = documentZip.getEntry("META-INF/manifest.xml");
+ if (original != null) {
+ result = new Manifest(documentZip.getInputStream(original));
+ }
+ }
+ catch (IOException ioe) {
+ result = null;
+ }
+ finally {
+ try {
+ if (documentZip != null)
+ documentZip.close();
+ }
+ catch (IOException ioe) {}
+ }
+
+ return result;
+ }
+
+ private Manifest addParcelToManifest(File document, File parcel)
+ throws IOException {
+
+ ZipFile parcelZip = null;
+ Manifest result = null;
+
+ result = getManifestFromDocument(document);
+ if (result == null)
+ return null;
+
+ String language = getParcelLanguage(parcel);
+
+ try {
+ parcelZip = new ZipFile(parcel);
+
+ String prefix = PARCEL_PREFIX_DIR + language + "/" +
+ getParcelDirFromParcelZip(parcel.getName()) + "/";
+
+ Enumeration entries = parcelZip.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ result.add(prefix + entry.getName());
+ }
+ }
+ catch (IOException ioe) {
+ return null;
+ }
+ finally {
+ try {
+ if (parcelZip != null)
+ parcelZip.close();
+ }
+ catch (IOException ioe) {}
+ }
+
+ return result;
+ }
+
+ private Manifest removeParcelFromManifest(File document, String name) {
+ Manifest result = null;
+
+ result = getManifestFromDocument(document);
+ if (result == null)
+ return null;
+
+ result.remove(name);
+ return result;
+ }
+
+ public String getParcelLanguage(File file) throws IOException {
+ ZipFile zf = null;
+ ZipEntry ze = null;
+ InputStream is = null;
+ ParcelDescriptor pd;
+
+ try {
+ zf = new ZipFile(file);
+ ze = zf.getEntry(PARCEL_DESCRIPTOR_XML);
+
+ if (ze == null)
+ throw new IOException("Could not find Parcel Descriptor in parcel");
+
+ is = zf.getInputStream(ze);
+ pd = new ParcelDescriptor(is);
+ }
+ finally {
+ if (zf != null)
+ zf.close();
+
+ if (is != null)
+ is.close();
+ }
+
+ return pd.getLanguage().toLowerCase();
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/editor/JavaKit.java b/scripting/java/org/openoffice/netbeans/editor/JavaKit.java
new file mode 100644
index 000000000000..ec09935de661
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/editor/JavaKit.java
@@ -0,0 +1,248 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package org.openoffice.netbeans.editor;
+
+import java.io.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.ActionEvent;
+import java.net.URL;
+import java.text.MessageFormat;
+
+import java.util.Map;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import javax.swing.KeyStroke;
+import javax.swing.JEditorPane;
+import javax.swing.JMenuItem;
+import javax.swing.Action;
+import javax.swing.text.Document;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.TextAction;
+import javax.swing.text.BadLocationException;
+import org.netbeans.editor.*;
+import org.netbeans.editor.ext.*;
+import org.netbeans.editor.ext.java.*;
+
+/**
+* Java editor kit with appropriate document
+*
+* @author Miloslav Metelka
+* @version 1.00
+*/
+
+/* This class is based on the JavaKit class in the demosrc directory of
+ * the editor module of the NetBeans project: http://www.netbeans.org
+ *
+ * The class sets up an EditorKit for syntax highlighting and code completion
+ * of Java syntax
+ */
+
+public class JavaKit extends ExtKit {
+
+ public static final String JAVA_MIME_TYPE = "text/x-java"; // NOI18N
+
+ static final long serialVersionUID =-5445829962533684922L;
+
+ static {
+ Settings.addInitializer( new JavaSettingsInitializer( JavaKit.class ) );
+ Settings.reset();
+
+ URL skeleton = null, body = null;
+ skeleton = JavaKit.class.getResource("OOo.jcs");
+ body = JavaKit.class.getResource("OOo.jcb");
+
+ if (skeleton != null && body != null) {
+ DAFileProvider provider = new DAFileProvider(
+ new URLAccessor(skeleton),
+ new URLAccessor(body));
+
+ JCBaseFinder finder = new JCBaseFinder();
+ finder.append( provider );
+ JavaCompletion.setFinder( finder );
+ }
+ }
+
+ public String getContentType() {
+ return JAVA_MIME_TYPE;
+ }
+
+ /** Create new instance of syntax coloring scanner
+ * @param doc document to operate on. It can be null in the cases the syntax
+ * creation is not related to the particular document
+ */
+ public Syntax createSyntax(Document doc) {
+ return new JavaSyntax();
+ }
+
+ /** Create syntax support */
+ public SyntaxSupport createSyntaxSupport(BaseDocument doc) {
+ return new JavaSyntaxSupport(doc);
+ }
+
+ public Completion createCompletion(ExtEditorUI extEditorUI) {
+ return new JavaCompletion(extEditorUI);
+ }
+
+ /** Create the formatter appropriate for this kit */
+ public Formatter createFormatter() {
+ return new JavaFormatter(this.getClass());
+ }
+
+ protected EditorUI createEditorUI() {
+ return new ExtEditorUI();
+ }
+
+ protected void initDocument(BaseDocument doc) {
+ doc.addLayer(new JavaDrawLayerFactory.JavaLayer(),
+ JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
+ doc.addDocumentListener(new JavaDrawLayerFactory.LParenWatcher());
+ }
+
+ /**
+ * DataAccessor for parser DB files via URL streams
+ *
+ * @author Petr Nejedly
+ */
+ public static class URLAccessor implements DataAccessor {
+
+ URL url;
+ InputStream stream;
+ int streamOff;
+ int actOff;
+
+ public URLAccessor(URL url) {
+ this.url = url;
+ }
+
+ /** Not implemented
+ */
+ public void append(byte[] buffer, int off, int len)
+ throws IOException
+ {
+ throw new IllegalArgumentException("read only!");
+ }
+
+ /**
+ * Reads exactly <code>len</code> bytes from this file resource
+ * into the byte array, starting at the current file pointer.
+ * This method reads repeatedly from the file until the requested
+ * number of bytes are read. This method blocks until the requested
+ * number of bytes are read, the end of the inputStream is detected,
+ * or an exception is thrown.
+ *
+ * @param buffer the buffer into which the data is read.
+ * @param off the start offset of the data.
+ * @param len the number of bytes to read.
+ */
+ public void read(byte[] buffer, int off, int len) throws IOException {
+ InputStream str = getStream(actOff);
+ while (len > 0) {
+ int count = str.read(buffer, off, len);
+ streamOff += count;
+ off += count;
+ len -= count;
+ }
+ }
+
+ /** Opens DataAccessor file resource
+ * @param requestWrite if true, file is opened for read/write
+ */
+ public void open(boolean requestWrite) throws IOException {
+ if(requestWrite)
+ throw new IllegalArgumentException("read only!");
+ }
+
+ /** Closes DataAccessor file resource */
+ public void close() throws IOException {
+ if (stream != null) {
+ stream.close();
+ stream = null;
+ }
+ }
+
+ /**
+ * Returns the current offset in this file.
+ *
+ * @return the offset from the beginning of the file, in bytes,
+ * at which the next read or write occurs.
+ */
+ public long getFilePointer() throws IOException {
+ return actOff;
+ }
+
+ /** Clears the file and sets the offset to 0 */
+ public void resetFile() throws IOException {
+ throw new IllegalArgumentException("read only!");
+ }
+
+ /**
+ * Sets the file-pointer offset, measured from the beginning of this
+ * file, at which the next read or write occurs.
+ */
+ public void seek(long pos) throws IOException {
+ actOff = (int)pos;
+ }
+
+ /** Gets InputStream prepared for reading from <code>off</code>
+ * offset position
+ */
+ private InputStream getStream(int off) throws IOException {
+ if (streamOff > off && stream != null) {
+ stream.close();
+ stream = null;
+ }
+
+ if(stream == null) {
+ stream = url.openStream();
+ streamOff = 0;
+ }
+
+ while (streamOff < off) {
+ long len = stream.skip(off - streamOff);
+ streamOff += (int)len;
+ if (len == 0) throw new IOException("EOF");
+ }
+
+ return stream;
+ }
+
+ public int getFileLength() {
+ try {
+ int l = url.openConnection().getContentLength();
+ return l;
+ } catch (IOException e) {
+ return 0;
+ }
+ }
+
+ public String toString() {
+ return url.toString();
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java b/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java
new file mode 100644
index 000000000000..cb49b888ebb4
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java
@@ -0,0 +1,209 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package org.openoffice.netbeans.editor;
+
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.DocumentEvent;
+
+import java.io.*;
+import java.util.ResourceBundle;
+
+import javax.swing.text.Caret;
+import org.netbeans.editor.*;
+import org.netbeans.editor.ext.*;
+
+import com.sun.star.script.framework.provider.beanshell.ScriptSourceView;
+import com.sun.star.script.framework.provider.beanshell.ScriptSourceModel;
+
+public class NetBeansSourceView extends JPanel
+ implements ScriptSourceView, DocumentListener {
+
+ private ScriptSourceModel model;
+ private JEditorPane pane;
+ private boolean isModified = false;
+
+ static {
+ // Feed our kits with their default Settings
+ Settings.addInitializer(
+ new BaseSettingsInitializer(), Settings.CORE_LEVEL);
+ Settings.addInitializer(
+ new ExtSettingsInitializer(), Settings.CORE_LEVEL);
+ Settings.reset();
+
+ try {
+ Class kitClass = Class.forName(
+ NetBeansSourceView.class.getPackage().getName() + ".JavaKit");
+
+ JEditorPane.registerEditorKitForContentType(
+ "text/x-java", kitClass.getName(), kitClass.getClassLoader());
+ }
+ catch( ClassNotFoundException exc ) {
+ }
+ }
+
+ private class MyLocalizer implements LocaleSupport.Localizer {
+ private ResourceBundle bundle;
+
+ public MyLocalizer( String bundleName ) {
+ bundle = ResourceBundle.getBundle( bundleName );
+ }
+
+ // Localizer
+ public String getString( String key ) {
+ return bundle.getString( key );
+ }
+ }
+
+ public NetBeansSourceView(ScriptSourceModel model) {
+ this.model = model;
+
+ LocaleSupport.addLocalizer(
+ new MyLocalizer("org.netbeans.editor.Bundle"));
+
+ pane = new JEditorPane("text/x-java", "");
+ pane.setText(model.getText());
+
+ JScrollPane spane = new JScrollPane();
+ spane.setViewportView(pane);
+ setLayout(new java.awt.GridLayout(1, 1));
+ add(spane);
+
+ pane.getDocument().addDocumentListener(this);
+ }
+
+ public static void main(String[] args) {
+ if (args.length < 1) {
+ System.err.println("No file specified");
+ System.exit(-1);
+ }
+
+ File f = new File(args[0]);
+
+ if (!f.exists() || !f.isFile()) {
+ System.err.println("Invalid file");
+ System.exit(-1);
+ }
+
+ java.net.URL url = null;
+ try {
+ url = f.toURL();
+ }
+ catch (java.net.MalformedURLException mue) {
+ System.err.println("Invalid file");
+ System.exit(-1);
+ }
+
+ NetBeansSourceView view =
+ new NetBeansSourceView(new ScriptSourceModel(url));
+
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(view);
+ frame.setSize(640, 480);
+ frame.show();
+ }
+
+ // Code grabbed from NetBeans editor module
+ public void scrollToLine(int line)
+ {
+ BaseDocument doc = Utilities.getDocument(pane);
+
+ int pos = -1;
+ if (doc != null) {
+ // Obtain the offset where to jump
+ pos = Utilities.getRowStartFromLineOffset(doc, line);
+ }
+
+ if (pos != -1) {
+ Caret caret = pane.getCaret();
+ if (caret instanceof BaseCaret) { // support extended scroll mode
+ BaseCaret bCaret = (BaseCaret)caret;
+ bCaret.setDot(pos, bCaret, EditorUI.SCROLL_FIND);
+ }
+ else {
+ caret.setDot(pos);
+ }
+ }
+ }
+
+ public void clear() {
+ pane.setText("");
+ }
+
+ public void update() {
+ /* Remove ourselves as a DocumentListener while loading the source
+ so we don't get a storm of DocumentEvents during loading */
+ pane.getDocument().removeDocumentListener(this);
+
+ if (isModified == false)
+ {
+ pane.setText(model.getText());
+ }
+
+ // scroll to current position of the model
+ try {
+ scrollToLine(model.getCurrentPosition());
+ }
+ catch (Exception e) {
+ // couldn't scroll to line, do nothing
+ }
+
+ // Add back the listener
+ pane.getDocument().addDocumentListener(this);
+ }
+
+ public boolean isModified() {
+ return isModified;
+ }
+
+ public void setModified(boolean value) {
+ isModified = value;
+ }
+
+ public String getText() {
+ return pane.getText();
+ }
+
+ /* 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) {
+ isModified = true;
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/editor/OOo.jcb b/scripting/java/org/openoffice/netbeans/editor/OOo.jcb
new file mode 100644
index 000000000000..7286934fae65
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/editor/OOo.jcb
@@ -0,0 +1,5 @@
+LABELED_BYshortSPLIT_PANEshortHYPER_LINKshortPOPUP_MENUshortGLASS_PANEshortTABLE_CELLshortTEXT_FRAMEshortSTATUS_BARshortROW_HEADERshortSCROLL_BARshortSELECTABLEshortEXPANDABLEshortMULTI_LINEshortHORIZONTALshortLastColumnintSegmentEndintdeleteTextbooleaninsertTextbooleanADJUST_ABScom.sun.star.awt.AdjustmentTypegetDefaultcom.sun.star.awt.AdjustmentTypeRightInsetintFocusFlagsshortDECORATIVEshortNONE_valueintgetDefaultcom.sun.star.awt.FontSlantBOLDDOTTEDshortDOUBLEWAVEshortDASHDOTDOTshortNORMALfloatULTRALIGHTfloat ULTRAEXPANDEDfloatStartColorintRECT_valueintELLIPTICALcom.sun.star.awt.GradientStylegetDefaultcom.sun.star.awt.GradientStyleNOCHILDRENshortPROPERTIESshortPROPERTIESshortRADIOCHECKshortClickCountintUpdateRectcom.sun.star.awt.RectangleEXECUTE_UPshortHELP_valueintgetDefaultcom.sun.star.awt.PushButtonTypeZEROBITS com.sun.star.awt.RasterOperationgetDefault com.sun.star.awt.RasterOperationHORIZONTALintNOTALLOWEDintDEF_CANCELintgetDefaultcom.sun.star.awt.WindowClassRightInsetintgetMaskDIBbytecreatePeervoidgetContextjava.lang.Object setContextvoidgetControlcom.sun.star.awt.XControladdControlvoidendExecutevoidsetFiltersvoidselectFontvoidkeyPressedbooleankeyPressedvoidselectItemvoidinsertItemvoidgetItemPosshortremoveItemvoidenableItemvoiddeactivatevoidmouseMovedvoidselectFormvoidupdateTextvoidremoveTextvoidgetMaximumintsetMaximumvoidisEditablebooleaninsertTextvoidsetMenuBarvoidgetWindowscom.sun.star.awt.XWindowgetPosSizecom.sun.star.awt.RectanglesetPosSizevoidsetVisiblevoidinvalidatevoidsetPointervoidgetToolkitcom.sun.star.awt.XToolkitAttributesshortREADONLYshortREMOVEABLEshortATTRIBUTESintgetDefault com.sun.star.beans.PropertyStategetStringsjava.lang.String setStringsvoidgetMethods"com.sun.star.reflection.XIdlMethod.lib.uno.typeinfo.TypeInfoAUTO_valueintgetDefault,com.sun.star.chart.ChartAxisArrangeOrderTypeDATA_RANGE&com.sun.star.chart.ChartDataChangeTypegetDefault&com.sun.star.chart.ChartDataChangeTypeROWS_valueintgetDefault%com.sun.star.chart.ChartDataRowSourceNONE_valueintgetDefault%com.sun.star.chart.ChartErrorCategoryNONE_valueintgetDefault*com.sun.star.chart.ChartErrorIndicatorType
+NONE_valueintLEFT_valueintgetDefault&com.sun.star.chart.ChartLegendPositionNONE_valueintPOLYNOMIAL+com.sun.star.chart.ChartRegressionCurveTypegetDefault+com.sun.star.chart.ChartRegressionCurveTypegetDiagramcom.sun.star.chart.XDiagramsetDiagramvoidattachDatavoidgetDownBarcom.sun.star.beans.XPropertySet__waitTimeint_otherSide-com.sun.star.comp.connections.PipedConnectionm_lateInitjava.lang.Object initializevoidm_manifestjava.lang.String initializevoidEXTENSIBLEshortlistLayers)com.sun.star.configuration.backend.XLayer"startLayervoidreadSchemavoidstartGroupvoidremoveNodevoidmodifyNodevoidtar.container.XElementAccess UNOTYPEINFO&com.sun.star.lib.uno.typeinfo.TypeInfogetByIndexjava.lang.Object request_idintrequest_idintrequest_idintrequest_idintobject_keybytegetDefault,com.sun.star.corba.giop.LocateStatusType_1_2byte_orderbooleangetDefault#com.sun.star.corba.giop.MsgType_1_1request_idintgetDefault+com.sun.star.corba.giop.ReplyStatusType_1_2service_context%com.sun.star.corba.iop.ServiceContextobject_keybyterequest_idintreserved_2byterequest_idintreserved_3byteobject_keybytereserved_1byteservice_context%com.sun.star.corba.iop.ServiceContextreserved_2bytereserved_1byterequest_idintreserved_3byteobject_keybyteobject_keybytecomponents&com.sun.star.corba.iop.TaggedComponentobject_keybytecontext_idinttk_booleancom.sun.star.corba.TCKindtk_wstringcom.sun.star.corba.TCKindgetDefaultcom.sun.star.corba.TCKindPersistantbyteDragSource)com.sun.star.datatransfer.dnd.XDragSourceDragActionbyteUserActionbyteDropActionbyteDropActionbyteDragSource)com.sun.star.datatransfer.dnd.XDragSourceDropActionbyteDropActionbyteautoscrollvoidacceptDragvoidrejectDragvoidrejectDropvoidacceptDropvoidUSE_CONFIGshortLEFT_valueintgetDefaultcom.sun.star.drawing.AlignmentMORE_FRONT com.sun.star.drawing.ArrangementBACK_valueintgetDefault com.sun.star.drawing.ArrangementgetDefaultcom.sun.star.drawing.BitmapModehorizontalshortFULL_valueintgetDefaultcom.sun.star.drawing.CircleKindMONO_valueintgetDefaultcom.sun.star.drawing.ColorModeLEFT_valueintAUTO_valueintgetDefault#com.sun.star.drawing.ConnectionTypeLINE_valueintgetDefault"com.sun.star.drawing.ConnectorTypeRECT_valueintgetDefaultcom.sun.star.drawing.DashStyleDirectionYdoubleDirectionZdoubleDirectionXdoubleDRAW_valueintgetDefault!com.sun.star.drawing.DrawViewModeDOWN_valueintLEFT_valueintHORIZONTAL$com.sun.star.drawing.EscapeDirectiongetDefault$com.sun.star.drawing.EscapeDirectionHATCHcom.sun.star.drawing.FillStyleNONE_valueintgetDefaultcom.sun.star.drawing.FillStyleIsRelativebooleangetDefaultcom.sun.star.drawing.HatchStyleLEFT_valueintAUTO_valueintgetDefault+com.sun.star.drawing.HorizontalDimensioninggetDefaultcom.sun.star.drawing.LayerType ARROW_valueintNONE_valueintgetDefault com.sun.star.drawing.LineEndType MITER_valueintNONE_valueintgetDefaultcom.sun.star.drawing.LineJointNONE_valueintDASH_valueintgetDefaultcom.sun.star.drawing.LineStylegetDefault com.sun.star.drawing.MeasureKindAUTO_valueintgetDefault'com.sun.star.drawing.MeasureTextHorzPosBREAKEDLINE_valueintWEST_valueintEAST_valueintAUTO_valueintgetDefault'com.sun.star.drawing.MeasureTextVertPosHORIZONTALcom.sun.star.drawing.MirrorAxisgetDefaultcom.sun.star.drawing.MirrorAxisFLAT_valueintgetDefault com.sun.star.drawing.NormalsKindgetDefault!com.sun.star.drawing.PolygonFlagsLINE_valueintPOLY_valueintPLIN_valueintgetDefault com.sun.star.drawing.PolygonKindgetDefault#com.sun.star.drawing.ProjectionModeMIDDLE_TOP#com.sun.star.drawing.RectanglePointgetDefault#com.sun.star.drawing.RectanglePointFLAT_valueintgetDefaultcom.sun.star.drawing.ShadeModeHORIZONTAL#com.sun.star.drawing.SnapObjectTypegetDefault#com.sun.star.drawing.SnapObjectTypeBLOCKcom.sun.star.drawing.TextAdjustLEFT_valueintgetDefaultcom.sun.star.drawing.TextAdjustDOWN_valueintLEFT_valueintgetDefault+com.sun.star.drawing.TextAnimationDirectionSCROLL&com.sun.star.drawing.TextAnimationKindNONE_valueintgetDefault&com.sun.star.drawing.TextAnimationKindNONE_valueintRESIZEATTR&com.sun.star.drawing.TextFitToSizeTypegetDefault&com.sun.star.drawing.TextFitToSizeTypeLEFT_valueintgetDefault)com.sun.star.drawing.TextHorizontalAdjustgetDefault'com.sun.star.drawing.TextVerticalAdjustgetDefault com.sun.star.drawing.TextureKindgetDefault!com.sun.star.drawing.TextureKind2getDefault com.sun.star.drawing.TextureModegetDefault*com.sun.star.drawing.TextureProjectionModeAUTO_valueintgetDefault)com.sun.star.drawing.VerticalDimensioningcanConnectbooleanconnectEndvoidgetControlcom.sun.star.awt.XControlModelsetControlvoidsendToBackvoidenterGroupvoidleaveGroupvoidnNextStateintgetClassIDbyteisReadonlybooleansaveObjectvoidgetPosRectcom.sun.star.awt.RectangledoHandsOffvoidisHandsOffbooleangetDefault#com.sun.star.form.DataSelectionTypeParameters#com.sun.star.container.XIndexAccessPUSH_valueintgetDefault com.sun.star.form.FormButtonTypeTEXT_valueintgetDefault$com.sun.star.form.FormSubmitEncodingPOST_valueintgetDefault"com.sun.star.form.FormSubmitMethodgetDefault com.sun.star.form.ListSourceTypeNONE_valueintgetDefault#com.sun.star.form.NavigationBarModePAGE_valueintgetDefault com.sun.star.form.TabulatorCyclesetColumnsvoidgetColumns&com.sun.star.container.XIndexContainerpositionedvoidnCharacterintsSymbolSetjava.lang.String FeatureURLcom.sun.star.util.URLbIsCommentbooleanFeatureURLcom.sun.star.util.URLgetDefaultcom.sun.star.frame.FrameActionHORIZONTALshortinitializevoidgetContentcom.sun.star.ucb.XContentsetCreatorvoidgetCreator"com.sun.star.frame.XFramesSupplierdeactivatevoidinitializevoidisReadonlybooleanstoreToURLvoidstoreAsURLvoidCTL_ARABICshortCTL_HEBREWshortSHORT_YEARintLONG_MONTHintDST_OFFSETshortAbbrevNamejava.lang.String BankSymboljava.lang.String getDefault#com.sun.star.i18n.DirectionPropertyformatCodejava.lang.String formatNamejava.lang.String formatTypejava.lang.String TITLE_CASEintANY_LETTERintASC_DOLLARintUNI_LETTERintUNI_NUMBERintANY_NUMBERintUNI_NUMBERintANY_NUMBERintASC_NUMBERintbreakIndexintNUMBER_ENDshortNUMBER_INTshortFRACTION_1shortTIME_STARTshortDATE_STARTshortFRACTION_2shortStartFlagsintCandidatesjava.lang.String getDefault(com.sun.star.i18n.TransliterationModulesgetDefault+com.sun.star.i18n.TransliterationModulesNewONE_TO_ONEshortkLao_valueintkMongoliancom.sun.star.i18n.UnicodeScriptkMalayalamcom.sun.star.i18n.UnicodeScriptgetDefaultcom.sun.star.i18n.UnicodeScriptUNASSIGNEDshortWORD_COUNTshortnextScriptintgetDefault"com.sun.star.i18n.NumberFormatCodeloadModulevoidABOVE_WORDshortBELOW_WORDshortFALSE_WORDshortgetDefault$com.sun.star.installation.ProtDlgResaExceptionjava.lang.Object exportDatavoidimportDatavoidreadDoubledoublewriteHypervoidwriteFloatvoidwriteShortvoidcloseInputvoidjumpToMarkvoiddeleteMarkvoidcreateMarkintreadObjectcom.sun.star.io.XPersistObjectwriteBytesvoidterminatedvoidreadStringjava.lang.String SYSTEM_OS2shortSYSTEM_MACshortinitializevoid_listenersjava.util.Vector _firstReadbooleansetWeakRefvoidsetWeakRefvoidshowStatusvoidshowStatusvoidgetContentjava.lang.Object setWeakRefvoidgetContentjava.lang.Object checkWritevoidcheckWritevoidgetContextjava.lang.Object addWatchervoid_iProtocol2com.sun.star.lib.uno.environments.remote.IProtocol(_negotiateboolean_listenersjava.util.Vector getContextjava.lang.Object isSynchronbooleanwriteReplyvoidreadObjectjava.lang.Object _jobQueuesjava.util.Hashtable _iReceiver2com.sun.star.lib.uno.environments.remote.IReceiver(isSynchronboolean_disposeIdjava.lang.Object _doDisposejava.lang.Object _ref_countint_throwablejava.lang.Throwable getContextjava.lang.Object bInDisposebooleantrimToSizevoidgetRootOidjava.lang.String writeReplyvoid_superType-com.sun.star.lib.uno.typedesc.TypeDescription_typeClasscom.sun.star.uno.TypeClassisReadOnlybooleanCONSTintisUnsignedbooleanFROM_RIGHT,com.sun.star.linguistic2.ConversionDirectiongetDefault,com.sun.star.linguistic2.ConversionDirectiongetDefault'com.sun.star.linguistic2.DictionaryTypegetEntries)com.sun.star.linguistic2.XDictionaryEntrygetEntries)com.sun.star.linguistic2.XDictionaryEntryisNegativebooleangetMeaningjava.lang.String getLocalescom.sun.star.lang.LocaleBEST_SPEEDshortPluginNamejava.lang.String getDefault"com.sun.star.plugin.PluginVariableNONE_valueintPATH_valueintHIDE_valueintgetDefault)com.sun.star.presentation.AnimationEffectSLOW_valueintFAST_valueintgetDefault(com.sun.star.presentation.AnimationSpeedVERB_valueintNONE_valueintgetDefault%com.sun.star.presentation.ClickActionNONE_valueintgetDefault$com.sun.star.presentation.FadeEffectgetDefault+com.sun.star.presentation.PresentationRangegetDefault'com.sun.star.reflection.FieldAccessModegetDefault"com.sun.star.reflection.MethodModegetDefault!com.sun.star.reflection.ParamModegetDefault2com.sun.star.reflection.TypeDescriptionSearchDepthgetMethods"com.sun.star.reflection.XIdlMethodgetClasses!com.sun.star.reflection.XIdlClassisReadOnlybooleangetMembers7com.sun.star.reflection.XInterfaceMemberTypeDescriptiongetMembers(com.sun.star.reflection.XTypeDescriptiongetService/com.sun.star.reflection.XServiceTypeDescriptionLINK_valueintgetDefault%com.sun.star.registry.RegistryKeyTypeSTRINGLIST'com.sun.star.registry.RegistryValueTypeLONG_valueintgetDefault'com.sun.star.registry.RegistryValueTypegetKeyNamejava.lang.String createLinkbooleanisReadOnlybooleangetKeyType%com.sun.star.registry.RegistryKeyTypedeleteLinkvoidgetRootKey"com.sun.star.registry.XRegistryKeyisReadOnlybooleansetDefaultvoidgetDefaultcom.sun.star.lang.LocaleloadBundle%com.sun.star.resource.XResourceBundleScanFailedcom.sun.star.scanner.ScanErrorgetDefaultcom.sun.star.scanner.ScanErrorMethodNamejava.lang.String SourceCodejava.lang.String UNKNOWNintgetDefault com.sun.star.script.FinishReasonSourceCodejava.lang.String Step_valueintBreakPoint#com.sun.star.script.InterruptReasongetDefault#com.sun.star.script.InterruptReasongetDefaultcom.sun.star.script.MemberTypeScriptCodejava.lang.String ScriptTypejava.lang.String ScriptCodejava.lang.String ScriptTypejava.lang.String doContinuevoidisVariablebooleanisFunctionbooleanConnectioncom.sun.star.sdbc.XConnectionParameters#com.sun.star.container.XIndexAccessgetBooleanbooleanupdateNullvoidupdateTimevoidupdateDatevoidupdateBytevoidupdateLongvoidgetQueries"com.sun.star.container.XNameAccessNOT_PSEUDOintNOT_PSEUDOintDuringReadbooleanIsRequiredbooleanclearBatchvoidfindColumnintgetTypeMap"com.sun.star.container.XNameAccessgetCatalogjava.lang.String setCatalogvoidisReadOnlybooleansetTypeMapvoidgetSchemascom.sun.star.sdbc.XResultSetgetColumnscom.sun.star.sdbc.XResultSetisReadOnlybooleanacceptsURLbooleansetBooleanvoidclearBatchvoidrefreshRowvoidrowUpdatedbooleanrowDeletedbooleanisWritablebooleanisCurrencybooleanisNullableintisReadOnlybooleangetBooleanbooleanrowChangedvoidupdateBytevoidupdateNullvoidupdateDatevoidupdateTimevoidupdateLongvoidreadDoubledoublereadObjectjava.lang.Object readStringjava.lang.String writeBytesvoidwriteArrayvoidwriteShortvoidwriteFloatvoidgetColumns"com.sun.star.container.XNameAccessdeleteRowsintdropByNamevoidgetIndexes"com.sun.star.container.XNameAccessgetContext+com.sun.star.security.XAccessControlContextFONT_valueintDELETEFILEcom.sun.star.setup.ActionTypeMAKEFOLDERcom.sun.star.setup.ActionTypegetDefaultcom.sun.star.setup.ActionTypebOverwritebooleanstrDirnamejava.lang.String strPatternjava.lang.String nDriveSizeintstrCountryjava.lang.String eErrorCode$com.sun.star.setup.ResponseErrorCodeFULLDELETEcom.sun.star.setup.InstallTypegetDefaultcom.sun.star.setup.InstallTypestrDirnamejava.lang.String isSelectedbooleanUNIX_SOLSGcom.sun.star.setup.OSTypeUNIX_LINUXcom.sun.star.setup.OSTypeUNIX_SOLIGcom.sun.star.setup.OSTypegetDefaultcom.sun.star.setup.OSTypestrSectionjava.lang.String getDefault$com.sun.star.setup.ResponseErrorCodestrPatternjava.lang.String bOverwritebooleangetDefaultcom.sun.star.setup.UpdateTypebDeleteAllbooleanLEFT_valueintgetDefaultcom.sun.star.sheet.Border COLUMNS_valueintNONE_valueintLEFT_valueintROWS_valueintgetDefault!com.sun.star.sheet.CellDeleteModeANNOTATIONint
+DOWN_valueintNONE_valueintROWS_valueintgetDefault!com.sun.star.sheet.CellInsertModeNONE_valueintLESS_valueintLESS_EQUAL$com.sun.star.sheet.ConditionOperatorgetDefault$com.sun.star.sheet.ConditionOperatorNONE_valueintgetDefault!com.sun.star.sheet.DataImportMode
+DATA_valueintPAGE_valueintgetDefault,com.sun.star.sheet.DataPilotFieldOrientationgetDefaultcom.sun.star.sheet.FillDateModegetDefault com.sun.star.sheet.FillDirection SIMPLE_valueintDATE_valueintAUTO_valueintgetDefaultcom.sun.star.sheet.FillModegetDefault#com.sun.star.sheet.FilterConnectionTOP_VALUES!com.sun.star.sheet.FilterOperatorLESS_valueintLESS_EQUAL!com.sun.star.sheet.FilterOperatorgetDefault!com.sun.star.sheet.FilterOperatorIsOptionalbooleanVARP_valueintNONE_valueintAUTO_valueintgetDefault"com.sun.star.sheet.GeneralFunctionDivergencedoublePRINT_AREAintROW_HEADERint
+NONE_valueintgetDefault!com.sun.star.sheet.PasteOperationNONE_valueintgetDefault com.sun.star.sheet.SheetLinkModeConnection#com.sun.star.sheet.FilterConnectionBOTH_valueintgetDefault%com.sun.star.sheet.TableOperationModeSTOP_valueintINFO_valueintgetDefault'com.sun.star.sheet.ValidationAlertStyleDATE_valueintLIST_valueintTIME_valueintgetDefault!com.sun.star.sheet.ValidationTypefillSeriesvoidsetSourcesvoidgetSources#com.sun.star.table.CellRangeAddressgetResultscom.sun.star.sheet.MemberResultgetResultscom.sun.star.sheet.DataResultgetMembers"com.sun.star.container.XNameAccessgetContentjava.lang.String setContentvoidoutputListvoidshowErrorsbooleansetLinkUrlvoidgetLinkUrljava.lang.String hideDetailvoidshowDetailvoidmoveByNamevoidcopyByNamevoidPRINT_AREAintROW_HEADERintNONE_valueintPAGE_AFTERcom.sun.star.style.BreakTypegetDefaultcom.sun.star.style.BreakTypeMIDDLE_TOP"com.sun.star.style.GraphicLocationNONE_valueintAREA_valueintgetDefault"com.sun.star.style.GraphicLocationLEFT_valueintgetDefault&com.sun.star.style.HorizontalAlignmentCHARS_THAIshortLEFT_valueintgetDefault"com.sun.star.style.PageStyleLayoutBLOCK"com.sun.star.style.ParagraphAdjustLEFT_valueintgetDefault"com.sun.star.style.ParagraphAdjustDEFAULTcom.sun.star.style.TabAlignLEFT_valueintgetDefaultcom.sun.star.style.TabAligngetDefault$com.sun.star.style.VerticalAlignmentGenerationintSyncFilterjava.lang.String VFS_FOLDERintinitializebooleanPosixErrorintgetSubjectjava.lang.String setSubjectvoidTEXT_valueintgetDefault"com.sun.star.table.CellContentTypeLEFT_valueintgetDefault"com.sun.star.table.CellHoriJustifygetDefault"com.sun.star.table.CellOrientationgetDefault"com.sun.star.table.CellVertJustifyBOTTOM_RIGHT_valueintNONE_valueintgetDefault!com.sun.star.table.ShadowLocationBottomLinecom.sun.star.table.BorderLineROWS_valueintgetDefault#com.sun.star.table.TableOrientationgetDefault%com.sun.star.table.TableSortFieldTypeautoFormatvoidsetFormulavoidgetFormulajava.lang.String gotoOffsetvoidgetColumns com.sun.star.table.XTableColumnsINFO_valueintgetDefault+com.sun.star.task.InteractionClassificationgetDefault%com.sun.star.task.PasswordRequestModegetRequestjava.lang.Object LOLA_valueintTEST_valueintgetDefault!com.sun.star.test.bridge.TestEnumsetValues2)com.sun.star.test.bridge.TestDataElementscallOnewayvoidcomplex_in*com.sun.star.test.performance.ComplexTypestestPassedbooleanFIRST_NAMEshortIDENTIFIERshortTECHREPORTshortCONFERENCEshortHARD_SPACEshortLINE_BREAKshortDDMMMMYYYYshortDISK_ABOVEshortDISK_BELOWshortLEFT_valueintgetDefault"com.sun.star.text.HorizontalAdjustONLY_valueintgetDefaultcom.sun.star.text.NotePrintModePREV_valueintNEXT_valueintgetDefault com.sun.star.text.PageNumberTypePRINT_AREAshortFRAME_LEFTshortPAGE_RIGHTshortPAGE_FRAMEshortBLOCKcom.sun.star.text.RubyAdjustLEFT_valueintgetDefaultcom.sun.star.text.RubyAdjustFilterNamejava.lang.String LeftMarginint AT_PARAGRAPH'com.sun.star.text.TextContentAnchorTypegetDefault'com.sun.star.text.TextContentAnchorTypeHHMMSSAMPMshortCHAR_TOPshortNONE_valueintLEFT_valueintgetDefaultcom.sun.star.text.WrapTextModegetDefaultcom.sun.star.text.WritingModejumpToPagebooleanprintPagesvoidsetColumnsvoidgetColumnscom.sun.star.text.TextColumninitializevoidgetColumns com.sun.star.table.XTableColumnsmergeRangebooleansplitRangebooleansetVisiblevoidServerNamejava.lang.String HasAccountbooleanDiagnosticjava.lang.String getDefault%com.sun.star.ucb.ContentCreationErrorPropertiescom.sun.star.beans.PropertyAttributesintgetDefaultcom.sun.star.ucb.CookiePolicySEND_valueintgetDefaultcom.sun.star.ucb.CookieRequestgetDefault"com.sun.star.ucb.DocumentStoreModeNO_DOCINFOintFetchErrorshortStartIndexintgetDefault"com.sun.star.ucb.FolderListCommandSubscribedbooleanCANT_WRITEcom.sun.star.ucb.IOErrorCodegetDefaultcom.sun.star.ucb.IOErrorCodeDiagnosticjava.lang.String Diagnosticjava.lang.String ActionInfojava.lang.Object LockTokensjava.lang.String ZERO_valueintgetDefaultcom.sun.star.ucb.LockDepthgetDefaultcom.sun.star.ucb.LockScopegetDefaultcom.sun.star.ucb.LockTypePropertiesjava.lang.String Propertiescom.sun.star.beans.PropertygetDefault%com.sun.star.ucb.OutgoingMessageState LOWEST_valueintHIGH_valueintgetDefaultcom.sun.star.ucb.PriorityValueState#com.sun.star.ucb.PropertyValueStategetDefault#com.sun.star.ucb.PropertyValueStateNewsgroupsjava.lang.String PERSISTENT'com.sun.star.ucb.RememberAuthenticationgetDefault'com.sun.star.ucb.RememberAuthenticationgetDefault2com.sun.star.ucb.RemoteContentProviderChangeActionIdentifierjava.lang.String MARKUNREADshortVALUE_TRUEshortPropertiescom.sun.star.beans.PropertyDEEP_valueintNONE_valueintgetDefault com.sun.star.ucb.SearchRecursiongetDefault"com.sun.star.ucb.SynchronizePolicyMOVE_valueintLINK_valueintCOPY_valueintgetDefault)com.sun.star.ucb.TransferCommandOperationONCE_valueintgetDefault!com.sun.star.ucb.VerificationModemapContentcom.sun.star.ucb.XContentgetDataURLjava.lang.String setDataURLvoidsetAccountvoidisReadOnlybooleanGET_SELECTED_ITEM_INDEXshortgetDefault,com.sun.star.ui.ContextMenuInterceptorActiongetContextjava.lang.Object isUnsignedboolean_typeClasscom.sun.star.uno.TypeClassCHAR_valueintBYTE_valueintTYPE_valueintVOID_valueintLONG_valueintENUM_valueintgetDefaultcom.sun.star.uno.TypeClassgetMappingcom.sun.star.uno.IMappinggetBridgescom.sun.star.uno.IBridgeisLoggablebooleanisLoggablebooleanDONE_valueintgetDefault%com.sun.star.util.DataEditorEventTypeEndMinutesshortStartHoursshortEndSecondsshortStartMonthshortINCH_100THshortSCIENTIFICshortgetDefault"com.sun.star.util.SearchAlgorithms searchStringjava.lang.String searchFlagintgetDefaultcom.sun.star.util.SortFieldTypegetContent#com.sun.star.container.XIndexAccessgetClasses!com.sun.star.util.AtomDescriptionisModifiedbooleanreplaceAllintmapStringsbooleansetOptionsvoidparseSmartbooleanPAGE_WIDTHshortUSER_valueintgetDefaultcom.sun.star.view.PaperFormatgetDefault"com.sun.star.view.PaperOrientationJOB_FAILED com.sun.star.view.PrintableStategetDefault com.sun.star.view.PrintableStategetControlcom.sun.star.awt.XControlgetPrinter com.sun.star.beans.PropertyValuesetPrintervoidgetPrinter com.sun.star.beans.PropertyValuescreenDownbooleanendElementvoidcharactersvoidLineNumberintcharactersvoidendElementvoidfatalErrorvoidstartCDATAvoidgetDesktopcom.sun.star.frame.XDesktop \ No newline at end of file
diff --git a/scripting/java/org/openoffice/netbeans/editor/OOo.jcs b/scripting/java/org/openoffice/netbeans/editor/OOo.jcs
new file mode 100644
index 000000000000..c5cc334221ba
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/editor/OOo.jcs
@@ -0,0 +1,21 @@
+!com.sun.star.awt.XProgressMonitor† ¸44com.sun.star.awt.XRadioButton† ¹hKcom.sun.star.awt.XRegion† º³‚´com.sun.star.awt.XScrollBar† ½g‚‹com.sun.star.awt.XSpinField† ¿òQcom.sun.star.awt.XSpinListener† ÁC+$com.sun.star.awt.XSystemChildFactory† Ân€Æ+com.sun.star.awt.XSystemDependentWindowPeer† Ã4€¤com.sun.star.awt.XTabController† ÃØé$com.sun.star.awt.XTabControllerModel† ÅÁ‚.com.sun.star.awt.XTextArea† Çï€com.sun.star.awt.XTextComponent† È‚„com.sun.star.awt.XTextEditField† Ë€‹&com.sun.star.awt.XTextLayoutConstrains† ËŽ€Úcom.sun.star.awt.XTextListener† Ìh€¦com.sun.star.awt.XTimeField† ÍÀcom.sun.star.awt.XToolkit† Î΂Kcom.sun.star.awt.XTopWindow† ÑY#com.sun.star.awt.XTopWindowListener† Òr‚%com.sun.star.awt.XUnoControlContainer† Ôˆh'com.sun.star.awt.XUserInputInterception† Õðucom.sun.star.awt.XVclContainer† ×e5&com.sun.star.awt.XVclContainerListener† Øš€î"com.sun.star.awt.XVclContainerPeer† Ùˆcom.sun.star.awt.XVclWindowPeer† Ú¢‚5com.sun.star.awt.XView† Ü×<com.sun.star.awt.XWindow† Þ„S com.sun.star.awt.XWindowListener† âfUcom.sun.star.awt.XWindowPeer† ã»O'com.sun.star.beans.IllegalTypeException å
+i)com.sun.star.beans.IntrospectionException åsi com.sun.star.beans.MethodConcept† åÜ€˜com.sun.star.beans.NamedValue æt€³)com.sun.star.beans.NotRemoveableException ç'icom.sun.star.beans.Property ç€ð$com.sun.star.beans.PropertyAttribute† è€€ä&com.sun.star.beans.PropertyChangeEvent édN"com.sun.star.beans.PropertyConcept† ê²l)com.sun.star.beans.PropertyExistException ëi(com.sun.star.beans.PropertySetInfoChange† ë‡J-com.sun.star.beans.PropertySetInfoChangeEvent ëÑ€Ñ com.sun.star.beans.PropertyState ì¢s+com.sun.star.beans.PropertyStateChangeEvent îo com.sun.star.beans.PropertyValue ï„(com.sun.star.beans.PropertyVetoException ðœicom.sun.star.beans.StringPair ñ€µ+com.sun.star.beans.UnknownPropertyException ñºicom.sun.star.beans.XExactName† ò#€¤#com.sun.star.beans.XFastPropertySet† òÇß+com.sun.star.beans.XHierarchicalPropertySet† ô¦‚‹/com.sun.star.beans.XHierarchicalPropertySetInfo† ÷1.com.sun.star.beans.XIntroTest† ø_…•!com.sun.star.beans.XIntrospection† ýô€¶'com.sun.star.beans.XIntrospectionAccess† þªƒ "com.sun.star.beans.XMaterialHolder†¡Ê€0com.sun.star.beans.XMultiHierarchicalPropertySet†¡Y‚3$com.sun.star.beans.XMultiPropertySet†¡Œ‚Þ'com.sun.star.beans.XMultiPropertyStates†¡j‚,com.sun.star.beans.XPropertiesChangeListener†¡ q€·,com.sun.star.beans.XPropertiesChangeNotifier†¡
+(Fcom.sun.star.beans.XProperty†¡ n€œ"com.sun.star.beans.XPropertyAccess†¡
+”*com.sun.star.beans.XPropertyChangeListener†¡ ž€µ%com.sun.star.beans.XPropertyContainer†¡S»com.sun.star.beans.XPropertySet†¡…1#com.sun.star.beans.XPropertySetInfo†¡?G1com.sun.star.beans.XPropertySetInfoChangeListener†¡†€Ã1com.sun.star.beans.XPropertySetInfoChangeNotifier†¡I2!com.sun.star.beans.XPropertyState†¡{‚X/com.sun.star.beans.XPropertyStateChangeListener†¡Ó€¿%com.sun.star.beans.XPropertyWithState†¡’J*com.sun.star.beans.XVetoableChangeListener†¡Ü€ß)com.sun.star.bridge.BridgeExistsException¡»i2com.sun.star.bridge.InvalidProtocolChangeException¡$"com.sun.star.bridge.ModelDependent†¡;R$com.sun.star.bridge.ProtocolProperty¡€³com.sun.star.bridge.XBridge†¡ @€ê"com.sun.star.bridge.XBridgeFactory†¡!*á#com.sun.star.bridge.XBridgeSupplier†¡# $com.sun.star.bridge.XBridgeSupplier2†¡$ €ê%com.sun.star.bridge.XInstanceProvider†¡$ö€Ò'com.sun.star.bridge.XProtocolProperties†¡%È:#com.sun.star.bridge.XUnoUrlResolver†¡'),com.sun.star.chart.ChartAxisArrangeOrderType¡(+î"com.sun.star.chart.ChartAxisAssign†¡*=!com.sun.star.chart.ChartAxisMarks†¡*V@#com.sun.star.chart.ChartDataCaption†¡*–m'com.sun.star.chart.ChartDataChangeEvent¡+C&com.sun.star.chart.ChartDataChangeType¡,F‚tcom.sun.star.chart.ChartDataRow¡.º%com.sun.star.chart.ChartDataRowSource¡/É!com.sun.star.chart.ChartDataValue¡0ီ%com.sun.star.chart.ChartErrorCategory¡1‚h*com.sun.star.chart.ChartErrorIndicatorType¡3÷Ì&com.sun.star.chart.ChartLegendPosition¡5Ãã+com.sun.star.chart.ChartRegressionCurveType¡7¦‚t%com.sun.star.chart.ChartSeriesAddress¡::!com.sun.star.chart.ChartSolidType†¡;T_"com.sun.star.chart.ChartSymbolType†¡;³€Ãcom.sun.star.chart.X3DDisplay†¡<v€Ê!com.sun.star.chart.XAxisXSupplier†¡=@4!com.sun.star.chart.XAxisYSupplier†¡>t4!com.sun.star.chart.XAxisZSupplier†¡?¨4com.sun.star.chart.XChartData†¡@Üp"com.sun.star.chart.XChartDataArray†¡BLc0com.sun.star.chart.XChartDataChangeEventListener†¡C¯€¸!com.sun.star.chart.XChartDocument†¡Dgécom.sun.star.chart.XDiagram†¡FP{$com.sun.star.chart.XStatisticDisplay†¡GË$com.sun.star.chart.XTwoAxisXSupplier†¡HÍ€ª$com.sun.star.chart.XTwoAxisYSupplier†¡Iw€ª-com.sun.star.comp.bridgefactory.BridgeFactory¡J!ƒ3&com.sun.star.comp.connections.Acceptor¡MT‚o'com.sun.star.comp.connections.Connector¡OÂ%6com.sun.star.comp.connections.ConstantInstanceProvider¡Qè‚¿-com.sun.star.comp.connections.PipedConnection¡T§ƒ®"com.sun.star.comp.helper.Bootstrap¡XUä)com.sun.star.comp.helper.ComponentContext¡Z9«.com.sun.star.comp.helper.ComponentContextEntry¡[䀘/com.sun.star.comp.helper.RegistryServiceFactory¡\|‚9,com.sun.star.comp.helper.SharedLibraryLoader¡^µƒ .com.sun.star.comp.loader.FactoryHelper.Factory ¡a¾…‡&com.sun.star.comp.loader.FactoryHelper¡gE‚´#com.sun.star.comp.loader.JavaLoader¡iù„ï*com.sun.star.comp.loader.JavaLoaderFactory¡nè‚°0com.sun.star.comp.loader.RegistrationClassFinder¡q˜‚ /com.sun.star.comp.servicemanager.ServiceManager ¡s¡‰°?com.sun.star.comp.typedescriptionmanager.TypeDescriptionManager(¡}Q96com.sun.star.comp.urlresolver.UrlResolver._UrlResolver ¡~ŠJ)com.sun.star.comp.urlresolver.UrlResolver¡Ô@com.sun.star.configuration.backend.AuthenticationFailedException"¡€ä€›9com.sun.star.configuration.backend.BackendAccessException"¡€‹8com.sun.star.configuration.backend.BackendSetupException"¡‚
+€û9com.sun.star.configuration.backend.CannotConnectException"¡ƒ€›:com.sun.star.configuration.backend.ConnectionLostException"¡ƒ €œDcom.sun.star.configuration.backend.InsufficientAccessRightsException"¡„<€œJcom.sun.star.configuration.backend.InvalidAuthenticationMechanismException"¡„Ø€›9com.sun.star.configuration.backend.MalformedDataException"¡…s€Ö0com.sun.star.configuration.backend.NodeAttribute"†¡†Ia2com.sun.star.configuration.backend.SchemaAttribute"†¡†ªb5com.sun.star.configuration.backend.TemplateIdentifier"¡‡ €·+com.sun.star.configuration.backend.XBackend"†¡‡ÃƒÝ3com.sun.star.configuration.backend.XBackendEntities"†¡‹ Ò2com.sun.star.configuration.backend.XCompositeLayer"†¡ré)com.sun.star.configuration.backend.XLayer"†¡[A0com.sun.star.configuration.backend.XLayerHandler"†¡œˆ„1com.sun.star.configuration.backend.XLayerImporter"†¡™ ƒ<5com.sun.star.configuration.backend.XMultiLayerStratum"†¡œ\…O*com.sun.star.configuration.backend.XSchema"†¡¡«‚ü1com.sun.star.configuration.backend.XSchemaHandler"†¡¤§Š2com.sun.star.configuration.backend.XSchemaSupplier"†¡®¿+6com.sun.star.configuration.backend.XSingleLayerStratum"†¡¯ê‚!2com.sun.star.configuration.backend.XUpdatableLayer"†¡² K1com.sun.star.configuration.backend.XUpdateHandler"†¡³V‹=;com.sun.star.configuration.CannotLoadConfigurationException¡¾“i:com.sun.star.configuration.InstallationIncompleteException¡¾ü€Š8com.sun.star.configuration.InvalidBootstrapFileException¡¿†€û8com.sun.star.configuration.MissingBootstrapFileException¡À€û-com.sun.star.configuration.XTemplateContainer†¡Á|€š,com.sun.star.configuration.XTemplateInstance†¡Â€“1com.sun.star.connection.AlreadyAcceptingException¡Â©i0com.sun.star.connection.ConnectionSetupException¡Ãi*com.sun.star.connection.NoConnectException¡Ã{i(com.sun.star.connection.SocketPermission¡Ã䀵!com.sun.star.connection.XAcceptor†¡Ä™\#com.sun.star.connection.XConnection†¡Åõc$com.sun.star.connection.XConnection2†¡ÇX€ê.com.sun.star.connection.XConnectionBroadcaster†¡ÈB€ð"com.sun.star.connection.XConnector†¡É2%com.sun.star.container.ContainerEvent¡ÊB,com.sun.star.container.ElementExistException¡ËUi-com.sun.star.container.NoSuchElementException¡Ë¾icom.sun.star.container.XChild†¡Ì'€Ý,com.sun.star.container.XComponentEnumeration†¡Í€Ô2com.sun.star.container.XComponentEnumerationAccess†¡ÍØ€È!com.sun.star.container.XContainer†¡Î 
+)com.sun.star.container.XContainerListener†¡Ïª>&com.sun.star.container.XContainerQuery†¡Ðè90com.sun.star.container.XContentEnumerationAccess†¡Ò!€ô%com.sun.star.container.XElementAccess†¡Ó€²#com.sun.star.container.XEnumeration†¡ÓÇ)com.sun.star.container.XEnumerationAccess†¡Ô΀²(com.sun.star.container.XHierarchicalName†¡Õ€-.com.sun.star.container.XHierarchicalNameAccess†¡Ö­1com.sun.star.container.XHierarchicalNameContainer†¡×Ââ/com.sun.star.container.XHierarchicalNameReplace†¡Ù¤Q(com.sun.star.container.XIdentifierAccess†¡Úõ+com.sun.star.container.XIdentifierContainer†¡Ü t)com.sun.star.container.XIdentifierReplace†¡Ý€7(com.sun.star.container.XImplicitIDAccess†¡Þ·+com.sun.star.container.XImplicitIDContainer†¡ß¾)com.sun.star.container.XImplicitIDReplace†¡à×€à#com.sun.star.container.XIndexAccess†¡á·
+&com.sun.star.container.XIndexContainer†¡âÁ¤$com.sun.star.container.XIndexReplace†¡äe,"com.sun.star.container.XNameAccess†¡å‘Y%com.sun.star.container.XNameContainer†¡æê¾#com.sun.star.container.XNameReplace†¡è¨9com.sun.star.container.XNamed†¡éဳcom.sun.star.container.XSet†¡ê”£&com.sun.star.container.XUniqueIDAccess†¡ì74+com.sun.star.corba.giop.CancelRequestHeader¡íkp*com.sun.star.corba.giop.FragmentHeader_1_2¡íÛp)com.sun.star.corba.giop.IORAddressingInfo¡îK€½-com.sun.star.corba.giop.LocateReplyHeader_1_2¡ï€ß/com.sun.star.corba.giop.LocateRequestHeader_1_0¡ï瀬,com.sun.star.corba.giop.LocateStatusType_1_2¡ð“‚ð)com.sun.star.corba.giop.MessageHeader_1_0¡óƒj)com.sun.star.corba.giop.MessageHeader_1_1¡ôí_#com.sun.star.corba.giop.MsgType_1_1¡öL‚ò'com.sun.star.corba.giop.ReplyHeader_1_2¡ù>…+com.sun.star.corba.giop.ReplyStatusType_1_2¡úÂâ)com.sun.star.corba.giop.RequestHeader_1_0¡ý¥‚)com.sun.star.corba.giop.RequestHeader_1_1¡ÿÄ‚s)com.sun.star.corba.giop.RequestHeader_1_2¢7‚80com.sun.star.corba.giop.SystemExceptionReplyBody¢o€ë%com.sun.star.corba.giop.TargetAddress¢Z€*com.sun.star.corba.giop.TargetAddressGroup†¢ÚWcom.sun.star.corba.giop.Version¢1€„/com.sun.star.corba.iiop.BiDirIIOPServiceContext¢µ€õ#com.sun.star.corba.iiop.ListenPoint¢ª€º'com.sun.star.corba.iiop.ProfileBody_1_0¢ dJ'com.sun.star.corba.iiop.ProfileBody_1_1¢
+®ìcom.sun.star.corba.iiop.Version¢ š€„com.sun.star.corba.iop.IOR¢ =%com.sun.star.corba.iop.ProfileIdGroup†¢[€‡%com.sun.star.corba.iop.ServiceContext¢‰%com.sun.star.corba.iop.ServiceIdGroup†¢’I&com.sun.star.corba.iop.TaggedComponent¢Û€­$com.sun.star.corba.iop.TaggedProfile¢ˆ€©com.sun.star.corba.CorbaString8¢1€‰com.sun.star.corba.CorbaUnion¢ºk"com.sun.star.corba.LogicalThreadID¢%€Òcom.sun.star.corba.ObjectKey¢÷€ïcom.sun.star.corba.OneThreadID¢怦com.sun.star.corba.TCKind¢ŒˆÊ2com.sun.star.datatransfer.clipboard.ClipboardEvent#¢V€×9com.sun.star.datatransfer.clipboard.RenderingCapabilities#†¢-<.com.sun.star.datatransfer.clipboard.XClipboard#†¢i@0com.sun.star.datatransfer.clipboard.XClipboardEx#†¢ ©€£5com.sun.star.datatransfer.clipboard.XClipboardFactory#†¢!L€ñ6com.sun.star.datatransfer.clipboard.XClipboardListener#†¢"=€Â5com.sun.star.datatransfer.clipboard.XClipboardManager#†¢"ÿñ6com.sun.star.datatransfer.clipboard.XClipboardNotifier#†¢$ð$3com.sun.star.datatransfer.clipboard.XClipboardOwner#†¢&€â7com.sun.star.datatransfer.clipboard.XFlushableClipboard#†¢&ö€†*com.sun.star.datatransfer.dnd.DNDConstants†¢'|€º.com.sun.star.datatransfer.dnd.DragGestureEvent¢(6^1com.sun.star.datatransfer.dnd.DragSourceDragEvent¢)” 1com.sun.star.datatransfer.dnd.DragSourceDropEvent¢*´'-com.sun.star.datatransfer.dnd.DragSourceEvent¢+ÛX6com.sun.star.datatransfer.dnd.DropTargetDragEnterEvent¢-3™1com.sun.star.datatransfer.dnd.DropTargetDragEvent¢.Ìu1com.sun.star.datatransfer.dnd.DropTargetDropEvent¢0AÙ-com.sun.star.datatransfer.dnd.DropTargetEvent¢2€Ž:com.sun.star.datatransfer.dnd.InvalidDNDOperationException¢2¨p)com.sun.star.datatransfer.dnd.XAutoscroll†¢3€¼2com.sun.star.datatransfer.dnd.XDragGestureListener†¢3Ô€Ä4com.sun.star.datatransfer.dnd.XDragGestureRecognizer†¢4˜<)com.sun.star.datatransfer.dnd.XDragSource†¢5Ô0com.sun.star.datatransfer.dnd.XDragSourceContext†¢7q€è1com.sun.star.datatransfer.dnd.XDragSourceListener†¢8Yë)com.sun.star.datatransfer.dnd.XDropTarget†¢:D™4com.sun.star.datatransfer.dnd.XDropTargetDragContext†¢;Ý€¡4com.sun.star.datatransfer.dnd.XDropTargetDropContext†¢<~€Å1com.sun.star.datatransfer.dnd.XDropTargetListener†¢=Cé$com.sun.star.datatransfer.DataFlavor¢?,4com.sun.star.datatransfer.UnsupportedFlavorException¢@.i/com.sun.star.datatransfer.XDataFormatTranslator†¢@—+*com.sun.star.datatransfer.XMimeContentType†¢A¤1com.sun.star.datatransfer.XMimeContentTypeFactory†¢Cf€ó-com.sun.star.datatransfer.XSystemTransferable†¢DY€“-com.sun.star.datatransfer.XTransferDataAccess†¢Dì€õ'com.sun.star.datatransfer.XTransferable†¢Eáž)com.sun.star.datatransfer.XTransferableEx†¢G€Ø-com.sun.star.datatransfer.XTransferableSource†¢HW€œ+com.sun.star.document.AmbigousFilterRequest¢Hó=*com.sun.star.document.BrokenPackageRequest¢J0€Ï!com.sun.star.document.EventObject¢Jÿ€ª*com.sun.star.document.FilterOptionsRequest¢K©t%com.sun.star.document.LinkUpdateModes†¢MX#com.sun.star.document.MacroExecMode†¢Mu€å)com.sun.star.document.NoSuchFilterRequest¢NZ€Í.com.sun.star.document.PrinterIndependentLayout†¢O'o(com.sun.star.document.RedlineDisplayType†¢O–j#com.sun.star.document.UpdateDocMode†¢P'com.sun.star.drawing.MeasureTextHorzPos¢”6Ä'com.sun.star.drawing.MeasureTextVertPos¢•úücom.sun.star.drawing.MirrorAxis¢—ö com.sun.star.drawing.NormalsKind¢™G,com.sun.star.drawing.PolyPolygonBezierCoords¢šKS'com.sun.star.drawing.PolyPolygonShape3D¢›ž!com.sun.star.drawing.PolygonFlags¢œ´– com.sun.star.drawing.PolygonKind¢žJ‚Ùcom.sun.star.drawing.Position3D¢¡#€³#com.sun.star.drawing.ProjectionMode¢¡Ö #com.sun.star.drawing.RectanglePoint¢¢öƒHcom.sun.star.drawing.ShadeMode¢¦>t#com.sun.star.drawing.SnapObjectType¢§²`com.sun.star.drawing.TextAdjust¢©¼+com.sun.star.drawing.TextAnimationDirection¢ªÎ¸&com.sun.star.drawing.TextAnimationKind¢¬†ñ&com.sun.star.drawing.TextFitToSizeType¢®wÀ)com.sun.star.drawing.TextHorizontalAdjust¢°7¶'com.sun.star.drawing.TextVerticalAdjust¢±íª com.sun.star.drawing.TextureKind¢³—
+!com.sun.star.drawing.TextureKind2¢´¡V com.sun.star.drawing.TextureMode¢µ÷K*com.sun.star.drawing.TextureProjectionMode¢·B)com.sun.star.drawing.VerticalDimensioning¢¸Ï¸&com.sun.star.drawing.XConnectableShape†¢º‡€ö$com.sun.star.drawing.XConnectorShape†¢»}Ç"com.sun.star.drawing.XControlShape†¢½D€Õcom.sun.star.drawing.XDrawPage†¢¾l(com.sun.star.drawing.XDrawPageDuplicator†¢¾…€½&com.sun.star.drawing.XDrawPageExpander†¢¿B€»(com.sun.star.drawing.XDrawPageSummarizer†¢¿ý€¾&com.sun.star.drawing.XDrawPageSupplier†¢À»€com.sun.star.drawing.XDrawPages†¢ÁX€æ'com.sun.star.drawing.XDrawPagesSupplier†¢Â>€Ÿcom.sun.star.drawing.XDrawView†¢ÂÝ€Ý(com.sun.star.drawing.XGluePointsSupplier†¢Ãº€§com.sun.star.drawing.XLayer†¢Äao"com.sun.star.drawing.XLayerManager†¢Äп#com.sun.star.drawing.XLayerSupplier†¢Æ€¥&com.sun.star.drawing.XMasterPageTarget†¢Ç4€Û)com.sun.star.drawing.XMasterPagesSupplier†¢È€¡com.sun.star.drawing.XShape†¢È°M"com.sun.star.drawing.XShapeAligner†¢Éý€Å#com.sun.star.drawing.XShapeArranger†¢Ê‚0!com.sun.star.drawing.XShapeBinder†¢Ìò€å#com.sun.star.drawing.XShapeCombiner†¢Í×€ç%com.sun.star.drawing.XShapeDescriptor†¢Î¾€ com.sun.star.drawing.XShapeGroup†¢ÏN€™"com.sun.star.drawing.XShapeGrouper†¢Ïç€ñ!com.sun.star.drawing.XShapeMirror†¢ÐØcom.sun.star.drawing.XShapes†¢Ññ€Ô.com.sun.star.drawing.XUniversalShapeDescriptor†¢ÒÅ€¢com.sun.star.embed.Aspects†¢Óg€¶com.sun.star.embed.BorderWidths¢Ô€¨com.sun.star.embed.ElementModes†¢ÔÅ€Äcom.sun.star.embed.EmbedMisc†¢Õ‰‚÷com.sun.star.embed.EmbedStates†¢Ø€€Œ#com.sun.star.embed.EmbedUpdateModes†¢Ù Qcom.sun.star.embed.EmbedVerbs†¢Ù]€Ú!com.sun.star.embed.EntryInitModes†¢Ú7€¤*com.sun.star.embed.InvalidStorageException¢ÚÛi%com.sun.star.embed.StorageWTException¢ÛD€‹,com.sun.star.embed.UnreachableStateException¢ÛÏ€Ó&com.sun.star.embed.WrongStateException¢Ü¢i$com.sun.star.embed.XClassifiedObject†¢Ý %com.sun.star.embed.XComponentSupplier†¢Þ €œ&com.sun.star.embed.XEmbedObjectFactory†¢Þ©ƒã com.sun.star.embed.XEmbedPersist†¢âŒ…¹"com.sun.star.embed.XEmbeddedClient†¢èE€Â"com.sun.star.embed.XEmbeddedObject†¢é„1-com.sun.star.embed.XEncryptionProtectedSource†¢í8€)com.sun.star.embed.XIPMainContainerWindow†¢íÈ+!com.sun.star.embed.XInplaceClient†¢îó„U!com.sun.star.embed.XInplaceObject†¢óH‚„#com.sun.star.embed.XInplaceUIWindow†¢õÌ‚"com.sun.star.embed.XLinkageSupport†¢÷Í%com.sun.star.embed.XPersistanceHolder†¢øÛ€àcom.sun.star.embed.XStorage†¢ù»ŒE$com.sun.star.embed.XTransactedObject†£'com.sun.star.embed.XTransactionListener†£)‚(com.sun.star.embed.XTransferableSupplier†£ «€ª com.sun.star.embed.XVisualObject†£
+U‚7"com.sun.star.embed.XWindowSupplier†£ Œ€•#com.sun.star.form.DataSelectionType£ ! %com.sun.star.form.DatabaseDeleteEvent£Á€Õ(com.sun.star.form.DatabaseParameterEvent£–€Ñcom.sun.star.form.ErrorEvent£g€§ com.sun.star.form.FormButtonType£|#com.sun.star.form.FormComponentType†£Š©$com.sun.star.form.FormSubmitEncoding£3W"com.sun.star.form.FormSubmitMethod£Š com.sun.star.form.ListSourceType£Ž‚ #com.sun.star.form.NavigationBarMode£®T com.sun.star.form.TabulatorCycle£G+com.sun.star.form.XApproveActionBroadcaster†£I(com.sun.star.form.XApproveActionListener†£Y€®!com.sun.star.form.XBoundComponent†£€Šcom.sun.star.form.XBoundControl†£‘€¡$com.sun.star.form.XChangeBroadcaster†£2€ô!com.sun.star.form.XChangeListener†£&€¥+com.sun.star.form.XConfirmDeleteBroadcaster†£Ë(com.sun.star.form.XConfirmDeleteListener†£ Û€°/com.sun.star.form.XDatabaseParameterBroadcaster†£!‹,com.sun.star.form.XDatabaseParameterListener†£"›€¼!com.sun.star.form.XDeleteListener†£#W€ã#com.sun.star.form.XErrorBroadcaster†£$:€ð com.sun.star.form.XErrorListener†£%*€©com.sun.star.form.XForm†£%Óp com.sun.star.form.XFormComponent†£&Cm!com.sun.star.form.XFormController†£&°?)com.sun.star.form.XFormControllerListener†£'ï€è com.sun.star.form.XFormsSupplier†£(×€¡com.sun.star.form.XGrid†£)x€¿$com.sun.star.form.XGridColumnFactory†£*7(com.sun.star.form.XGridFieldDataSupplier†£+=€ícom.sun.star.form.XGridPeer†£,*€å(com.sun.star.form.XImageProducerSupplier†£-€£!com.sun.star.form.XInsertListener†£-²€Ýcom.sun.star.form.XLoadListener†£.~com.sun.star.form.XLoadable†£0 ;&com.sun.star.form.XPositioningListener†£1H€¨com.sun.star.form.XReset†£1ð com.sun.star.form.XResetListener†£2ò€ã"com.sun.star.form.XRestoreListener†£3Õ€¦com.sun.star.form.XSubmit†£4{C!com.sun.star.form.XSubmitListener†£5¾€®$com.sun.star.form.XUpdateBroadcaster†£6l€ô!com.sun.star.form.XUpdateListener†£7`€ã%com.sun.star.formula.SymbolDescriptor£8CÂ%com.sun.star.frame.DispatchDescriptor£:€â&com.sun.star.frame.DispatchResultEvent£:ç€À&com.sun.star.frame.DispatchResultState†£;§N$com.sun.star.frame.DispatchStatement£;õw0com.sun.star.frame.DoubleInitializationException£=li$com.sun.star.frame.FeatureStateEvent£=Õ_com.sun.star.frame.FrameAction£?4ƒ8#com.sun.star.frame.FrameActionEvent£Bl"com.sun.star.frame.FrameSearchFlag†£Cp€š-com.sun.star.frame.IllegalArgumentIOException£D
+j+com.sun.star.frame.TerminationVetoException£Dti com.sun.star.frame.WindowArrange†£DÝ€†)com.sun.star.frame.XBrowseHistoryRegistry†£Ec#com.sun.star.frame.XComponentLoader†£Fd@%com.sun.star.frame.XComponentRegistry†£G¤€¼!com.sun.star.frame.XConfigManager†£H`com.sun.star.frame.XController†£Ið£com.sun.star.frame.XDesktop†£K“Ãcom.sun.star.frame.XDesktopTask†£MV€´com.sun.star.frame.XDispatch†£N
+z"com.sun.star.frame.XDispatchHelper†£O„$com.sun.star.frame.XDispatchProvider†£P’.0com.sun.star.frame.XDispatchProviderInterception†£QÀ0/com.sun.star.frame.XDispatchProviderInterceptor†£Rðš$com.sun.star.frame.XDispatchRecorder†£TŠž,com.sun.star.frame.XDispatchRecorderSupplier†£V(n*com.sun.star.frame.XDispatchResultListener†£W–€·%com.sun.star.frame.XDocumentTemplates†£XM‚¤+com.sun.star.frame.XExtendedFilterDetection†£Zñ€Â com.sun.star.frame.XFilterDetect†£[³€Úcom.sun.star.frame.XFrame†£\ƒ¦'com.sun.star.frame.XFrameActionListener†£`3€¯com.sun.star.frame.XFrameLoader†£`â $com.sun.star.frame.XFrameLoaderQuery†£aïH!com.sun.star.frame.XFrameSetModel†£c7€·com.sun.star.frame.XFrames†£cî"com.sun.star.frame.XFramesSupplier†£dõ€ý#com.sun.star.frame.XInterceptorInfo†£eò€–%com.sun.star.frame.XLoadEventListener†£fˆ€écom.sun.star.frame.XLoadable†£gqŠcom.sun.star.frame.XModel†£hû‚Ë%com.sun.star.frame.XNotifyingDispatch†£kÆ€ü&com.sun.star.frame.XRecordableDispatch†£l€î"com.sun.star.frame.XStatusListener†£m°€²com.sun.star.frame.XStorable†£nbË'com.sun.star.frame.XSynchronousDispatch†£p-€Ø*com.sun.star.frame.XSynchronousFrameLoader†£q€Ócom.sun.star.frame.XTask†£qØ€Þ!com.sun.star.frame.XTasksSupplier†£r¶€Ó%com.sun.star.frame.XTerminateListener†£s‰com.sun.star.frame.XUrlList†£t£€³"com.sun.star.frame.XWindowArranger†£uV€²com.sun.star.i18n.AmPmValue†£v1com.sun.star.i18n.Boundary£v9€„com.sun.star.i18n.BreakType†£v½acom.sun.star.i18n.CTLScriptType†£w~com.sun.star.i18n.Calendar£wœ‚‰%com.sun.star.i18n.CalendarDisplayCode†£z%g&com.sun.star.i18n.CalendarDisplayIndex†£{Œb$com.sun.star.i18n.CalendarFieldIndex†£{îNcom.sun.star.i18n.CalendarItem£}<€ècom.sun.star.i18n.CharType†£~$ƒ3'com.sun.star.i18n.CharacterIteratorMode†£Wa!com.sun.star.i18n.CollatorOptions†£¸€Šcom.sun.star.i18n.Currency£‚B‡#com.sun.star.i18n.DirectionProperty£ƒÉ‡‚%com.sun.star.i18n.ForbiddenCharacters£‹K€ºcom.sun.star.i18n.FormatElement£Œš com.sun.star.i18n.Implementation£Ÿ€¦(com.sun.star.i18n.InputSequenceCheckMode†£ŽEN com.sun.star.i18n.KCharacterType†£Ž“€¥#com.sun.star.i18n.KNumberFormatType†£8G$com.sun.star.i18n.KNumberFormatUsage†£€Âcom.sun.star.i18n.KParseTokens†£A‚Ócom.sun.star.i18n.KParseType†£“€Ö%com.sun.star.i18n.LanguageCountryInfo£“êc-com.sun.star.i18n.LineBreakHyphenationOptions£•Mp"com.sun.star.i18n.LineBreakResults£–½€ö&com.sun.star.i18n.LineBreakUserOptions£—³e com.sun.star.i18n.LocaleDataItem£™„`com.sun.star.i18n.LocaleItem†£x‚com.sun.star.i18n.Months†£Ÿ—€å.com.sun.star.i18n.MultipleCharsOutputException£ |i"com.sun.star.i18n.NativeNumberMode†£ å€ñ+com.sun.star.i18n.NativeNumberXmlAttributes£¡Ö€õ"com.sun.star.i18n.NumberFormatCode£¢ËR#com.sun.star.i18n.NumberFormatIndex†£¤†¶com.sun.star.i18n.ParseResult£ªÓI!com.sun.star.i18n.ScriptDirection†£¬Ycom.sun.star.i18n.ScriptType†£¬uX&com.sun.star.i18n.TextConversionOption†£¬Íg&com.sun.star.i18n.TextConversionResult£­4€ü$com.sun.star.i18n.TextConversionType†£®0j(com.sun.star.i18n.TransliterationModules£®šŽù+com.sun.star.i18n.TransliterationModulesNew£½“š½%com.sun.star.i18n.TransliterationType†£ØP€com.sun.star.i18n.UnicodeScript£ØÝ›ãcom.sun.star.i18n.UnicodeType†£ôÀƒ5com.sun.star.i18n.Weekdays†£÷õ€–com.sun.star.i18n.WordType†£ø‹} com.sun.star.i18n.XBreakIterator†£ù‡žcom.sun.star.i18n.XCalendar†¤€ê&com.sun.star.lang.NoSuchFieldException¤Vôi'com.sun.star.lang.NoSuchMethodException¤W]i$com.sun.star.lang.NoSupportException¤WÆi&com.sun.star.lang.NullPointerException¤X/i/com.sun.star.lang.ServiceNotRegisteredException¤X˜i!com.sun.star.lang.SystemDependent†¤Y€ž(com.sun.star.lang.WrappedTargetException¤YŸ€Ù/com.sun.star.lang.WrappedTargetRuntimeException¤Zx€àcom.sun.star.lang.XComponent†¤[X"com.sun.star.lang.XConnectionPoint†¤\\¶+com.sun.star.lang.XConnectionPointContainer†¤^z com.sun.star.lang.XEventListener†¤_Œ€¢!com.sun.star.lang.XInitialization†¤`.€²com.sun.star.lang.XLocalizable†¤`à€Çcom.sun.star.lang.XMain†¤a§€Ž(com.sun.star.lang.XMultiComponentFactory†¤b5Ì&com.sun.star.lang.XMultiServiceFactory†¤dk%com.sun.star.lang.XServiceDisplayName†¤el€µcom.sun.star.lang.XServiceInfo†¤f!€ýcom.sun.star.lang.XServiceName†¤g€’)com.sun.star.lang.XSingleComponentFactory†¤g°s'com.sun.star.lang.XSingleServiceFactory†¤i#com.sun.star.lang.XTypeProvider†¤j5€±com.sun.star.lang.XUnoTunnel†¤j怌)com.sun.star.ldap.LdapConnectionException¤kri&com.sun.star.ldap.LdapGenericException¤kÛ€¹0com.sun.star.lib.connections.pipe.PipeConnection!¤l”ƒˆ.com.sun.star.lib.connections.pipe.pipeAcceptor!¤p‚E/com.sun.star.lib.connections.pipe.pipeConnector!¤raû4com.sun.star.lib.connections.socket.SocketConnection#¤t\ƒê2com.sun.star.lib.connections.socket.socketAcceptor#¤xF‚E3com.sun.star.lib.connections.socket.socketConnector#¤z‹û!com.sun.star.lib.sandbox.Cachable†¤|†x%com.sun.star.lib.sandbox.ClassContext†¤|þ‚ *com.sun.star.lib.sandbox.ClassContextProxy¤ ƒß#com.sun.star.lib.sandbox.CodeSource¤‚èY#com.sun.star.lib.sandbox.Disposable†¤ƒA+)com.sun.star.lib.sandbox.ExecutionContext„¤ƒl…com.sun.star.lib.sandbox.Holder†¤ˆ†l!com.sun.star.lib.sandbox.JarEntry¤ˆò€µ-com.sun.star.lib.sandbox.PermissionCollection¤‰§€Ô)com.sun.star.lib.sandbox.ProtectionDomain¤Š{€¶!com.sun.star.lib.sandbox.Resource†¤‹1°&com.sun.star.lib.sandbox.ResourceProxy¤ŒáƒM'com.sun.star.lib.sandbox.ResourceViewer¤.€‘(com.sun.star.lib.sandbox.SandboxSecurity¤¿†Ë1com.sun.star.lib.sandbox.SandboxSecurityException¤—Š€Ñ+com.sun.star.lib.sandbox.SandboxThreadGroup¤˜[€Ö com.sun.star.lib.sandbox.WeakRef¤™1€"com.sun.star.lib.sandbox.WeakTable¤™Îtcom.sun.star.lib.sandbox.XImage†¤›B„²=com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter¤Ÿô?com.sun.star.lib.uno.adapter.XOutputStreamToOutputStreamAdapter¤¡‘#Mcom.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.MessageDispatcher(¤¢´€;com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge(¤£C‡Õ7com.sun.star.lib.uno.environments.java.java_environment&¤«‚1com.sun.star.lib.uno.environments.remote.IMarshal(†¤­6z1com.sun.star.lib.uno.environments.remote.IMessage(†¤­°X2com.sun.star.lib.uno.environments.remote.IProtocol(†¤¯ƒ2com.sun.star.lib.uno.environments.remote.IReceiver(†¤²€4com.sun.star.lib.uno.environments.remote.IThreadPool(†¤²‚c3com.sun.star.lib.uno.environments.remote.IUnmarshal(†¤´ó_7com.sun.star.lib.uno.environments.remote.JavaThreadPool(¤µR‚>com.sun.star.lib.uno.environments.remote.JavaThreadPoolFactory(¤·á€Î,com.sun.star.lib.uno.environments.remote.Job(¤¸¯ƒ©1com.sun.star.lib.uno.environments.remote.JobQueue(¤¼X‚Ï1com.sun.star.lib.uno.environments.remote.Protocol(„¤¿'‚]1com.sun.star.lib.uno.environments.remote.ThreadId(¤Á„:com.sun.star.lib.uno.environments.remote.ThreadPoolManager(¤ÂŒq;com.sun.star.lib.uno.environments.remote.remote_environment(¤Âýõ)com.sun.star.lib.uno.helper.ComponentBase¤Äò¸#com.sun.star.lib.uno.helper.Factory¤Æªƒ.com.sun.star.lib.uno.helper.InterfaceContainer¤ÉÀ„47com.sun.star.lib.uno.helper.MultiTypeInterfaceContainer¤Íôm'com.sun.star.lib.uno.helper.PropertySet¤Ïa•"com.sun.star.lib.uno.helper.UnoUrl¤ßö‚2'com.sun.star.lib.uno.helper.WeakAdapter¤â(€ß$com.sun.star.lib.uno.helper.WeakBase¤ã2?com.sun.star.lib.uno.protocols.urp.Marshal.M_InterfaceReference" ¤ä9x5com.sun.star.lib.uno.protocols.urp.Marshal.M_ThreadId" ¤ä±l&com.sun.star.lib.uno.protocols.urp.urp"¤åƒ5.com.sun.star.lib.uno.typedesc.FieldDescription¤èR€¹/com.sun.star.lib.uno.typedesc.MethodDescription¤é ‚È-com.sun.star.lib.uno.typedesc.TypeDescription¤ëÓ‹¬/com.sun.star.lib.uno.typeinfo.AttributeTypeInfo¤÷€.com.sun.star.lib.uno.typeinfo.ConstantTypeInfo¤øL,com.sun.star.lib.uno.typeinfo.MemberTypeInfo¤øZf,com.sun.star.lib.uno.typeinfo.MethodTypeInfo¤øÀ€Â/com.sun.star.lib.uno.typeinfo.ParameterTypeInfo¤ù‚&com.sun.star.lib.uno.typeinfo.TypeInfo¤úOcom.sun.star.lib.uno.Proxy†¤ûß%com.sun.star.lib.util.DisposeListener†¤ûöZ%com.sun.star.lib.util.DisposeNotifier†¤üP_ com.sun.star.lib.util.IInvokable†¤ü¯J!com.sun.star.lib.util.IInvokeHook†¤üù€ƒ)com.sun.star.lib.util.NativeLibraryLoader¤ý|€§"com.sun.star.lib.util.StringHelper¤þ#fcom.sun.star.lib.util.WeakMap¤þ‰‚d#com.sun.star.lib.util.WeakMap.Entry„ ¥{ƒ2com.sun.star.linguistic2.XConversionDictionaryList†¥ ™‚Â$com.sun.star.linguistic2.XDictionary†¥[ƒ%com.sun.star.linguistic2.XDictionary1†¥܃_)com.sun.star.linguistic2.XDictionaryEntry†¥;€Ú1com.sun.star.linguistic2.XDictionaryEventListener†¥€¿(com.sun.star.linguistic2.XDictionaryList†¥Ôƒ}5com.sun.star.linguistic2.XDictionaryListEventListener†¥Q€Ç(com.sun.star.linguistic2.XHyphenatedWord†¥=$com.sun.star.linguistic2.XHyphenator†¥U‚Ö6com.sun.star.linguistic2.XLinguServiceEventBroadcaster†¥!+43com.sun.star.linguistic2.XLinguServiceEventListener†¥"_€Ã-com.sun.star.linguistic2.XLinguServiceManager†¥#"‚ã!com.sun.star.linguistic2.XMeaning†¥&€´)com.sun.star.linguistic2.XPossibleHyphens†¥&¹2com.sun.star.linguistic2.XSearchableDictionaryList†¥'¾+com.sun.star.linguistic2.XSpellAlternatives†¥(Â&com.sun.star.linguistic2.XSpellChecker†¥)ÝÊ'com.sun.star.linguistic2.XSpellChecker1†¥+§¦,com.sun.star.linguistic2.XSupportedLanguages†¥-M€©*com.sun.star.linguistic2.XSupportedLocales†¥-ö€Ë#com.sun.star.linguistic2.XThesaurus†¥.Á12com.sun.star.loader.CannotActivateFactoryException¥/òi)com.sun.star.loader.XImplementationLoader†¥0[Î'com.sun.star.mozilla.MenuMultipleChange¥2)%com.sun.star.mozilla.MenuSingleChange¥3¶€¸*com.sun.star.mozilla.XCloseSessionListener†¥4n€™com.sun.star.mozilla.XMenuProxy†¥5,'com.sun.star.mozilla.XMenuProxyListener†¥63"$com.sun.star.mozilla.XPluginInstance†¥7U‚.com.sun.star.mozilla.XPluginInstanceNotifySink†¥9f€•(com.sun.star.mozilla.XPluginInstancePeer†¥9û‚ð,com.sun.star.mozilla.XPluginInstanceSyncPeer†¥<ë€Ó&com.sun.star.mozilla.XPluginWindowPeer†¥=¾€š2com.sun.star.mozilla.XRemoteServiceManagerProvider†¥>X€¿.com.sun.star.packages.manifest.XManifestReader†¥?€È.com.sun.star.packages.manifest.XManifestWriter†¥?߀Ò&com.sun.star.packages.zip.ZipConstants†¥@±ƒÀ"com.sun.star.packages.zip.ZipEntry¥DqÌ&com.sun.star.packages.zip.ZipException¥F=i(com.sun.star.packages.zip.ZipIOException¥F¦j3com.sun.star.packages.EncryptionNotAllowedException¥Gi+com.sun.star.packages.NoEncryptionException¥Gyi*com.sun.star.packages.NoRawFormatException¥Gâj,com.sun.star.packages.WrongPasswordException¥HLi*com.sun.star.packages.XDataSinkEncrSupport†¥Hµ‚q%com.sun.star.plugin.PluginDescription¥K&$#com.sun.star.plugin.PluginException¥LJ€½com.sun.star.plugin.PluginMode†¥M6"com.sun.star.plugin.PluginVariable¥M="com.sun.star.plugin.XPlugin†¥N_"com.sun.star.plugin.XPluginContext†¥Ou„ô"com.sun.star.plugin.XPluginManager†¥Ti‚ )com.sun.star.presentation.AnimationEffect¥W  *Õ(com.sun.star.presentation.AnimationSpeed¥Þg%com.sun.star.presentation.ClickAction¥ƒE„Œ$com.sun.star.presentation.FadeEffect¥‡Ñ”_+com.sun.star.presentation.PresentationRange¥œ0ò5com.sun.star.presentation.XCustomPresentationSupplier†¥ž"€¯0com.sun.star.presentation.XHandoutMasterSupplier†¥žÑ€¦'com.sun.star.presentation.XPresentation†¥Ÿw€©+com.sun.star.presentation.XPresentationPage†¥  €¡/com.sun.star.presentation.XPresentationSupplier†¥ Á€ª'com.sun.star.reflection.FieldAccessMode¥¡kÀ0com.sun.star.reflection.InvalidTypeNameException¥£+i1com.sun.star.reflection.InvocationTargetException¥£”€‹"com.sun.star.reflection.MethodMode¥¤/com.sun.star.reflection.NoSuchTypeNameException¥¥-i!com.sun.star.reflection.ParamInfo¥¥–'!com.sun.star.reflection.ParamMode¥¦½<2com.sun.star.reflection.TypeDescriptionSearchDepth¥§ùL-com.sun.star.reflection.XArrayTypeDescription†¥©E€ê0com.sun.star.reflection.XCompoundTypeDescription†¥ª/0com.sun.star.reflection.XConstantTypeDescription†¥«I€¡1com.sun.star.reflection.XConstantsTypeDescription†¥«ê€½,com.sun.star.reflection.XEnumTypeDescription†¥¬§€Õ!com.sun.star.reflection.XIdlArray†¥­|‚J!com.sun.star.reflection.XIdlClass†¥¯ÆƒÖ)com.sun.star.reflection.XIdlClassProvider†¥³œ€¢!com.sun.star.reflection.XIdlField†¥´>Ê"com.sun.star.reflection.XIdlField2†¥¶Ê"com.sun.star.reflection.XIdlMember†¥·Ò€Æ"com.sun.star.reflection.XIdlMethod†¥¸˜‚2&com.sun.star.reflection.XIdlReflection†¥ºÊ€õ0com.sun.star.reflection.XIndirectTypeDescription†¥»¿€º:com.sun.star.reflection.XInterfaceAttributeTypeDescription†¥¼y€Ù7com.sun.star.reflection.XInterfaceMemberTypeDescription†¥½R€µ7com.sun.star.reflection.XInterfaceMethodTypeDescription†¥¾Y1com.sun.star.reflection.XInterfaceTypeDescription†¥¿`!(com.sun.star.reflection.XMethodParameter†¥À.com.sun.star.reflection.XModuleTypeDescription†¥Á„€³0com.sun.star.reflection.XPropertyTypeDescription†¥Â7€á%com.sun.star.reflection.XProxyFactory†¥Ã€°/com.sun.star.reflection.XServiceTypeDescription†¥ÃÈô1com.sun.star.reflection.XSingletonTypeDescription†¥Å¼€º(com.sun.star.reflection.XTypeDescription†¥Æv€º3com.sun.star.reflection.XTypeDescriptionEnumeration†¥Ç0€æ9com.sun.star.reflection.XTypeDescriptionEnumerationAccess†¥È’-com.sun.star.reflection.XUnionTypeDescription†¥É¨¿;com.sun.star.registry.CannotRegisterImplementationException¥Ëgi.com.sun.star.registry.InvalidRegistryException¥ËÐi+com.sun.star.registry.InvalidValueException¥Ì9i,com.sun.star.registry.MergeConflictException¥Ì¢i%com.sun.star.registry.RegistryKeyType¥Í 'com.sun.star.registry.RegistryValueType¥Î‚è1com.sun.star.registry.XImplementationRegistration†¥Ñ‚"com.sun.star.registry.XRegistryKey†¥Ó‹³%com.sun.star.registry.XSimpleRegistry†¥ÞÅ‚Ü.com.sun.star.resource.MissingResourceException¥á¡pcom.sun.star.resource.XLocale†¥â…ä%com.sun.star.resource.XResourceBundle†¥çõO+com.sun.star.resource.XResourceBundleLoader†¥éD‡com.sun.star.scanner.ScanError¥êË‚V#com.sun.star.scanner.ScannerContext¥í!€§%com.sun.star.scanner.ScannerException¥íÈ€ë$com.sun.star.scanner.XScannerManager†¥î³‚–"com.sun.star.script.AllEventObject¥ñIy*com.sun.star.script.CannotConvertException¥òÂ%0com.sun.star.script.CannotCreateAdapterException¥óçi&com.sun.star.script.ContextInformation¥ôPŒcom.sun.star.script.FailReason†¥õÜ€þ%com.sun.star.script.FinishEngineEvent¥öÚ- com.sun.star.script.FinishReason¥ø=(com.sun.star.script.InterruptEngineEvent¥ùDÉ#com.sun.star.script.InterruptReason¥û ‚Ú"com.sun.star.script.InvocationInfo¥ýç‚:com.sun.star.script.MemberType¦seAccess†¦E"÷(com.sun.star.sdb.XDatabaseAccessListener†¦G7%com.sun.star.sdb.XDatabaseEnvironment†¦HPc'com.sun.star.sdb.XFormDocumentsSupplier†¦I³€¦-com.sun.star.sdb.XInteractionSupplyParameters†¦JY€¸$com.sun.star.sdb.XParametersSupplier†¦K€¤!com.sun.star.sdb.XQueriesSupplier†¦Kµ€ *com.sun.star.sdb.XQueryDefinitionsSupplier†¦LU€©)com.sun.star.sdb.XReportDocumentsSupplier†¦Lþ€¨!com.sun.star.sdb.XResultSetAccess†¦M¦€¿*com.sun.star.sdb.XRowSetApproveBroadcaster†¦Ne'com.sun.star.sdb.XRowSetApproveListener†¦Os9 com.sun.star.sdb.XRowSetSupplier†¦P¬€É%com.sun.star.sdb.XSQLErrorBroadcaster†¦Qu€ú"com.sun.star.sdb.XSQLErrorListener†¦Ro€«"com.sun.star.sdb.XSQLQueryComposer†¦S‚â)com.sun.star.sdb.XSQLQueryComposerFactory†¦Uü€©&com.sun.star.sdbc.BatchUpdateException¦V¥com.sun.star.sdbc.BestRowScope†¦WµMcom.sun.star.sdbc.BestRowType†¦XIcom.sun.star.sdbc.ChangeAction†¦XKQcom.sun.star.sdbc.ChangeEvent¦Xœ€¡com.sun.star.sdbc.ColumnSearch†¦Y=Lcom.sun.star.sdbc.ColumnType†¦Y‰Icom.sun.star.sdbc.ColumnValue†¦YÒR com.sun.star.sdbc.DataTruncation¦Z$_com.sun.star.sdbc.DataType†¦[ƒÂcom.sun.star.sdbc.Deferrability†¦]E[$com.sun.star.sdbc.DriverPropertyInfo¦] d com.sun.star.sdbc.FetchDirection†¦_Gcom.sun.star.sdbc.IndexType†¦_K`com.sun.star.sdbc.KeyRule†¦_«o!com.sun.star.sdbc.ProcedureColumn†¦`j!com.sun.star.sdbc.ProcedureResult†¦`„C&com.sun.star.sdbc.ResultSetConcurrency†¦`Ç;com.sun.star.sdbc.ResultSetType†¦a`com.sun.star.sdbc.SQLException¦ab"com.sun.star.sdbc.SQLWarning¦b„€œ&com.sun.star.sdbc.TransactionIsolation†¦c €com.sun.star.sdbc.XArray†¦c¡‚Ð!com.sun.star.sdbc.XBatchExecution†¦fq#com.sun.star.sdbc.XBlob†¦g”Ùcom.sun.star.sdbc.XClob†¦im÷com.sun.star.sdbc.XCloseable†¦kd€com.sun.star.sdbc.XColumnLocate†¦l€µcom.sun.star.sdbc.XConnection†¦l¶…·com.sun.star.sdbc.XDataSource†¦rmd#com.sun.star.sdbc.XDatabaseMetaData†¦sÑ /com.sun.star.sdbc.XDriver†¦£n‚com.sun.star.sdbc.XDriverAccess†¦¥v€¯ com.sun.star.sdbc.XDriverManager†¦¦%£%com.sun.star.sdbc.XGeneratedResultSet†¦§È€Â%com.sun.star.sdbc.XIsolatedConnection†¦¨Š€"com.sun.star.sdbc.XMultipleResults†¦ª
+4 com.sun.star.sdbc.XOutParameters†¦«>+com.sun.star.sdbc.XParameters†¦¬i‡ª#com.sun.star.sdbc.XPooledConnection†¦´€¾)com.sun.star.sdbc.XPreparedBatchExecution†¦´Ñ$com.sun.star.sdbc.XPreparedStatement†¦µàcom.sun.star.sdbc.XRef†¦·_€³com.sun.star.sdbc.XResultSet†¦¸„n$com.sun.star.sdbc.XResultSetMetaData†¦¼€†&,com.sun.star.sdbc.XResultSetMetaDataSupplier†¦Â¦€Ã"com.sun.star.sdbc.XResultSetUpdate†¦ÃiÃcom.sun.star.sdbc.XRow†¦Å,† com.sun.star.sdbc.XRowSet†¦ËL)!com.sun.star.sdbc.XRowSetListener†¦Ìucom.sun.star.sdbc.XRowUpdate†¦Í‘…Þcom.sun.star.sdbc.XSQLData†¦Óoncom.sun.star.sdbc.XSQLInput†¦ÔÝ…ˆcom.sun.star.sdbc.XSQLOutput†¦Úe†[com.sun.star.sdbc.XStatement†¦àÀ»com.sun.star.sdbc.XStruct†¦â{#com.sun.star.sdbc.XWarningsSupplier†¦ã™€écom.sun.star.sdbcx.CheckOption†¦ä‚B"com.sun.star.sdbcx.CompareBookmark†¦äÄkcom.sun.star.sdbcx.KeyType†¦å/Fcom.sun.star.sdbcx.Privilege†¦åu€œ"com.sun.star.sdbcx.PrivilegeObject†¦æAcom.sun.star.sdbcx.XAlterTable†¦æR¥com.sun.star.sdbcx.XAppend†¦ç÷€û com.sun.star.sdbcx.XAuthorizable†¦èòÙ#com.sun.star.sdbcx.XColumnsSupplier†¦êË€ !com.sun.star.sdbcx.XCreateCatalog†¦ëk€÷*com.sun.star.sdbcx.XDataDefinitionSupplier†¦ìb)com.sun.star.sdbcx.XDataDescriptorFactory†¦ícom.sun.star.sdbcx.XDeleteRows†¦î–€µcom.sun.star.sdbcx.XDrop†¦ïKQcom.sun.star.sdbcx.XDropCatalog†¦ðœ
+"com.sun.star.sdbcx.XGroupsSupplier†¦ñ¦€Ÿ#com.sun.star.sdbcx.XIndexesSupplier†¦òE€  com.sun.star.sdbcx.XKeysSupplier†¦ò倞com.sun.star.sdbcx.XRename†¦óƒ€àcom.sun.star.sdbcx.XRowLocate†¦ôc‚U"com.sun.star.sdbcx.XTablesSupplier†¦ö¸€Ÿcom.sun.star.sdbcx.XUser†¦÷W€Ó!com.sun.star.sdbcx.XUsersSupplier†¦ø*€ž!com.sun.star.sdbcx.XViewsSupplier†¦øÈ€ž,com.sun.star.security.AccessControlException¦ùf€ã#com.sun.star.security.AllPermission¦úIm'com.sun.star.security.RuntimePermission¦ú¶€„+com.sun.star.security.XAccessControlContext†¦û:€É'com.sun.star.security.XAccessController†¦ü‚)com.sun.star.security.XAction†¦þ,€£com.sun.star.security.XPolicy†¦þÏ€ècom.sun.star.setup.ActionType¦ÿ·„˜com.sun.star.setup.BaseAction§O€Ü!com.sun.star.setup.CopyFileAction§+Ú"com.sun.star.setup.DeleteDirAction§€Î#com.sun.star.setup.DeleteFileAction§Ó·%com.sun.star.setup.DeleteFolderAction§ Š€Ñ)com.sun.star.setup.DeleteFolderItemAction§
+[!com.sun.star.setup.DownloadAction§ a€úcom.sun.star.setup.FontAction§ ['%com.sun.star.setup.InstallEnvironment§ ‚†"com.sun.star.setup.InstallResponse§…+com.sun.star.setup.InstallType§°‚Ž com.sun.star.setup.MakeDirAction§>€å#com.sun.star.setup.MakeFolderAction§#€ô'com.sun.star.setup.MakeFolderItemAction§º%com.sun.star.setup.MakeShortcutAction§Ñncom.sun.star.setup.MirrorEntry§?€Ûcom.sun.star.setup.ModuleInfo§‚gcom.sun.star.setup.ModuleState§€Êcom.sun.star.setup.OSType§ Kƒ$com.sun.star.setup.ProfileItemAction§#Y‡$com.sun.star.setup.ResponseErrorCode§$à,com.sun.star.setup.SizeInfo§& €Ôcom.sun.star.setup.UnzipAction§&à‚lcom.sun.star.setup.UpdateType§)L~$com.sun.star.setup.VersionIdentifier§*Êy(com.sun.star.setup.WindowsRegistryAction§,CÂcom.sun.star.setup.XSetup†§.†ocom.sun.star.sheet.Border§4tR!com.sun.star.sheet.CellDeleteMode§5ƾcom.sun.star.sheet.CellFlags†§7„€©!com.sun.star.sheet.CellInsertMode§8-Ä$com.sun.star.sheet.ConditionOperator§9ñƒ`!com.sun.star.sheet.DataImportMode§=Q€,com.sun.star.sheet.DataPilotFieldOrientation§>Ñ‚com.sun.star.sheet.DataResult§@à€†"com.sun.star.sheet.DataResultFlags†§AfFcom.sun.star.sheet.FillDateMode§A¬È com.sun.star.sheet.FillDirection§Ct”com.sun.star.sheet.FillMode§Ež#com.sun.star.sheet.FilterConnection§F¦!com.sun.star.sheet.FilterOperator§Gªƒê com.sun.star.sheet.FormulaResult†§K”B#com.sun.star.sheet.FunctionArgument§KÖ€Û#com.sun.star.sheet.FunctionCategory†§L±€Ö"com.sun.star.sheet.GeneralFunction§M‡ƒÑcom.sun.star.sheet.GoalResult§QX€’ com.sun.star.sheet.LocalizedName§Qê€Äcom.sun.star.sheet.MemberResult§R®€Ê$com.sun.star.sheet.MemberResultFlags†§SxK com.sun.star.sheet.MoveDirection†§SÃR!com.sun.star.sheet.NamedRangeFlag†§Tk!com.sun.star.sheet.PasteOperation§T€Î&com.sun.star.sheet.RangeSelectionEvent§VN€°com.sun.star.sheet.ResultEvent§Vþ€¦ com.sun.star.sheet.SheetLinkMode§W¤A$com.sun.star.sheet.StatusBarFunction†§X倆!com.sun.star.sheet.SubTotalColumn§Yk€Â#com.sun.star.sheet.TableFilterField§Z-‘%com.sun.star.sheet.TableOperationMode§[¾V%com.sun.star.sheet.TablePageBreakData§]€‘,com.sun.star.sheet.TableValidationVisibility†§]¥X'com.sun.star.sheet.ValidationAlertStyle§]ýª!com.sun.star.sheet.ValidationType§_§‚ˆcom.sun.star.sheet.XAddIn†§b/‚Zcom.sun.star.sheet.XAreaLink†§d‰5com.sun.star.sheet.XAreaLinks†§e¾#%com.sun.star.sheet.XArrayFormulaRange†§fá€Ã com.sun.star.sheet.XCalculatable†§g¤€ù#com.sun.star.sheet.XCellAddressable†§h€ ,com.sun.star.sheet.XCellFormatRangesSupplier†§i=€ª(com.sun.star.sheet.XCellRangeAddressable†§i瀦!com.sun.star.sheet.XCellRangeData†§j€½$com.sun.star.sheet.XCellRangeFormula†§kJ€Ã%com.sun.star.sheet.XCellRangeMovement†§l ñ%com.sun.star.sheet.XCellRangeReferrer†§mþ€¡#com.sun.star.sheet.XCellRangesQuery†§nŸ‚–com.sun.star.sheet.XCellSeries†§q5<&com.sun.star.sheet.XCompatibilityNames†§rq€½"com.sun.star.sheet.XConsolidatable†§s.+com.sun.star.sheet.XConsolidationDescriptor†§t<‚¯com.sun.star.sheet.XDDELink†§vë€Ó'com.sun.star.sheet.XDataPilotDescriptor†§w¾‚Ò*com.sun.star.sheet.XDataPilotMemberResults†§z€$com.sun.star.sheet.XDataPilotResults†§{-€›"com.sun.star.sheet.XDataPilotTable†§{È€¹#com.sun.star.sheet.XDataPilotTables†§|e+com.sun.star.sheet.XDataPilotTablesSupplier†§}怩!com.sun.star.sheet.XDatabaseRange†§~ô"com.sun.star.sheet.XDatabaseRanges†§€ƒ€ó&com.sun.star.sheet.XDimensionsSupplier†§v€£$com.sun.star.sheet.XDocumentAuditing†§‚€…#com.sun.star.sheet.XFillAcrossSheet†§‚ž€ com.sun.star.sheet.XFormulaQuery†§ƒ-€÷"com.sun.star.sheet.XFunctionAccess†§„$(com.sun.star.sheet.XFunctionDescriptions†§…7€Öcom.sun.star.sheet.XGoalSeek†§† €ñ'com.sun.star.sheet.XHeaderFooterContent†§†þ€ï'com.sun.star.sheet.XHierarchiesSupplier†§‡í€¤com.sun.star.sheet.XLabelRange†§ˆ‘Ycom.sun.star.sheet.XLabelRanges†§‰ê€õ"com.sun.star.sheet.XLevelsSupplier†§Šß€Ÿ#com.sun.star.sheet.XMembersSupplier†§‹~€ %com.sun.star.sheet.XMultipleOperation†§Œcom.sun.star.sheet.XNamedRange†§;gcom.sun.star.sheet.XNamedRanges†§Ž¢£com.sun.star.sheet.XPrintAreas†§E‚u"com.sun.star.sheet.XRangeSelection†§’º‚=0com.sun.star.sheet.XRangeSelectionChangeListener†§”÷€¸*com.sun.star.sheet.XRangeSelectionListener†§•¯€é#com.sun.star.sheet.XRecentFunctions†§–˜€Ô"com.sun.star.sheet.XResultListener†§—l€§com.sun.star.sheet.XScenario†§˜5com.sun.star.sheet.XScenarios†§™H%com.sun.star.sheet.XScenariosSupplier†§šO€#com.sun.star.sheet.XSheetAnnotation†§šì)com.sun.star.sheet.XSheetAnnotationAnchor†§œ €¤$com.sun.star.sheet.XSheetAnnotations†§œ¯€à,com.sun.star.sheet.XSheetAnnotationsSupplier†§€¦!com.sun.star.sheet.XSheetAuditing†§ž5Ú#com.sun.star.sheet.XSheetCellCursor†§ D"com.sun.star.sheet.XSheetCellRange†§¡S€£+com.sun.star.sheet.XSheetCellRangeContainer†§¡öý#com.sun.star.sheet.XSheetCellRanges†§£ó"com.sun.star.sheet.XSheetCondition†§¥û+com.sun.star.sheet.XSheetConditionalEntries†§§
+€Ý)com.sun.star.sheet.XSheetConditionalEntry†§§ç€½)com.sun.star.sheet.XSheetFilterDescriptor†§¨¤€é#com.sun.star.sheet.XSheetFilterable†§©€þ%com.sun.star.sheet.XSheetFilterableEx†§ª‹€ê!com.sun.star.sheet.XSheetLinkable†§«u‚"com.sun.star.sheet.XSheetOperation†§­}€ì com.sun.star.sheet.XSheetOutline†§®i‚G"com.sun.star.sheet.XSheetPageBreak†§°°!com.sun.star.sheet.XSheetPastable†§±À£com.sun.star.sheet.XSpreadsheet†§³c'com.sun.star.sheet.XSpreadsheetDocument†§´r€#com.sun.star.sheet.XSpreadsheetView†§µ€ß com.sun.star.sheet.XSpreadsheets†§µî*(com.sun.star.sheet.XSubTotalCalculatable†§·)&com.sun.star.sheet.XSubTotalDescriptor†§¸A€¼!com.sun.star.sheet.XSubTotalField†§¸ý'2com.sun.star.sheet.XUniqueCellFormatRangesSupplier†§º$€°"com.sun.star.sheet.XUsedAreaCursor†§ºÔ€¿!com.sun.star.sheet.XViewFreezable†§»“€´com.sun.star.sheet.XViewPane†§¼G4%com.sun.star.sheet.XViewPanesSupplier†§½{€£!com.sun.star.sheet.XViewSplitable†§¾ "com.sun.star.sheet.XVolatileResult†§¿>€öcom.sun.star.sheet._NamedRange†§À4kcom.sun.star.style.BreakType§ÀŸ‚_com.sun.star.style.CaseMap†§Âþr com.sun.star.style.DropCapFormat§Ãp€ "com.sun.star.style.GraphicLocation§Äƒü&com.sun.star.style.HorizontalAlignment§È _%com.sun.star.style.LineNumberPosition†§ÉkYcom.sun.star.style.LineSpacing§ÉÄ€ˆ"com.sun.star.style.LineSpacingMode†§ÊLX com.sun.star.style.NumberingType†§Ê¤ƒs"com.sun.star.style.PageStyleLayout§ÎŒ"com.sun.star.style.ParagraphAdjust§Ï£Ñ)com.sun.star.style.ParagraphStyleCategory†§Ñtvcom.sun.star.style.TabAlign§Ñê¤com.sun.star.style.TabStop§ÓŽ€î$com.sun.star.style.VerticalAlignment§Ô|U$com.sun.star.style.XDefaultsSupplier†§ÕÑ€žcom.sun.star.style.XStyle†§Öo&"com.sun.star.style.XStyleCondition†§×•€å)com.sun.star.style.XStyleFamiliesSupplier†§Øz€¦com.sun.star.style.XStyleLoader†§Ù com.sun.star.svg.XSVGPrinter†§Ú< com.sun.star.svg.XSVGWriter†§ÛG€®com.sun.star.sync.SyncAction†§Ûõ€ïcom.sun.star.sync.SyncElement§Üä€ýcom.sun.star.sync.SyncEvent†§Ýဋcom.sun.star.sync.SyncInfo§Þl…com.sun.star.sync.SyncMode†§ßñ€com.sun.star.sync.SyncOptions†§à~€¿com.sun.star.sync.SyncScheme§á=€´com.sun.star.sync.SyncType†§áñ€µ com.sun.star.sync.XSyncCollector†§â¦ƒ_com.sun.star.sync.XSynchronizer†§æŸ*com.sun.star.sync2.BadPartnershipException§ç¤€Õ)com.sun.star.system.SimpleMailClientFlags†§èyZ/com.sun.star.system.SystemShellExecuteException§èÓ€º+com.sun.star.system.SystemShellExecuteFlags†§éH"com.sun.star.system.XProxySettings†§éÕ‚f%com.sun.star.system.XSimpleMailClient†§ì;L-com.sun.star.system.XSimpleMailClientSupplier†§í‡€®&com.sun.star.system.XSimpleMailMessage†§î5‚'com.sun.star.system.XSystemShellExecute†§ðÄ com.sun.star.table.BorderLine§ñÏ€Ïcom.sun.star.table.CellAddress§òž€˜"com.sun.star.table.CellContentType§ó6Ž"com.sun.star.table.CellHoriJustify§ôÄ‚"com.sun.star.table.CellOrientation§öÚ¦#com.sun.star.table.CellRangeAddress§ø€€Ñ"com.sun.star.table.CellVertJustify§ùQ’com.sun.star.table.ShadowFormat§úã!com.sun.star.table.ShadowLocation§ûæìcom.sun.star.table.TableBorder§ýÒƒc#com.sun.star.table.TableOrientation¨5!com.sun.star.table.TableSortField¨E•%com.sun.star.table.TableSortFieldType¨Út#com.sun.star.table.XAutoFormattable†¨N€Âcom.sun.star.table.XCell†¨5com.sun.star.table.XCellCursor†¨E€êcom.sun.star.table.XCellRange†¨/©"com.sun.star.table.XColumnRowRange†¨ Ø€Ëcom.sun.star.table.XTableChart†¨
+£scom.sun.star.table.XTableCharts†¨ ''com.sun.star.table.XTableChartsSupplier†¨ =€œ com.sun.star.table.XTableColumns†¨ Ù€Ãcom.sun.star.table.XTableRows†¨œ€Ã.com.sun.star.task.ClassifiedInteractionRequest¨_)com.sun.star.task.DocumentPasswordRequest¨m-"com.sun.star.task.ErrorCodeRequest¨š€·+com.sun.star.task.InteractionClassification¨QÄ'com.sun.star.task.MasterPasswordRequest¨€È#com.sun.star.task.NoMasterException¨Ý€ÿ!com.sun.star.task.PasswordRequest¨Ü;%com.sun.star.task.PasswordRequestMode¨–-com.sun.star.task.UnsupportedOverwriteRequest¨­com.sun.star.task.UrlRecord¨¾com.sun.star.task.UserRecord¨Á€æcom.sun.star.task.XAsyncJob†¨§€ó#com.sun.star.task.XInteractionAbort†¨šz%com.sun.star.task.XInteractionApprove†¨z*com.sun.star.task.XInteractionContinuation†¨Ž~(com.sun.star.task.XInteractionDisapprove†¨ z%com.sun.star.task.XInteractionHandler†¨†€§&com.sun.star.task.XInteractionPassword†¨-€Ê%com.sun.star.task.XInteractionRequest†¨÷€Ñ#com.sun.star.task.XInteractionRetry†¨ Èzcom.sun.star.task.XJob†¨!B€ôcom.sun.star.task.XJobExecutor†¨"6€“com.sun.star.task.XJobListener†¨"É€»$com.sun.star.task.XPasswordContainer†¨#„ƒA"com.sun.star.task.XStatusIndicator†¨&Å€þ)com.sun.star.task.XStatusIndicatorFactory†¨'À«*com.sun.star.task.XStatusIndicatorSupplier†¨(n€¨)com.sun.star.test.bridge.TestDataElements¨)Á$com.sun.star.test.bridge.TestElement¨*×|!com.sun.star.test.bridge.TestEnum¨,S‚4#com.sun.star.test.bridge.TestSimple¨.‡®$com.sun.star.test.bridge.XBridgeTest†¨05«%com.sun.star.test.bridge.XBridgeTest2†¨1à…(com.sun.star.test.bridge.XBridgeTestBase†¨7}‰ž'com.sun.star.test.bridge.XRecursiveCall†¨A€¸*com.sun.star.test.performance.ComplexTypes¨AÓ’)com.sun.star.test.performance.SimpleTypes¨Ce^.com.sun.star.test.performance.XPerformanceTest†¨DǺcom.sun.star.test.TestEvent¨L}€Ûcom.sun.star.test.XSimpleTest†¨MXÏcom.sun.star.test.XTest†¨O'‚;com.sun.star.test.XTestListener†¨Qb%com.sun.star.text.AuthorDisplayFormat†¨Rvb'com.sun.star.text.BibliographyDataField†¨RØ‚Q&com.sun.star.text.BibliographyDataType†¨U)¶com.sun.star.text.ChapterFormat†¨Vßx*com.sun.star.text.CharacterCompressionType†¨WW`"com.sun.star.text.ControlCharacter†¨W·€¢#com.sun.star.text.DateDisplayFormat†¨XY€Å#com.sun.star.text.DocumentStatistic†¨YW'com.sun.star.text.FilenameDisplayFormat†¨Yu[com.sun.star.text.FontEmphasis†¨YЀÔcom.sun.star.text.FontRelief†¨Z¤L#com.sun.star.text.FootnoteNumbering†¨ZðWcom.sun.star.text.GraphicCrop¨[G€¨!com.sun.star.text.HoriOrientation†¨['com.sun.star.text.HoriOrientationFormat¨\€ß"com.sun.star.text.HorizontalAdjust¨]oK-com.sun.star.text.InvalidTextContentException¨^º€ñ com.sun.star.text.MailMergeEvent¨_«€¸com.sun.star.text.MailMergeType†¨`c8com.sun.star.text.NotePrintMode¨`›~ com.sun.star.text.PageNumberType¨bA$com.sun.star.text.ParagraphVertAlign†¨cZn!com.sun.star.text.PlaceholderType†¨cÈm$com.sun.star.text.ReferenceFieldPart†¨d5€Á&com.sun.star.text.ReferenceFieldSource†¨dö€ com.sun.star.text.RelOrientation†¨ew€Îcom.sun.star.text.RubyAdjust¨fE±!com.sun.star.text.SectionFileLink¨gö€»!com.sun.star.text.SetVariableType†¨h±[com.sun.star.text.SizeType†¨i F&com.sun.star.text.TableColumnSeparator¨iR€“'com.sun.star.text.TemplateDisplayFormat†¨iåzcom.sun.star.text.TextColumn¨j_€ 'com.sun.star.text.TextContentAnchorType¨jÿ‚$com.sun.star.text.TextGridMode†¨m#P#com.sun.star.text.TimeDisplayFormat†¨ms€œcom.sun.star.text.UserDataPart†¨n !com.sun.star.text.UserFieldFormat†¨o/E!com.sun.star.text.VertOrientation†¨ot€Ô'com.sun.star.text.VertOrientationFormat¨pH€µcom.sun.star.text.WrapTextMode¨pýúcom.sun.star.text.WritingMode¨r÷2com.sun.star.text.WritingMode2†¨t)f$com.sun.star.text.XAutoTextContainer†¨tt com.sun.star.text.XAutoTextEntry†¨v€Ÿ com.sun.star.text.XAutoTextGroup†¨v¢‚j%com.sun.star.text.XBookmarkInsertTool†¨y €×$com.sun.star.text.XBookmarksSupplier†¨y〢+com.sun.star.text.XChapterNumberingSupplier†¨z…€°+com.sun.star.text.XDefaultNumberingProvider†¨{56%com.sun.star.text.XDependentTextField†¨|k com.sun.star.text.XDocumentIndex†¨}‚€¨$com.sun.star.text.XDocumentIndexMark†¨~*€À*com.sun.star.text.XDocumentIndexesSupplier†¨~ꀩ+com.sun.star.text.XEndnotesSettingsSupplier†¨“€¦#com.sun.star.text.XEndnotesSupplier†¨€9€Ücom.sun.star.text.XFootnote†¨€¸,com.sun.star.text.XFootnotesSettingsSupplier†¨Í€§$com.sun.star.text.XFootnotesSupplier†¨‚t€Þcom.sun.star.text.XHeaderFooter†¨ƒR€Ì(com.sun.star.text.XHeaderFooterPageStyle†¨„€Í*com.sun.star.text.XLineNumberingProperties†¨„뀭(com.sun.star.text.XLineNumberingSupplier†¨…˜€ï'com.sun.star.text.XMailMergeBroadcaster†¨†‡
+$com.sun.star.text.XMailMergeListener†¨‡‘€°com.sun.star.text.XModule†¨ˆAk%com.sun.star.text.XNumberingFormatter†¨ˆ¬)com.sun.star.text.XNumberingRulesSupplier†¨‰¯€¨$com.sun.star.text.XNumberingTypeInfo†¨ŠW1com.sun.star.text.XPageCursor†¨‹ˆ` com.sun.star.text.XPagePrintable†¨ŒèT"com.sun.star.text.XParagraphCursor†¨Ž<g)com.sun.star.text.XReferenceMarksSupplier†¨£€§,com.sun.star.text.XRelativeTextContentInsert†¨J’,com.sun.star.text.XRelativeTextContentRemove†¨‘ÜN com.sun.star.text.XRubySelection†¨“*€ñ!com.sun.star.text.XSentenceCursor†¨”acom.sun.star.text.XSimpleText†¨•|Úcom.sun.star.text.XText†¨—Vscom.sun.star.text.XTextColumns†¨˜É.com.sun.star.text.XTextContent†¨™÷€ùcom.sun.star.text.XTextCursor†¨šð“com.sun.star.text.XTextDocument†¨œƒ€¥%com.sun.star.text.XTextEmbeddedObject†¨(€º.com.sun.star.text.XTextEmbeddedObjectsSupplier†¨â€¨com.sun.star.text.XTextField†¨žŠ€¡%com.sun.star.text.XTextFieldsSupplier†¨Ÿ+€ècom.sun.star.text.XTextFrame†¨ €•%com.sun.star.text.XTextFramesSupplier†¨ ¨€£-com.sun.star.text.XTextGraphicObjectsSupplier†¨¡K€§com.sun.star.text.XTextRange†¨¡ò6#com.sun.star.text.XTextRangeCompare†¨£(ƒ!com.sun.star.text.XTextRangeMover†¨¤«€®com.sun.star.text.XTextSection†¨¥Y€Ü'com.sun.star.text.XTextSectionsSupplier†¨¦5€¥%com.sun.star.text.XTextShapesSupplier†¨¦Ú€ com.sun.star.text.XTextTable†¨§z¯"com.sun.star.text.XTextTableCursor†¨©)ü%com.sun.star.text.XTextTablesSupplier†¨«%€£!com.sun.star.text.XTextViewCursor†¨«È€Ò)com.sun.star.text.XTextViewCursorSupplier†¨¬š€¢com.sun.star.text.XWordCursor†¨­<I,com.sun.star.ucb.AlreadyInitializedException¨®…i&com.sun.star.ucb.AuthenticationRequest¨®î‚—#com.sun.star.ucb.CHAOSProgressStart¨±…€²com.sun.star.ucb.Command¨²7€Ì(com.sun.star.ucb.CommandAbortedException¨³i'com.sun.star.ucb.CommandFailedException¨³l€Ðcom.sun.star.ucb.CommandInfo¨´<€Õ"com.sun.star.ucb.CommandInfoChange†¨µH'com.sun.star.ucb.CommandInfoChangeEvent¨µY€Ñcom.sun.star.ucb.ConnectionMode†¨¶*:com.sun.star.ucb.ContentAction†¨¶dq%com.sun.star.ucb.ContentCreationError¨¶Õ‚Ì)com.sun.star.ucb.ContentCreationException¨¹¡€úcom.sun.star.ucb.ContentEvent¨º›"com.sun.star.ucb.ContentInfo¨»½%com.sun.star.ucb.ContentInfoAttribute†¨¼Ü€Š$com.sun.star.ucb.ContentProviderInfo¨½f€á+com.sun.star.ucb.ContentResultSetCapability†¨¾G(com.sun.star.ucb.Cookie¨¾o¾com.sun.star.ucb.CookiePolicy¨À-:com.sun.star.ucb.CookieRequest¨Ág€ücom.sun.star.ucb.CrossReference¨Âc€—$com.sun.star.ucb.DocumentHeaderField¨Âú€³"com.sun.star.ucb.DocumentStoreMode¨Ã­ 4com.sun.star.ucb.DuplicateCommandIdentifierException¨Ä¹i+com.sun.star.ucb.DuplicateProviderException¨Å"icom.sun.star.ucb.Error†¨Å‹Š!com.sun.star.ucb.ExportStreamInfo¨Ïª€Ãcom.sun.star.ucb.FetchError†¨ÐmQcom.sun.star.ucb.FetchResult¨Ð¾#com.sun.star.ucb.FileSystemNotation†¨ÑÃpcom.sun.star.ucb.FolderList¨Ò3/"com.sun.star.ucb.FolderListCommand¨ÓbU com.sun.star.ucb.FolderListEntry¨Ô·*.com.sun.star.ucb.GlobalTransferCommandArgument¨Õál%com.sun.star.ucb.HandleCookiesRequest¨×MÌcom.sun.star.ucb.IOErrorCode¨ÙŠî+com.sun.star.ucb.IllegalIdentifierException¨äi&com.sun.star.ucb.InsertCommandArgument¨äp€Ã(com.sun.star.ucb.InteractiveAppException¨å3€÷0com.sun.star.ucb.InteractiveAugmentedIOException¨æ*Z3com.sun.star.ucb.InteractiveBadTransferURLException¨ç„i*com.sun.star.ucb.InteractiveCHAOSException¨çíS+com.sun.star.ucb.InteractiveFileIOException¨é@.'com.sun.star.ucb.InteractiveIOException¨ên)3com.sun.star.ucb.InteractiveNetworkConnectException¨ë—,com.sun.star.ucb.InteractiveNetworkException¨ì¨€¬3com.sun.star.ucb.InteractiveNetworkGeneralException¨íT€ª3com.sun.star.ucb.InteractiveNetworkOffLineException¨íþ€ª0com.sun.star.ucb.InteractiveNetworkReadException¨î¨7com.sun.star.ucb.InteractiveNetworkResolveNameException¨ï½1com.sun.star.ucb.InteractiveNetworkWriteException¨ðÎ0com.sun.star.ucb.InteractiveWrongMediumException¨ñãcom.sun.star.ucb.Link¨òö€»com.sun.star.ucb.ListAction¨ó±€Õcom.sun.star.ucb.ListActionType†¨ô†€“com.sun.star.ucb.ListEvent¨õ€ò,com.sun.star.ucb.ListenerAlreadySetException¨ö icom.sun.star.ucb.Lock¨öt†com.sun.star.ucb.LockDepth¨÷ú#com.sun.star.ucb.LockEntry¨ù€Ùcom.sun.star.ucb.LockScope¨ùö€ôcom.sun.star.ucb.LockType¨úꀮ,com.sun.star.ucb.MissingInputStreamException¨û˜i+com.sun.star.ucb.MissingPropertiesException¨ü‰#com.sun.star.ucb.PropertyValueState© œÂcom.sun.star.ucb.RecipientInfo© ^‚æ'com.sun.star.ucb.RememberAuthentication©Dl2com.sun.star.ucb.RemoteContentProviderChangeAction©°N1com.sun.star.ucb.RemoteContentProviderChangeEvent©þ#com.sun.star.ucb.ResultSetException©€œcom.sun.star.ucb.Rule©¹com.sun.star.ucb.RuleAction†©Í€Ücom.sun.star.ucb.RuleOperator†©©€¹com.sun.star.ucb.RuleSet©b€ßcom.sun.star.ucb.RuleTerm©A#&com.sun.star.ucb.SearchCommandArgument©d com.sun.star.ucb.SearchCriterium©€Çcom.sun.star.ucb.SearchInfo©Fé com.sun.star.ucb.SearchRecursion©/Ecom.sun.star.ucb.SendInfo©t€»com.sun.star.ucb.SendMediaTypes©/€â)com.sun.star.ucb.ServiceNotFoundException© icom.sun.star.ucb.SortingInfo© z€­"com.sun.star.ucb.SynchronizePolicy©!'‰)com.sun.star.ucb.TransferCommandOperation©"°hcom.sun.star.ucb.TransferInfo©$€ôcom.sun.star.ucb.TransferResult©% €æ,com.sun.star.ucb.UnsupportedCommandException©%òi-com.sun.star.ucb.UnsupportedDataSinkException©&[€Î.com.sun.star.ucb.UnsupportedNameClashException©')€¹-com.sun.star.ucb.UnsupportedOpenModeException©'‸!com.sun.star.ucb.VerificationMode©(šF.com.sun.star.ucb.WelcomeDynamicResultSetStruct©)à€àcom.sun.star.ucb.XAnyCompare†©*À€¨#com.sun.star.ucb.XAnyCompareFactory†©+h€º/com.sun.star.ucb.XCachedContentResultSetFactory†©,"€ú3com.sun.star.ucb.XCachedContentResultSetStubFactory†©-€Ð/com.sun.star.ucb.XCachedDynamicResultSetFactory†©-ì3com.sun.star.ucb.XCachedDynamicResultSetStubFactory†©.òî$com.sun.star.ucb.XCommandEnvironment†©0à€êcom.sun.star.ucb.XCommandInfo†©1Êã+com.sun.star.ucb.XCommandInfoChangeListener†©3­€¹+com.sun.star.ucb.XCommandInfoChangeNotifier†©4f"com.sun.star.ucb.XCommandProcessor†©5„X#com.sun.star.ucb.XCommandProcessor2†©6Ü€žcom.sun.star.ucb.XContent†©7zjcom.sun.star.ucb.XContentAccess†©8ä com.sun.star.ucb.XContentCreator†©9ô€ü&com.sun.star.ucb.XContentEventListener†©:ð€ª#com.sun.star.ucb.XContentIdentifier†©;š€É*com.sun.star.ucb.XContentIdentifierFactory†©<c€Â*com.sun.star.ucb.XContentIdentifierMapping†©=%Œ!com.sun.star.ucb.XContentProvider†©>±X(com.sun.star.ucb.XContentProviderFactory†©@ €¾(com.sun.star.ucb.XContentProviderManager†©@Ç‚)com.sun.star.ucb.XContentProviderSupplier†©B×€§$com.sun.star.ucb.XContentTransmitter†©C~€¯com.sun.star.ucb.XDataContainer†©D-J"com.sun.star.ucb.XDynamicResultSet†©Ew‚**com.sun.star.ucb.XDynamicResultSetListener†©G¡€¡com.sun.star.ucb.XFetchProvider†©HB€®/com.sun.star.ucb.XFetchProviderForContentAccess†©Hðf)com.sun.star.ucb.XFileIdentifierConverter†©JV@+com.sun.star.ucb.XInteractionCookieHandling†©K–€ü,com.sun.star.ucb.XInteractionHandlerSupplier†©L’€0com.sun.star.ucb.XInteractionReplaceExistingData†©M"z1com.sun.star.ucb.XInteractionSupplyAuthentication†©Mœƒ'com.sun.star.ucb.XInteractionSupplyName†©P°€¢.com.sun.star.ucb.XParameterizedContentProvider†©QR”'com.sun.star.ucb.XPersistentPropertySet†©Ræ€Ç!com.sun.star.ucb.XProgressHandler†©S­€Ç!com.sun.star.ucb.XPropertyMatcher†©Tt€Ð(com.sun.star.ucb.XPropertyMatcherFactory†©UD€Î%com.sun.star.ucb.XPropertySetRegistry†©V€û,com.sun.star.ucb.XPropertySetRegistryFactory†©W €Æcom.sun.star.ucb.XRecycler†©WÓ€Ñ/com.sun.star.ucb.XRemoteContentProviderAcceptor†©X¤[0com.sun.star.ucb.XRemoteContentProviderActivator†©Yÿ€º5com.sun.star.ucb.XRemoteContentProviderChangeListener†©Z¹€Í5com.sun.star.ucb.XRemoteContentProviderChangeNotifier†©[†F8com.sun.star.ucb.XRemoteContentProviderConnectionControl†©\Ì€Ö2com.sun.star.ucb.XRemoteContentProviderDistributor†©]¢¢3com.sun.star.ucb.XRemoteContentProviderDoneListener†©_D€É/com.sun.star.ucb.XRemoteContentProviderSupplier†©` €È"com.sun.star.ucb.XSimpleFileAccess†©`Õˆ#com.sun.star.ucb.XSimpleFileAccess2†©hê€Ø#com.sun.star.ucb.XSimpleFileAccess3†©iÂ`/com.sun.star.ucb.XSortedDynamicResultSetFactory†©k"'&com.sun.star.ucb.XSourceInitialization†©lI€Ã2com.sun.star.ui.dialogs.CommonFilePickerElementIds†©m €Ò&com.sun.star.ui.dialogs.ControlActions†©mÞ1com.sun.star.ui.dialogs.ExecutableDialogException©nãi/com.sun.star.ui.dialogs.ExecutableDialogResults†©oL54com.sun.star.ui.dialogs.ExtendedFilePickerElementIds†©o¹'com.sun.star.ui.dialogs.FilePickerEvent©q:€”/com.sun.star.ui.dialogs.FilePreviewImageFormats†©qÎ(-com.sun.star.ui.dialogs.ListboxControlActions†©qö€µ+com.sun.star.ui.dialogs.TemplateDescription†©r«®&com.sun.star.ui.dialogs.XControlAccess†©tYq+com.sun.star.ui.dialogs.XControlInformation†©uÊÂ)com.sun.star.ui.dialogs.XExecutableDialog†©wŒ€©#com.sun.star.ui.dialogs.XFilePicker†©x5‚0com.sun.star.ui.dialogs.XFilePickerControlAccess†©y·k+com.sun.star.ui.dialogs.XFilePickerListener†©{"¾+com.sun.star.ui.dialogs.XFilePickerNotifier†©|à$com.sun.star.ui.dialogs.XFilePreview†©}ðŒ+com.sun.star.ui.dialogs.XFilterGroupManager†©|€ê&com.sun.star.ui.dialogs.XFilterManager†©€f^%com.sun.star.ui.dialogs.XFolderPicker†©ÄY*com.sun.star.ui.ActionTriggerSeparatorType†©ƒJ'com.sun.star.ui.ContextMenuExecuteEvent©ƒg¨,com.sun.star.ui.ContextMenuInterceptorAction©…‚(com.sun.star.ui.XContextMenuInterception†©‡'com.sun.star.ui.XContextMenuInterceptor†©ˆ'€ãcom.sun.star.uno.Any©‰
+3com.sun.star.uno.AnyConverter©Š=ˆTcom.sun.star.uno.Ascii©’‘2com.sun.star.uno.AsciiString©’ÃP$com.sun.star.uno.DeploymentException©“pcom.sun.star.uno.Enum„©“ƒ5com.sun.star.uno.Exception©“¸€¶com.sun.star.uno.IBridge†©”n¦com.sun.star.uno.IEnvironment†©–Å"com.sun.star.uno.IFieldDescription†©—Ù€ com.sun.star.uno.IMapping†©˜yi#com.sun.star.uno.IMemberDescription†©˜â€•#com.sun.star.uno.IMethodDescription†©™wB com.sun.star.uno.IQueryInterface†©š¹€ !com.sun.star.uno.ITypeDescription†©›Y‚‘!com.sun.star.uno.MappingException©êp!com.sun.star.uno.RuntimeException©žZ€½"com.sun.star.uno.SecurityException©Ÿpcom.sun.star.uno.Type©Ÿ‡„Þcom.sun.star.uno.TypeClass©¤eˆ8com.sun.star.uno.Uik©¬€Ñcom.sun.star.uno.Union©­nXcom.sun.star.uno.UnoRuntime©­Æ„ºcom.sun.star.uno.WeakReference©²€pcom.sun.star.uno.XAdapter†©²ðcom.sun.star.uno.XAggregation†©³ó€Ú"com.sun.star.uno.XComponentContext†©´Í€è com.sun.star.uno.XCurrentContext†©µµ€¦com.sun.star.uno.XInterface†©¶[Ncom.sun.star.uno.XNamingService†©¶©ocom.sun.star.uno.XReference†©¸com.sun.star.uno.XWeak†©¸—€™"com.sun.star.util.logging.LogLevel†©¹0€”!com.sun.star.util.logging.XLogger†©¹Ä['com.sun.star.util.logging.XLoggerRemote†©»€'com.sun.star.util.AliasProgrammaticPair©¼Ÿ€¿"com.sun.star.util.AtomClassRequest©½^€ž!com.sun.star.util.AtomDescription©½ü€Ÿ com.sun.star.util.CellProtection©¾›€âcom.sun.star.util.ChangesEvent©¿},$com.sun.star.util.CloseVetoException©À©i!com.sun.star.util.DataEditorEvent©Á€Ï%com.sun.star.util.DataEditorEventType©Áácom.sun.star.util.Date©Âû€žcom.sun.star.util.DateTime©Ã™com.sun.star.util.DateTimeRange©Äª‚#com.sun.star.util.DiskFullException©Æ®pcom.sun.star.util.ElementChange©Ç€ò!com.sun.star.util.FileIOException©Èi0com.sun.star.util.MalformedNumberFormatException©Èy€¸com.sun.star.util.MeasureUnit†©É1!com.sun.star.util.ModeChangeEvent©ÊL€¨%com.sun.star.util.NotNumericException©Êôicom.sun.star.util.NumberFormat†©Ë]€û"com.sun.star.util.SearchAlgorithms©ÌX_com.sun.star.util.SearchFlags†©Í·€Ëcom.sun.star.util.SearchOptions©Î‚ïcom.sun.star.util.SearchResult©Ðq€écom.sun.star.util.SortField©ÑZ€ácom.sun.star.util.SortFieldType©Ò;Vcom.sun.star.util.Time©Ó‘€Écom.sun.star.util.URL©ÔZ‚Mcom.sun.star.util.VetoException©Ö§icom.sun.star.util.XArchiver†©×Äcom.sun.star.util.XAtomServer†©ØÔ° com.sun.star.util.XCancelManager†©Ú„€îcom.sun.star.util.XCancellable†©Ûr~com.sun.star.util.XChainable†©Ûðocom.sun.star.util.XChangesBatch†©Ý_ "com.sun.star.util.XChangesListener†©Þh€®"com.sun.star.util.XChangesNotifier†©ß€øcom.sun.star.util.XChangesSet†©à€ªcom.sun.star.util.XCloneable†©à¸€›#com.sun.star.util.XCloseBroadcaster†©áS€ð com.sun.star.util.XCloseListener†©âCcom.sun.star.util.XCloseable†©ãY€¶com.sun.star.util.XDataEditor†©ä_%com.sun.star.util.XDataEditorListener†©ån€² com.sun.star.util.XFlushListener†©æ €¥com.sun.star.util.XFlushable†©æÅcom.sun.star.util.XImportable†©çÇ€îcom.sun.star.util.XIndent†©èµ€£com.sun.star.util.XLinkUpdate†©éX€ƒ#com.sun.star.util.XLocalizedAliases†©éÛ„ƒ com.sun.star.util.XMacroExpander†©î^€Ðcom.sun.star.util.XMergeable†©ï.€£,com.sun.star.util.XModeChangeApproveListener†©ïÑ€Ô(com.sun.star.util.XModeChangeBroadcaster†©ð¥‚%com.sun.star.util.XModeChangeListener†©òª€­com.sun.star.util.XModeSelector†©óW3com.sun.star.util.XModifiable†©ôŠ€Û$com.sun.star.util.XModifyBroadcaster†©õe€ô!com.sun.star.util.XModifyListener†©öY€¦(com.sun.star.util.XNumberFormatPreviewer†©öÿ»$com.sun.star.util.XNumberFormatTypes†©øº— com.sun.star.util.XNumberFormats†©úQ‚Ô(com.sun.star.util.XNumberFormatsSupplier†©ý%€ã"com.sun.star.util.XNumberFormatter†©þ‚ý"com.sun.star.util.XPropertyReplace†ª‚lcom.sun.star.util.XProtectable†ªq"com.sun.star.util.XRefreshListener†ªu€§com.sun.star.util.XRefreshable†ª $com.sun.star.util.XReplaceDescriptor†ª(€Ícom.sun.star.util.XReplaceable†ªõ€î#com.sun.star.util.XSearchDescriptor†ªã€Çcom.sun.star.util.XSearchable†ªª¬%com.sun.star.util.XSimpleErrorHandler†ª
+V€šcom.sun.star.util.XSortable†ª
+ð€Ý%com.sun.star.util.XStringAbbreviation†ª Í€Ñcom.sun.star.util.XStringEscape†ª ž7 com.sun.star.util.XStringMapping†ª Õ€™%com.sun.star.util.XStringSubstitution†ªncom.sun.star.util.XStringWidth†ª €›com.sun.star.util.XTextSearch†ª¦Rcom.sun.star.util.XTimeStamped†ªø€!com.sun.star.util.XURLTransformer†ªˆc"com.sun.star.util.XUniqueIDFactory†ª뀒com.sun.star.util.XUpdatable†ª}~"com.sun.star.view.DocumentZoomType†ªû€‚com.sun.star.view.PaperFormatª}‚€"com.sun.star.view.PaperOrientationªýcom.sun.star.view.PrintJobEventª€Æ com.sun.star.view.PrintableStateªÛ‚X%com.sun.star.view.PrintableStateEventª3€Æ com.sun.star.view.XControlAccess†ªù€ècom.sun.star.view.XLineCursor†ªá€ócom.sun.star.view.XPrintJob†ªÔ&com.sun.star.view.XPrintJobBroadcaster†ªñ€ü#com.sun.star.view.XPrintJobListener†ª 퀭com.sun.star.view.XPrintPreview†ª!š€å(com.sun.star.view.XPrintSettingsSupplier†ª"€£com.sun.star.view.XPrintable†ª#"g'com.sun.star.view.XPrintableBroadcaster†ª$‰ \ No newline at end of file
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/Bundle.properties
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/Bundle.properties
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/Bundle_en_US.properties b/scripting/java/org/openoffice/netbeans/modules/office/Bundle_en_US.properties
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/Bundle_en_US.properties
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java
new file mode 100644
index 000000000000..a4863b271b42
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.util.Vector;
+import java.util.Enumeration;
+
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.RequestProcessor;
+import org.openide.actions.BuildAllAction;
+
+import org.openide.compiler.Compiler;
+import org.openide.compiler.CompilerJob;
+import org.openide.compiler.CompilerTask;
+
+import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker;
+
+public class BuildParcelAction extends BuildAllAction {
+ public String getName() {
+ return "Build";
+ }
+
+ protected void performAction(Node[] activatedNodes) {
+ FrameworkJarChecker.mountDependencies();
+
+ for (int i = 0; i < activatedNodes.length; i++) {
+ Vector v = new Vector(1);
+ v.addElement(activatedNodes[i]);
+
+ CompilerJob job = createJob(v.elements(), Compiler.DEPTH_INFINITE);
+ CompilerTask task = job.start();
+ task.waitFinished();
+
+ if (task.isSuccessful()) {
+ ParcelFolderCookie cookie = (ParcelFolderCookie)
+ activatedNodes[i].getCookie(ParcelFolderCookie.class);
+
+ if (cookie != null)
+ cookie.generate();
+ }
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java
new file mode 100644
index 000000000000..3d5bbc1c0445
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.openide.nodes.Node;
+import org.openide.actions.CompileAllAction;
+
+import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker;
+
+public class CompileParcelAction extends CompileAllAction {
+ public String getName() {
+ return "Compile";
+ }
+
+ protected void performAction(Node[] activatedNodes) {
+ FrameworkJarChecker.mountDependencies();
+ super.performAction(activatedNodes);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java
new file mode 100644
index 000000000000..b6b5c88809b2
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.RequestProcessor;
+import org.openide.util.actions.CookieAction;
+
+import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker;
+
+public class ConfigureParcelAction extends CookieAction {
+
+ public java.lang.String getName() {
+ return "Configure";
+ }
+
+ protected java.lang.Class[] cookieClasses() {
+ return new Class[] {ParcelFolderCookie.class};
+ }
+
+ protected int mode() {
+ return CookieAction.MODE_EXACTLY_ONE;
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ protected void performAction(final Node[] activatedNodes)
+ {
+ FrameworkJarChecker.mountDependencies();
+
+ RequestProcessor.getDefault().post(new Runnable() {
+ public void run() {
+ for (int i = 0; i < activatedNodes.length; i++) {
+ ParcelFolderCookie pfc = (ParcelFolderCookie)
+ activatedNodes[i].getCookie(ParcelFolderCookie.class);
+ if (pfc != null)
+ pfc.configure();
+ }
+ }
+ });
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java
new file mode 100644
index 000000000000..f66922801a22
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java
@@ -0,0 +1,244 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.swing.JMenuItem;
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+import org.openide.awt.Actions;
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+import org.openide.util.actions.*;
+import org.openide.awt.JMenuPlus;
+
+import org.openoffice.idesupport.SVersionRCFile;
+import org.openoffice.idesupport.OfficeInstallation;
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.idesupport.LocalOffice;
+
+import org.openoffice.netbeans.modules.office.utils.NagDialog;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+
+public class DeployParcelAction extends CookieAction implements Presenter.Popup {
+
+ private static final String BROWSE_LABEL = "Office Document...";
+ private static final String DEPLOY_LABEL = "Deploy To";
+
+ public String getName () {
+ return DEPLOY_LABEL;
+ }
+
+ public HelpCtx getHelpCtx () {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ public JMenuItem getPopupPresenter() {
+ JMenuPlus menu = new JMenuPlus(DEPLOY_LABEL);
+ JMenuItem item, user, share;
+ final OfficeInstallation oi = OfficeSettings.getDefault().getOfficeDirectory();
+
+ ActionListener listener = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JMenuItem choice = (JMenuItem)e.getSource();
+ String label = choice.getText();
+
+ Node[] nodes = getActivatedNodes();
+ final ParcelCookie parcelCookie =
+ (ParcelCookie)nodes[0].getCookie(ParcelCookie.class);
+
+ File target = new File(oi.getPath(File.separator + label +
+ File.separator + "Scripts"));
+
+ File langdir = new File(target, parcelCookie.getLanguage());
+
+ if (!langdir.exists()) {
+ boolean response = askIfCreateDirectory(langdir);
+ if (response == false) {
+ return;
+ }
+ }
+
+ deploy(target);
+ }
+ };
+
+ user = new JMenuItem("user");
+ user.addActionListener(listener);
+
+ share = new JMenuItem("share");
+ share.addActionListener(listener);
+
+ item = new JMenuPlus(oi.getName());
+ item.add(user);
+ item.add(share);
+ menu.add(item);
+
+ menu.addSeparator();
+ item = new JMenuItem(BROWSE_LABEL);
+ item.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ File target = getTargetFile();
+ if (target == null)
+ return;
+ deploy(target);
+ }
+ });
+ menu.add(item);
+
+ return menu;
+ }
+
+ protected int mode () {
+ return MODE_ONE;
+ }
+
+ protected Class[] cookieClasses () {
+ return new Class[] { ParcelCookie.class };
+ }
+
+ protected void performAction (Node[] activatedNodes) {
+ // do nothing, should not happen
+ }
+
+ private void deploy(final File target) {
+ Node[] nodes = getActivatedNodes();
+ final ParcelCookie parcelCookie =
+ (ParcelCookie)nodes[0].getCookie(ParcelCookie.class);
+
+ RequestProcessor.getDefault().post(new Runnable() {
+ public void run() {
+ boolean result = parcelCookie.deploy(target);
+
+ if (result == true && target.isDirectory()) {
+ showNagDialog();
+ // refreshOffice((String)versions.get(label));
+ }
+ }
+ });
+ }
+
+ private boolean askIfCreateDirectory(File directory) {
+ String message = directory.getAbsolutePath() + " does not exist. " +
+ "Do you want to create it now?";
+
+ NotifyDescriptor d = new NotifyDescriptor.Confirmation(
+ message, NotifyDescriptor.OK_CANCEL_OPTION);
+ TopManager.getDefault().notify(d);
+
+ if (d.getValue() == NotifyDescriptor.CANCEL_OPTION)
+ return false;
+
+ boolean result;
+ try {
+ result = directory.mkdirs();
+ }
+ catch (SecurityException se) {
+ result = false;
+ }
+
+ if (result == false) {
+ String tmp = "Error creating: " + directory.getAbsolutePath();
+ NotifyDescriptor d2 = new NotifyDescriptor.Message(
+ tmp, NotifyDescriptor.ERROR_MESSAGE);
+ TopManager.getDefault().notify(d2);
+ }
+ return result;
+ }
+
+ private void refreshOffice(String path) {
+ ClassLoader syscl = TopManager.getDefault().currentClassLoader();
+ LocalOffice office = LocalOffice.create(syscl, path, 8100);
+ office.refreshStorage("file://" + path + "/program/../user");
+ office.disconnect();
+ }
+
+ private void showNagDialog() {
+ String message = "If you currently have Office running you will " +
+ "need to click on the Tools/Scripting Add-on's/Refresh All Scripts " +
+ " menu item in Office so that the scripts in this parcel can be detected.";
+
+ OfficeSettings settings = OfficeSettings.getDefault();
+
+ if (settings.getWarnAfterDirDeploy() == true) {
+ NagDialog warning = NagDialog.createInformationDialog(
+ message, "Show this message in future", true);
+
+ warning.show();
+
+ if (warning.getState() == false)
+ settings.setWarnAfterDirDeploy(false);
+ }
+ }
+
+ private File getTargetFile() {
+ File target = null;
+
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle("Deploy Parcel To Office Document");
+ chooser.setApproveButtonText("Deploy");
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ chooser.setFileFilter(new FileFilter() {
+ public boolean accept(File file) {
+ if (file.isDirectory() ||
+ file.getName().endsWith(".sxw") ||
+ file.getName().endsWith(".sxc") ||
+ file.getName().endsWith(".sxd") ||
+ file.getName().endsWith(".sxi"))
+ return true;
+ return false;
+ }
+
+ public String getDescription() {
+ return "Office Documents";
+ }
+ });
+
+ int result = chooser.showDialog(null, null);
+
+ if (result == JFileChooser.APPROVE_OPTION) {
+ target = chooser.getSelectedFile();
+ }
+ return target;
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java
new file mode 100644
index 000000000000..775caf05bd51
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.RequestProcessor;
+import org.openide.util.actions.CookieAction;
+
+/**
+ *
+ * @author adams
+ * @version 1.0
+ */
+public class MountDocumentAction extends CookieAction
+{
+ public MountDocumentAction()
+ {
+ }
+
+ public java.lang.String getName()
+ {
+ return "Mount Document"; //NOI18N
+ }
+
+ public HelpCtx getHelpCtx()
+ {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ protected int mode()
+ {
+ // enable duplication for as many qualifying nodes as are selected:
+ return CookieAction.MODE_ALL;
+ }
+
+ protected java.lang.Class[] cookieClasses()
+ {
+ // just the DuplicateCookie:
+ return new Class[] {OfficeDocumentCookie.class};
+ }
+
+ protected void performAction(final Node[] activatedNodes)
+ {
+ RequestProcessor.getDefault().post(new Runnable()
+ {
+ public void run()
+ {
+ for (int i=0; i<activatedNodes.length; i++)
+ {
+ OfficeDocumentCookie cookie = (OfficeDocumentCookie)activatedNodes[i].getCookie(OfficeDocumentCookie.class);
+ if (cookie != null)
+ {
+ cookie.mount();
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java
new file mode 100644
index 000000000000..7b07c2d098f3
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.RequestProcessor;
+import org.openide.util.actions.CookieAction;
+
+/**
+ *
+ * @author adams
+ * @version 1.0
+ */
+public class MountParcelAction extends CookieAction
+{
+ public MountParcelAction()
+ {
+ }
+
+ public java.lang.String getName()
+ {
+ return "Mount Parcel"; //NOI18N
+ }
+
+ public HelpCtx getHelpCtx()
+ {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ protected int mode()
+ {
+ // enable duplication for as many qualifying nodes as are selected:
+ return CookieAction.MODE_ALL;
+ }
+
+ protected java.lang.Class[] cookieClasses()
+ {
+ return new Class[] {ParcelCookie.class};
+ }
+
+ protected void performAction(final Node[] activatedNodes)
+ {
+ RequestProcessor.getDefault().post(new Runnable()
+ {
+ public void run()
+ {
+ for (int i=0; i<activatedNodes.length; i++)
+ {
+ ParcelCookie mpc = (ParcelCookie)activatedNodes[i].getCookie(ParcelCookie.class);
+ if (mpc != null)
+ {
+ mpc.mount();
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java
new file mode 100644
index 000000000000..2799b08f2af1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.util.Enumeration;
+import javax.swing.event.ChangeListener;
+import org.openide.nodes.Node;
+
+public interface OfficeDocumentCookie extends Node.Cookie
+{
+ public void mount();
+ public Enumeration getParcels();
+ public void removeParcel(String name);
+
+ public void addChangeListener(ChangeListener cl);
+ public void removeChangeListener(ChangeListener cl);
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java
new file mode 100644
index 000000000000..0be80d6786b7
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.IOException;
+import java.io.File;
+import java.beans.PropertyVetoException;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+
+import org.openide.ErrorManager;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.FileChangeListener;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileAttributeEvent;
+import org.openide.filesystems.FileRenameEvent;
+import org.openide.cookies.OpenCookie;
+
+import org.openoffice.idesupport.OfficeDocument;
+
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.netbeans.modules.office.loader.OfficeDocumentDataObject;
+import org.openoffice.netbeans.modules.office.utils.ZipMounter;
+import org.openoffice.netbeans.modules.office.utils.ManifestParser;
+
+public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie, FileChangeListener
+{
+ protected OfficeDocumentDataObject dataObj;
+ private boolean isMounted = false;
+ private OfficeDocument document;
+ private Set listeners;
+
+ public OfficeDocumentSupport(OfficeDocumentDataObject dataObj) {
+ this.dataObj = dataObj;
+ FileObject fo = dataObj.getPrimaryFile();
+ try {
+ this.document = new OfficeDocument(FileUtil.toFile(fo));
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ fo.addFileChangeListener(this);
+ }
+
+ public void mount() {
+ File file = FileUtil.toFile(dataObj.getPrimaryFile());
+
+ try {
+ ZipMounter.getZipMounter().mountZipFile(file);
+ isMounted = true;
+ }
+ catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ }
+ catch (PropertyVetoException pve) {
+ ErrorManager.getDefault().notify(pve);
+ }
+ }
+
+ public void open () {
+ File file = FileUtil.toFile(dataObj.getPrimaryFile());
+
+ OfficeSettings settings = OfficeSettings.getDefault();
+ File soffice = new File(settings.getOfficeDirectory().getPath(
+ File.separator + "soffice"));
+
+ try {
+ Process p = Runtime.getRuntime ().exec (new String[] {
+ soffice.getAbsolutePath(), file.getAbsolutePath ()
+ });
+ } catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ }
+ }
+
+ public Enumeration getParcels() {
+ return document.getParcels();
+ }
+
+ public void removeParcel(String name) {
+ document.removeParcel(name);
+ dataObj.getPrimaryFile().refresh(true);
+ }
+
+ public void addChangeListener(ChangeListener cl) {
+ if (listeners == null)
+ listeners = new HashSet();
+
+ listeners.add(cl);
+ }
+
+ public void removeChangeListener(ChangeListener cl) {
+ if (listeners == null)
+ return;
+
+ listeners.remove(cl);
+ }
+
+ public void fileChanged(FileEvent fe) {
+ if (listeners != null) {
+ Iterator iter = listeners.iterator();
+
+ while (iter.hasNext())
+ ((ChangeListener)iter.next()).stateChanged(new ChangeEvent(this));
+ }
+ }
+
+ public void fileAttributeChanged(FileAttributeEvent fe) {}
+ public void fileDataCreated(FileEvent fe) {}
+ public void fileDeleted(FileEvent fe) {}
+ public void fileFolderCreated(FileEvent fe) {}
+ public void fileRenamed(FileRenameEvent fe) {}
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java
new file mode 100644
index 000000000000..23ace1c11160
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.File;
+import org.openide.nodes.Node;
+
+public interface ParcelCookie extends Node.Cookie
+{
+ public File getFile();
+
+ public String getLanguage();
+
+ public void mount();
+
+ public boolean deploy(File target);
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java
new file mode 100644
index 000000000000..5f9f67dcfe60
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.IOException;
+
+import org.openide.cookies.*;
+import org.openide.filesystems.FileLock;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataObject;
+import org.openide.text.DataEditorSupport;
+import org.openide.windows.CloneableOpenSupport;
+
+import org.openoffice.netbeans.modules.office.loader.ParcelDescriptorDataObject;
+
+/** Support for editing a data object as text.
+ *
+ * @author tomaso
+ */
+// Replace OpenCookie with EditCookie or maybe ViewCookie as desired:
+public class ParcelDescriptorEditorSupport extends DataEditorSupport implements EditorCookie, OpenCookie, CloseCookie, PrintCookie {
+
+ /** Create a new editor support.
+ * @param obj the data object whose primary file will be edited as text
+ */
+ public ParcelDescriptorEditorSupport(ParcelDescriptorDataObject obj) {
+ super(obj, new ParcelDescriptorEnv(obj));
+ // Set a MIME type as needed, e.g.:
+ setMIMEType("text/xml");
+ }
+
+ /** Called when the document is modified.
+ * Here, adding a save cookie to the object and marking it modified.
+ * @return true if the modification is acceptable
+ */
+ protected boolean notifyModified() {
+ if (!super.notifyModified()) {
+ return false;
+ }
+ ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject();
+ if (obj.getCookie(SaveCookie.class) == null) {
+ obj.setModified(true);
+ // You must implement this method on the object:
+ obj.addSaveCookie(new Save());
+ }
+ return true;
+ }
+
+ /** Called when the document becomes unmodified.
+ * Here, removing the save cookie from the object and marking it unmodified.
+ */
+ protected void notifyUnmodified() {
+ ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject();
+ SaveCookie save = (SaveCookie)obj.getCookie(SaveCookie.class);
+ if (save != null) {
+ // You must implement this method on the object:
+ obj.removeSaveCookie(save);
+ obj.setModified(false);
+ }
+ super.notifyUnmodified();
+ }
+
+ /** A save cookie to use for the editor support.
+ * When saved, saves the document to disk and marks the object unmodified.
+ */
+ private class Save implements SaveCookie {
+ public void save() throws IOException {
+ saveDocument();
+ getDataObject().setModified(false);
+ }
+ }
+
+ /** A description of the binding between the editor support and the object.
+ * Note this may be serialized as part of the window system and so
+ * should be static, and use the transient modifier where needed.
+ */
+ private static class ParcelDescriptorEnv extends DataEditorSupport.Env {
+
+ //private static final long serialVersionUID = ...L;
+
+ /** Create a new environment based on the data object.
+ * @param obj the data object to edit
+ */
+ public ParcelDescriptorEnv(ParcelDescriptorDataObject obj) {
+ super(obj);
+ }
+
+ /** Get the file to edit.
+ * @return the primary file normally
+ */
+ protected FileObject getFile() {
+ return getDataObject().getPrimaryFile();
+ }
+
+ /** Lock the file to edit.
+ * Should be taken from the file entry if possible, helpful during
+ * e.g. deletion of the file.
+ * @return a lock on the primary file normally
+ * @throws IOException if the lock could not be taken
+ */
+ protected FileLock takeLock() throws IOException {
+ return ((ParcelDescriptorDataObject)getDataObject()).getPrimaryEntry().takeLock();
+ }
+
+ /** Find the editor support this environment represents.
+ * Note that we have to look it up, as keeping a direct
+ * reference would not permit this environment to be serialized.
+ * @return the editor support
+ */
+ public CloneableOpenSupport findCloneableOpenSupport() {
+ return (ParcelDescriptorEditorSupport)getDataObject().getCookie(ParcelDescriptorEditorSupport.class);
+ }
+
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java
new file mode 100644
index 000000000000..925a451efe21
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.w3c.dom.NodeList;
+import javax.swing.event.ChangeListener;
+import org.openide.nodes.Node;
+
+public interface ParcelDescriptorParserCookie extends Node.Cookie
+{
+ // should return a NodeList of org.w3c.dom.Element
+ public NodeList getScriptElements();
+
+ public void addChangeListener(ChangeListener cl);
+
+ public void removeChangeListener(ChangeListener cl);
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java
new file mode 100644
index 000000000000..aae9c51b5726
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.*;
+import java.util.*;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.openide.filesystems.*;
+import org.openide.xml.XMLUtil;
+
+public class ParcelDescriptorParserSupport
+ implements ParcelDescriptorParserCookie, FileChangeListener
+{
+ private FileObject fo;
+ private Document document;
+ private Set listeners;
+
+ public ParcelDescriptorParserSupport(FileObject fo)
+ {
+ this.fo = fo;
+ fo.addFileChangeListener(this);
+ }
+
+ private synchronized void parseFile()
+ {
+ File file = FileUtil.toFile(fo);
+ InputSource is;
+
+ try {
+ is = new InputSource(new FileInputStream(file));
+ }
+ catch (FileNotFoundException fnfe) {
+ System.out.println("Couldn't find file: " + file.getName());
+ return;
+ }
+
+ document = null;
+ try {
+ document = XMLUtil.parse(is, false, false, null, null);
+ }
+ catch (IOException ioe) {
+ System.out.println("IO Error parsing file: " + file.getName());
+ }
+ catch (SAXException se) {
+ System.out.println("Sax Error parsing file: " + file.getName());
+ }
+ }
+
+ public synchronized NodeList getScriptElements()
+ {
+ if (document == null)
+ parseFile();
+
+ if (document != null)
+ return document.getElementsByTagName("script");
+ return null;
+ }
+
+ public void addChangeListener(ChangeListener cl) {
+ if (listeners == null)
+ listeners = new HashSet();
+
+ listeners.add(cl);
+ }
+
+ public void removeChangeListener(ChangeListener cl) {
+ if (listeners == null)
+ return;
+
+ listeners.remove(cl);
+ }
+
+ public void fileChanged(FileEvent fe) {
+ parseFile();
+
+ if (listeners != null) {
+ Iterator iter = listeners.iterator();
+
+ while (iter.hasNext())
+ ((ChangeListener)iter.next()).stateChanged(new ChangeEvent(this));
+ }
+ }
+
+ public void fileAttributeChanged(FileAttributeEvent fe) {}
+ public void fileDataCreated(FileEvent fe) {}
+ public void fileDeleted(FileEvent fe) {}
+ public void fileFolderCreated(FileEvent fe) {}
+ public void fileRenamed(FileRenameEvent fe) {}
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java
new file mode 100644
index 000000000000..714204ffde41
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import org.openide.nodes.Node;
+
+public interface ParcelFolderCookie extends Node.Cookie
+{
+ public void generate();
+
+ public boolean configure();
+
+ public void setClasspath(String value);
+ public String getClasspath();
+
+ public String getLanguage();
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java
new file mode 100644
index 000000000000..6644b0e66d44
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.util.Vector;
+import java.util.StringTokenizer;
+
+import java.io.*;
+import java.beans.PropertyVetoException;
+import java.awt.Dialog;
+
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.openide.TopManager;
+import org.openide.DialogDescriptor;
+import org.openide.ErrorManager;
+import org.openide.xml.XMLUtil;
+import org.openide.execution.NbClassPath;
+
+import org.openide.cookies.OpenCookie;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataNode;
+
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.JarFileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.Repository;
+
+import org.openide.nodes.*;
+import org.openide.windows.OutputWriter;
+
+import org.openoffice.netbeans.modules.office.loader.ParcelFolder;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.netbeans.modules.office.utils.ManifestParser;
+
+import com.sun.star.script.framework.container.ParcelDescriptor;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.idesupport.filter.FileFilter;
+import org.openoffice.idesupport.ui.ConfigurePanel;
+
+public class ParcelFolderSupport implements ParcelFolderCookie
+{
+ protected ParcelFolder parcelFolder;
+ private ConfigurePanel configuror = null;
+
+ public ParcelFolderSupport(ParcelFolder parcelFolder) {
+ this.parcelFolder = parcelFolder;
+ }
+
+ public String getLanguage() {
+ ParcelDescriptor descriptor = getParcelDescriptor();
+
+ if (descriptor == null) {
+ return "";
+ }
+ else {
+ return descriptor.getLanguage();
+ }
+ }
+
+ public String getClasspath() {
+ ParcelDescriptor descriptor = getParcelDescriptor();
+
+ if (descriptor == null) {
+ return "";
+ }
+ else {
+ return descriptor.getLanguageProperty("classpath");
+ }
+ }
+
+ public void setClasspath(String value) {
+ ParcelDescriptor descriptor = getParcelDescriptor();
+
+ if (descriptor != null) {
+ descriptor.setLanguageProperty("classpath", value);
+
+ try {
+ descriptor.write();
+ }
+ catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ }
+ }
+ }
+
+ private ParcelDescriptor getParcelDescriptor() {
+ FileObject primary = parcelFolder.getPrimaryFile();
+
+ File contents = FileUtil.toFile(
+ primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
+
+ return ParcelDescriptor.getParcelDescriptor(contents);
+ }
+
+ public void generate() {
+ ParcelFolder.ParcelFolderNode node =
+ (ParcelFolder.ParcelFolderNode)parcelFolder.getNodeDelegate();
+
+ FileObject parcelBase = parcelFolder.getPrimaryFile();
+ FileObject contentsBase =
+ parcelBase.getFileObject(ParcelZipper.CONTENTS_DIRNAME);
+
+ File parcelDir = FileUtil.toFile(parcelBase);
+ File contentsDir = FileUtil.toFile(contentsBase);
+
+ // The Location property is not displayed so just
+ // use the Parcel Recipe directory as the target directory
+ File targetDir = FileUtil.toFile(parcelFolder.getPrimaryFile());
+ File targetfile = new File(targetDir, File.separator +
+ parcelBase.getName() + "." + ParcelZipper.PARCEL_EXTENSION);
+
+ boolean proceed = configure();
+ if (proceed == false) {
+ return;
+ }
+
+ final OutputWriter out =
+ ParcelSupport.getOutputWindowWriter(parcelDir.getName() + " (generating)");
+ try {
+ out.println("Generating: " + parcelDir.getName(), null);
+ ParcelZipper.getParcelZipper().zipParcel(contentsDir, targetfile, node.getFileFilter());
+ out.println("\nGENERATION SUCCESSFUL.");
+ out.println("\nRight click on the generated parcel to deploy it");
+
+ if (targetDir.equals(parcelDir)) {
+ parcelBase.refresh(true);
+ }
+ }
+ catch (IOException ioe) {
+ out.println("GENERATION FAILED: reason: " + ioe.getClass().getName() + ": "+ ioe.getMessage());
+ }
+ finally
+ {
+ if( out != null)
+ {
+ out.close();
+ }
+ }
+ }
+
+ public boolean configure() {
+
+ FileObject primary = parcelFolder.getPrimaryFile();
+
+ File contents = FileUtil.toFile(
+ primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
+
+ Vector classpath = getConfigureClasspath();
+ classpath.addElement(contents.getAbsolutePath());
+
+ try {
+ ParcelDescriptor descriptor = getParcelDescriptor();
+ if (descriptor == null) {
+ descriptor = ParcelDescriptor.createParcelDescriptor(contents);
+ }
+
+ if (configuror == null) {
+ configuror = new ConfigurePanel(contents.getAbsolutePath(),
+ classpath, descriptor);
+ }
+ else {
+ configuror.reload(contents.getAbsolutePath(), classpath,
+ descriptor);
+ }
+ }
+ catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ return false;
+ }
+
+ DialogDescriptor dd = new DialogDescriptor(configuror,
+ ConfigurePanel.DIALOG_TITLE);
+
+ Dialog dialog = TopManager.getDefault().createDialog(dd);
+ dialog.show();
+
+ if (dd.getValue() == DialogDescriptor.OK_OPTION) {
+ try {
+ ParcelDescriptor descriptor = configuror.getConfiguration();
+ descriptor.write();
+ }
+ catch (Exception e) {
+ ErrorManager.getDefault().notify(e);
+ }
+ }
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private Vector getConfigureClasspath() {
+ Vector result = new Vector();
+
+ String classpath = NbClassPath.createRepositoryPath().getClassPath();
+ if ( System.getProperty( "os.name" ).startsWith( "Windows" ) )
+ {
+ // under windows path is enclosed by quotes
+ // e.g. C:\path1;d:\path2 would appear as
+ // "C:\path1;d:\path2" therefore for us
+ // we need to remove 1 character at either end of the
+ // classpath returned from "createRepositoryPath().getClassPath()"
+
+ if ( classpath.startsWith("\"") && classpath.endsWith("\"") )
+ {
+ StringBuffer buff = new StringBuffer(classpath);
+ buff.delete(0,1);
+ buff.delete( buff.length() - 1, buff.length() );
+ classpath = buff.toString();
+ }
+ }
+ StringTokenizer tokens = new StringTokenizer(classpath, File.pathSeparator);
+
+ while(tokens.hasMoreTokens())
+ result.addElement(tokens.nextToken());
+
+ OfficeSettings settings = OfficeSettings.getDefault();
+ File classesDir = new File(settings.getOfficeDirectory().getPath(
+ File.separator + "program" + File.separator + "classes"));
+ File[] jarfiles = classesDir.listFiles();
+
+ for (int i = 0; i < jarfiles.length; i++)
+ result.addElement(jarfiles[i].getAbsolutePath());
+
+ return result;
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java
new file mode 100644
index 000000000000..5c9fa8b02789
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.beans.PropertyVetoException;
+import java.util.Enumeration;
+import java.util.Calendar;
+
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+import org.openide.windows.OutputWriter;
+import org.openide.windows.InputOutput;
+
+import org.openide.ErrorManager;
+import org.openide.nodes.Node;
+import org.openide.filesystems.Repository;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.FileEvent;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.netbeans.modules.office.utils.NagDialog;
+import org.openoffice.netbeans.modules.office.utils.ZipMounter;
+import org.openoffice.netbeans.modules.office.utils.ManifestParser;
+
+public class ParcelSupport implements ParcelCookie
+{
+ private FileObject fo;
+ private ParcelZipper zipper = ParcelZipper.getParcelZipper();
+ private String language = null;
+
+ public ParcelSupport(FileObject fo) {
+ this.fo = fo;
+ }
+
+ public File getFile() {
+ return FileUtil.toFile(fo);
+ }
+
+ public String getLanguage() {
+ if (language == null) {
+ try {
+ language = zipper.getParcelLanguage(getFile());
+ }
+ catch (IOException ioe) {
+ return null;
+ }
+ }
+ return language;
+ }
+
+ public void mount()
+ {
+ File parcel = FileUtil.toFile(fo);
+
+ if (parcel != null) {
+ try {
+ ZipMounter.getZipMounter().mountZipFile(parcel);
+ }
+ catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ }
+ catch (PropertyVetoException pve) {
+ ErrorManager.getDefault().notify(pve);
+ }
+ }
+ }
+
+ public boolean deploy(File target) {
+ File source = FileUtil.toFile(fo);
+
+ if (!target.isDirectory()) {
+ OfficeSettings settings = OfficeSettings.getDefault();
+ String message = "If you already have this document open in " +
+ "Office, please close it before continuing. Click OK to " +
+ "continue deployment.";
+
+ if (settings.getWarnBeforeDocDeploy() == true) {
+ NagDialog warning = NagDialog.createConfirmationDialog(
+ message, "Show this message in future", true);
+
+ boolean result = warning.show();
+
+ if (warning.getState() == false)
+ settings.setWarnBeforeDocDeploy(false);
+
+ if (result == false)
+ return false;
+ }
+ }
+
+ OutputWriter out =
+ getOutputWindowWriter(fo.getName() + " (deploying)");
+
+ try {
+ if (zipper.isOverwriteNeeded(source, target) == true)
+ if (promptForOverwrite(source, target) == false)
+ return false;
+ }
+ catch (IOException ioe) {
+ out.println("DEPLOYMENT FAILED: reason: " +
+ ioe.getClass().getName() + ": "+ ioe.getMessage());
+ return false;
+ }
+
+ try {
+ out.println("Deploying: " + fo.getName() +
+ "\nTo: " + target.getAbsolutePath(), null);
+
+ zipper.deployParcel(source, target);
+
+ out.println("\nDEPLOYMENT SUCCESSFUL.");
+
+ FileObject[] fileobjs = FileUtil.fromFile(target);
+ if (fileobjs != null) {
+ for (int i = 0; i < fileobjs.length; i++)
+ fileobjs[i].refresh(true);
+ }
+ }
+ catch (IOException ioe) {
+ out.println("DEPLOYMENT FAILED: reason: " +
+ ioe.getClass().getName() + ": "+ ioe.getMessage());
+ return false;
+ }
+ finally {
+ if( out != null)
+ out.close();
+ }
+ return true;
+ }
+
+ public static OutputWriter getOutputWindowWriter(String title) {
+ InputOutput io = TopManager.getDefault().getIO(title, false);
+ io.setFocusTaken(true);
+ io.setOutputVisible(true);
+
+ OutputWriter out = io.getOut();
+ try {
+ out.reset();
+ }
+ catch( IOException e) {
+ e.printStackTrace(System.err);
+ }
+ out.println(Calendar.getInstance().getTime() + ":\n");
+ return out;
+ }
+
+ private boolean promptForOverwrite(File source, File target) {
+ String message = source.getName() + " has already been deployed " +
+ "to this target. Do you wish to overwrite it?";
+
+ NotifyDescriptor d = new NotifyDescriptor.Confirmation(
+ message, NotifyDescriptor.OK_CANCEL_OPTION);
+ TopManager.getDefault().notify(d);
+
+ if (d.getValue() == NotifyDescriptor.CANCEL_OPTION)
+ return false;
+ else
+ return true;
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties
new file mode 100644
index 000000000000..f776ff9e7933
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties
@@ -0,0 +1,44 @@
+# Filesystems API
+# {0} - root path
+# x-no-translate
+LAB_invalid_file_system=invalid OpenOffice.org document {0}
+# {0} - root path
+LAB_valid_file_system={0}
+# {0} - root path
+EXC_root_dir_does_not_exist=Root directory {0} does not exist.
+# {0} - original name before annotation
+LBL_modified_files={0} <somehow annotated>
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_file_could_not_be_locked={2} could not be locked; it did not exist or was not writable.
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_create_empty_name=Cannot create a file with an empty name.
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_folder_already_exists=Folder {2} already exists.
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_folder_could_not_be_created=Folder {2} could not be created.
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_file_could_not_be_created=File {2} could not be created.
+# {0} - old file name and extension
+# {1} - new file name and extension
+# {2} - display name of filesystem
+# {3} - full path to old file
+# {4} - full path to new file
+EXC_file_could_not_be_renamed=File {3} could not be renamed to {4}.
+# {0} - file name and extension
+# {1} - display name of filesystem
+# {2} - full path to file
+EXC_file_could_not_be_deleted=File {2} could not be deleted.
+PROP_readOnly=Read Only
+HINT_readOnly=Whether this filesystem should be writable, or read-only.
+PROP_document=OpenOffice.org Document
+HINT_document=OpenOffice.org Document (mount point) of this filesystem.
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle_en_US.properties b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle_en_US.properties
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle_en_US.properties
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java
new file mode 100644
index 000000000000..795da90df74f
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java
@@ -0,0 +1,1192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.filesystem;
+
+import java.beans.*;
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+import org.openide.ErrorManager;
+import org.openide.filesystems.*;
+import org.openide.filesystems.FileSystem; // override java.io.FileSystem
+import org.openide.util.NbBundle;
+
+// ISSUES:
+// - This FS saves (updates) the file on 'setDocument' or 'removeNotify'.
+// It has to let the user to decide to update or not.
+//
+// TODOS:
+// - 'Update' action on the mounted document which saves all recent modifications.
+// - To introduce 'scope' editable property to control editable portion of
+// the mounted document.
+// - Acceptable document type identification before mount.
+
+/**
+ * OpenOffice.org Document filesystem.
+ *
+ * @author misha <misha@openoffice.org>
+ */
+public class OpenOfficeDocFileSystem
+ extends AbstractFileSystem
+{
+ public static final String SCRIPTS_ROOT = "Scripts"; // must be a folder
+ public static final String SEPARATOR = "/"; // zip file separator
+
+ private static final int OS_UNKNOWN = 0;
+ private static final int OS_UNIX = 1;
+ private static final int OS_MACOS = 2;
+ private static final int OS_WINDOWS = 3;
+
+ private static final int REFRESH_OFF = -1; // -1 is desabled
+ private static final int REFRESH_TIME = REFRESH_OFF; // (mS)
+ private static final String TMP_FILE_PREF = "sx_";
+ private static final String TMP_FILE_SUFX = ".sxx";
+
+ private transient Map cache; // filesystem cache
+ private transient File docFile; // OpenOffice document
+ private transient ZipFile zipFile;
+
+ private static transient int osType; // type of OS
+
+ private transient ChildrenStrategy childrenStrategy;
+ private transient EditableStrategy editableStrategy;
+
+ private transient boolean isModified; // true if an entry has been removed
+
+ /**
+ * Static constructor.
+ */
+ static {
+ // Identify the type of OS
+ String osname = System.getProperty("os.name");
+ if (osname.startsWith("Mac OS"))
+ osType = OS_MACOS;
+ else if (osname.startsWith("Windows"))
+ osType = OS_WINDOWS;
+ else
+ osType = OS_UNIX;
+ }
+
+ /**
+ * Default constructor. Initializes new OpenOffice filesystem.
+ */
+ public OpenOfficeDocFileSystem()
+ {
+ // Create the filesystem cache
+ cache = new HashMap();
+
+ // Initialize strategies
+ editableStrategy = new EditableStrategy(SCRIPTS_ROOT);
+ childrenStrategy = new ChildrenStrategy();
+
+ // Create and use implementations of filesystem functionality:
+ info = new InfoImpl();
+ change = new ChangeImpl();
+
+ // Handle filesystem.attributes files normally:
+ DefaultAttributes defattr = new DefaultAttributes(
+ info, change, new ListImpl());
+
+ // Handle filesystem.attributes files normally + adds virtual attribute
+ // "java.io.File" that is used in conversion routines FileUtil.toFile and
+ // FileUtil.fromFile
+ //defattr = new InnerAttrs(this, info, change, new ListImpl());
+ // (Otherwise set attr to a special implementation, and use ListImpl for list.)
+ attr = defattr;
+ list = defattr;
+
+ // transfer = new TransferImpl();
+ setRefreshTime(REFRESH_OFF);
+ }
+
+ /**
+ * Constructor. Initializes new OpenOffice filesystem with FS capability.
+ */
+ public OpenOfficeDocFileSystem(FileSystemCapability cap)
+ {
+ this();
+ setCapability(cap);
+ }
+
+ /**
+ * Provides unique signature of an instance of the filesystem.
+ * NOTE: The scope is not a part of the signature so it is impossible
+ * to mount the same archive more then once.
+ */
+ public static String computeSystemName(File file)
+ {
+ return OpenOfficeDocFileSystem.class.getName() + "[" + file + "]";
+ }
+
+ // ----------- PROPERTIES --------------
+
+ /**
+ * Provides the 'human readable' name of the instance of the filesystem.
+ */
+ public String getDisplayName()
+ {
+ if (!isValid())
+ return NbBundle.getMessage(OpenOfficeDocFileSystem.class,
+ "LAB_invalid_file_system", ((docFile != null)? docFile.toString(): ""));
+ else
+ return NbBundle.getMessage(OpenOfficeDocFileSystem.class,
+ "LAB_valid_file_system", docFile.toString());
+ }
+
+ /**
+ * Retrives the 'document' property.
+ */
+ public File getDocument()
+ {
+ return docFile;
+ }
+
+ /**
+ * Sets the 'document' property.
+ */
+ // Bean setter. Changing the OpenOffice document (or in general, the identity
+ // of the root file object) should cause everything using this filesystem
+ // to refresh. The system name must change and refreshRoot should be used
+ // to ensure that everything is correctly updated.
+ public synchronized void setDocument(File file)
+ throws java.beans.PropertyVetoException, java.io.IOException
+ {
+System.out.println("OpenOfficeDocFileSystem.setDocument: file=\"" + file.toString() + "\"");
+ if((file.exists() == false) || (file.isFile() == false)) {
+ IOException ioe = new IOException(
+ file.toString() + " does not exist");
+ ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(
+ OpenOfficeDocFileSystem.class, "EXC_root_dir_does_not_exist",
+ file.toString()));
+ throw ioe;
+ }
+ // update the document
+ try {
+ updateDocument();
+ } catch(IOException ioe) {
+ // cannot save all!!!
+System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
+System.out.println(" file: " + ((docFile != null)? docFile.toString(): ""));
+System.out.println(" exception: " + ioe.getMessage());
+ }
+ // new document type verification!!!
+ closeDocument();
+ // open a new document
+ try {
+ openDocument(file);
+ firePropertyChange(PROP_ROOT, null, refreshRoot());
+ setRefreshTime(REFRESH_TIME);
+ } catch(IOException ioe) {
+ // cannot open a new document!!!
+System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
+System.out.println(" file: " + ((file != null)? file.toString(): ""));
+System.out.println(" exception: " + ioe.getMessage());
+ }
+ }
+
+ /**
+ * Retrives 'readonly' property.
+ * NOTE: The portion of the mounted document available to the user is
+ * always editable.
+ */
+ public boolean isReadOnly()
+ {
+ return false;
+ }
+
+ /**
+ * Sets 'readonly' property.
+ * NOTE: The portion of the mounted document available to the user is
+ * always editable.
+ */
+ public void setReadOnly(boolean flag)
+ {
+ // sorry! it is not supported.
+ }
+
+ // ----------- SPECIAL CAPABILITIES --------------
+
+ /**
+ * Participates in the environment configuration.
+ * This is how you can affect the classpath for execution, compilation, etc.
+ */
+ public void prepareEnvironment(FileSystem.Environment environment)
+ {
+ // BUG: the compiller cannot access files withing the OpenOffice document.
+ //environment.addClassPath(docFile.toString());
+ }
+
+ /* -----------------------------------------------------------
+ * Affect the name and icon of files on this filesystem according to their
+ * "status", e.g. version-control modification-commit state:
+ /*
+ private class StatusImpl implements Status {
+ public Image annotateIcon(Image icon, int iconType, Set files) {
+ // You may first modify it, e.g. by adding a check mark to the icon
+ // if that makes sense for this file or group of files.
+ return icon;
+ }
+ public String annotateName(String name, Set files) {
+ // E.g. add some sort of suffix to the name if some of the
+ // files are modified but not backed up or committed somehow:
+ if (theseFilesAreModified(files))
+ return NbBundle.getMessage(OpenOfficeDocFileSystem.class, "LBL_modified_files", name);
+ else
+ return name;
+ }
+ }
+
+ private transient Status status;
+
+ public Status getStatus() {
+ if (status == null) {
+ status = new StatusImpl();
+ }
+ return status;
+ }
+ // And use fireFileStatusChanged whenever you know something has changed.
+ */
+
+ /*
+ // Filesystem-specific actions, such as version-control operations.
+ // The actions should typically be CookieActions looking for DataObject
+ // cookies, where the object's primary file is on this type of filesystem.
+ public SystemAction[] getActions() {
+// ------>>>> UPDATE OPENOFFICE DOCUMENT <<<<------
+ return new SystemAction[] {
+ SystemAction.get(SomeAction.class),
+ null, // separator
+ SystemAction.get(SomeOtherAction.class)
+ };
+ }
+ */
+
+ /**
+ * Notifies this filesystem that it has been removed from the repository.
+ * Concrete filesystem implementations could perform clean-up here.
+ * The default implementation does nothing.
+ * <p>Note that this method is <em>advisory</em> and serves as an optimization
+ * to avoid retaining resources for too long etc. Filesystems should maintain correct
+ * semantics regardless of whether and when this method is called.
+ */
+ public void removeNotify()
+ {
+ setRefreshTime(REFRESH_OFF); // disable refresh
+ // update the document
+ try {
+ updateDocument();
+ } catch(IOException ioe) {
+ // cannot save all!!!
+System.out.println("*** OpenOfficeDocFileSystem.removeNotify:");
+System.out.println(" exception: " + ioe.getMessage());
+ }
+ closeDocument();
+ super.removeNotify();
+ }
+
+ /*
+ * Opens (mounts) an OpenOffice document.
+ */
+ private void openDocument(File file)
+ throws IOException, PropertyVetoException
+ {
+ synchronized(cache) {
+ setSystemName(computeSystemName(file));
+ docFile = file;
+ zipFile = new ZipFile(docFile);
+ cacheDocument(zipFile.entries(), editableStrategy);
+ isModified = false;
+ } // synchronized
+ }
+
+ /*
+ * Closes the document and cleans up the cache.
+ */
+ private void closeDocument()
+ {
+ synchronized(cache) {
+ // if a document mounted - close it
+ if(docFile != null) {
+ // close the document archive
+ if(zipFile != null) {
+ try {
+ zipFile.close();
+ } catch(IOException ioe) {
+ // sorry! we can do nothing about it.
+ }
+ }
+ zipFile = null;
+ // clean up cache
+ scanDocument(new CleanStrategy());
+ docFile = null;
+ isModified = false;
+ }
+ } // synchronized
+ }
+
+ /*
+ * Creates a document cache.
+ */
+ private void cacheDocument(Enumeration entries, Strategy editables)
+ {
+ Entry cacheEntry;
+ ZipEntry archEntry;
+ synchronized(cache) {
+ cache.clear();
+ // root folder
+ cacheEntry = new ReadWriteEntry(null);
+ cache.put(cacheEntry.getName(), cacheEntry);
+ // the rest of items
+ while(entries.hasMoreElements()) {
+ archEntry = (ZipEntry)entries.nextElement();
+ cacheEntry = new Entry(archEntry);
+ if(editables.evaluate(cacheEntry))
+ cacheEntry = new ReadWriteEntry(archEntry);
+ cache.put(cacheEntry.getName(), cacheEntry);
+ }
+ } // synchronized
+ }
+
+ /*
+ * Updates the document.
+ */
+ private void updateDocument()
+ throws IOException
+ {
+ if(docFile == null)
+ return;
+ synchronized(cache) {
+ ModifiedStrategy modifiedStrategy = new ModifiedStrategy();
+ scanDocument(modifiedStrategy);
+ if((isModified == true) ||
+ (modifiedStrategy.isModified() == true))
+ {
+ File tmpFile = null;
+ try {
+ // create updated document
+ tmpFile = File.createTempFile(
+ TMP_FILE_PREF, TMP_FILE_SUFX, docFile.getParentFile());
+ saveDocument(tmpFile);
+ } catch(IOException ioe) {
+ if(tmpFile != null)
+ tmpFile.delete();
+ throw ioe;
+ }
+ // close the document archive
+ if(zipFile != null) {
+ try {
+ zipFile.close();
+ } catch(IOException ioe) {
+ }
+ }
+ zipFile = null;
+ // create the document and backup
+ File newFile = new File(docFile.getParentFile() + File.separator +
+ "~" + docFile.getName());
+ if(newFile.exists())
+ newFile.delete(); // delete old backup
+ docFile.renameTo(newFile);
+ tmpFile.renameTo(docFile);
+ // open the document archive
+ zipFile = new ZipFile(docFile);
+ }
+ isModified = false;
+ } // synchronized
+ }
+
+ /*
+ * Saves the document in a new archive.
+ */
+ private void saveDocument(File file)
+ throws IOException
+ {
+ synchronized(cache) {
+ SaveStrategy saver = new SaveStrategy(file);
+ scanDocument(saver);
+ saver.close();
+ } // synchronized
+ }
+
+ /*
+ * Provides each individual entry in the cached document to an apraiser.
+ */
+ private void scanDocument(Strategy strategy)
+ {
+ synchronized(cache) {
+ Iterator itr = cache.values().iterator();
+ while(itr.hasNext()) {
+ strategy.evaluate((Entry)itr.next());
+ }
+ } // synchronized
+ }
+
+ /*
+ * Retrives or creates a file.
+ */
+ private Entry getFileEntry(String name)
+ throws IOException
+ {
+ Entry cEntry = null;
+ synchronized(cache) {
+ cEntry = (Entry)cache.get(name);
+ if(cEntry == null) {
+ // create a new file
+ ZipEntry zEntry = new ZipEntry(name);
+ zEntry.setTime(new Date().getTime());
+ cEntry = new Entry(zEntry);
+ if(editableStrategy.evaluate(cEntry) == false) {
+ throw new IOException(
+ "cannot create/edit readonly file"); // I18N
+ }
+ cEntry = new ReadWriteEntry(zEntry);
+ cache.put(cEntry.getName(), cEntry);
+ isModified = true;
+ }
+ } // synchronized
+ return cEntry;
+ }
+
+ /*
+ * Retrives or creates a folder.
+ */
+ private Entry getFolderEntry(String name)
+ throws IOException
+ {
+ Entry cEntry = null;
+ synchronized(cache) {
+ cEntry = (Entry)cache.get(name);
+ if(cEntry == null) {
+ // create a new folder
+ ZipEntry zEntry = new ZipEntry(name + SEPARATOR);
+ zEntry.setMethod(ZipEntry.STORED);
+ zEntry.setSize(0);
+ CRC32 crc = new CRC32();
+ zEntry.setCrc(crc.getValue());
+ zEntry.setTime(new Date().getTime());
+ cEntry = new Entry(zEntry);
+ if(editableStrategy.evaluate(cEntry) == false) {
+ throw new IOException(
+ "cannot create folder"); // I18N
+ }
+ cEntry = new ReadWriteEntry(zEntry);
+ cEntry.getOutputStream(); // sets up modified flag
+ cache.put(cEntry.getName(), cEntry);
+ isModified = true;
+ } else {
+ if(cEntry.isFolder() == false)
+ cEntry = null;
+ }
+ } // synchronized
+ return cEntry;
+ }
+
+ /*
+ * Converts the name to ZIP file name.
+ * Removes the leading file separator if there is one.
+ * This is WORKAROUND of the BUG in AbstractFileObject:
+ * While AbstractFileObject reprecents the root of the filesystem it uses
+ * the absolute path (the path starts with '/'). It is inconsistent with
+ * the rest of the code.
+ * WORKAROUND: we have to strip leading '/' if it is in the name.
+ */
+ private static String zipName(String name)
+ {
+ String zname = ((name.startsWith(File.separator))?
+ name.substring(File.separator.length()): name);
+ switch(osType) {
+ case OS_MACOS:
+ zname = zname.replace(':', '/'); // ':' by '/'
+ break;
+ case OS_WINDOWS:
+ zname = zname.replace((char)0x5c, '/'); // '\' by '/'
+ break;
+ default:
+ break;
+ }
+ return zname;
+ }
+
+ // ----------- IMPLEMENTATIONS OF ABSTRACT FUNCTIONALITY ----------
+
+ /* -----------------------------------------------------------
+ * Information about files and operations on the contents which do
+ * not affect the file's presence or name.
+ */
+ private class InfoImpl
+ implements Info
+ {
+ public boolean folder(String name) {
+ synchronized(cache) {
+ String zname = zipName(name);
+ Entry entry = (Entry)cache.get(zname);
+ if(entry != null)
+ return entry.isFolder();
+ // logical zip file entry
+ childrenStrategy.setParent(zname);
+ scanDocument(childrenStrategy);
+ return (childrenStrategy.countChildren() > 0);
+ }
+ }
+
+ public Date lastModified(String name) {
+ synchronized(cache) {
+ Entry entry = (Entry)cache.get(zipName(name));
+ return new Date((entry != null)? entry.getTime(): 0L);
+ }
+ }
+
+ public boolean readOnly(String name) {
+ synchronized(cache) {
+ Entry entry = (Entry)cache.get(zipName(name));
+ return (entry != null)? entry.isReadOnly(): false;
+ }
+ }
+
+ public String mimeType(String name) {
+ // Unless you have some special means of determining MIME type
+ // (e.g. HTTP headers), ask IDE to use its normal heuristics:
+ // the MIME resolver pool and then file extensions, or if nothing
+ // matches, just content/unknown.
+ return null;
+ }
+
+ public long size(String name) {
+ synchronized(cache) {
+ Entry entry = (Entry)cache.get(zipName(name));
+ return (entry != null)? entry.getSize(): 0;
+ } // synchronized
+ }
+
+ public InputStream inputStream(String name)
+ throws FileNotFoundException
+ {
+ synchronized(cache) {
+ Entry entry = (Entry)cache.get(zipName(name));
+ return (entry != null)? entry.getInputStream(): null;
+ } // synchronized
+ }
+
+ public OutputStream outputStream(String name)
+ throws IOException
+ {
+ return getFileEntry(zipName(name)).getOutputStream();
+ }
+
+ // AbstractFileSystem handles locking the file to the rest of the IDE.
+ // This only means that you should define how the file should be locked
+ // to the outside world--perhaps it does not need to be.
+ public void lock(String name)
+ throws IOException
+ {
+/*
+ File file = getFile(name);
+ if (file.exists() == true && file.canWrite() == false) {
+ IOException ioe = new IOException("file " + file +
+ " could not be locked");
+ ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(
+ OpenOfficeDocFileSystem.class, "EXC_file_could_not_be_locked",
+ file.getName(), getDisplayName(), file.getPath()));
+ throw ioe;
+ }
+*/
+ }
+
+ public void unlock(String name) {
+ // Nothing special needed to unlock a file to the outside world.
+ }
+
+ public void markUnimportant(String name) {
+ // Do nothing special. Version-control systems may use this to mark
+ // certain files (e.g. *.class) as not needing to be stored in the VCS
+ // while others (source files) are by default important.
+ }
+
+ }
+
+ /* -----------------------------------------------------------
+ * Operations that change the available files.
+ */
+ private class ChangeImpl
+ implements Change
+ {
+ public void createFolder(String name)
+ throws IOException
+ {
+ synchronized(cache) {
+ String zname = zipName(name);
+ if(cache.get(zname) != null) {
+ throw new IOException(
+ "cannot create new folder: " + name); // I18N
+ }
+ getFolderEntry(zname);
+ } // synchronized
+ }
+
+ public void createData(String name)
+ throws IOException
+ {
+ synchronized(cache) {
+ String zname = zipName(name);
+ if(cache.get(zname) != null) {
+ throw new IOException(
+ "cannot create new data: " + name); // I18N
+ }
+ OutputStream os = getFileEntry(zname).getOutputStream();
+ os.close();
+ } // synchronized
+ }
+
+ public void rename(String oldName, String newName)
+ throws IOException
+ {
+ String oname = zipName(oldName);
+ String nname = zipName(newName);
+ if((oname.length() == 0) || (nname.length() == 0)) {
+ throw new IOException(
+ "cannot move or rename the root folder"); // I18N
+ }
+ synchronized(cache) {
+ if(cache.get(nname) != null) {
+ throw new IOException(
+ "target file/folder " + newName + " exists"); // I18N
+ }
+ Entry entry = (Entry)cache.get(oname);
+ if(entry == null) {
+ throw new IOException(
+ "there is no such a file/folder " + oldName); // I18N
+ }
+ if(entry.isReadOnly() == true) {
+ throw new IOException(
+ "file/folder " + oldName + " is readonly"); // I18N
+ }
+ entry.rename(nname);
+ if(editableStrategy.evaluate(entry) == false) {
+ entry.rename(oname);
+ throw new IOException(
+ "cannot create file/folder"); // I18N
+ }
+ cache.remove(oname);
+ cache.put(entry.getName(), entry);
+ } // synchronized
+ }
+
+ public void delete(String name)
+ throws IOException
+ {
+ String zname = zipName(name);
+ if(zname.length() == 0) {
+ throw new IOException(
+ "cannot delete the root folder"); // I18N
+ }
+ synchronized(cache) {
+ Entry entry = (Entry)cache.remove(zname);
+ if(entry != null) {
+ // BUG: this is the design bug. Cache has to
+ // remember that the entry was removed.
+ isModified = true;
+ entry.clean();
+ }
+ } // synchronized
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * Operation which provides the directory structure.
+ */
+ private class ListImpl
+ implements List
+ {
+ public String[] children(String name)
+ {
+ String[] children = null;
+ synchronized(cache) {
+ String zname = zipName(name);
+ Entry entry = (Entry)cache.get(zname);
+ if(entry != null) {
+ // real zip file entry
+ if(entry.isFolder()) {
+ childrenStrategy.setParent(entry.getName());
+ }
+ } else {
+ // logical zip file entry
+ // (portion of the path of a real zip file entry)
+ childrenStrategy.setParent(zname);
+ }
+ scanDocument(childrenStrategy);
+ children = childrenStrategy.getChildren();
+ } // synchronize
+ return children;
+ }
+
+ }
+
+ /** -----------------------------------------------------------
+ * This class adds new virtual attribute "java.io.File".
+ * Because of the fact that FileObjects of __Sample__FileSystem are convertible
+ * to java.io.File by means of attributes. */
+ /*private static class InnerAttrs extends DefaultAttributes {
+ //static final long serialVersionUID = 1257351369229921993L;
+ __Sample__FileSystem sfs;
+ public InnerAttrs(__Sample__FileSystem sfs, AbstractFileSystem.Info info,
+ AbstractFileSystem.Change change,AbstractFileSystem.List list ) {
+ super(info, change, list);
+ this.sfs = sfs;
+ }
+ public Object readAttribute(String name, String attrName) {
+ if (attrName.equals("java.io.File")) // NOI18N
+ return sfs.getFile(name);
+
+ return super.readAttribute(name, attrName);
+ }
+ }*/
+
+ /* -----------------------------------------------------------
+ // Optional special implementations of copy and (cross-directory) move.
+ private class TransferImpl implements Transfer {
+
+ public boolean copy(String name, Transfer target, String targetName) throws IOException {
+ // Only permit special implementation within single FS
+ // (or you could implement it across filesystems if you wished):
+ if (target != this) return false;
+ // Specially copy the file in an efficient way, e.g. implement
+ // a copy-on-write algorithm.
+ return true;
+ }
+
+ public boolean move(String name, Transfer target, String targetName) throws IOException {
+ // Only permit special implementation within single FS
+ // (or you could implement it across filesystems if you wished):
+ if (target != this) return false;
+ // Specially move the file, e.g. retain rename information even
+ // across directories in a version-control system.
+ return true;
+ }
+
+ }
+ */
+
+ /* -----------------------------------------------------------
+ * This interface hides an action will be performed on an entry.
+ */
+ private interface Strategy
+ {
+ public boolean evaluate(Entry entry);
+ }
+
+ /* -----------------------------------------------------------
+ * Recognizes editable (read-write) entires
+ */
+ private class EditableStrategy
+ implements Strategy
+ {
+ private String scope;
+
+ public EditableStrategy(String scope)
+ {
+ this.scope = scope;
+ }
+
+ public boolean evaluate(Entry entry)
+ {
+ // recognizes all entries in a subtree of the
+ // 'scope' as editable entries
+ return (entry != null)?
+ entry.getName().startsWith(scope): false;
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * Recognizes and accumulates immediate children of the parent.
+ */
+ private class ChildrenStrategy
+ implements Strategy
+ {
+ private String parent;
+ private Collection children = new HashSet();
+
+ public ChildrenStrategy()
+ {
+ }
+
+ public void setParent(String name)
+ {
+ parent = (name.length() > 0)? (name + SEPARATOR): "";
+ if(children == null)
+ children = (java.util.List)new LinkedList();
+ children.clear();
+ }
+
+ public boolean evaluate(Entry entry)
+ {
+ // do not accept "children" of a file
+ // ignore "read only" part of the filesystem
+ if(entry.isReadOnly() == false) {
+ // identify a child
+ if( (entry.getName().length() > 0) &&
+ (entry.getName().startsWith(parent)))
+ {
+ // identify an immediate child
+ String child = entry.getName();
+ if(parent.length() > 0) {
+ child = entry.getName().substring(parent.length());
+ }
+ int idx = child.indexOf(SEPARATOR);
+ if(idx > 0) // more path elements ahead
+ child = child.substring(0, idx);
+ return children.add(child);
+ }
+ }
+ return false;
+ }
+
+ public int countChildren()
+ {
+ return children.size();
+ }
+
+ public String[] getChildren()
+ {
+ String[] chn = new String[children.size()];
+ Iterator itr = children.iterator();
+ int idx = 0;
+ while(itr.hasNext()) {
+ chn[idx++] = (String)itr.next();
+ }
+ return chn;
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * Recognizes cache entries which have to be save into new archive.
+ */
+ private class ModifiedStrategy
+ implements Strategy
+ {
+ private boolean modified;
+
+ public boolean evaluate(Entry entry)
+ {
+ modified |= entry.isModified();
+ return entry.isModified();
+ }
+
+ public boolean isModified()
+ {
+ return modified;
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * Saves each entry in the filesystem cache.
+ */
+ private class SaveStrategy
+ implements Strategy
+ {
+ ZipOutputStream docos;
+ IOException ioexp;
+
+ public SaveStrategy(File newdoc)
+ throws IOException
+ {
+ docos = new ZipOutputStream(new FileOutputStream(newdoc));
+ ioexp = null; // success by default
+ }
+
+ public boolean evaluate(Entry entry)
+ {
+ if(entry.getName().length() == 0)
+ return false;
+ try {
+ entry.save(docos);
+ } catch(IOException ioe) {
+ if(ioexp == null)
+ ioexp = ioe;
+ }
+ return true;
+ }
+
+ public void close()
+ throws IOException
+ {
+ if(docos != null) {
+ try {
+ docos.close();
+ } catch (IOException ioe) {
+ ioexp = ioe;
+ } finally {
+ docos = null;
+ }
+ if(ioexp != null) {
+ throw ioexp;
+ }
+ }
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * Cleans each entiry in the filesystem cache.
+ */
+ private class CleanStrategy
+ implements Strategy
+ {
+ public boolean evaluate(Entry entry)
+ {
+ try {
+ entry.clean();
+ } catch(java.lang.Exception exp) {
+ // sorry! can do nothing about it.
+ }
+ return true;
+ }
+ }
+
+ /* -----------------------------------------------------------
+ * ReadOnly cache entry
+ */
+ private class Entry
+ {
+ private String name;
+ private boolean folder;
+ private long size;
+ private long time;
+ private File node; // data files only
+
+ public Entry(ZipEntry entry)
+ {
+ if(entry != null) {
+ name = entry.getName();
+ folder = entry.isDirectory();
+ size = entry.getSize();
+ time = entry.getTime();
+ // removes tail file separator from a folder name
+ if((folder == true) && (name.endsWith(SEPARATOR))) {
+ name = name.substring(
+ 0, name.length() - SEPARATOR.length());
+ }
+ } else {
+ // 'null' is special cace of root folder
+ name = "";
+ folder = true;
+ size = 0;
+ time = -1;
+ }
+ }
+
+ public boolean isReadOnly()
+ {
+ return true;
+ }
+
+ public boolean isFolder()
+ {
+ return folder;
+ }
+
+ public boolean isModified()
+ {
+ return false;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public long getSize()
+ {
+ return size;
+ }
+
+ public long getTime()
+ {
+ // ajust last modified time to the java.io.File
+ return (time >= 0)? time: 0;
+ }
+
+ public InputStream getInputStream()
+ throws FileNotFoundException
+ {
+ return (isFolder() == false)? new FileInputStream(getFile()): null;
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ return null;
+ }
+
+ public void rename(String name)
+ throws IOException
+ {
+// throw new IOException(
+// "cannot rename readonly file: " + getName()); // I18N
+ // BUG: this is the design bug. Cache has to mamage such kind
+ // of operation in order to keep the data integrity.
+ this.name = name;
+ }
+
+ public void save(ZipOutputStream arch)
+ throws IOException
+ {
+ InputStream is = null;
+ ZipEntry entry = new ZipEntry(
+ getName() + ((isFolder())? SEPARATOR: ""));
+ try {
+ if(isFolder()) {
+ // folder
+ entry.setMethod(ZipEntry.STORED);
+ entry.setSize(0);
+ CRC32 crc = new CRC32();
+ entry.setCrc(crc.getValue());
+ entry.setTime(getTime());
+ arch.putNextEntry(entry);
+ } else {
+ // file
+ if(isModified() == false)
+ entry.setTime(getTime());
+ else
+ entry.setTime(node.lastModified());
+ arch.putNextEntry(entry);
+ is = getInputStream();
+ FileUtil.copy(is, arch);
+ }
+ } finally {
+ // close streams
+ if(is != null) {
+ try {
+ is.close();
+ } catch(java.io.IOException ioe) {
+ // sorry! can do nothing about it.
+ }
+ }
+ if(arch != null)
+ arch.closeEntry();
+ }
+ }
+
+ public void clean()
+ throws IOException
+ {
+ if(node != null)
+ node.delete();
+ }
+
+ public String toString()
+ {
+ return (
+ ((isReadOnly())? "RO ": "RW ") +
+ ((isFolder())? "D": "F") +
+ " \"" + getName() + "\"");
+ }
+
+ /* package */ File getFile()
+ throws FileNotFoundException
+ {
+ if(node == null) {
+ try {
+ node = File.createTempFile(TMP_FILE_PREF, TMP_FILE_SUFX);
+ // copy the file from archive to the cache
+ OutputStream nos = null;
+ InputStream zis = null;
+ try {
+ ZipEntry entry = zipFile.getEntry(getName());
+ if(entry != null) {
+ // copy existing file to the cache
+ zis = zipFile.getInputStream(entry);
+ nos = new FileOutputStream(node);
+ FileUtil.copy(zis, nos);
+ }
+ } finally {
+ // close streams
+ if(nos != null) {
+ try {
+ nos.close();
+ } catch(java.io.IOException ioe) {
+ }
+ }
+ if(zis != null) {
+ try {
+ zis.close();
+ } catch(java.io.IOException ioe) {
+ }
+ }
+ }
+ } catch(java.lang.Exception exp) {
+ // delete cache file
+ if(node != null)
+ node.delete();
+ node = null;
+ throw new FileNotFoundException(
+ "cannot access file: " + getName()); // I18N
+ }
+ }
+ return node;
+ }
+
+ }
+
+ /* -----------------------------------------------------------
+ * ReadWrite cache entry
+ */
+ private class ReadWriteEntry
+ extends Entry
+ {
+ private boolean modified;
+
+ // 'null' is special cace of root folder
+ public ReadWriteEntry(ZipEntry entry)
+ {
+ super(entry);
+ }
+
+ public boolean isReadOnly()
+ {
+ return false;
+ }
+
+ public boolean isModified()
+ {
+ return modified;
+ }
+
+ public void rename(String name)
+ throws IOException
+ {
+ modified = true;
+ super.rename(name);
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ modified = true;
+ return (isFolder() == false)? new FileOutputStream(getFile()): null;
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java
new file mode 100644
index 000000000000..c282a2fa2ad7
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.filesystem;
+
+import java.awt.Image;
+import java.io.File;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.filesystems.FileSystem;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+/**
+ * Description of the OpenOffice.org Document filesystem.
+ *
+ * @author misha <misha@openoffice.org>
+ */
+public class OpenOfficeDocFileSystemBeanInfo
+ extends SimpleBeanInfo
+{
+ private static String ICONLOCATION =
+ "org/openoffice/netbeans/modules/office/resources";
+ private static String COLORICON16NAME =
+ ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon.png";
+ private static String COLORICON32NAME =
+ ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon32.png";
+
+ /**
+ * Retrives an additional bean information.
+ */
+ public BeanInfo[] getAdditionalBeanInfo()
+ {
+ try {
+ return new BeanInfo[] {
+ Introspector.getBeanInfo(FileSystem.class)
+ };
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+/*
+ // If you have a visual dialog to customize configuration of the
+ // filesystem:
+ public BeanDescriptor getBeanDescriptor()
+ {
+ return new BeanDescriptor(OpenOfficeDocFileSystem.class,
+ OpenOfficeDocFileSystemCustomizer.class);
+ }
+*/
+ /**
+ * Retrives bean property descriptors.
+ */
+ public PropertyDescriptor[] getPropertyDescriptors()
+ {
+ try {
+ // Included only to make it a writable property (it is read-only
+ // in FileSystem):
+ PropertyDescriptor readOnly = new PropertyDescriptor(
+ "readOnly", OpenOfficeDocFileSystem.class);
+ readOnly.setDisplayName(NbBundle.getMessage(
+ OpenOfficeDocFileSystemBeanInfo.class, "PROP_readOnly"));
+ readOnly.setShortDescription(NbBundle.getMessage(
+ OpenOfficeDocFileSystemBeanInfo.class, "HINT_readOnly"));
+
+ // This could be whatever properties you use to configure the
+ // filesystem:
+ PropertyDescriptor document = new PropertyDescriptor(
+ "Document", OpenOfficeDocFileSystem.class);
+ document.setDisplayName(NbBundle.getMessage(
+ OpenOfficeDocFileSystemBeanInfo.class, "PROP_document"));
+ document.setShortDescription(NbBundle.getMessage(
+ OpenOfficeDocFileSystemBeanInfo.class, "HINT_document"));
+ // Request to the property editor that it be permitted only to
+ // choose directories:
+ document.setValue("directories", Boolean.FALSE); // NOI18N
+ document.setValue("files", Boolean.TRUE); // NOI18N
+
+ return new PropertyDescriptor[] {readOnly, document};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ /**
+ * Retrives an icon by the icon type.
+ */
+ public Image getIcon(int type)
+ {
+ if((type == BeanInfo.ICON_COLOR_16x16) ||
+ (type == BeanInfo.ICON_MONO_16x16)) {
+ return Utilities.loadImage(COLORICON16NAME);
+ } else {
+ return Utilities.loadImage(COLORICON32NAME);
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties
new file mode 100644
index 000000000000..eab2fa1f3fbc
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties
@@ -0,0 +1,13 @@
+# Datasystems API
+#PROP_myProp=<name of my property>
+#HINT_myProp=<description of my property>
+#LBL_DataNode_exec_sheet=Execution
+#HINT_DataNode_exec_sheet=Properties pertaining to compiling, running, and debugging.
+# x-no-translate
+LBL_loaderName=<display name of the data loader>
+# Datasystems API
+#PROP_myProp=<name of my property>
+#HINT_myProp=<description of my property>
+#LBL_DataNode_exec_sheet=Execution
+#HINT_DataNode_exec_sheet=Properties pertaining to compiling, running, and debugging.
+LBL_loaderName=<display name of the data loader>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java
new file mode 100644
index 000000000000..27aae5ccce4a
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.IOException;
+import java.io.File;
+
+import org.openide.actions.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+import org.openoffice.netbeans.modules.office.actions.MountDocumentAction;
+
+/** Recognizes single files in the Repository as being of a certain type.
+ *
+ * @author tomaso
+ */
+public class OfficeDocumentDataLoader extends UniFileLoader {
+
+ public OfficeDocumentDataLoader() {
+ this("org.openoffice.netbeans.modules.office.loader.OfficeDocumentDataObject");
+ }
+
+ // Can be useful for subclasses:
+ protected OfficeDocumentDataLoader(String recognizedObjectClass) {
+ super(recognizedObjectClass);
+ }
+
+ protected String defaultDisplayName() {
+ return "Office Document";
+ }
+
+ protected void initialize() {
+ super.initialize();
+
+ ExtensionList extensions = new ExtensionList();
+ extensions.addExtension("sxw");
+ extensions.addExtension("sxc");
+ extensions.addExtension("sxd");
+ extensions.addExtension("sxi");
+ setExtensions(extensions);
+ }
+
+ protected FileObject findPrimaryFile(FileObject fo) {
+ ExtensionList extensions = getExtensions();
+ if (extensions.isRegistered(fo) == false)
+ return null;
+
+ File document = FileUtil.toFile(fo);
+ JarFileSystem jarFs = new JarFileSystem();
+
+ try {
+ jarFs.setJarFile(document);
+ }
+ catch (IOException e) {
+ // TopManager.getDefault().notify(new NotifyDescriptor.Exception(e, "asdf"));
+ return null;
+ }
+ catch (Exception e) {
+ return null;
+ }
+ return fo;
+ }
+
+ protected SystemAction[] defaultActions() {
+ return new SystemAction[] {
+ SystemAction.get(OpenAction.class),
+ // SystemAction.get(MountDocumentAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ // SystemAction.get(ToolsAction.class),
+ SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ return new OfficeDocumentDataObject(primaryFile, this);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoaderBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoaderBeanInfo.java
new file mode 100644
index 000000000000..cea24a71b126
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoaderBeanInfo.java
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.Image;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+public class OfficeDocumentDataLoaderBeanInfo extends SimpleBeanInfo {
+
+ // If you have additional properties:
+ /*
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor myProp = new PropertyDescriptor("myProp", OfficeDocumentDataLoader.class);
+ myProp.setDisplayName(NbBundle.getMessage(OfficeDocumentDataLoaderBeanInfo.class, "PROP_myProp"));
+ myProp.setShortDescription(NbBundle.getMessage(OfficeDocumentDataLoaderBeanInfo.class, "HINT_myProp"));
+ return new PropertyDescriptor[] {myProp};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+ */
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ // I.e. MultiFileLoader.class or UniFileLoader.class.
+ return new BeanInfo[] {Introspector.getBeanInfo(OfficeDocumentDataLoader.class.getSuperclass())};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif");
+ } else {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/resources/OfficeIcon32.gif");
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java
new file mode 100644
index 000000000000..095b04a9f90c
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.datatransfer.Transferable;
+import java.util.List;
+import java.io.*;
+
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.util.NbBundle;
+import org.openide.filesystems.*;
+
+import org.openoffice.netbeans.modules.office.actions.OfficeDocumentCookie;
+import org.openoffice.netbeans.modules.office.nodes.OfficeDocumentChildren;
+
+/** A node to represent this object.
+ *
+ * @author tomaso
+ */
+public class OfficeDocumentDataNode extends DataNode {
+
+ public OfficeDocumentDataNode(OfficeDocumentDataObject obj) {
+ // this(obj, Children.LEAF);
+ this(obj, new OfficeDocumentChildren((OfficeDocumentCookie)
+ obj.getCookie(OfficeDocumentCookie.class)));
+ }
+
+ public OfficeDocumentDataNode(OfficeDocumentDataObject obj, Children ch) {
+ super(obj, ch);
+ setIconBase("/org/openoffice/netbeans/modules/office/resources/OfficeIcon");
+ }
+
+ protected OfficeDocumentDataObject getOfficeDocumentDataObject() {
+ return (OfficeDocumentDataObject)getDataObject();
+ }
+
+ // Allow for pasting of Script Parcels to Office Documents
+ protected void createPasteTypes(Transferable t, List ls) {
+ Node[] copies = NodeTransfer.nodes(t, NodeTransfer.COPY);
+
+ if (copies != null) {
+ for (int i = 0; i < copies.length; i++) {
+ if (copies[i] instanceof ParcelDataNode) {
+ File source = FileUtil.toFile(((ParcelDataNode)copies[i]).getDataObject().getPrimaryFile());
+ File target = FileUtil.toFile(getDataObject().getPrimaryFile());
+
+ if (source.exists() && source.canRead() &&
+ target.exists() && target.canWrite()) {
+ ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)copies[i], target, false));
+ }
+ }
+ }
+ }
+
+ Node[] moves = NodeTransfer.nodes(t, NodeTransfer.MOVE);
+ if (moves != null) {
+ for (int i = 0; i < moves.length; i++) {
+ if (moves[i] instanceof ParcelDataNode) {
+ File source = FileUtil.toFile(((ParcelDataNode)moves[i]).getDataObject().getPrimaryFile());
+ File target = FileUtil.toFile(getDataObject().getPrimaryFile());
+
+ if (source.exists() && source.canRead() &&
+ target.exists() && target.canWrite()) {
+ ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)moves[i], target, true));
+ }
+ }
+ }
+ }
+
+ // Also try superclass, but give it lower priority:
+ super.createPasteTypes(t, ls);
+ }
+
+ /* Example of adding Executor / Debugger / Arguments to node:
+ protected Sheet createSheet() {
+ Sheet sheet = super.createSheet();
+ Sheet.Set set = sheet.get(ExecSupport.PROP_EXECUTION);
+ if (set == null) {
+ set = new Sheet.Set();
+ set.setName(ExecSupport.PROP_EXECUTION);
+ set.setDisplayName(NbBundle.getMessage(OfficeDocumentDataNode.class, "LBL_DataNode_exec_sheet"));
+ set.setShortDescription(NbBundle.getMessage(OfficeDocumentDataNode.class, "HINT_DataNode_exec_sheet"));
+ }
+ ((ExecSupport)getCookie(ExecSupport.class)).addProperties(set);
+ // Maybe:
+ ((CompilerSupport)getCookie(CompilerSupport.class)).addProperties(set);
+ sheet.put(set);
+ return sheet;
+ }
+ */
+
+ // Don't use getDefaultAction(); just make that first in the data loader's getActions list
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java
new file mode 100644
index 000000000000..b93f59d21350
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import org.openide.actions.*;
+import org.openide.cookies.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.util.HelpCtx;
+
+import org.openoffice.netbeans.modules.office.actions.*;
+
+public class OfficeDocumentDataObject extends MultiDataObject {
+
+ public OfficeDocumentDataObject(FileObject pf, OfficeDocumentDataLoader loader) throws DataObjectExistsException {
+ super(pf, loader);
+ init();
+ }
+
+ private void init() {
+ CookieSet cookies = getCookieSet();
+ cookies.add(new OfficeDocumentSupport(this));
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ protected Node createNodeDelegate() {
+ return new OfficeDocumentDataNode(this);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java
new file mode 100644
index 000000000000..5bca0a6b2d5a
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.IOException;
+
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+import org.openide.ErrorManager;
+
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileLock;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.DataObjectExistsException;
+
+import org.openide.nodes.Node;
+import org.openide.util.datatransfer.NewType;
+
+import org.openoffice.netbeans.modules.office.actions.ParcelFolderCookie;
+import org.openoffice.netbeans.modules.office.utils.PackageRemover;
+
+public class ParcelContentsFolder extends DataFolder {
+ public ParcelContentsFolder(FileObject pf, ParcelContentsFolderDataLoader loader)
+ throws DataObjectExistsException {
+ super(pf, loader);
+ }
+
+ public Node createNodeDelegate() {
+ return new DataFolder.FolderNode() {
+ public NewType[] getNewTypes() {
+ NewType[] newtypes = new NewType[1];
+ newtypes[0] = new NewType() {
+ public String getName() {
+ return "New Script";
+ }
+
+ public void create() {
+ DataFolder contents = (DataFolder)getDataObject();
+ ParcelFolderCookie cookie =
+ (ParcelFolderCookie)contents.getFolder().
+ getCookie(ParcelFolderCookie.class);
+
+ String language = cookie.getLanguage();
+ ParcelContentsFolder.createEmptyScript(contents,
+ language);
+ }
+ };
+ return newtypes;
+ }
+ };
+ }
+
+ public static void createEmptyScript(DataFolder parent, String language) {
+ String sourceFile = "Templates/OfficeScripting/EmptyScript/Empty";
+
+ if (language.toLowerCase().equals("java")) {
+ sourceFile += ".java";
+ }
+ else if (language.toLowerCase().equals("beanshell")) {
+ sourceFile += ".bsh";
+ }
+ else {
+ NotifyDescriptor d = new NotifyDescriptor.Message(
+ "Language not defined for this Parcel Folder");
+ TopManager.getDefault().notify(d);
+ return;
+ }
+
+ FileSystem fs = Repository.getDefault().getDefaultFileSystem();
+ DataObject result = null;
+ try {
+ DataObject dObj = DataObject.find(fs.findResource(sourceFile));
+ result = dObj.createFromTemplate(parent);
+ }
+ catch (IOException ioe) {
+ ErrorManager.getDefault().notify(ioe);
+ }
+
+ FileObject fo = result.getPrimaryFile();
+ if (fo.getExt().equals("java")) {
+ FileLock lock = null;
+ try {
+ PackageRemover.removeDeclaration(FileUtil.toFile(fo));
+
+ // IssueZilla 11986 - rename the FileObject
+ // so the JavaNode is resynchronized
+ lock = fo.lock();
+ if (lock != null) {
+ fo.rename(lock, fo.getName(), fo.getExt());
+ }
+ }
+ catch (IOException ioe) {
+ NotifyDescriptor d = new NotifyDescriptor.Message(
+ "Error removing package declaration from file: " +
+ fo.getNameExt() +
+ ". You should manually remove this declaration " +
+ "before building the Parcel Recipe");
+ TopManager.getDefault().notify(d);
+ }
+ finally {
+ if (lock != null) {
+ lock.releaseLock();
+ }
+ }
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java
new file mode 100644
index 000000000000..4c0777cf1c25
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import org.openide.loaders.*;
+import org.openide.filesystems.FileObject;
+import org.openide.actions.*;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+public class ParcelContentsFolderDataLoader extends UniFileLoader {
+
+ public ParcelContentsFolderDataLoader() {
+ this("org.openide.loaders.DataFolder");
+ }
+
+ protected ParcelContentsFolderDataLoader(String recognizedObjectClass) {
+ super(recognizedObjectClass);
+ }
+
+ protected String defaultDisplayName() {
+ return "Office Script Parcel Contents";
+ }
+
+ protected void initialize() {
+ super.initialize();
+ }
+
+ protected FileObject findPrimaryFile(FileObject fo) {
+ if (fo.isFolder() == false ||
+ fo.getName().equals(ParcelZipper.CONTENTS_DIRNAME) == false ||
+ fo.getFileObject(ParcelZipper.PARCEL_DESCRIPTOR_XML) == null)
+ return null;
+
+ return fo;
+ }
+
+ protected SystemAction[] defaultActions() {
+ return new SystemAction[] {
+ SystemAction.get(PasteAction.class),
+ SystemAction.get(NewAction.class),
+ // null,
+ // SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ protected MultiDataObject createMultiObject(FileObject primaryFile)
+ throws DataObjectExistsException {
+ return new ParcelContentsFolder(primaryFile, this);
+ }
+
+ protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
+ return new FileEntry.Folder(obj, primaryFile);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoaderBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoaderBeanInfo.java
new file mode 100644
index 000000000000..6f1f44255945
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoaderBeanInfo.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.Image;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+/** Description of {@link ParcelFolderDataLoader}.
+ *
+ * @author tomaso
+ */
+public class ParcelContentsFolderDataLoaderBeanInfo extends SimpleBeanInfo {
+
+ // If you have additional properties:
+ /*
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor myProp = new PropertyDescriptor("myProp", ParcelFolderDataLoader.class);
+ myProp.setDisplayName(NbBundle.getMessage(ParcelFolderDataLoaderBeanInfo.class, "PROP_myProp"));
+ myProp.setShortDescription(NbBundle.getMessage(ParcelFolderDataLoaderBeanInfo.class, "HINT_myProp"));
+ return new PropertyDescriptor[] {myProp};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+ */
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ // I.e. MultiFileLoader.class or UniFileLoader.class.
+ return new BeanInfo[] {Introspector.getBeanInfo(ParcelContentsFolderDataLoader.class.getSuperclass())};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelFolderDataIcon.gif");
+ } else {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelFolderDataIcon32.gif");
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java
new file mode 100644
index 000000000000..81a753bab7a0
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.IOException;
+import java.io.File;
+
+import org.openide.actions.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+import org.openoffice.netbeans.modules.office.actions.*;
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+/** Recognizes single files in the Repository as being of a certain type.
+ *
+ * @author tomaso
+ */
+public class ParcelDataLoader extends UniFileLoader {
+
+ public ParcelDataLoader() {
+ this("org.openoffice.netbeans.modules.office.loader.ParcelDataObject");
+ }
+
+ // Can be useful for subclasses:
+ protected ParcelDataLoader(String recognizedObjectClass) {
+ super(recognizedObjectClass);
+ }
+
+ protected String defaultDisplayName() {
+ return "Office Script Parcel";
+ }
+
+ protected void initialize() {
+ super.initialize();
+
+ ExtensionList extensions = new ExtensionList();
+ extensions.addExtension(ParcelZipper.PARCEL_EXTENSION);
+ setExtensions(extensions);
+ }
+
+ protected SystemAction[] defaultActions() {
+ return new SystemAction[] {
+ // SystemAction.get(MountParcelAction.class),
+ SystemAction.get(DeployParcelAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ // SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ // SystemAction.get(ToolsAction.class),
+ SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ return new ParcelDataObject(primaryFile, this);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoaderBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoaderBeanInfo.java
new file mode 100644
index 000000000000..3fdd32f497f4
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoaderBeanInfo.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.Image;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+/** Description of {@link ParcelDataLoader}.
+ *
+ * @author tomaso
+ */
+public class ParcelDataLoaderBeanInfo extends SimpleBeanInfo {
+
+ // If you have additional properties:
+ /*
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor myProp = new PropertyDescriptor("myProp", ParcelDataLoader.class);
+ myProp.setDisplayName(NbBundle.getMessage(ParcelDataLoaderBeanInfo.class, "PROP_myProp"));
+ myProp.setShortDescription(NbBundle.getMessage(ParcelDataLoaderBeanInfo.class, "HINT_myProp"));
+ return new PropertyDescriptor[] {myProp};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+ */
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ // I.e. MultiFileLoader.class or UniFileLoader.class.
+ return new BeanInfo[] {Introspector.getBeanInfo(ParcelDataLoader.class.getSuperclass())};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelDataIcon.gif");
+ } else {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelDataIcon32.gif");
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java
new file mode 100644
index 000000000000..bc6cf5a64336
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.*;
+import java.awt.datatransfer.Transferable;
+import java.util.zip.*;
+
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.filesystems.FileObject;
+import org.openide.util.NbBundle;
+import org.openide.util.datatransfer.*;
+import org.openide.ErrorManager;
+import org.openide.windows.OutputWriter;
+
+import org.openoffice.netbeans.modules.office.actions.ParcelCookie;
+
+/** A node to represent this object.
+ *
+ * @author tomaso
+ */
+public class ParcelDataNode extends DataNode {
+
+ public ParcelDataNode(ParcelDataObject obj) {
+ this(obj, Children.LEAF);
+ }
+
+ public ParcelDataNode(ParcelDataObject obj, Children ch) {
+ super(obj, ch);
+ setIconBase("/org/openoffice/netbeans/modules/office/resources/ParcelIcon");
+ }
+
+ protected ParcelDataObject getParcelDataObject() {
+ return (ParcelDataObject)getDataObject();
+ }
+
+ public static class ParcelPasteType extends PasteType {
+ ParcelDataNode sourceParcel = null;
+ File targetDocument = null;
+ boolean isCut = false;
+
+ public ParcelPasteType(ParcelDataNode sourceParcel,
+ File targetDocument, boolean isCut) {
+ this.sourceParcel = sourceParcel;
+ this.targetDocument = targetDocument;
+ this.isCut = isCut;
+ }
+
+ public Transferable paste() {
+ ParcelCookie parcelCookie =
+ (ParcelCookie)sourceParcel.getCookie(ParcelCookie.class);
+ parcelCookie.deploy(targetDocument);
+
+ if (isCut == true) {
+ FileObject fo = sourceParcel.getDataObject().getPrimaryFile();
+ try {
+ fo.delete();
+ }
+ catch (IOException ioe) {}
+ return ExTransferable.EMPTY;
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ /* Example of adding Executor / Debugger / Arguments to node:
+ protected Sheet createSheet() {
+ Sheet sheet = super.createSheet();
+ Sheet.Set set = sheet.get(ExecSupport.PROP_EXECUTION);
+ if (set == null) {
+ set = new Sheet.Set();
+ set.setName(ExecSupport.PROP_EXECUTION);
+ set.setDisplayName(NbBundle.getMessage(ParcelDataNode.class, "LBL_DataNode_exec_sheet"));
+ set.setShortDescription(NbBundle.getMessage(ParcelDataNode.class, "HINT_DataNode_exec_sheet"));
+ }
+ ((ExecSupport)getCookie(ExecSupport.class)).addProperties(set);
+ // Maybe:
+ ((CompilerSupport)getCookie(CompilerSupport.class)).addProperties(set);
+ sheet.put(set);
+ return sheet;
+ }
+ */
+
+ // Don't use getDefaultAction(); just make that first in the data loader's getActions list
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java
new file mode 100644
index 000000000000..7aeeda69176a
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import org.openide.actions.*;
+import org.openide.cookies.*;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.util.HelpCtx;
+
+import org.openoffice.netbeans.modules.office.actions.*;
+
+/** Represents a Parcel object in the Repository.
+ *
+ * @author tomaso
+ */
+public class ParcelDataObject extends MultiDataObject {
+
+ public ParcelDataObject(FileObject pf, ParcelDataLoader loader) throws DataObjectExistsException {
+ super(pf, loader);
+ init();
+ }
+
+ private void init() {
+ CookieSet cookies = getCookieSet();
+ cookies.add(new ParcelSupport(getPrimaryFile()));
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ // If you add context help, change to:
+ // return new HelpCtx(ParcelDataObject.class);
+ }
+
+ protected Node createNodeDelegate() {
+ return new ParcelDataNode(this);
+ }
+
+ /* If you made an Editor Support you will want to add these methods:
+
+ final void addSaveCookie(SaveCookie save) {
+ getCookieSet().add(save);
+ }
+
+ final void removeSaveCookie(SaveCookie save) {
+ getCookieSet().remove(save);
+ }
+
+ */
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java
new file mode 100644
index 000000000000..80fbcd99ee58
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.IOException;
+
+import org.openide.actions.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+import org.openoffice.idesupport.OfficeDocument;
+
+/** Recognizes single files in the Repository as being of a certain type.
+ *
+ * @author tomaso
+ */
+public class ParcelDescriptorDataLoader extends UniFileLoader {
+
+ public ParcelDescriptorDataLoader() {
+ this("org.openoffice.netbeans.modules.office.loader.ParcelDescriptorDataObject");
+ }
+
+ // Can be useful for subclasses:
+ protected ParcelDescriptorDataLoader(String recognizedObjectClass) {
+ super(recognizedObjectClass);
+ }
+
+ protected String defaultDisplayName() {
+ return OfficeDocument.OFFICE_PRODUCT_NAME + " Script Parcel Descriptor";
+ }
+
+ protected void initialize() {
+ super.initialize();
+
+ // ExtensionList extensions = new ExtensionList();
+ // extensions.addMimeType("text/x-parcel+xml");
+ // extensions.addExtension("pml");
+ getExtensions().addMimeType("text/x-parcel+xml");
+ // setExtensions(extensions);
+ }
+
+ protected SystemAction[] defaultActions() {
+ return new SystemAction[] {
+ SystemAction.get(OpenAction.class),
+ // SystemAction.get(GenerateParcelAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ // SystemAction.get(SaveAsTemplateAction.class),
+ // null,
+ // SystemAction.get(ToolsAction.class),
+ SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ return new ParcelDescriptorDataObject(primaryFile, this);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoaderBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoaderBeanInfo.java
new file mode 100644
index 000000000000..42b89fdf86ed
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoaderBeanInfo.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.Image;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+/** Description of {@link ParcelDescriptorDataLoader}.
+ *
+ * @author tomaso
+ */
+public class ParcelDescriptorDataLoaderBeanInfo extends SimpleBeanInfo {
+
+ // If you have additional properties:
+ /*
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor myProp = new PropertyDescriptor("myProp", ParcelDescriptorDataLoader.class);
+ myProp.setDisplayName(NbBundle.getMessage(ParcelDescriptorDataLoaderBeanInfo.class, "PROP_myProp"));
+ myProp.setShortDescription(NbBundle.getMessage(ParcelDescriptorDataLoaderBeanInfo.class, "HINT_myProp"));
+ return new PropertyDescriptor[] {myProp};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+ */
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ // I.e. MultiFileLoader.class or UniFileLoader.class.
+ return new BeanInfo[] {Introspector.getBeanInfo(ParcelDescriptorDataLoader.class.getSuperclass())};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelDescriptorDataIcon.gif");
+ } else {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelDescriptorDataIcon32.gif");
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataNode.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataNode.java
new file mode 100644
index 000000000000..440e91cbabf4
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataNode.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.util.NbBundle;
+
+import org.openoffice.netbeans.modules.office.nodes.*;
+import org.openoffice.netbeans.modules.office.actions.*;
+
+/** A node to represent this object.
+ *
+ * @author tomaso
+ */
+public class ParcelDescriptorDataNode extends DataNode {
+
+ public ParcelDescriptorDataNode(ParcelDescriptorDataObject obj) {
+ this(obj, Children.LEAF);
+ }
+
+ public ParcelDescriptorDataNode(ParcelDescriptorDataObject obj, Children ch) {
+ super(obj, ch);
+ setHidden(true);
+ setIconBase("/org/openoffice/netbeans/modules/office/resources/OfficeIcon");
+ }
+
+ protected ParcelDescriptorDataObject getParcelDescriptorDataObject() {
+ return (ParcelDescriptorDataObject)getDataObject();
+ }
+
+ public boolean canRename() {
+ return false;
+ }
+
+ /* Example of adding Executor / Debugger / Arguments to node:
+ protected Sheet createSheet() {
+ Sheet sheet = super.createSheet();
+ Sheet.Set set = sheet.get(ExecSupport.PROP_EXECUTION);
+ if (set == null) {
+ set = new Sheet.Set();
+ set.setName(ExecSupport.PROP_EXECUTION);
+ set.setDisplayName(NbBundle.getMessage(ParcelDescriptorDataNode.class, "LBL_DataNode_exec_sheet"));
+ set.setShortDescription(NbBundle.getMessage(ParcelDescriptorDataNode.class, "HINT_DataNode_exec_sheet"));
+ }
+ ((ExecSupport)getCookie(ExecSupport.class)).addProperties(set);
+ // Maybe:
+ ((CompilerSupport)getCookie(CompilerSupport.class)).addProperties(set);
+ sheet.put(set);
+ return sheet;
+ }
+ */
+
+ // Don't use getDefaultAction(); just make that first in the data loader's getActions list
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java
new file mode 100644
index 000000000000..9a80dcd5534b
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import org.openide.actions.*;
+import org.openide.cookies.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.nodes.*;
+import org.openide.util.HelpCtx;
+
+import org.openoffice.netbeans.modules.office.actions.ParcelDescriptorEditorSupport;
+import org.openoffice.netbeans.modules.office.actions.ParcelDescriptorParserSupport;
+
+/** Represents a ParcelDescriptor object in the Repository.
+ *
+ * @author tomaso
+ */
+public class ParcelDescriptorDataObject extends MultiDataObject {
+
+ private boolean canParse = false;
+
+ public ParcelDescriptorDataObject(FileObject pf, ParcelDescriptorDataLoader loader) throws DataObjectExistsException {
+ super(pf, loader);
+ init();
+ }
+
+ private void init() {
+ FileObject fo = getPrimaryFile();
+ if (FileUtil.toFile(fo) != null)
+ canParse = true;
+
+ CookieSet cookies = getCookieSet();
+ cookies.add(new ParcelDescriptorEditorSupport(this));
+ if (canParse == true)
+ cookies.add(new ParcelDescriptorParserSupport(getPrimaryFile()));
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ protected Node createNodeDelegate() {
+ if (canParse == true)
+ return new ParcelDescriptorDataNode(this);
+ else
+ return new ParcelDescriptorDataNode(this, Children.LEAF);
+ }
+
+ // If you made an Editor Support you will want to add these methods:
+ public final void addSaveCookie(SaveCookie save) {
+ getCookieSet().add(save);
+ }
+
+ public final void removeSaveCookie(SaveCookie save) {
+ getCookieSet().remove(save);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java
new file mode 100644
index 000000000000..44d04be0414a
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.File;
+import java.io.IOException;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorSupport;
+
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataFilter;
+import org.openide.loaders.DataObjectExistsException;
+
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+import org.openide.nodes.CookieSet;
+import org.openide.nodes.Node;
+import org.openide.nodes.PropertySupport;
+import org.openide.nodes.Sheet;
+import org.openide.util.HelpCtx;
+
+import org.openoffice.idesupport.filter.*;
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.netbeans.modules.office.actions.ParcelFolderCookie;
+import org.openoffice.netbeans.modules.office.actions.ParcelFolderSupport;
+
+public class ParcelFolder extends DataFolder {
+
+ public static final String LANGUAGE_ATTRIBUTE = "language";
+
+ public ParcelFolder(FileObject pf, ParcelFolderDataLoader loader)
+ throws DataObjectExistsException {
+ super(pf, loader);
+ CookieSet cookies = getCookieSet();
+ cookies.add(new ParcelFolderSupport(this));
+ }
+
+ public Node createNodeDelegate() {
+ return new ParcelFolderNode(this, new ParcelFolderFilter());
+ }
+
+ public class ParcelFolderNode extends DataFolder.FolderNode {
+ private static final String LOCATION = "location";
+ private static final String FILTER = "filter";
+ private static final String LANGUAGE = LANGUAGE_ATTRIBUTE;
+ private static final String CLASSPATH = "classpath";
+
+ private File location;
+ private FileFilter filter;
+ private String language;
+ private String classpath;
+
+ private final FileFilter DEFAULT_FILTER = BinaryOnlyFilter.getInstance();
+
+ public ParcelFolderNode(ParcelFolder pf, DataFilter dataFilter) {
+ super(pf.createNodeChildren(dataFilter));
+
+ location = (File)pf.getPrimaryFile().getAttribute(LOCATION);
+ if (location == null)
+ location = FileUtil.toFile(pf.getPrimaryFile());
+
+ String name = (String)pf.getPrimaryFile().getAttribute(FILTER);
+ if (name == null)
+ filter = DEFAULT_FILTER;
+ else {
+ for (int i = 0; i < availableFilters.length; i++)
+ if (name.equals(availableFilters[i].toString()))
+ filter = availableFilters[i];
+ }
+
+ language = (String)pf.getPrimaryFile().getAttribute(LANGUAGE);
+
+ ParcelFolderCookie cookie =
+ (ParcelFolderCookie)pf.getCookie(ParcelFolderCookie.class);
+ String s = cookie.getClasspath();
+ if (s != null) {
+ classpath = s;
+ }
+ else {
+ classpath = ".";
+ cookie.setClasspath(classpath);
+ }
+ }
+
+ public File getTargetDir() {
+ return location;
+ }
+
+ public FileFilter getFileFilter() {
+ return filter;
+ }
+
+ public String getLanguage() {
+ if (language == null)
+ language = (String)getPrimaryFile().getAttribute(LANGUAGE);
+ return language;
+ }
+
+ public Sheet createSheet() {
+ Sheet sheet;
+ Sheet.Set props;
+ Node.Property prop;
+
+ sheet = super.createSheet();
+ props = sheet.get(Sheet.PROPERTIES);
+ if (props == null) {
+ props = Sheet.createPropertiesSet();
+ sheet.put(props);
+ }
+
+ // prop = createLocationProperty();
+ // props.put(prop);
+
+ prop = createFilterProperty();
+ props.put(prop);
+
+ prop = createFilterProperty();
+ props.put(prop);
+
+ // prop = createLanguageProperty();
+ // props.put(prop);
+
+ prop = createClasspathProperty();
+ props.put(prop);
+
+ return sheet;
+ }
+
+ private Node.Property createLocationProperty() {
+ Node.Property prop =
+ new PropertySupport.ReadWrite(LOCATION, File.class,
+ "Location", "Output location of Parcel Zip File") {
+ public void setValue(Object obj) {
+ if (obj instanceof File) {
+ location = (File)obj;
+ try {
+ getPrimaryFile().setAttribute(LOCATION, location);
+ }
+ catch (IOException ioe) {
+ }
+ }
+ }
+
+ public Object getValue() {
+ return location;
+ }
+ };
+ prop.setValue("files", Boolean.FALSE);
+ return prop;
+ }
+
+ private String[] languages = {"Java", "BeanShell"};
+
+ private Node.Property createLanguageProperty() {
+ Node.Property prop =
+ new PropertySupport.ReadWrite(LANGUAGE, String.class,
+ "Parcel Language", "Language of scripts in this Parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof String) {
+ language = (String)obj;
+
+ try {
+ getPrimaryFile().setAttribute(LANGUAGE, language);
+ }
+ catch (IOException ioe) {
+ }
+ }
+ }
+
+ public Object getValue() {
+ if (language == null)
+ language = (String)getPrimaryFile().getAttribute(LANGUAGE);
+ return language;
+ }
+
+ public PropertyEditor getPropertyEditor() {
+ return new PropertyEditorSupport() {
+ public String[] getTags() {
+ return languages;
+ }
+
+ public void setAsText(String text) {
+ for (int i = 0; i < languages.length; i++)
+ if (text.equals(languages[i]))
+ this.setValue(languages[i]);
+ }
+
+ public String getAsText() {
+ return (String)this.getValue();
+ }
+ };
+ }
+ };
+ return prop;
+ }
+
+ private FileFilter[] availableFilters = new FileFilter[] {
+ BinaryOnlyFilter.getInstance(), AllFilesFilter.getInstance()};
+
+ private Node.Property createFilterProperty() {
+ Node.Property prop =
+ new PropertySupport.ReadWrite(FILTER, String.class,
+ "File Filter", "Files to be included in Parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof FileFilter) {
+ filter = (FileFilter)obj;
+
+ try {
+ getPrimaryFile().setAttribute(FILTER, filter.toString());
+ }
+ catch (IOException ioe) {
+ }
+ }
+ }
+
+ public Object getValue() {
+ return filter;
+ }
+
+ public PropertyEditor getPropertyEditor() {
+ return new PropertyEditorSupport() {
+ public String[] getTags() {
+ String[] tags = new String[availableFilters.length];
+
+ for (int i = 0; i < availableFilters.length; i++)
+ tags[i] = availableFilters[i].toString();
+
+ return tags;
+ }
+
+ public void setAsText(String text) {
+ for (int i = 0; i < availableFilters.length; i++)
+ if (text.equals(availableFilters[i].toString()))
+ this.setValue(availableFilters[i]);
+ }
+
+ public String getAsText() {
+ return this.getValue().toString();
+ }
+ };
+ }
+ };
+ return prop;
+ }
+
+ private Node.Property createClasspathProperty() {
+ Node.Property prop =
+ new PropertySupport.ReadWrite(CLASSPATH, String.class,
+ "Classpath", "Classpath property for scripts in this parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof String) {
+ classpath = (String)obj;
+
+ ParcelFolderCookie cookie = (ParcelFolderCookie)
+ getDataObject().getCookie(ParcelFolderCookie.class);
+ cookie.setClasspath(classpath);
+ }
+ }
+
+ public Object getValue() {
+ return classpath;
+ }
+ };
+ return prop;
+ }
+ }
+
+ private class ParcelFolderFilter implements DataFilter {
+ public boolean acceptDataObject(DataObject dobj) {
+ String name = dobj.getPrimaryFile().getNameExt();
+ if (name.equals(ParcelZipper.PARCEL_DESCRIPTOR_XML))
+ return false;
+ return true;
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java
new file mode 100644
index 000000000000..ee3957ccb2ef
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.io.IOException;
+import java.io.File;
+
+import org.openide.actions.*;
+import org.openide.filesystems.*;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.netbeans.modules.office.actions.*;
+
+/** Recognizes single files in the Repository as being of a certain type.
+ *
+ * @author tomaso
+ */
+
+public class ParcelFolderDataLoader extends UniFileLoader {
+
+ public ParcelFolderDataLoader() {
+ this("org.openoffice.netbeans.modules.office.loader.ParcelFolder");
+ }
+
+ protected ParcelFolderDataLoader(String recognizedObjectClass) {
+ super(recognizedObjectClass);
+ }
+
+ protected String defaultDisplayName() {
+ return "Office Script Parcel Folder";
+ }
+
+ protected void initialize() {
+ super.initialize();
+ }
+
+ protected FileObject findPrimaryFile(FileObject fo) {
+ if (fo.isFolder() == false)
+ return null;
+
+ FileObject contents = fo.getFileObject(ParcelZipper.CONTENTS_DIRNAME);
+ if (contents == null)
+ return null;
+
+ FileObject descriptor = contents.getFileObject(ParcelZipper.PARCEL_DESCRIPTOR_XML);
+ if (descriptor == null)
+ return null;
+
+ return fo;
+ }
+
+ protected SystemAction[] defaultActions() {
+ return new SystemAction[] {
+ // SystemAction.get(OpenLocalExplorerAction.class),
+ // SystemAction.get(FindAction.class),
+ // null,
+ // SystemAction.get(FileSystemAction.class),
+ // null,
+ SystemAction.get(CompileParcelAction.class),
+ SystemAction.get(BuildParcelAction.class),
+ SystemAction.get(ConfigureParcelAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ // SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ // SystemAction.get(SaveAsTemplateAction.class),
+ // null,
+ // SystemAction.get(ToolsAction.class),
+ SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ return new ParcelFolder(primaryFile, this);
+ }
+
+ protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
+ return new FileEntry.Folder(obj, primaryFile);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoaderBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoaderBeanInfo.java
new file mode 100644
index 000000000000..68888dde3c52
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoaderBeanInfo.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.loader;
+
+import java.awt.Image;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+/** Description of {@link ParcelFolderDataLoader}.
+ *
+ * @author tomaso
+ */
+public class ParcelFolderDataLoaderBeanInfo extends SimpleBeanInfo {
+
+ // If you have additional properties:
+ /*
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor myProp = new PropertyDescriptor("myProp", ParcelFolderDataLoader.class);
+ myProp.setDisplayName(NbBundle.getMessage(ParcelFolderDataLoaderBeanInfo.class, "PROP_myProp"));
+ myProp.setShortDescription(NbBundle.getMessage(ParcelFolderDataLoaderBeanInfo.class, "HINT_myProp"));
+ return new PropertyDescriptor[] {myProp};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+ */
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ // I.e. MultiFileLoader.class or UniFileLoader.class.
+ return new BeanInfo[] {Introspector.getBeanInfo(ParcelFolderDataLoader.class.getSuperclass())};
+ } catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelFolderDataIcon.gif");
+ } else {
+ return Utilities.loadImage("org/openoffice/netbeans/modules/office/loaders/ParcelFolderDataIcon32.gif");
+ }
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java
new file mode 100644
index 000000000000..83a239367c58
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.nodes;
+
+import java.io.IOException;
+import java.util.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.nodes.*;
+import org.openide.actions.*;
+import org.openide.util.actions.SystemAction;
+import org.openide.util.HelpCtx;
+
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.netbeans.modules.office.utils.NagDialog;
+import org.openoffice.netbeans.modules.office.actions.OfficeDocumentCookie;
+
+public class OfficeDocumentChildren extends Children.Keys
+ implements ChangeListener {
+
+ private OfficeDocumentCookie document = null;
+
+ public OfficeDocumentChildren(OfficeDocumentCookie cookie) {
+ document = cookie;
+ }
+
+ private void refreshKeys() {
+ if (document == null) {
+ setKeys(Collections.EMPTY_SET);
+ return;
+ }
+
+ Enumeration parcels = document.getParcels();
+ if (parcels.hasMoreElements() != true) {
+ setKeys(Collections.EMPTY_SET);
+ return;
+ }
+
+ ArrayList keys = new ArrayList();
+ while (parcels.hasMoreElements()) {
+ String parcel = (String)parcels.nextElement();
+ keys.add(parcel);
+ }
+ setKeys(keys);
+ }
+
+ protected void addNotify() {
+ super.addNotify();
+ document.addChangeListener(this);
+ refreshKeys();
+ }
+
+ protected void removeNotify() {
+ super.removeNotify();
+ document.removeChangeListener(this);
+ setKeys(Collections.EMPTY_SET);
+ }
+
+ protected Node[] createNodes(Object key) {
+ String name = (String)key;
+ return new Node[] {new ParcelNode(name)};
+ }
+
+ public void stateChanged(ChangeEvent e) {
+ refreshKeys();
+ }
+
+ private class ParcelNode extends AbstractNode {
+ private String name;
+
+ public ParcelNode(String name) {
+ super(Children.LEAF);
+ this.name = name;
+ init();
+ }
+
+ private void init() {
+ setIconBase("/org/openoffice/netbeans/modules/office/resources/ParcelIcon");
+
+ setName(name);
+ setDisplayName(name.substring(name.lastIndexOf("/") + 1));
+ setShortDescription(name);
+ }
+
+ protected SystemAction[] createActions() {
+ return new SystemAction[] {
+ SystemAction.get(DeleteAction.class),
+ };
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ public boolean canDestroy() {
+ return true;
+ }
+
+ public void destroy() throws IOException {
+ OfficeSettings settings = OfficeSettings.getDefault();
+ String message = "If you already have this document open in " +
+ "Office, please close it before continuing. Click OK to " +
+ "delete this parcel.";
+
+ if (settings.getWarnBeforeParcelDelete() == true) {
+ NagDialog warning = NagDialog.createConfirmationDialog(
+ message, "Show this message in future", true);
+
+ boolean result = warning.show();
+
+ if (warning.getState() == false)
+ settings.setWarnBeforeParcelDelete(false);
+
+ if (result == false)
+ return;
+ }
+ super.destroy();
+ document.removeParcel(name);
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java
new file mode 100644
index 000000000000..e503cdb98964
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.nodes;
+
+import java.util.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+
+import org.openide.nodes.*;
+import org.openoffice.netbeans.modules.office.actions.ParcelDescriptorParserCookie;
+
+/** List of children of a containing node.
+ * Remember to document what your permitted keys are!
+ *
+ * @author tomaso
+ */
+public class ParcelDescriptorChildren extends Children.Keys implements ChangeListener {
+
+ private ParcelDescriptorParserCookie parserCookie = null;
+
+ public ParcelDescriptorChildren(ParcelDescriptorParserCookie cookie) {
+ parserCookie = cookie;
+ }
+
+ private void refreshKeys() {
+ NodeList nl;
+ int len;
+
+ if (parserCookie == null ||
+ (nl = parserCookie.getScriptElements()) == null ||
+ (len = nl.getLength()) == 0) {
+ setKeys(Collections.EMPTY_SET);
+ return;
+ }
+
+ ArrayList keys = new ArrayList(len);
+ for (int i = 0; i < len; i++)
+ keys.add(nl.item(i));
+ setKeys(keys);
+ }
+
+ protected void addNotify() {
+ super.addNotify();
+ parserCookie.addChangeListener(this);
+ refreshKeys();
+ }
+
+ protected void removeNotify() {
+ super.removeNotify();
+ parserCookie.removeChangeListener(this);
+ setKeys(Collections.EMPTY_SET);
+ }
+
+ protected Node[] createNodes(Object key) {
+ Element el = (Element)key;
+ System.out.println("element is: " + el);
+ return new Node[] {new ScriptNode(el)};
+ }
+
+ public void stateChanged(ChangeEvent e) {
+ refreshKeys();
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java
new file mode 100644
index 000000000000..9606fc93b269
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.nodes;
+
+import org.w3c.dom.*;
+
+import org.openide.actions.*;
+import org.openide.nodes.*;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.SystemAction;
+
+/** A simple node with no children.
+ *
+ * @author tomaso
+ */
+public class ScriptNode extends AbstractNode {
+ private Element element;
+ private static final String LOGICAL_NAME = "logicalname";
+ private static final String LANGUAGE_NAME = "languagename";
+
+ public ScriptNode(Element element) {
+ super(Children.LEAF);
+ this.element = element;
+ init();
+ }
+
+ private void init() {
+ setIconBase("/org/openoffice/netbeans/modules/office/resources/OfficeIcon");
+ setDefaultAction(SystemAction.get(PropertiesAction.class));
+
+ NodeList nl = element.getElementsByTagName(LOGICAL_NAME);
+ Element nameElement = (Element)nl.item(0);
+
+ String name = nameElement.getAttribute("value");
+ setName(name);
+ setDisplayName(name.substring(name.lastIndexOf(".") + 1));
+ setShortDescription(name);
+ }
+
+ protected SystemAction[] createActions() {
+ return new SystemAction[] {
+ SystemAction.get(ToolsAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ // RECOMMENDED - handle cloning specially (so as not to invoke the overhead of FilterNode):
+ /*
+ public Node cloneNode() {
+ // Try to pass in similar constructor params to what you originally got:
+ return new ScriptNode();
+ }
+ */
+
+ protected Sheet createSheet() {
+ Sheet sheet = super.createSheet();
+ Sheet.Set props = sheet.get(Sheet.PROPERTIES);
+ if (props == null) {
+ props = Sheet.createPropertiesSet();
+ sheet.put(props);
+ }
+
+ org.openide.nodes.Node.Property prop = null;
+ if ((prop = getStringProperty(LOGICAL_NAME)) != null)
+ props.put(prop);
+
+ if ((prop = getStringProperty(LANGUAGE_NAME)) != null)
+ props.put(prop);
+
+ return sheet;
+ }
+
+ private org.openide.nodes.Node.Property getStringProperty(String name) {
+ NodeList nl = element.getElementsByTagName(name);
+ if(nl.getLength() != 1)
+ return null;
+
+ Element nameElement = (Element)nl.item(0);
+ String value = nameElement.getAttribute("value");
+
+ return new StringProperty(this, name, value);
+ }
+
+ private class StringProperty extends PropertySupport.ReadOnly {
+ private String name, value;
+ private ScriptNode sn;
+
+ public StringProperty(ScriptNode sn, String name, String value) {
+ super(value, String.class, name,
+ "The name of the java language method for this script");
+ this.sn = sn;
+ this.name = name;
+ this.value = value;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ /* public void setValue(Object obj) {
+ System.out.println("Setting value to: " + obj.toString());
+
+ if ((value instanceof String) != true)
+ throw new IllegalArgumentException(name +
+ " property must be of type String");
+
+ value = obj.toString();
+ if (name.equals(LOGICAL_NAME)) {
+ sn.setName(value);
+ sn.setDisplayName(value.substring(value.lastIndexOf(".") + 1));
+ sn.setShortDescription(value);
+ }
+ } */
+ }
+
+ /* public boolean canRename() {
+ return true;
+ }
+
+ public void setName(String nue) {
+ // Update visible name, fire property changes:
+ super.setName(nue);
+ } */
+
+ /*
+ public boolean canDestroy() {
+ return true;
+ }
+ public void destroy() throws IOException {
+ // Actually remove the node itself and fire property changes:
+ super.destroy();
+ // perform additional actions, i.e. delete underlying object
+ } */
+
+ // Handle copying and cutting specially:
+ /*
+ public boolean canCopy() {
+ return true;
+ }
+ public boolean canCut() {
+ return true;
+ }
+ public Transferable clipboardCopy() {
+ // Add to, do not replace, the default node copy flavor:
+ ExTransferable et = ExTransferable.create(super.clipboardCopy());
+ et.put(new ExTransferable.Single(DataFlavor.stringFlavor) {
+ protected Object getData() {
+ return ScriptNode.this.getDisplayName();
+ }
+ });
+ return et;
+ }
+ public Transferable clipboardCut() {
+ // Add to, do not replace, the default node cut flavor:
+ ExTransferable et = ExTransferable.create(super.clipboardCut());
+ // This is not so useful because this node will not be destroyed afterwards
+ // (it is up to the paste type to decide whether to remove the "original",
+ // and it is not safe to assume that getData will only be called once):
+ et.put(new ExTransferable.Single(DataFlavor.stringFlavor) {
+ protected Object getData() {
+ return ScriptNode.this.getDisplayName();
+ }
+ });
+ return et;
+ }
+ */
+
+ // Permit user to customize whole node at once (instead of per-property):
+ /*
+ public boolean hasCustomizer() {
+ return true;
+ }
+ public Component getCustomizer() {
+ return new MyCustomizingPanel(this);
+ }
+ */
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties
new file mode 100644
index 000000000000..6a9112e8c768
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties
@@ -0,0 +1,14 @@
+# Options API
+# x-no-translate
+LBL_settings=Office Settings
+PROP_OfficeDirectory=Path to Office installation
+HINT_OfficeDirectory=Path to the Office installation
+
+HINT_WarnBeforeDocDeploy=Pop up a dialog before deploying to a document
+PROP_WarnBeforeDocDeploy=Pop up a dialog before deploying to a document
+
+HINT_WarnAfterDirDeploy=Pop up a dialog after deploying to a directory
+PROP_WarnAfterDirDeploy=Pop up a dialog after deploying to a directory
+
+HINT_WarnBeforeMount=Warn before mounting Office Scripting Framework support jar
+PROP_WarnBeforeMount=Warn before mounting Office Scripting Framework support jar
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java
new file mode 100644
index 000000000000..3d33e214f736
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.options;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.io.File;
+import java.io.IOException;
+
+import org.openide.options.SystemOption;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+
+import org.openoffice.idesupport.SVersionRCFile;
+import org.openoffice.idesupport.OfficeInstallation;
+
+/** Options for something or other.
+ *
+ * @author tomaso
+ */
+public class OfficeSettings extends SystemOption {
+
+ // private static final long serialVersionUID = ...;
+
+ public static final String OFFICE_DIRECTORY = "OfficeDirectory";
+ public static final String WARN_BEFORE_DOC_DEPLOY = "WarnBeforeDocDeploy";
+ public static final String WARN_BEFORE_PARCEL_DELETE = "WarnBeforeParcelDelete";
+ public static final String WARN_AFTER_DIR_DEPLOY = "WarnAfterDirDeploy";
+ public static final String WARN_BEFORE_MOUNT = "WarnBeforeMount";
+
+ protected void initialize() {
+ super.initialize();
+
+ setWarnBeforeDocDeploy(true);
+ setWarnBeforeParcelDelete(true);
+ setWarnAfterDirDeploy(true);
+ setWarnBeforeMount(true);
+
+ if (getOfficeDirectory() == null) {
+ SVersionRCFile sversion = SVersionRCFile.createInstance();
+
+ try {
+ Enumeration enum = sversion.getVersions();
+ OfficeInstallation oi;
+
+ while (enum.hasMoreElements()) {
+ oi = (OfficeInstallation)enum.nextElement();
+ setOfficeDirectory(oi);
+ return;
+ }
+ }
+ catch (IOException ioe) {
+ }
+ }
+ }
+
+ public String displayName() {
+ return "Office Settings";
+ }
+
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ public static OfficeSettings getDefault() {
+ return (OfficeSettings)findObject(OfficeSettings.class, true);
+ }
+
+ public OfficeInstallation getOfficeDirectory() {
+ return (OfficeInstallation)getProperty(OFFICE_DIRECTORY);
+ }
+
+ public void setOfficeDirectory(OfficeInstallation oi) {
+ putProperty(OFFICE_DIRECTORY, oi, true);
+ }
+
+ public boolean getWarnBeforeDocDeploy() {
+ return ((Boolean)getProperty(WARN_BEFORE_DOC_DEPLOY)).booleanValue();
+ }
+
+ public void setWarnBeforeDocDeploy(boolean value) {
+ putProperty(WARN_BEFORE_DOC_DEPLOY, new Boolean(value), true);
+ }
+
+ public boolean getWarnBeforeParcelDelete() {
+ return ((Boolean)getProperty(WARN_BEFORE_PARCEL_DELETE)).booleanValue();
+ }
+
+ public void setWarnBeforeParcelDelete(boolean value) {
+ putProperty(WARN_BEFORE_PARCEL_DELETE, new Boolean(value), true);
+ }
+
+ public boolean getWarnAfterDirDeploy() {
+ return ((Boolean)getProperty(WARN_AFTER_DIR_DEPLOY)).booleanValue();
+ }
+
+ public void setWarnAfterDirDeploy(boolean value) {
+ putProperty(WARN_AFTER_DIR_DEPLOY, new Boolean(value), true);
+ }
+
+ public boolean getWarnBeforeMount() {
+ return ((Boolean)getProperty(WARN_BEFORE_MOUNT)).booleanValue();
+ }
+
+ public void setWarnBeforeMount(boolean value) {
+ putProperty(WARN_BEFORE_MOUNT, new Boolean(value), true);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java
new file mode 100644
index 000000000000..f9747d7db398
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.options;
+
+import java.awt.Image;
+import java.awt.Component;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+import java.beans.*;
+
+import org.openide.ErrorManager;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+import org.openoffice.idesupport.OfficeInstallation;
+import org.openoffice.netbeans.modules.office.wizard.SelectPathPanel;
+
+/** Description of {@link OfficeSettings}.
+ *
+ * @author tomaso
+ */
+public class OfficeSettingsBeanInfo extends SimpleBeanInfo {
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor[] props = new PropertyDescriptor[] {
+ new PropertyDescriptor(OfficeSettings.OFFICE_DIRECTORY,
+ OfficeSettings.class,
+ "get" + OfficeSettings.OFFICE_DIRECTORY,
+ "set" + OfficeSettings.OFFICE_DIRECTORY),
+ new PropertyDescriptor(OfficeSettings.WARN_BEFORE_DOC_DEPLOY,
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY,
+ "set" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY),
+ new PropertyDescriptor(OfficeSettings.WARN_BEFORE_PARCEL_DELETE,
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE,
+ "set" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE),
+ new PropertyDescriptor(OfficeSettings.WARN_AFTER_DIR_DEPLOY,
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_AFTER_DIR_DEPLOY,
+ "set" + OfficeSettings.WARN_AFTER_DIR_DEPLOY),
+ new PropertyDescriptor(OfficeSettings.WARN_BEFORE_MOUNT,
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_MOUNT,
+ "set" + OfficeSettings.WARN_BEFORE_MOUNT)
+ };
+
+ props[0].setDisplayName(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "PROP_OfficeDirectory"));
+ props[0].setShortDescription(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "HINT_OfficeDirectory"));
+ props[0].setPropertyEditorClass(OfficeDirectoryEditor.class);
+
+ props[1].setDisplayName(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "PROP_WarnBeforeDocDeploy"));
+ props[1].setShortDescription(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "HINT_WarnBeforeDocDeploy"));
+ props[1].setHidden(true);
+
+ props[2].setDisplayName(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "PROP_WarnAfterDirDeploy"));
+ props[2].setShortDescription(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "HINT_WarnAfterDirDeploy"));
+ props[2].setHidden(true);
+
+ props[3].setDisplayName(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "PROP_WarnBeforeMount"));
+ props[3].setShortDescription(NbBundle.getMessage(
+ OfficeSettingsBeanInfo.class, "HINT_WarnBeforeMount"));
+ props[3].setHidden(true);
+
+ return props;
+ }
+ catch (IntrospectionException ie) {
+ ErrorManager.getDefault().notify(ie);
+ return null;
+ }
+ }
+
+ public Image getIcon(int type) {
+ if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
+ return Utilities.loadImage("/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon.gif");
+ } else {
+ return Utilities.loadImage("/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon32.gif");
+ }
+ }
+
+ public static class OfficeDirectoryEditor extends PropertyEditorSupport
+ implements ChangeListener {
+
+ private SelectPathPanel panel;
+
+ public String getAsText () {
+ return ((OfficeInstallation)getValue()).getPath();
+ }
+
+ public void setAsText (String path) {
+ OfficeInstallation oi = new OfficeInstallation(path);
+
+ if (!oi.supportsFramework())
+ throw new IllegalArgumentException(path +
+ " is not a valid Office install");
+ else
+ setValue (oi);
+ }
+
+ public Component getCustomEditor() {
+ panel = new SelectPathPanel();
+ panel.addChangeListener(this);
+ return panel.getComponent();
+ }
+
+ public boolean supportsCustomEditor() {
+ return true;
+ }
+
+ public void stateChanged(ChangeEvent evt) {
+ setValue(panel.getSelectedPath());
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon.gif b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon.gif
new file mode 100644
index 000000000000..9bed8526705b
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon32.gif b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon32.gif
new file mode 100644
index 000000000000..65bfc82bc25f
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsIcon32.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.html b/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.html
new file mode 100644
index 000000000000..ee576e74ce61
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+ <HEAD>
+ <TITLE></TITLE>
+ </HEAD>
+ <BODY>
+ <P>
+This wizard will let you mount the Office Application scripts directory
+ </BODY>
+</HTML>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.settings b/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.settings
new file mode 100644
index 000000000000..b682273020b3
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/AppStorage.settings
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="org.openoffice.netbeans.modules.office/1"/>
+ <instanceof class="org.openide.filesystems.FileSystem"/>
+ <instance class="org.netbeans.core.ExLocalFileSystem"/>
+</settings>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties
new file mode 100644
index 000000000000..22aea6525f3d
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties
@@ -0,0 +1,24 @@
+# x-no-translate
+Templates/OfficeScripting=Office Scripting
+Templates/OfficeScripting/parcel.xml=Script Parcel Descriptor
+Services/MIMEResolver/org-netbeans-modules-office-mime-resolver.xml=Script Parcel Descriptor File
+Templates=Templates
+Templates/OfficeScripting/HelloWorld=Hello World Example Script
+
+Templates/Mount/org-openoffice-netbeans-modules-office-resources-AppStorage.settings=Office Application Scripts
+Templates/Mount/org-openoffice-netbeans-modules-office-resources-OpenOfficeDocFileSystem.settings=OpenOffice.org document
+
+UI/Services/IDEConfiguration/ServerAndExternalToolSettings/org-openoffice-netbeans-modules-office-options-OfficeSettings.instance=Office Settings
+
+Services/org-openoffice-netbeans-modules-office-resources-OfficeSettings.settings=Office Settings
+
+PROP_OfficeDirectory=Office Installation Directory
+
+HINT_OfficeDirectory=Path to directory where Office is installed
+
+Templates/OfficeScripting/Parcel=Parcel Recipe
+Templates/OfficeScripting/EmptyScript=Empty Script
+Templates/OfficeScripting/EmptyScript/Empty.java=Java
+Templates/OfficeScripting/EmptyScript/Empty.bsh=BeanShell
+
+Menu/Help/office-scripting.url=&Office Scripting Framework Site
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/EmptyParcel.html b/scripting/java/org/openoffice/netbeans/modules/office/resources/EmptyParcel.html
new file mode 100644
index 000000000000..f3c478c42aa3
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/EmptyParcel.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+ <HEAD>
+ <TITLE></TITLE>
+ </HEAD>
+ <BODY>
+ <P>
+This allows you to create an Empty Office Script.
+ </BODY>
+</HTML>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif
new file mode 100644
index 000000000000..ec7507ef9e54
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon32.gif b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon32.gif
new file mode 100644
index 000000000000..94fdab1eba0c
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeIcon32.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeSettings.settings b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeSettings.settings
new file mode 100644
index 000000000000..df98da11659b
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OfficeSettings.settings
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="org.openoffice.netbeans.modules.office"/>
+ <instanceof class="org.openide.util.SharedClassObject"/>
+ <instanceof class="org.openide.util.SystemOption"/>
+ <instanceof class="org.openoffice.netbeans.modules.office.options.OfficeSettings"/>
+ <instance class="org.openoffice.netbeans.modules.office.options.OfficeSettings"/>
+</settings>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.html b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.html
new file mode 100644
index 000000000000..5a879388bb28
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+ <HEAD>
+ <TITLE></TITLE>
+ </HEAD>
+ <BODY>
+ <P>
+This allows you to mount OpenOffice.org document.
+ </BODY>
+</HTML>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.settings b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.settings
new file mode 100644
index 000000000000..32a5bd490be1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.settings
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
+<settings version="1.0">
+ <module name="org.openoffice.netbeans.modules.office/1"/>
+ <instanceof class="org.openide.filesystems.FileSystem"/>
+ <instance class="org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem"/>
+</settings>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon.png b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon.png
new file mode 100644
index 000000000000..a441019346f9
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon.png
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon32.png b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon32.png
new file mode 100644
index 000000000000..1b2ee21e6d9c
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon32.png
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/ParcelIcon.gif b/scripting/java/org/openoffice/netbeans/modules/office/resources/ParcelIcon.gif
new file mode 100644
index 000000000000..a889c2614edf
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/ParcelIcon.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcel.html b/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcel.html
new file mode 100644
index 000000000000..c0f489032b9c
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcel.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+ <HEAD>
+ <TITLE></TITLE>
+ </HEAD>
+ <BODY>
+ <P>
+This allows you to create a Hello World example Office Script.
+ </BODY>
+</HTML>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcelDescriptor.html b/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcelDescriptor.html
new file mode 100644
index 000000000000..d753d5dfe926
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/ScriptParcelDescriptor.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+ <HEAD>
+ <TITLE></TITLE>
+ </HEAD>
+ <BODY>
+ <P>
+This allows you to create a Office Script Parcel Descriptor File.
+ </BODY>
+</HTML>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/layer.xml b/scripting/java/org/openoffice/netbeans/modules/office/resources/layer.xml
new file mode 100644
index 000000000000..86b834d0d065
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/layer.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
+<filesystem>
+ <folder name="Templates">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+
+ <folder name="OfficeScripting">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <folder name="Parcel">
+ <attr boolvalue="true" name="template"/>
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif"/>
+ <attr name="templateWizardURL" urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/EmptyParcel.html"/>
+ <attr name="templateWizardIterator" newvalue="org.openoffice.netbeans.modules.office.wizard.ParcelContentsIterator"/>
+ <folder name="Contents">
+ <file name="parcel-descriptor.xml" url="templates/EmptyParcelDescriptor.xml_"/>
+ <!-- file name="Empty.java" url="templates/Empty.java_"/ -->
+ </folder>
+ </folder>
+ <folder name="EmptyScript">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <file name="Empty.java" url="templates/Empty.java_">
+ <attr name="template" boolvalue="true"/>
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="templateWizardIterator" newvalue="org.openoffice.netbeans.modules.office.wizard.JavaScriptIterator"/>
+ </file>
+ <file name="Empty.bsh" url="templates/Empty.bsh_">
+ <attr name="template" boolvalue="true"/>
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ </file>
+ </folder>
+ </folder>
+ <attr boolvalue="true" name="Ant/OfficeScripting"/>
+ <attr boolvalue="true" name="OfficeScripting/Other"/>
+
+ <!-- OpenOfficeDoc FileSystem BEGIN: -->
+ <!-- Uncomment to enable writable mounting of Office Documents
+ <folder name="Mount">
+ <attr name="org-netbeans-core-ExLocalFileSystem.settings/org-openoffice-netbeans-modules-office-resources-OpenOfficeDocFileSystem.settings"
+ boolvalue="true"/>
+ <attr name="org-openoffice-netbeans-modules-office-resources-OpenOfficeDocFileSystem.settings/VCS"
+ boolvalue="true"/>
+
+ <file name="org-openoffice-netbeans-modules-office-resources-OpenOfficeDocFileSystem.settings"
+ url="OpenOfficeDocFileSystem.settings">
+ <attr name="template"
+ boolvalue="true"/>
+ <attr name="SystemFileSystem.localizingBundle"
+ stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="SystemFileSystem.icon"
+ urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystemIcon.png"/>
+ <attr name="templateWizardIterator"
+ methodvalue="org.netbeans.core.ui.MountNode.iterator"/>
+ <attr name="templateWizardURL"
+ urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/OpenOfficeDocFileSystem.html"/>
+ </file>
+ </folder>
+ -->
+ <!-- OpenOfficeDoc FileSystem END: -->
+ </folder>
+
+ <folder name="Services">
+ <folder name="MIMEResolver">
+ <file name="org-netbeans-modules-office-mime-resolver.xml" url="mime-resolver.xml">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif"/>
+ </file>
+ </folder>
+ <file name="org-openoffice-netbeans-modules-office-resources-OfficeSettings.settings" url="OfficeSettings.settings">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/OfficeIcon.gif"/>
+ </file>
+ </folder>
+
+ <folder name="Menu">
+ <folder name="Help">
+ <attr name="submit-feedback-link.url/office-scripting.url" boolvalue="true"/>
+ <file name="office-scripting.url" url="office-scripting.url">
+ <attr name="SystemFileSystem.localizingBundle" stringvalue="org.openoffice.netbeans.modules.office.resources.Bundle"/>
+ <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/openoffice/netbeans/modules/office/resources/webLink.gif"/>
+ </file>
+ </folder>
+ </folder>
+
+ <folder name="UI">
+ <folder name="Services">
+ <folder name="IDEConfiguration">
+ <folder name="ServerAndExternalToolSettings">
+ <file name="org-openoffice-netbeans-modules-office-resources-OfficeSettings.shadow">
+ <attr name="originalFile" stringvalue="Services/org-openoffice-netbeans-modules-office-resources-OfficeSettings.settings"/>
+ </file>
+ </folder>
+ </folder>
+ </folder>
+ </folder>
+
+ <attr boolvalue="true" name="Templates/Services"/>
+</filesystem>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/mime-resolver.xml b/scripting/java/org/openoffice/netbeans/modules/office/resources/mime-resolver.xml
new file mode 100644
index 000000000000..3e0f3053a81e
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/mime-resolver.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
+
+<MIME-resolver>
+
+ <!-- Resolve according to root element: -->
+ <file>
+ <ext name="xml"/>
+ <resolver mime="text/x-parcel+xml">
+ <xml-rule>
+ <element name="parcel"/>
+ </xml-rule>
+ </resolver>
+ </file>
+
+</MIME-resolver>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/office-scripting.url b/scripting/java/org/openoffice/netbeans/modules/office/resources/office-scripting.url
new file mode 100644
index 000000000000..f7be83c0eae4
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/office-scripting.url
@@ -0,0 +1 @@
+http://framework.openoffice.org/scripting/netbeans-devguide.html
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.bsh_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.bsh_
new file mode 100644
index 000000000000..9354dba121b6
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.bsh_
@@ -0,0 +1,24 @@
+// If using XComponentContext need to uncomment import directive below:
+// import com.sun.star.uno.XComponentContext;
+
+// If using XDesktop need to uncomment import directive below:
+// import com.sun.star.frame.XDesktop;
+
+// If using XComponent need to uncomment import directive below:
+// import com.sun.star.frame.XModel;
+
+import drafts.com.sun.star.script.framework.runtime.XScriptContext;
+
+/* Use the XScriptContext variable "context" to access the document for
+ which this script was invoked. This variable will be initialised
+ automatically by the Scripting Framework when the script is invoked.
+
+ Methods available are:
+
+ context.getDocument() returns XModel
+ context.getDesktop() returns XDesktop
+ context.getComponentContext() returns XComponentContext
+*/
+
+// Uncomment to get the current document model
+// xmodel = context.getDocument();
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.java_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.java_
new file mode 100644
index 000000000000..cf997b0f1082
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/Empty.java_
@@ -0,0 +1,27 @@
+// If using XComponentContext need to uncomment import directive below:
+// import com.sun.star.uno.XComponentContext;
+
+// If using XDesktop need to uncomment import directive below:
+// import com.sun.star.frame.XDesktop;
+
+// If using XComponent need to uncomment import directive below:
+// import com.sun.star.frame.XModel;
+
+import drafts.com.sun.star.script.framework.runtime.XScriptContext;
+
+public class Empty {
+
+ public void doMethod(XScriptContext xSc) {
+
+ /* Methods available from XScriptContext:
+ xSc.getDocument() returns XModel
+ xSc.getDesktop() returns XDesktop
+ xSc.getComponentContext() returns XComponentContext
+ */
+
+ // Uncomment to get the current document as a component
+ // XComponent xcomponent = xSc.getDocument();
+
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/EmptyParcelDescriptor.xml_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/EmptyParcelDescriptor.xml_
new file mode 100644
index 000000000000..7c016c322e0a
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/EmptyParcelDescriptor.xml_
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<parcel language="Java" xmlns:parcel="scripting.dtd">
+</parcel>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_
new file mode 100644
index 000000000000..36e66aeeb20e
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_
@@ -0,0 +1,41 @@
+// If using XMultiServiceFactory need to uncomment import directive below:
+//import com.sun.star.lang.XMultiServiceFactory;
+
+// If using XDesktop need to uncomment import directive below:
+//import com.sun.star.frame.XDesktop;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+import com.sun.star.text.*;
+
+import drafts.com.sun.star.script.framework.runtime.XScriptContext;
+
+
+public class HelloWorld {
+
+ public void printHello(XScriptContext xSc) {
+
+ /* Methods available from XScriptContext:
+ xSc.getDocument() returns XModel
+ xSc.getDesktop() returns XDesktop
+ xSc.getMultiComponentFactory() returns XMultiComponentFactory
+ */
+
+ // Getting the current document as a component
+ XComponent xcomponent = xSc.getDocument();
+
+ // Getting the text document object
+ XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(
+XTextDocument.class, xcomponent);
+
+ //Getting the text object
+ XText oText = xtextdocument.getText();
+
+ //Create a cursor object
+ XTextCursor oCursor = oText.createTextCursor();
+
+ // Print out Hello World
+ oText.insertString( oCursor, "**** HELLO ****", false );
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/ParcelDescriptor.xml_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/ParcelDescriptor.xml_
new file mode 100644
index 000000000000..81ffce04e37d
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/ParcelDescriptor.xml_
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<parcel>
+ <script language="Java" deploymentdir="java/HelloWorld">
+ <logicalname value="HelloWorld.printHello"/>
+ <languagename value="HelloWorld.printHello" location="HelloWorld.class"/>
+ </script>
+</parcel>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/webLink.gif b/scripting/java/org/openoffice/netbeans/modules/office/resources/webLink.gif
new file mode 100755
index 000000000000..ae40f9af595f
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/webLink.gif
Binary files differ
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java
new file mode 100644
index 000000000000..a9ac1b4bdaa9
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.beans.PropertyVetoException;
+
+import org.openide.filesystems.Repository;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.JarFileSystem;
+
+import org.openoffice.idesupport.SVersionRCFile;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+
+public class FrameworkJarChecker {
+
+ public static void mountDependencies() {
+ String unoilPath = SVersionRCFile.getPathForUnoil(
+ OfficeSettings.getDefault().getOfficeDirectory().getPath());
+
+ if (unoilPath == null)
+ return;
+
+ File unoilFile = new File(unoilPath + File.separator + "unoil.jar");
+ JarFileSystem jfs = new JarFileSystem();
+ try {
+ jfs.setJarFile(unoilFile);
+ }
+ catch (IOException ioe) {
+ return;
+ }
+ catch (PropertyVetoException pve) {
+ return;
+ }
+
+ FileSystem result;
+ try {
+ result =
+ Repository.getDefault().findFileSystem(jfs.getSystemName());
+ }
+ catch(Exception exp) {
+ result = null;
+ }
+ finally {
+ jfs.removeNotify();
+ }
+
+ if(result == null) {
+ // warnBeforeMount();
+ JarFileSystem newjfs = new JarFileSystem();
+ try {
+ newjfs.setJarFile(unoilFile);
+ }
+ catch (IOException ioe) {
+ return;
+ }
+ catch (PropertyVetoException pve) {
+ return;
+ }
+ Repository.getDefault().addFileSystem(newjfs);
+ newjfs.setHidden(true);
+ }
+ }
+
+ public static void unmountDependencies() {
+ String unoilPath = SVersionRCFile.getPathForUnoil(
+ OfficeSettings.getDefault().getOfficeDirectory().getPath());
+
+ if (unoilPath == null)
+ return;
+
+ File unoilFile = new File(unoilPath + File.separator + "unoil.jar");
+ JarFileSystem jfs = new JarFileSystem();
+ try {
+ jfs.setJarFile(unoilFile);
+ }
+ catch (IOException ioe) {
+ return;
+ }
+ catch (PropertyVetoException pve) {
+ return;
+ }
+
+ FileSystem result;
+ try {
+ result =
+ Repository.getDefault().findFileSystem(jfs.getSystemName());
+ if(result != null)
+ Repository.getDefault().removeFileSystem(result);
+ }
+ catch(Exception exp) {
+ }
+ }
+
+ private static void warnBeforeMount() {
+ OfficeSettings settings = OfficeSettings.getDefault();
+
+ if (settings.getWarnBeforeMount() == false)
+ return;
+
+ String message = "The Office Scripting Framework support jar file " +
+ "is not mounted, so Office scripts will not compile. NetBeans " +
+ "is going to mount this jar file automatically.";
+
+ String prompt = "Show this message in future.";
+
+ NagDialog warning = NagDialog.createInformationDialog(
+ message, prompt, true);
+
+ if (warning.getState() == false) {
+ settings.setWarnBeforeMount(false);
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java
new file mode 100644
index 000000000000..b15d4b270027
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.File;
+
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.openide.xml.XMLUtil;
+
+import com.sun.star.script.framework.container.XMLParser;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.idesupport.OfficeInstallation;
+
+public class ManifestParser implements XMLParser {
+
+ private static ManifestParser parser = null;
+
+ private ManifestParser() {
+ }
+
+ public static ManifestParser getManifestParser() {
+ if (parser == null) {
+ synchronized(ManifestParser.class) {
+ if (parser == null)
+ parser = new ManifestParser();
+ }
+ }
+ return parser;
+ }
+
+ public Document parse(InputStream inputStream) {
+ InputSource is;
+ Document result = null;
+
+ try {
+ OfficeInstallation oi = OfficeSettings.getDefault().getOfficeDirectory();
+ String id = oi.getURL("share/dtd/officedocument/1_0/");
+
+ is = new InputSource(inputStream);
+ is.setSystemId(id);
+
+ result = XMLUtil.parse(is, false, false, null, null);
+ }
+ catch (IOException ioe) {
+ System.out.println("IO Error parsing stream.");
+ return null;
+ }
+ catch (SAXParseException spe) {
+ System.out.println("Sax Error parsing stream: " + spe.getMessage());
+ System.out.println("\tPublicId: " + spe.getPublicId());
+ System.out.println("\tSystemId: " + spe.getSystemId());
+ return null;
+ }
+ catch (SAXException se) {
+ System.out.println("Sax Error parsing stream: " + se.getMessage());
+ return null;
+ }
+
+ return result;
+ }
+
+ public void write(Document doc, OutputStream out) throws IOException {
+ XMLUtil.write(doc, out, "");
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java
new file mode 100644
index 000000000000..05bd8ee966a4
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+import javax.swing.JPanel;
+import javax.swing.JOptionPane;
+import javax.swing.JCheckBox;
+import javax.swing.border.EmptyBorder;
+
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+
+public class NagDialog {
+
+ private NotifyDescriptor descriptor;
+ private JPanel panel;
+ private JCheckBox checkbox;
+
+ private NagDialog(String message, String prompt, boolean initialState,
+ int type) {
+ initUI(message, prompt, initialState, type);
+ }
+
+ public static NagDialog createInformationDialog(
+ String message, String prompt, boolean initialState) {
+ NagDialog result = new NagDialog(
+ message, prompt, initialState, JOptionPane.INFORMATION_MESSAGE);
+
+ result.setDescriptor(new NotifyDescriptor.Message(result.getPanel(),
+ NotifyDescriptor.PLAIN_MESSAGE));
+
+ return result;
+ }
+
+ public static NagDialog createConfirmationDialog(
+ String message, String prompt, boolean initialState) {
+ NagDialog result = new NagDialog(
+ message, prompt, initialState, JOptionPane.QUESTION_MESSAGE);
+
+ result.setDescriptor(new NotifyDescriptor.Confirmation(
+ result.getPanel(), NotifyDescriptor.OK_CANCEL_OPTION,
+ NotifyDescriptor.PLAIN_MESSAGE));
+
+ return result;
+ }
+
+ public boolean show() {
+ TopManager.getDefault().notify(descriptor);
+
+ if (descriptor.getValue() == NotifyDescriptor.OK_OPTION)
+ return true;
+ else
+ return false;
+ }
+
+ public boolean getState() {
+ return checkbox.isSelected();
+ }
+
+ private JPanel getPanel() {
+ return this.panel;
+ }
+
+ private void setDescriptor(NotifyDescriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ private void initUI(String message, String prompt, boolean initialState,
+ int type) {
+
+ this.panel = new JPanel();
+ JOptionPane optionPane = new JOptionPane(message, type, 0, null,
+ new Object[0], null)
+ {
+ public int getMaxCharactersPerLineCount() {
+ return 100;
+ }
+ };
+ optionPane.setUI(new javax.swing.plaf.basic.BasicOptionPaneUI() {
+ public Dimension getMinimumOptionPaneSize() {
+ if (minimumSize == null) {
+ return new Dimension(MinimumWidth, 50);
+ }
+ return new Dimension(minimumSize.width, 50);
+ }
+ });
+ optionPane.setWantsInput(false);
+
+ JPanel checkPanel = new JPanel();
+ checkbox = new JCheckBox(prompt, initialState);
+ checkPanel.setLayout(new BorderLayout());
+ checkPanel.setBorder(new EmptyBorder(0, 20, 0, 0));
+ checkPanel.add(checkbox, BorderLayout.WEST);
+
+ this.panel.setLayout(new BorderLayout());
+ this.panel.add(optionPane, BorderLayout.CENTER);
+ this.panel.add(checkPanel, BorderLayout.SOUTH);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java
new file mode 100644
index 000000000000..8cf16eb08a82
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import org.openide.TopManager;
+import org.openide.WizardDescriptor;
+import org.openide.NotifyDescriptor;
+import org.openide.modules.ModuleInstall;
+
+import com.sun.star.script.framework.container.XMLParserFactory;
+import org.openoffice.idesupport.OfficeInstallation;
+import org.openoffice.netbeans.modules.office.wizard.InstallationPathDescriptor;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+
+public class OfficeModule extends ModuleInstall {
+
+ private static final long serialVersionUID = -8499324854301243852L;
+
+ public void installed () {
+ WizardDescriptor wiz = new InstallationPathDescriptor();
+ TopManager.getDefault().createDialog(wiz).show();
+
+ if(wiz.getValue() == NotifyDescriptor.OK_OPTION) {
+ OfficeInstallation oi = (OfficeInstallation)
+ wiz.getProperty(InstallationPathDescriptor.PROP_INSTALLPATH);
+
+ OfficeSettings settings = OfficeSettings.getDefault();
+ settings.setOfficeDirectory(oi);
+ }
+ FrameworkJarChecker.mountDependencies();
+ XMLParserFactory.setParser(ManifestParser.getManifestParser());
+ }
+
+ public void restored () {
+ FrameworkJarChecker.mountDependencies();
+ XMLParserFactory.setParser(ManifestParser.getManifestParser());
+ }
+
+ public boolean closing () {
+ FrameworkJarChecker.unmountDependencies();
+ return true;
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
new file mode 100644
index 000000000000..07c2c939372f
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+
+public class PackageRemover {
+ private PackageRemover() {
+ }
+
+ public static void removeDeclaration(File source) throws IOException {
+ File tmp = new File(source.getAbsolutePath() + ".tmp");
+
+ BufferedReader in = new BufferedReader(new FileReader(source));
+ BufferedWriter out = new BufferedWriter(new FileWriter(tmp));
+
+ try {
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (line.startsWith("package")) {
+ String newDeclaration = evaluate(line);
+ if (newDeclaration != null) {
+ out.write(newDeclaration, 0, newDeclaration.length());
+ out.newLine();
+ }
+ }
+ else {
+ out.write(line, 0, line.length());
+ out.newLine();
+ }
+ }
+ }
+ finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+
+ if (source.delete() == false) {
+ tmp.delete();
+ throw new IOException("Could not overwrite " + source);
+ }
+ else {
+ tmp.renameTo(source);
+ }
+ }
+
+ public static String evaluate(String line) {
+
+ int idx = line.indexOf(ParcelZipper.CONTENTS_DIRNAME);
+ if (idx == -1)
+ return line;
+
+ idx = idx + ParcelZipper.CONTENTS_DIRNAME.length();
+ if (line.charAt(idx) == '.')
+ return "package " + line.substring(idx + 1);;
+
+ return null;
+ }
+
+ public static void main(String[] args) {
+ File source = new File(args[0]);
+
+ try {
+ removeDeclaration(source);
+ }
+ catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java
new file mode 100644
index 000000000000..8616bfaefdb2
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.utils;
+
+import java.io.*;
+import java.util.zip.*;
+import java.beans.PropertyVetoException;
+
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+
+import org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem;
+
+public class ZipMounter
+{
+ private static ZipMounter mounter = null;
+
+ private ZipMounter() {
+ }
+
+ public static ZipMounter getZipMounter() {
+ if (mounter == null) {
+ synchronized(ZipMounter.class) {
+ if (mounter == null)
+ mounter = new ZipMounter();
+ }
+ }
+ return mounter;
+ }
+
+ public void mountZipFile(File zipfile)
+ throws IOException, PropertyVetoException
+ {
+ if (zipfile != null) {
+ addDocumentToRepository(zipfile, true);
+ }
+ }
+
+ private FileSystem addDocumentToRepository(File rootFile, boolean writeable)
+ throws IOException, PropertyVetoException
+ {
+ Repository repo = Repository.getDefault();
+ OpenOfficeDocFileSystem oofs;
+ oofs = (OpenOfficeDocFileSystem)getMountedDocument(rootFile);
+ if(oofs != null)
+ repo.removeFileSystem(oofs);
+ oofs = new OpenOfficeDocFileSystem();
+ oofs.setDocument(rootFile);
+ repo.addFileSystem(oofs);
+ return oofs;
+ }
+
+ /** @return FileSystem which has given jar file as its root or
+ * null if no such file system could be found in repository */
+ private FileSystem getMountedDocument(File rootFile)
+ {
+ if (rootFile == null)
+ return null;
+ FileSystem oofs = null;
+ try {
+ oofs = Repository.getDefault().findFileSystem(
+ OpenOfficeDocFileSystem.computeSystemName(rootFile));
+ } catch(Exception exp) {
+ }
+ return oofs;
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties
new file mode 100644
index 000000000000..a40b4b373959
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties
@@ -0,0 +1,27 @@
+# Window System API
+# x-no-translate
+
+# TopComponent
+LBL_component_name=<name of component>
+#LBL_mode_name=<name of mode>
+#LBL_workspace_name=<name of workspace>
+
+# WizardDescriptor
+# Dialog title:
+TITLE_wizard=Select Path to OpenOffice.org Installation
+
+# WizardDescriptor.Iterator
+# Label the sequence #. Appears at top of pane:
+# e.g. "Panel Name (1 of 3)"
+TITLE_x_of_y={0} of {1}
+# Provide list of steps to show in left pane:
+#LBL_step_1=Select First Thing
+#LBL_step_2=Configure Details
+
+# WizardDescriptor.Panel
+# Will appear in dialog title; see above
+TITLE_ParcelPropertiesVisualPanel=Parcel Recipe Properties
+TITLE_SelectPathVisualPanel=Path to OpenOffice.org
+
+# CallableSystemAction
+LBL_Action=Run Action
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle_en_US.properties b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle_en_US.properties
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle_en_US.properties
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java
new file mode 100644
index 000000000000..f7c057cf48b3
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java
@@ -0,0 +1,72 @@
+/*
+ * InstallationPathDescriptor.java
+ *
+ * Created on February 12, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.openide.TopManager;
+import org.openide.WizardDescriptor;
+import org.openide.util.NbBundle;
+
+/** A wizard descriptor.
+ *
+ * @author tomaso
+ */
+public class InstallationPathDescriptor extends WizardDescriptor {
+
+ private final InstallationPathIterator iterator;
+ public static final String PROP_INSTALLPATH = "INSTALLPATH";
+
+ /** Make a descriptor suited to use InstallationPathIterator.
+ * Sets up various wizard properties to follow recommended
+ * style guidelines.
+ */
+ public InstallationPathDescriptor() {
+ this(new InstallationPathIterator());
+ }
+ private InstallationPathDescriptor(InstallationPathIterator iterator) {
+ super(iterator);
+ this.iterator = iterator;
+ // Set title for the dialog:
+ setTitle(NbBundle.getMessage(InstallationPathDescriptor.class, "TITLE_wizard"));
+ // Make the left pane appear:
+ putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N
+ // Make the left pane show list of steps etc.:
+ putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N
+ // Number the steps.
+ // putProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N
+ /*
+ // Optional: make nonmodal.
+ setModal(false);
+ // (If you make the wizard nonmodal, you will call it differently;
+ // see InstallationPathAction for instructions.)
+ // Optional: show a help tab with special info about the pane:
+ putProperty("WizardPanel_helpDisplayed", Boolean.TRUE); // NOI18N
+ // Optional: set the size of the left pane explicitly:
+ putProperty("WizardPanel_leftDimension", new Dimension(100, 400)); // NOI18N
+ // Optional: if you want a special background image for the left pane:
+ try {
+ putProperty("WizardPanel_image", // NOI18N
+ Toolkit.getDefaultToolkit().getImage
+ (new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/InstallationPathImage.gif"))); // NOI18N
+ } catch (MalformedURLException mfue) {
+ throw new IllegalStateException(mfue.toString());
+ }
+ */
+ }
+
+ // Called when user moves forward or backward etc.:
+ protected void updateState() {
+ super.updateState();
+ putProperty("WizardPanel_contentData", iterator.getSteps()); // NOI18N
+ putProperty("WizardPanel_contentSelectedIndex", new Integer(iterator.getIndex())); // NOI18N
+ }
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java
new file mode 100644
index 000000000000..323175d4c5b8
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java
@@ -0,0 +1,136 @@
+/*
+ * InstallationPathIterator.java
+ *
+ * Created on February 12, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.WizardDescriptor;
+import org.openide.util.NbBundle;
+
+/** A wizard iterator (sequence of panels).
+ * Used to create a wizard. Create one or more
+ * panels from template as needed too.
+ *
+ * @author tomaso
+ */
+public class InstallationPathIterator implements WizardDescriptor.Iterator {
+
+ // You should define what panels you want to use here:
+
+ protected WizardDescriptor.Panel[] createPanels() {
+ return new WizardDescriptor.Panel[] {
+ new SelectPathPanel()
+ };
+ }
+
+ // And the list of step names:
+
+ protected String[] createSteps() {
+ return new String[] {
+ "Select OpenOffice.org Installation"
+ };
+ }
+
+ // --- The rest probably does not need to be touched. ---
+
+ // Keep track of the panels and selected panel:
+
+ private transient int index = 0;
+ // Also package-accessible to descriptor:
+ protected final int getIndex() {
+ return index;
+ }
+ private transient WizardDescriptor.Panel[] panels = null;
+ protected final WizardDescriptor.Panel[] getPanels() {
+ if (panels == null) {
+ panels = createPanels();
+ }
+ return panels;
+ }
+
+ // Also the list of steps in the left pane:
+
+ private transient String[] steps = null;
+ // Also package-accessible to descriptor:
+ protected final String[] getSteps() {
+ if (steps == null) {
+ steps = createSteps();
+ }
+ return steps;
+ }
+
+ // --- WizardDescriptor.Iterator METHODS: ---
+ // Note that this is very similar to WizardDescriptor.Iterator, but with a
+ // few more options for customization. If you e.g. want to make panels appear
+ // or disappear dynamically, go ahead.
+
+ public String name() {
+ return NbBundle.getMessage(InstallationPathIterator.class, "TITLE_x_of_y",
+ new Integer(index + 1), new Integer(getPanels().length));
+ }
+
+ public boolean hasNext() {
+ return index < getPanels().length - 1;
+ }
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+ public void nextPanel() {
+ if (!hasNext()) throw new NoSuchElementException();
+ index++;
+ }
+ public void previousPanel() {
+ if (!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ }
+ public WizardDescriptor.Panel current() {
+ return getPanels()[index];
+ }
+
+ // If nothing unusual changes in the middle of the wizard, simply:
+ public final void addChangeListener(ChangeListener l) {}
+ public final void removeChangeListener(ChangeListener l) {}
+ // If something changes dynamically (besides moving between panels),
+ // e.g. the number of panels changes in response to user input, then
+ // uncomment the following and call when needed:
+ // fireChangeEvent();
+ /*
+ private transient Set listeners = new HashSet(1); // Set<ChangeListener>
+ public final void addChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.add(l);
+ }
+ }
+ public final void removeChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.remove(l);
+ }
+ }
+ protected final void fireChangeEvent() {
+ Iterator it;
+ synchronized (listeners) {
+ it = new HashSet(listeners).iterator();
+ }
+ ChangeEvent ev = new ChangeEvent(this);
+ while (it.hasNext()) {
+ ((ChangeListener)it.next()).stateChanged(ev);
+ }
+ }
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ listeners = new HashSet(1);
+ }
+ */
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java
new file mode 100644
index 000000000000..65f6b0684000
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.awt.Component;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import javax.swing.JComponent;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.ErrorManager;
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+import org.openide.WizardDescriptor;
+import org.openide.cookies.OpenCookie;
+import org.openide.cookies.SourceCookie;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.filesystems.*;
+
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.netbeans.modules.office.loader.ParcelFolder;
+import org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem;
+import org.openoffice.netbeans.modules.office.utils.PackageRemover;
+
+/** A template wizard iterator (sequence of panels).
+ * Used to fill in the second and subsequent panels in the New wizard.
+ * Associate this to a template inside a layer using the
+ * Sequence of Panels extra property.
+ * Create one or more panels from template as needed too.
+ *
+ * @author tomaso
+ */
+public class JavaScriptIterator implements TemplateWizard.Iterator {
+
+
+ // private static final long serialVersionUID = ...L;
+
+ // You should define what panels you want to use here:
+
+ protected WizardDescriptor.Panel[] createPanels() {
+ return new WizardDescriptor.Panel[] {
+ // keep the default 2nd panel:
+ wiz.targetChooser(),
+ };
+ }
+
+ // And the list of step names:
+
+ protected String[] createSteps() {
+ return new String[] {
+ null,
+ };
+ }
+
+ private DataFolder checkTarget(DataFolder folder) {
+ FileObject fo = folder.getPrimaryFile();
+
+ try {
+ FileSystem fs = fo.getFileSystem();
+
+ if (fs instanceof OpenOfficeDocFileSystem && fo.isRoot()) {
+ FileObject scripts =
+ fo.getFileObject(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+ if (scripts == null)
+ scripts =
+ fo.createFolder(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+
+ FileObject javafolder = scripts.getFileObject("java");
+ if (javafolder == null)
+ javafolder = scripts.createFolder("java");
+
+ DataFolder subfolder = new DataFolder(javafolder);
+ return subfolder;
+ }
+ }
+ catch (IOException ioe) {
+ /* do nothing, we will just return the folder we were passed in */
+ }
+ return folder;
+ }
+
+ public Set instantiate(TemplateWizard wiz) throws IOException {
+ String name = wiz.getTargetName();
+ DataFolder targetFolder = wiz.getTargetFolder();
+ targetFolder = checkTarget(targetFolder);
+
+ DataObject template = wiz.getTemplate();
+ DataObject result;
+ if (name == null) {
+ // Default name.
+ result = template.createFromTemplate(targetFolder);
+ } else {
+ result = template.createFromTemplate(targetFolder, name);
+ }
+
+ FileObject tmp = result.getPrimaryFile();
+ if (tmp.getExt().equals("java")) {
+ try {
+ PackageRemover.removeDeclaration(FileUtil.toFile(tmp));
+
+ // IssueZilla 11986 - rename the FileObject
+ // so the JavaNode is resynchronized
+ tmp.rename(tmp.lock(), tmp.getName(), tmp.getExt());
+ }
+ catch (IOException ioe) {
+ NotifyDescriptor d = new NotifyDescriptor.Message(
+ "Error removing package declaration from file: " +
+ tmp.getNameExt() +
+ ". You should manually remove this declaration " +
+ "before building the Parcel Recipe");
+ TopManager.getDefault().notify(d);
+ }
+ }
+
+ return Collections.singleton(result);
+ }
+
+ // --- The rest probably does not need to be touched. ---
+
+ private transient int index;
+ private transient WizardDescriptor.Panel[] panels;
+ private transient TemplateWizard wiz;
+
+ // You can keep a reference to the TemplateWizard which can
+ // provide various kinds of useful information such as
+ // the currently selected target name.
+ // Also the panels will receive wiz as their "settings" object.
+ public void initialize(TemplateWizard wiz) {
+ this.wiz = wiz;
+ index = 0;
+ panels = createPanels();
+ // Make sure list of steps is accurate.
+ String[] steps = createSteps();
+ for (int i = 0; i < panels.length; i++) {
+ Component c = panels[i].getComponent();
+ if (steps[i] == null) {
+ // Default step name to component name of panel.
+ // Mainly useful for getting the name of the target
+ // chooser to appear in the list of steps.
+ steps[i] = c.getName();
+ }
+ if (c instanceof JComponent) { // assume Swing components
+ JComponent jc = (JComponent)c;
+ // Step #.
+ jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i)); // NOI18N
+ // Step name (actually the whole list for reference).
+ jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
+ }
+ }
+ }
+ public void uninitialize(TemplateWizard wiz) {
+ this.wiz = null;
+ panels = null;
+ }
+
+ // --- WizardDescriptor.Iterator METHODS: ---
+ // Note that this is very similar to WizardDescriptor.Iterator, but with a
+ // few more options for customization. If you e.g. want to make panels appear
+ // or disappear dynamically, go ahead.
+
+ public String name() {
+ return "";
+ }
+
+ public boolean hasNext() {
+ return index < panels.length - 1;
+ }
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+ public void nextPanel() {
+ if (!hasNext()) throw new NoSuchElementException();
+ index++;
+ }
+ public void previousPanel() {
+ if (!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ }
+ public WizardDescriptor.Panel current() {
+ return panels[index];
+ }
+
+ // If nothing unusual changes in the middle of the wizard, simply:
+ public final void addChangeListener(ChangeListener l) {}
+ public final void removeChangeListener(ChangeListener l) {}
+ // If something changes dynamically (besides moving between panels),
+ // e.g. the number of panels changes in response to user input, then
+ // uncomment the following and call when needed:
+ // fireChangeEvent();
+ /*
+ private transient Set listeners = new HashSet(1); // Set<ChangeListener>
+ public final void addChangeListener(ChangeListener l) {
+ synchronized(listeners) {
+ listeners.add(l);
+ }
+ }
+ public final void removeChangeListener(ChangeListener l) {
+ synchronized(listeners) {
+ listeners.remove(l);
+ }
+ }
+ protected final void fireChangeEvent() {
+ Iterator it;
+ synchronized (listeners) {
+ it = new HashSet(listeners).iterator();
+ }
+ ChangeEvent ev = new ChangeEvent(this);
+ while (it.hasNext()) {
+ ((ChangeListener)it.next()).stateChanged(ev);
+ }
+ }
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ listeners = new HashSet(1);
+ }
+ */
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java
new file mode 100644
index 000000000000..5978ae6a19a9
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.awt.Component;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import javax.swing.JComponent;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.TopManager;
+import org.openide.NotifyDescriptor;
+import org.openide.WizardDescriptor;
+import org.openide.cookies.OpenCookie;
+import org.openide.cookies.SourceCookie;
+import org.openide.loaders.*;
+import org.openide.util.NbBundle;
+import org.openide.filesystems.*;
+
+import com.sun.star.script.framework.container.ParcelDescriptor;
+import org.openoffice.idesupport.zip.ParcelZipper;
+import org.openoffice.netbeans.modules.office.loader.ParcelFolder;
+import org.openoffice.netbeans.modules.office.loader.ParcelContentsFolder;
+import org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem;
+
+/** A template wizard iterator (sequence of panels).
+ * Used to fill in the second and subsequent panels in the New wizard.
+ * Associate this to a template inside a layer using the
+ * Sequence of Panels extra property.
+ * Create one or more panels from template as needed too.
+ *
+ * @author tomaso
+ */
+public class ParcelContentsIterator implements TemplateWizard.Iterator {
+
+
+ // private static final long serialVersionUID = ...L;
+
+ // You should define what panels you want to use here:
+
+ public static final String PROP_LANGUAGE =
+ ParcelFolder.LANGUAGE_ATTRIBUTE;
+
+ protected WizardDescriptor.Panel[] createPanels() {
+ return new WizardDescriptor.Panel[] {
+ // keep the default 2nd panel:
+ // wiz.targetChooser(),
+ new ParcelPropertiesPanel(),
+ };
+ }
+
+ // And the list of step names:
+
+ protected String[] createSteps() {
+ return new String[] {
+ // null,
+ "Parcel Properties",
+ };
+ }
+
+ private DataFolder checkTarget(DataFolder folder) {
+ FileObject fo = folder.getPrimaryFile();
+
+ try {
+ FileSystem fs = fo.getFileSystem();
+
+ if (fs instanceof OpenOfficeDocFileSystem && fo.isRoot()) {
+ FileObject scripts =
+ fo.getFileObject(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+ if (scripts == null)
+ scripts =
+ fo.createFolder(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+
+ FileObject javafolder = scripts.getFileObject("java");
+ if (javafolder == null)
+ javafolder = scripts.createFolder("java");
+
+ DataFolder subfolder = new DataFolder(javafolder);
+ return subfolder;
+ }
+ }
+ catch (IOException ioe) {
+ /* do nothing, we will just return the folder we were passed in */
+ }
+ return folder;
+ }
+
+ public Set instantiate(TemplateWizard wiz) throws IOException {
+ String name = wiz.getTargetName();
+ DataFolder targetFolder = wiz.getTargetFolder();
+ targetFolder = checkTarget(targetFolder);
+
+ String language = (String)wiz.getProperty(PROP_LANGUAGE);
+
+ DataObject template = wiz.getTemplate();
+ DataObject result;
+ if (name == null) {
+ // Default name.
+ result = template.createFromTemplate(targetFolder);
+ } else {
+ result = template.createFromTemplate(targetFolder, name);
+ }
+
+ FileObject recipe = result.getPrimaryFile();
+
+ FileObject contents =
+ recipe.getFileObject(ParcelZipper.CONTENTS_DIRNAME);
+
+ if (contents != null) {
+ File f = FileUtil.toFile(contents);
+ ParcelDescriptor pd = ParcelDescriptor.createParcelDescriptor(f);
+ pd.setLanguage(language);
+ pd.write();
+
+ DataFolder parent = DataFolder.findFolder(contents);
+ ParcelContentsFolder.createEmptyScript(parent, language);
+ }
+
+ return Collections.singleton(result);
+ }
+
+ // --- The rest probably does not need to be touched. ---
+
+ private transient int index;
+ private transient WizardDescriptor.Panel[] panels;
+ private transient TemplateWizard wiz;
+
+ // You can keep a reference to the TemplateWizard which can
+ // provide various kinds of useful information such as
+ // the currently selected target name.
+ // Also the panels will receive wiz as their "settings" object.
+ public void initialize(TemplateWizard wiz) {
+ this.wiz = wiz;
+ index = 0;
+ panels = createPanels();
+ // Make sure list of steps is accurate.
+ String[] steps = createSteps();
+ for (int i = 0; i < panels.length; i++) {
+ Component c = panels[i].getComponent();
+ if (steps[i] == null) {
+ // Default step name to component name of panel.
+ // Mainly useful for getting the name of the target
+ // chooser to appear in the list of steps.
+ steps[i] = c.getName();
+ }
+ if (c instanceof JComponent) { // assume Swing components
+ JComponent jc = (JComponent)c;
+ // Step #.
+ jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i)); // NOI18N
+ // Step name (actually the whole list for reference).
+ jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
+ }
+ }
+ }
+ public void uninitialize(TemplateWizard wiz) {
+ this.wiz = null;
+ panels = null;
+ }
+
+ // --- WizardDescriptor.Iterator METHODS: ---
+ // Note that this is very similar to WizardDescriptor.Iterator, but with a
+ // few more options for customization. If you e.g. want to make panels appear
+ // or disappear dynamically, go ahead.
+
+ public String name() {
+ return "";
+ }
+
+ public boolean hasNext() {
+ return index < panels.length - 1;
+ }
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+ public void nextPanel() {
+ if (!hasNext()) throw new NoSuchElementException();
+ index++;
+ }
+ public void previousPanel() {
+ if (!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ }
+ public WizardDescriptor.Panel current() {
+ return panels[index];
+ }
+
+ // If nothing unusual changes in the middle of the wizard, simply:
+ public final void addChangeListener(ChangeListener l) {}
+ public final void removeChangeListener(ChangeListener l) {}
+ // If something changes dynamically (besides moving between panels),
+ // e.g. the number of panels changes in response to user input, then
+ // uncomment the following and call when needed:
+ // fireChangeEvent();
+ /*
+ private transient Set listeners = new HashSet(1); // Set<ChangeListener>
+ public final void addChangeListener(ChangeListener l) {
+ synchronized(listeners) {
+ listeners.add(l);
+ }
+ }
+ public final void removeChangeListener(ChangeListener l) {
+ synchronized(listeners) {
+ listeners.remove(l);
+ }
+ }
+ protected final void fireChangeEvent() {
+ Iterator it;
+ synchronized (listeners) {
+ it = new HashSet(listeners).iterator();
+ }
+ ChangeEvent ev = new ChangeEvent(this);
+ while (it.hasNext()) {
+ ((ChangeListener)it.next()).stateChanged(ev);
+ }
+ }
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ listeners = new HashSet(1);
+ }
+ */
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java
new file mode 100644
index 000000000000..704bb6f66aed
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java
@@ -0,0 +1,117 @@
+/*
+ * ParcelPropertiesPanel.java
+ *
+ * Created on January 15, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.awt.Component;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.WizardDescriptor;
+import org.openide.loaders.TemplateWizard;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+
+/** A single panel descriptor for a wizard.
+ * You probably want to make a wizard iterator to hold it.
+ *
+ * @author tomaso
+ */
+public class ParcelPropertiesPanel implements WizardDescriptor.FinishPanel {
+
+ /** The visual component that displays this panel.
+ * If you need to access the component from this class,
+ * just use getComponent().
+ */
+ private ParcelPropertiesVisualPanel component;
+
+ /** Create the wizard panel descriptor. */
+ public ParcelPropertiesPanel() {
+ }
+
+ // Get the visual component for the panel. In this template, the component
+ // is kept separate. This can be more efficient: if the wizard is created
+ // but never displayed, or not all panels are displayed, it is better to
+ // create only those which really need to be visible.
+ public Component getComponent() {
+ if (component == null) {
+ component = new ParcelPropertiesVisualPanel(this);
+ }
+ return component;
+ }
+
+ public HelpCtx getHelp() {
+ // Show no Help button for this panel:
+ return HelpCtx.DEFAULT_HELP;
+ // If you have context help:
+ // return new HelpCtx(ParcelPropertiesPanel.class);
+ }
+
+ public boolean isValid() {
+ // If it is always OK to press Next or Finish, then:
+ return true;
+ // If it depends on some condition (form filled out...), then:
+ // return someCondition();
+ // and when this condition changes (last form field filled in...) then:
+ // fireChangeEvent();
+ // and uncomment the complicated stuff below.
+ }
+
+ public final void addChangeListener(ChangeListener l) {}
+ public final void removeChangeListener(ChangeListener l) {}
+ /*
+ private final Set listeners = new HashSet(1); // Set<ChangeListener>
+ public final void addChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.add(l);
+ }
+ }
+ public final void removeChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.remove(l);
+ }
+ }
+ protected final void fireChangeEvent() {
+ Iterator it;
+ synchronized (listeners) {
+ it = new HashSet(listeners).iterator();
+ }
+ ChangeEvent ev = new ChangeEvent(this);
+ while (it.hasNext()) {
+ ((ChangeListener)it.next()).stateChanged(ev);
+ }
+ }
+ */
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ private String language = "Java";
+ private String name = null;
+
+ // You can use a settings object to keep track of state.
+ // Normally the settings object will be the WizardDescriptor,
+ // so you can use WizardDescriptor.getProperty & putProperty
+ // to store information entered by the user.
+ public void readSettings(Object settings) {
+ }
+
+ public void storeSettings(Object settings) {
+ TemplateWizard wiz = (TemplateWizard)settings;
+ wiz.setTargetName(name);
+ wiz.putProperty(ParcelContentsIterator.PROP_LANGUAGE, language);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form
new file mode 100644
index 000000000000..0bfb183f5047
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[500, 300]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,75,0,0,1,-112"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Parcel Recipe Name"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="11" insetsRight="2" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JTextField" name="recipeName">
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="recipeNameActionPerformed"/>
+ <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="recipeNameFocusGained"/>
+ <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="recipeNameFocusLost"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="0" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="10" weightX="1.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Initial Script Language"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="11" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="languagesComboBox">
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="languagesComboBoxActionPerformed"/>
+ </Events>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CodeGeneration" type="java.lang.Integer" value="0"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java
new file mode 100644
index 000000000000..fa3ea085dadb
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java
@@ -0,0 +1,157 @@
+/*
+ * ParcelPropertiesVisualPanel.java
+ *
+ * Created on January 15, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import org.openide.util.NbBundle;
+
+/** A single panel for a wizard - the GUI portion.
+ *
+ * @author tomaso
+ */
+public class ParcelPropertiesVisualPanel extends javax.swing.JPanel {
+
+ /** The wizard panel descriptor associated with this GUI panel.
+ * If you need to fire state changes or something similar, you can
+ * use this handle to do so.
+ */
+ private final ParcelPropertiesPanel panel;
+
+ /** Create the wizard panel and set up some basic properties. */
+ public ParcelPropertiesVisualPanel(ParcelPropertiesPanel panel) {
+ this.panel = panel;
+ initComponents();
+
+ languagesComboBox.addItem("Java");
+ languagesComboBox.addItem("BeanShell");
+
+ // Provide a name in the title bar.
+ setName(NbBundle.getMessage(ParcelPropertiesVisualPanel.class, "TITLE_ParcelPropertiesVisualPanel"));
+ /*
+ // Optional: provide a special description for this pane.
+ // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed
+ // (see descriptor in standard iterator template for an example of this).
+ try {
+ putClientProperty("WizardPanel_helpURL", // NOI18N
+ new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualHelp.html")); // NOI18N
+ } catch (MalformedURLException mfue) {
+ throw new IllegalStateException(mfue.toString());
+ }
+ */
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ private void initComponents() {//GEN-BEGIN:initComponents
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ jLabel1 = new javax.swing.JLabel();
+ recipeName = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ languagesComboBox = new javax.swing.JComboBox();
+ jPanel1 = new javax.swing.JPanel();
+
+ setLayout(new java.awt.GridBagLayout());
+
+ setPreferredSize(new java.awt.Dimension(500, 300));
+ jLabel1.setText("Parcel Recipe Name");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 2);
+ add(jLabel1, gridBagConstraints);
+
+ recipeName.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ recipeNameActionPerformed(evt);
+ }
+ });
+
+ recipeName.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusGained(java.awt.event.FocusEvent evt) {
+ recipeNameFocusGained(evt);
+ }
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ recipeNameFocusLost(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(12, 0, 11, 11);
+ add(recipeName, gridBagConstraints);
+
+ jLabel2.setText("Initial Script Language");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 12);
+ add(jLabel2, gridBagConstraints);
+
+ languagesComboBox.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ languagesComboBoxActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
+ add(languagesComboBox, gridBagConstraints);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
+ gridBagConstraints.weighty = 1.0;
+ add(jPanel1, gridBagConstraints);
+
+ }//GEN-END:initComponents
+
+ private void recipeNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusGained
+ recipeName.selectAll();
+ }//GEN-LAST:event_recipeNameFocusGained
+
+ private void recipeNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusLost
+ changeName();
+ }//GEN-LAST:event_recipeNameFocusLost
+
+ private void languagesComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languagesComboBoxActionPerformed
+ String language = (String)languagesComboBox.getSelectedItem();
+ panel.setLanguage(language);
+ }//GEN-LAST:event_languagesComboBoxActionPerformed
+
+ private void recipeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recipeNameActionPerformed
+ changeName();
+ }//GEN-LAST:event_recipeNameActionPerformed
+
+ private void changeName() {
+ String name = recipeName.getText().trim();
+ if (name.equals(""))
+ name = null;
+ panel.setName(name);
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField recipeName;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JComboBox languagesComboBox;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java
new file mode 100644
index 000000000000..77f1c0f8b2e5
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java
@@ -0,0 +1,123 @@
+/*
+ * SelectPathPanel.java
+ *
+ * Created on February 12, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.awt.Component;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.openide.WizardDescriptor;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+import org.openoffice.idesupport.OfficeInstallation;
+import org.openoffice.idesupport.SVersionRCFile;
+
+/** A single panel descriptor for a wizard.
+ * You probably want to make a wizard iterator to hold it.
+ *
+ * @author tomaso
+ */
+public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel */ {
+
+ /** The visual component that displays this panel.
+ * If you need to access the component from this class,
+ * just use getComponent().
+ */
+ private SelectPathVisualPanel component;
+ private OfficeInstallation office;
+
+ /** Create the wizard panel descriptor. */
+ public SelectPathPanel() {
+ office = OfficeSettings.getDefault().getOfficeDirectory();
+
+ if (office == null) {
+ try {
+ office = SVersionRCFile.createInstance().getDefaultVersion();
+ }
+ catch (java.io.IOException ioe) {}
+ }
+ }
+
+ // Get the visual component for the panel. In this template, the component
+ // is kept separate. This can be more efficient: if the wizard is created
+ // but never displayed, or not all panels are displayed, it is better to
+ // create only those which really need to be visible.
+ public Component getComponent() {
+ if (component == null) {
+ component = new SelectPathVisualPanel(this);
+ }
+ return component;
+ }
+
+ public HelpCtx getHelp() {
+ // Show no Help button for this panel:
+ return HelpCtx.DEFAULT_HELP;
+ // If you have context help:
+ // return new HelpCtx(SelectPathPanel.class);
+ }
+
+ public boolean isValid() {
+ // If it is always OK to press Next or Finish, then:
+ return true;
+ // If it depends on some condition (form filled out...), then:
+ // return someCondition();
+ // and when this condition changes (last form field filled in...) then:
+ // fireChangeEvent();
+ // and uncomment the complicated stuff below.
+ }
+
+ // public final void addChangeListener(ChangeListener l) {}
+ // public final void removeChangeListener(ChangeListener l) {}
+
+ private final Set listeners = new HashSet(1); // Set<ChangeListener>
+ public final void addChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.add(l);
+ }
+ }
+ public final void removeChangeListener(ChangeListener l) {
+ synchronized (listeners) {
+ listeners.remove(l);
+ }
+ }
+ protected final void fireChangeEvent() {
+ Iterator it;
+ synchronized (listeners) {
+ it = new HashSet(listeners).iterator();
+ }
+ ChangeEvent ev = new ChangeEvent(this);
+ while (it.hasNext()) {
+ ((ChangeListener)it.next()).stateChanged(ev);
+ }
+ }
+
+ public void setSelectedPath(OfficeInstallation oi) {
+ this.office = oi;
+ fireChangeEvent();
+ }
+
+ public OfficeInstallation getSelectedPath() {
+ return office;
+ }
+
+ // You can use a settings object to keep track of state.
+ // Normally the settings object will be the WizardDescriptor,
+ // so you can use WizardDescriptor.getProperty & putProperty
+ // to store information entered by the user.
+ public void readSettings(Object settings) {
+ }
+
+ public void storeSettings(Object settings) {
+ WizardDescriptor wiz = (WizardDescriptor)settings;
+ wiz.putProperty(InstallationPathDescriptor.PROP_INSTALLPATH, office);
+ }
+}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form
new file mode 100644
index 000000000000..b054e349f390
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[600, 300]"/>
+ </Property>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,27,0,0,2,1"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Installations Detected"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="11" insetsRight="2" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JTextField" name="installPath">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="10" weightX="1.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Installation Directory"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="11" insetsRight="12" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="installationsComboBox">
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value=""/>
+ <AuxValue name="JavaCodeGenerator_CodeGeneration" type="java.lang.Integer" value="0"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="11" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ <Component class="javax.swing.JButton" name="browseButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Browse..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="2" gridY="1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ </SubComponents>
+</Form>
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java
new file mode 100644
index 000000000000..b39cd4452d4c
--- /dev/null
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java
@@ -0,0 +1,196 @@
+/*
+ * SelectPathVisualPanel.java
+ *
+ * Created on February 12, 2003
+ */
+
+package org.openoffice.netbeans.modules.office.wizard;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.io.File;
+import java.io.IOException;
+import javax.swing.JFileChooser;
+
+import org.openide.util.NbBundle;
+import org.openoffice.idesupport.SVersionRCFile;
+import org.openoffice.idesupport.OfficeInstallation;
+import org.openoffice.netbeans.modules.office.options.OfficeSettings;
+
+/** A single panel for a wizard - the GUI portion.
+ *
+ * @author tomaso
+ */
+public class SelectPathVisualPanel extends javax.swing.JPanel {
+
+ /** The wizard panel descriptor associated with this GUI panel.
+ * If you need to fire state changes or something similar, you can
+ * use this handle to do so.
+ */
+ private final SelectPathPanel panel;
+
+ /** Create the wizard panel and set up some basic properties. */
+ public SelectPathVisualPanel(SelectPathPanel panel) {
+ this.panel = panel;
+ initComponents();
+ OfficeInstallation orig = panel.getSelectedPath();
+
+ try {
+ Enumeration enumer = SVersionRCFile.createInstance().getVersions();
+
+ while (enumer.hasMoreElements()) {
+ OfficeInstallation oi = (OfficeInstallation)enumer.nextElement();
+ installationsComboBox.addItem(oi);
+ }
+ }
+ catch (IOException ioe) {
+ installationsComboBox.addItem("<empty>");
+ }
+
+ if (orig != null) {
+ installationsComboBox.setSelectedItem(orig);
+ installPath.setText(orig.getPath());
+ }
+
+ installationsComboBox.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installationsComboBoxActionPerformed(evt);
+ }
+ }
+ );
+
+ // Provide a name in the title bar.
+ setName(NbBundle.getMessage(SelectPathVisualPanel.class, "TITLE_SelectPathVisualPanel"));
+ /*
+ // Optional: provide a special description for this pane.
+ // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed
+ // (see descriptor in standard iterator template for an example of this).
+ try {
+ putClientProperty("WizardPanel_helpURL", // NOI18N
+ new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualHelp.html")); // NOI18N
+ } catch (MalformedURLException mfue) {
+ throw new IllegalStateException(mfue.toString());
+ }
+ */
+ }
+
+ private void installationsComboBoxActionPerformed(
+ java.awt.event.ActionEvent evt) {
+
+ OfficeInstallation oi =
+ (OfficeInstallation)installationsComboBox.getSelectedItem();
+
+ installPath.setText(oi.getPath());
+ panel.setSelectedPath(oi);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ private void initComponents() {//GEN-BEGIN:initComponents
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ jLabel1 = new javax.swing.JLabel();
+ installPath = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ installationsComboBox = new javax.swing.JComboBox();
+ jPanel1 = new javax.swing.JPanel();
+ browseButton = new javax.swing.JButton();
+
+ setLayout(new java.awt.GridBagLayout());
+
+ setPreferredSize(new java.awt.Dimension(600, 300));
+ jLabel1.setText("Installations Detected");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 2);
+ add(jLabel1, gridBagConstraints);
+
+ installPath.setEditable(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(12, 0, 11, 11);
+ add(installPath, gridBagConstraints);
+
+ jLabel2.setText("Installation Directory");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 12);
+ add(jLabel2, gridBagConstraints);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(11, 0, 11, 11);
+ add(installationsComboBox, gridBagConstraints);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
+ gridBagConstraints.weighty = 1.0;
+ add(jPanel1, gridBagConstraints);
+
+ browseButton.setText("Browse...");
+ browseButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ browseButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ add(browseButton, gridBagConstraints);
+
+ }//GEN-END:initComponents
+
+ private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
+ // Add your handling code here:
+ File target = null;
+
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ int result = chooser.showDialog(null, null);
+
+ if (result == JFileChooser.APPROVE_OPTION) {
+ target = chooser.getSelectedFile();
+
+ String path;
+ try {
+ path = target.getCanonicalPath();
+ }
+ catch (IOException ioe) {
+ path = target.getAbsolutePath();
+ }
+
+ OfficeInstallation oi = new OfficeInstallation(path, path);
+
+ if (oi.supportsFramework()) {
+ installPath.setText(path);
+ panel.setSelectedPath(oi);
+ }
+ }
+
+ }//GEN-LAST:event_browseButtonActionPerformed
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField installPath;
+ private javax.swing.JButton browseButton;
+ private javax.swing.JComboBox installationsComboBox;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel1;
+ // End of variables declaration//GEN-END:variables
+}