19 package org.openoffice.xmerge.test;
22 import java.io.FileInputStream;
23 import java.io.FileOutputStream;
24 import java.util.ArrayList;
25 import java.util.Iterator;
54 private final ArrayList<String>
deviceFiles =
new ArrayList<String>();
58 "sxc",
"staroffice/sxc",
59 "sxw",
"staroffice/sxw"
67 public static void main(String args[]) {
70 String propFile =
"ConverterInfoList.properties";
74 while (jarFileEnum.hasNext()) {
75 String jarName = jarFileEnum.next();
81 System.out.println(
"\nCannot not load <" + jarName +
82 "> from the <" + propFile +
"> property file");
89 }
catch (IllegalArgumentException ex) {
91 String msg = ex.getMessage();
92 if (msg != null)
System.out.println(
"\n" + msg);
97 String msg = ex.getMessage();
98 if (msg != null)
System.out.println(
"\n" + msg);
103 private static void close(FileOutputStream c) {
104 if (c == null)
return;
122 String processFile = null;
124 if (myConvert == null) {
125 System.out.println(
"\nNo plug-in exists to convert from <" +
126 fromMime +
"> to <" + toMime +
">");
127 throw new IllegalArgumentException();
131 Iterator<String> dfEnum = deviceFiles.iterator();
132 while (dfEnum.hasNext()) {
133 processFile = dfEnum.next();
138 System.out.println(processFile +
" does not exist!");
141 FileInputStream fis =
new FileInputStream(f);
145 throw new IllegalArgumentException(
"\nFile <" + processFile +
"> is not in <" +
146 fromMime +
"> format", addExcept);
154 System.out.println(
"\nThere was an error in the conversion");
155 convertExcept.printStackTrace();
158 if (dataOut != null ) {
160 if (mergeFile == null) {
162 while (docEnum.hasNext()) {
165 FileOutputStream fos = null;
167 fos =
new FileOutputStream(fileName);
171 System.out.println(
"\nThere was a writing out file <" +
173 writeExcept.printStackTrace();
180 FileInputStream mergeIS =
new FileInputStream(mergeFile);
186 merger.
merge(convertedFile);
189 FileOutputStream fos = null;
191 fos =
new FileOutputStream(mergeFile);
198 System.out.println(
"\nThere was an error in the merge");
199 mergeExcept.printStackTrace();
209 System.out.println(
"\nUsage:");
210 System.out.println(
"\n java org.openoffice.xmerge.test.Driver <args>");
211 System.out.println(
"\n where <args> is as follows:");
212 System.out.println(
" -from <MIMETYPE> -to <MIMETYPE> [ -merge <OrigDoc ] <document>\n");
223 throws IllegalArgumentException {
225 if (
args.length == 0) {
226 throw new IllegalArgumentException();
229 for (
int i = 0;
i <
args.length;
i++) {
232 if (
"-to".equals(arg)) {
234 for (
int j = 0; j < mimeTypes.length; j+=2) {
236 toMime = mimeTypes[j+1];
239 }
else if (
"-from".equals(arg)) {
241 for (
int j = 0; j < mimeTypes.length; j+=2) {
243 fromMime = mimeTypes[j+1];
246 }
else if (
"-merge".equals(arg)) {
248 if (!
isZip(mergeFile)) {
250 IllegalArgumentException(
"Arg " +
i +
251 ": expected zip, got " +
256 deviceFiles.add(arg);
260 System.out.println(
"\nConverting from " + fromMime +
" to " + toMime +
261 ((mergeFile != null) ?
" with merge " :
" "));
279 throws IllegalArgumentException {
281 if (
i+1 <
args.length)
284 IllegalArgumentException(
"Arg " +
i +
285 ": expected arg for " +
args[
i]);
295 private boolean isZip(String zipName) {
297 String str = zipName.toLowerCase();
298 return str.endsWith(
"sxw") || zipName.endsWith(
"sxc");
This class is a command-line driver for the converter framework.
Factory that provides access to.
Provides general purpose utilities.
Provides an interface for plug-in registration.
void parseCommandLine(String args[])
Parse command-line arguments.
DocumentMerger getDocumentMerger(Document origDoc)
Returns a.
final String mimeTypes[]
Command-line parameter shortcuts.
Document getOfficeDocument(String name, InputStream is)
Returns the appropriate "Office".
Convert getConverter(String mimeTypeIn, String mimeTypeOut)
Returns the.
exports com.sun.star. java
final ArrayList< String > deviceFiles
Command-line parameter.
Manages the converter plug-ins that are currently active.
static void addPlugIn(ConverterInfo ci)
Adds a converter plug-in to the registry.
static void showUsage()
Display usage.
boolean isZip(String zipName)
Simple validation for Office ZIP files.
Iterator< String > getJarFileEnum()
Returns an.
Iterator< Object > getDocumentEnumeration()
Gets an.
String fromMime
Command-line parameter.
String getFileName()
Returns the.
void doConversion()
Gets a.
void write(OutputStream os)
Writes out the.
Class for storing the information about a converter plug-in.
static void close(FileOutputStream c)
void(* f)(TrueTypeTable *)
Provides interfaces for converting between two.
void addInputStream(String name, InputStream is)
Adds an.
static void main(String args[])
Main.
void merge(Document modifiedDoc)
This method will find the changes that had happened in the.
String extractArg(int i, String args[])
Extract the next argument from the array, while checking to see that the array size is not exceeded...
ConvertData convert()
Convert the input specified in calls to the.
Iterator< ConverterInfo > getConverterInfoEnumeration()
Returns an.
String toMime
Command-line parameter.
Loads a properties file so that registry knows which plug-ins it needs to load.