From 6484f92ba1b2420dbbf0533c55ead08acd32e6eb Mon Sep 17 00:00:00 2001 From: Bertrand Delacretaz Date: Thu, 31 Oct 2002 17:26:05 +0000 Subject: [PATCH] rtf renderer selection mechanism added, no rtf renderer yet git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195396 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/apps/CommandLineOptions.java | 21 ++++++++++++++++++- src/org/apache/fop/apps/Driver.java | 9 ++++++++ src/org/apache/fop/tools/anttasks/Fop.java | 6 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java index 764424308..4297d2e56 100644 --- a/src/org/apache/fop/apps/CommandLineOptions.java +++ b/src/org/apache/fop/apps/CommandLineOptions.java @@ -50,6 +50,8 @@ public class CommandLineOptions { private static final int SVG_OUTPUT = 8; /* output: XML area tree */ private static final int AREA_OUTPUT = 9; + /* output: RTF file */ + private static final int RTF_OUTPUT = 10; /* show configuration information */ Boolean dumpConfiguration = Boolean.FALSE; @@ -184,6 +186,15 @@ public class CommandLineOptions { outfile = new File(args[i + 1]); i++; } + } else if (args[i].equals("-rtf")) { + setOutputMode(RTF_OUTPUT); + if ((i + 1 == args.length) + || (args[i + 1].charAt(0) == '-')) { + throw new FOPException("you must specify the rtf output file"); + } else { + outfile = new File(args[i + 1]); + i++; + } } else if (args[i].equals("-print")) { setOutputMode(PRINT_OUTPUT); // show print help @@ -347,6 +358,8 @@ public class CommandLineOptions { case AREA_OUTPUT: rendererOptions.put("fineDetail", isCoarseAreaXml()); return Driver.RENDER_XML; + case RTF_OUTPUT: + return Driver.RENDER_RTF; default: throw new FOPException("Invalid Renderer setting!"); } @@ -471,7 +484,7 @@ public class CommandLineOptions { * shows the commandline syntax including a summary of all available options and some examples */ public static void printUsage() { - System.err.println("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|-at|-print] \n" + System.err.println("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] \n" + " [OPTIONS] \n" + " -d debug mode \n" + " -x dump configuration settings \n" @@ -489,6 +502,7 @@ public class CommandLineOptions { + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n" + " -awt input will be displayed on screen \n" + " -mif outfile input will be rendered as mif file (outfile req'd)\n" + + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n" + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n" + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n" + " -txt outfile input will be rendered as text file (outfile req'd) \n" @@ -500,6 +514,7 @@ public class CommandLineOptions { + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n" + " Fop foo.fo -mif foo.mif\n" + + " Fop foo.fo -rtf foo.rtf\n" + " Fop foo.fo -print or Fop -print foo.fo \n" + " Fop foo.fo -awt \n"); } @@ -556,6 +571,10 @@ public class CommandLineOptions { log.debug("mif"); log.debug("output file: " + outfile.toString()); break; + case RTF_OUTPUT: + log.debug("rtf"); + log.debug("output file: " + outfile.toString()); + break; case PRINT_OUTPUT: log.debug("print directly"); if (outfile != null) { diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 4b341a0cd..d885c9ab2 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -134,6 +134,11 @@ public class Driver implements LogEnabled { */ public static final int RENDER_SVG = 9; + /** + * Render to RTF. OutputStream must be set + */ + public static final int RENDER_RTF = 10; + /** * the FO tree builder */ @@ -308,6 +313,7 @@ public class Driver implements LogEnabled { *
  • RENDER_PS *
  • RENDER_TXT *
  • RENDER_SVG + *
  • RENDER_RTF * * @param renderer the type of renderer to use */ @@ -338,6 +344,9 @@ public class Driver implements LogEnabled { case RENDER_SVG: setRenderer("org.apache.fop.render.svg.SVGRenderer"); break; + case RENDER_RTF: + if(true) throw new IllegalArgumentException("-rtf option recognized but RTF output is not implemented yet"); + break; default: throw new IllegalArgumentException("Unknown renderer type"); } diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java index cc9e07e3b..47a665c7e 100644 --- a/src/org/apache/fop/tools/anttasks/Fop.java +++ b/src/org/apache/fop/tools/anttasks/Fop.java @@ -205,6 +205,10 @@ class FOPTaskStarter extends Starter { } else if (format.equalsIgnoreCase("application/vnd.mif") || format.equalsIgnoreCase("mif")) { return Driver.RENDER_MIF; + } else if (format.equalsIgnoreCase("application/msword") || + format.equalsIgnoreCase("application/rtf") || + format.equalsIgnoreCase("rtf")) { + return Driver.RENDER_RTF; } else if (format.equalsIgnoreCase("application/vnd.hp-PCL") || format.equalsIgnoreCase("pcl")) { return Driver.RENDER_PCL; @@ -230,6 +234,8 @@ class FOPTaskStarter extends Starter { return ".ps"; case Driver.RENDER_MIF: return ".mif"; + case Driver.RENDER_RTF: + return ".rtf"; case Driver.RENDER_PCL: return ".pcl"; case Driver.RENDER_TXT: -- 2.39.5