/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: CommandLineTools.java,v $ * * $Revision: 1.9 $ * * last change: $Author: rt $ $Date: 2005-09-09 02:05:31 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library 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 for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ************************************************************************/ 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