diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-10-07 14:22:35 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-10-07 14:22:35 +0000 |
commit | 100d17a594efcbe9594acb6df6144e87284ab303 (patch) | |
tree | f67782f7dea18631d66020b7f1158a2dd0d7b4f3 /src/java/org/apache/fop/cli | |
parent | f59abd860a61c94ee6f0d31178b92ef7ea1bff32 (diff) | |
download | xmlgraphics-fop-100d17a594efcbe9594acb6df6144e87284ab303.tar.gz xmlgraphics-fop-100d17a594efcbe9594acb6df6144e87284ab303.zip |
Allow "-if [mime] out" as for "-at".
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@822753 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/cli')
-rw-r--r-- | src/java/org/apache/fop/cli/CommandLineOptions.java | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 7a6bc7353..3bc694a79 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -30,9 +30,10 @@ import java.util.Vector; import javax.swing.UIManager; +import org.xml.sax.SAXException; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.xml.sax.SAXException; import org.apache.fop.Version; import org.apache.fop.apps.FOPException; @@ -45,7 +46,9 @@ import org.apache.fop.pdf.PDFEncryptionParams; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.render.Renderer; import org.apache.fop.render.awt.AWTRenderer; -import org.apache.fop.render.intermediate.IFRenderer; +import org.apache.fop.render.intermediate.IFContext; +import org.apache.fop.render.intermediate.IFDocumentHandler; +import org.apache.fop.render.intermediate.IFSerializer; import org.apache.fop.render.pdf.PDFRenderer; import org.apache.fop.render.print.PagesMode; import org.apache.fop.render.print.PrintRenderer; @@ -209,13 +212,19 @@ public class CommandLineOptions { //Make sure the prepared XMLRenderer is used foUserAgent.setRendererOverride(xmlRenderer); - } else if (MimeConstants.MIME_FOP_IF.equals(outputmode)) { + } else if (MimeConstants.MIME_FOP_IF.equals(outputmode) + && mimicRenderer != null) { // render from FO to Intermediate Format - IFRenderer xml2Renderer = new IFRenderer(); - xml2Renderer.setUserAgent(foUserAgent); + IFSerializer serializer = new IFSerializer(); + serializer.setContext(new IFContext(foUserAgent)); + + IFDocumentHandler targetHandler + = foUserAgent.getRendererFactory().createDocumentHandler( + foUserAgent, mimicRenderer); + serializer.mimicDocumentHandler(targetHandler); - //Make sure the prepared IFRenderer is used - foUserAgent.setRendererOverride(xml2Renderer); + //Make sure the prepared serializer is used + foUserAgent.setDocumentHandlerOverride(serializer); } return true; } @@ -709,11 +718,12 @@ public class CommandLineOptions { } else if ((i + 2 == args.length) || (args[i + 2].charAt(0) == '-')) { // only output file is specified - outfile = new File(args[i + 1]); + setOutputFile(args[i + 1]); return 1; } else { // mimic format and output file have been specified - outfile = new File(args[i + 2]); + mimicRenderer = args[i + 1]; + setOutputFile(args[i + 2]); return 2; } } @@ -1167,16 +1177,18 @@ public class CommandLineOptions { + " -png outfile input will be rendered as PNG (outfile req'd)\n" + " -txt outfile input will be rendered as plain text (outfile req'd) \n" + " -at [mime] out representation of area tree as XML (outfile req'd) \n" - + " specify optional mime output to allow AT to be converted\n" + + " specify optional mime output to allow the AT to be converted\n" + + " to final format later\n" + + " -if [mime] out representation of document in intermediate format XML (outfile req'd)\n" + + " specify optional mime output to allow the IF to be converted\n" + " to final format later\n" - + " -if out representation of area tree as intermediate format XML (outfile req'd)\n" + " -print input file will be rendered and sent to the printer \n" + " see options with \"-print help\" \n" + " -out mime outfile input will be rendered using the given MIME type\n" + " (outfile req'd) Example: \"-out application/pdf D:\\out.pdf\"\n" + " (Tip: \"-out list\" prints the list of supported MIME types)\n" - + " -mif outfile input will be rendered as MIF (FrameMaker) (outfile req'd)\n" - + " Experimental feature - requires additional fop-sandbox.jar.\n" + //+ " -mif outfile input will be rendered as MIF (FrameMaker) (outfile req'd)\n" + //+ " Experimental feature - requires additional fop-sandbox.jar.\n" + " -svg outfile input will be rendered as an SVG slides file (outfile req'd) \n" + " Experimental feature - requires additional fop-sandbox.jar.\n" + "\n" @@ -1219,7 +1231,7 @@ public class CommandLineOptions { break; case FO_INPUT: log.info("FO "); - if (this.useStdIn) { + if (isInputFromStdIn()) { log.info("fo input file: from stdin"); } else { log.info("fo input file: " + fofile.toString()); @@ -1227,7 +1239,7 @@ public class CommandLineOptions { break; case XSLT_INPUT: log.info("xslt transformation"); - if (this.useStdIn) { + if (isInputFromStdIn()) { log.info("xml input file: from stdin"); } else { log.info("xml input file: " + xmlfile.toString()); @@ -1236,7 +1248,7 @@ public class CommandLineOptions { break; case AREATREE_INPUT: log.info("AT "); - if (this.useStdIn) { + if (isInputFromStdIn()) { log.info("area tree input file: from stdin"); } else { log.info("area tree input file: " + areatreefile.toString()); @@ -1244,7 +1256,7 @@ public class CommandLineOptions { break; case IF_INPUT: log.info("IF "); - if (this.useStdIn) { + if (isInputFromStdIn()) { log.info("intermediate input file: from stdin"); } else { log.info("intermediate input file: " + iffile.toString()); @@ -1252,7 +1264,7 @@ public class CommandLineOptions { break; case IMAGE_INPUT: log.info("Image "); - if (this.useStdIn) { + if (isInputFromStdIn()) { log.info("image input file: from stdin"); } else { log.info("image input file: " + imagefile.toString()); @@ -1281,7 +1293,7 @@ public class CommandLineOptions { if (mimicRenderer != null) { log.info("mimic renderer: " + mimicRenderer); } - if (this.useStdOut) { + if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { log.info("output file: " + outfile.toString()); @@ -1291,7 +1303,7 @@ public class CommandLineOptions { log.info("output file: " + outfile.toString()); } else { log.info(outputmode); - if (this.useStdOut) { + if (isOutputToStdOut()) { log.info("output file: to stdout"); } else { log.info("output file: " + outfile.toString()); |