From 3a8d3519889a68ddf209ea7c83307bec51cd6da0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 12 Aug 2014 12:11:25 +0200 Subject: java: remove unused methods Change-Id: Ibb905e6f3e7d92a0e558f1f6562e5b472cd2717b --- .../script/framework/browse/DialogFactory.java | 95 ------ .../framework/container/ParcelDescriptor.java | 31 -- .../openoffice/idesupport/zip/ParcelZipper.java | 376 --------------------- scripting/workben/installer/InstUtil.java | 62 ---- 4 files changed, 564 deletions(-) (limited to 'scripting') diff --git a/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java index 4b80e9a685f1..6e46e193f8cf 100644 --- a/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java +++ b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java @@ -126,101 +126,6 @@ public class DialogFactory 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 = 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 = - 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 = 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 = 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 = UnoRuntime.queryInterface( - XPropertySet.class, cancelButtonModel); - buttonProps.setPropertyValue("Name", "Cancel"); - buttonProps.setPropertyValue("Label", "Cancel"); - - // insert the control models into the dialog model - XNameContainer xNameCont = 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 = UnoRuntime.queryInterface( - XControl.class, dialog); - - 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 = UnoRuntime.queryInterface( - XToolkit.class, toolkit); - XWindow xWindow = UnoRuntime.queryInterface( - XWindow.class, xControl); - xWindow.setVisible(false); - xControl.createPeer(xToolkit, null); - - return UnoRuntime.queryInterface(XDialog.class, dialog); - } - private void setDimensions(Object o, int x, int y, int width, int height) throws com.sun.star.uno.Exception { diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java index 0fd2c85d9969..8f39afdc9568 100644 --- a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java +++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java @@ -20,7 +20,6 @@ package com.sun.star.script.framework.container; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -60,28 +59,6 @@ public class ParcelDescriptor { - // returns the ParcelDescriptor in the corresponding directory - // returns null if no ParcelDescriptor is found in the directory - private static synchronized ParcelDescriptor - getParcelDescriptor(File parent) { - - File path = new File(parent, PARCEL_DESCRIPTOR_NAME); - ParcelDescriptor pd = 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; - } - - - public ParcelDescriptor() throws IOException { ByteArrayInputStream bis = null; try { @@ -136,14 +113,6 @@ public class ParcelDescriptor { initLanguageProperties(); } - private void write(File file) throws IOException { - FileOutputStream fos = new FileOutputStream(file); - XMLParserFactory.getParser().write(document, fos); - fos.close(); - } - - - 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 index 30cf598a706a..45cdb185f313 100644 --- a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java +++ b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java @@ -19,11 +19,9 @@ package org.openoffice.idesupport.zip; import java.io.*; -import java.util.Enumeration; import java.util.zip.*; import org.openoffice.idesupport.filter.FileFilter; import org.openoffice.idesupport.filter.BinaryOnlyFilter; -import com.sun.star.script.framework.container.ParcelDescriptor; import org.openoffice.idesupport.xml.Manifest; public class ParcelZipper @@ -57,315 +55,6 @@ public class ParcelZipper - private 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(); - } - } - - - - 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; - } - - - - 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