aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/apps/FOUserAgent.java3
-rw-r--r--src/java/org/apache/fop/apps/Fop.java11
-rw-r--r--src/java/org/apache/fop/cli/CommandLineOptions.java3
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java6
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java4
-rw-r--r--src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java4
-rw-r--r--src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java4
-rw-r--r--src/java/org/apache/fop/servlet/FopPrintServlet.java9
-rw-r--r--src/java/org/apache/fop/servlet/FopServlet.java7
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java49
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java127
11 files changed, 116 insertions, 111 deletions
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java
index 5d2686920..e8e86eb45 100644
--- a/src/java/org/apache/fop/apps/FOUserAgent.java
+++ b/src/java/org/apache/fop/apps/FOUserAgent.java
@@ -39,6 +39,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
// FOP
+import org.apache.fop.Version;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
@@ -117,7 +118,7 @@ public class FOUserAgent {
/** Producer: Metadata element for the system/software that produces
* the document. (Some renderers can store this in the document.)
*/
- protected String producer = "Apache FOP Version " + Fop.getVersion();
+ protected String producer = "Apache FOP Version " + Version.getVersion();
/** Creator: Metadata element for the user that created the
* document. (Some renderers can store this in the document.)
diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java
index 912e1a402..e87c1aa4d 100644
--- a/src/java/org/apache/fop/apps/Fop.java
+++ b/src/java/org/apache/fop/apps/Fop.java
@@ -32,7 +32,8 @@ import org.apache.fop.fo.FOTreeBuilder;
* Primary class that activates the FOP process for embedded usage.
* <P>
* JAXP is the standard method of embedding FOP in Java programs.
- * Please check our <a href="http://xmlgraphics.apache.org/fop/embedding.html">embedding page</a>
+ * Please check our
+ * <a href="http://xmlgraphics.apache.org/fop/trunk/embedding.html">embedding page</a>
* for samples (these are also available within the distribution in
* FOP_DIR\examples\embedding)
* <P>
@@ -40,6 +41,9 @@ import org.apache.fop.fo.FOTreeBuilder;
* process. For example, a specific Renderer object can be specified,
* also ElementMappings which determine elements in the FO that can be
* processed) can be added.
+ * <P>
+ * At the moment, it is recommended not to reuse an instance of this
+ * class for more than one rendering run.
*/
public class Fop implements Constants {
@@ -103,6 +107,8 @@ public class Fop implements Constants {
* </ul>
* @param ua FOUserAgent object
* @throws IllegalArgumentException if an unsupported renderer type was requested.
+ * @deprecated Use {@link org.apache.fop.apps.Fop#Fop(java.lang.String, FOUserAgent)} instead!
+ * This constructor will be removed.
*/
public Fop(int renderType, FOUserAgent ua) {
this(getMimeTypeForRenderType(renderType), ua);
@@ -111,6 +117,8 @@ public class Fop implements Constants {
/**
* Constructor that creates a default FOUserAgent
* @see org.apache.fop.apps.Fop#Fop(int, FOUserAgent)
+ * @deprecated Use {@link org.apache.fop.apps.Fop#Fop(java.lang.String)} instead!
+ * This constructor will be removed.
*/
public Fop(int renderType) {
this(renderType, null);
@@ -197,6 +205,7 @@ public class Fop implements Constants {
/**
* Get the version of FOP
* @return the version string
+ * @deprecated Use {@link org.apache.fop.Version#getVersion()} instead!
*/
public static String getVersion() {
return org.apache.fop.Version.getVersion();
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java
index c1d922964..5788633e3 100644
--- a/src/java/org/apache/fop/cli/CommandLineOptions.java
+++ b/src/java/org/apache/fop/cli/CommandLineOptions.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.util.Locale;
import java.util.Vector;
+import org.apache.fop.Version;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
@@ -225,7 +226,7 @@ public class CommandLineOptions implements Constants {
} else if (args[i].equals("-at")) {
i = i + parseAreaTreeOption(args, i);
} else if (args[i].equals("-v")) {
- System.out.println("FOP Version " + Fop.getVersion());
+ System.out.println("FOP Version " + Version.getVersion());
} else if (args[i].equals("-param")) {
if (i + 2 < args.length) {
if (xsltParams == null) {
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java
index 433150bf8..1c64194c4 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import java.awt.event.WindowEvent;
import java.awt.event.ActionEvent;
//FOP
-import org.apache.fop.apps.Fop;
+import org.apache.fop.Version;
/**
* AWT Viewer's "About" dialog.
@@ -68,7 +68,7 @@ public class PreviewDialogAboutBox extends Dialog implements ActionListener {
imageControl1.setIcon(new ImageIcon(getClass().getResource("images/fop.gif")));
JLabel label1 = new JLabel(translator.getString("About.Product"));
JLabel label2 = new JLabel(translator.getString("About.Version")
- + " " + Fop.getVersion());
+ + " " + Version.getVersion());
JLabel label3 = new JLabel(translator.getString("About.Copyright"));
panel1.setLayout(new BorderLayout());
panel2.setLayout(new BorderLayout());
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
index b70723093..f2a94eb29 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
@@ -38,9 +38,9 @@ import javax.swing.border.EmptyBorder;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
-import org.apache.fop.fo.Constants;
import org.apache.fop.render.awt.AWTRenderer;
@@ -304,7 +304,7 @@ public class PreviewPanel extends JPanel {
}
//Always recreate the Fop instance. It is a use-once only.
- fop = new Fop(Constants.RENDER_AWT, foUserAgent);
+ fop = new Fop(MimeConstants.MIME_FOP_AWT_PREVIEW, foUserAgent);
pagePanels = null;
diff --git a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
index 81a202940..461cfcadd 100644
--- a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
+++ b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
@@ -20,7 +20,7 @@ package org.apache.fop.render.ps;
import java.io.IOException;
-import org.apache.fop.apps.Fop;
+import org.apache.fop.Version;
/**
* This class is a wrapper for the <tt>AbstractPSDocumentGraphics2D</tt> that
@@ -54,7 +54,7 @@ public class EPSDocumentGraphics2D extends AbstractPSDocumentGraphics2D {
//PostScript Header
gen.writeln(DSCConstants.PS_ADOBE_30 + " " + DSCConstants.EPSF_30);
gen.writeDSCComment(DSCConstants.CREATOR,
- new String[] {"Apache FOP " + Fop.getVersion()
+ new String[] {"Apache FOP " + Version.getVersion()
+ ": EPS Transcoder for SVG"});
gen.writeDSCComment(DSCConstants.CREATION_DATE,
new Object[] {new java.util.Date()});
diff --git a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
index afa4a83e2..08bbc3050 100644
--- a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
+++ b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
@@ -24,7 +24,7 @@ import java.io.OutputStream;
import java.io.IOException;
//FOP
-import org.apache.fop.apps.Fop;
+import org.apache.fop.Version;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup;
@@ -91,7 +91,7 @@ public class PSDocumentGraphics2D extends AbstractPSDocumentGraphics2D {
//PostScript Header
gen.writeln(DSCConstants.PS_ADOBE_30);
gen.writeDSCComment(DSCConstants.CREATOR,
- new String[] {"Apache FOP " + Fop.getVersion()
+ new String[] {"Apache FOP " + Version.getVersion()
+ ": PostScript Transcoder for SVG"});
gen.writeDSCComment(DSCConstants.CREATION_DATE,
new Object[] {new java.util.Date()});
diff --git a/src/java/org/apache/fop/servlet/FopPrintServlet.java b/src/java/org/apache/fop/servlet/FopPrintServlet.java
index aff3f063f..3b4f92f60 100644
--- a/src/java/org/apache/fop/servlet/FopPrintServlet.java
+++ b/src/java/org/apache/fop/servlet/FopPrintServlet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@ import javax.xml.transform.stream.StreamSource;
// XML
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.MimeConstants;
/**
@@ -57,7 +58,7 @@ import org.apache.fop.apps.Fop;
* Example URL: http://servername/fop/servlet/FopPrintServlet?xml=data.xml&xsl=format.xsl
*
* @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a>
- * @version $Id: FopPrintServlet.java,v 1.2 2003/03/07 09:48:05 jeremias Exp $
+ * @version $Id$
* (todo) Doesn't work since there's no AWTRenderer at the moment. Revisit when
* available.
* (todo) Ev. add caching mechanism for Templates objects
@@ -131,7 +132,7 @@ public class FopPrintServlet extends HttpServlet {
public void renderFO(InputStream foFile,
HttpServletResponse response) throws ServletException {
try {
- Fop fop = new Fop(Fop.RENDER_PRINT);
+ Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT);
// Setup JAXP
TransformerFactory factory = TransformerFactory.newInstance();
@@ -162,7 +163,7 @@ public class FopPrintServlet extends HttpServlet {
public void renderXML(File xmlfile, File xsltfile,
HttpServletResponse response) throws ServletException {
try {
- Fop fop = new Fop(Fop.RENDER_PRINT);
+ Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index ef211fcbc..79649d0b0 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ import org.apache.commons.logging.impl.SimpleLog;
//FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.MimeConstants;
/**
* Example servlet to generate a PDF from a servlet.
@@ -61,7 +62,7 @@ import org.apache.fop.apps.FOPException;
* to the URL.
*
* @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a>
- * @version $Id: FopServlet.java,v 1.2 2003/03/07 09:48:05 jeremias Exp $
+ * @version $Id$
* (todo) Ev. add caching mechanism for Templates objects
*/
public class FopServlet extends HttpServlet {
@@ -200,7 +201,7 @@ public class FopServlet extends HttpServlet {
throws FOPException, TransformerException {
//Setup FOP
- Fop fop = new Fop(Fop.RENDER_PDF);
+ Fop fop = new Fop(MimeConstants.MIME_PDF);
//Setup output
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 802579995..27176b47e 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -27,6 +27,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler;
import org.apache.fop.tools.anttasks.FileCompare;
import org.w3c.dom.Document;
@@ -35,7 +36,6 @@ import org.w3c.dom.NodeList;
import org.apache.commons.logging.impl.SimpleLog;
-
/**
* TestConverter is used to process a set of tests specified in
* a testsuite.
@@ -45,12 +45,11 @@ import org.apache.commons.logging.impl.SimpleLog;
* The area tree can be used for automatic comparisons between different
* versions of FOP or the pdf can be view for manual checking and
* pdf rendering.
- *
*/
public class TestConverter {
private boolean failOnly = false;
- private int renderType = Fop.RENDER_XML;
+ private String outputFormat = MimeConstants.MIME_FOP_AREA_TREE;
private File destdir;
private File compare = null;
private String baseDir = "./";
@@ -84,11 +83,11 @@ public class TestConverter {
if (args[count].equals("-failOnly")) {
tc.setFailOnly(true);
} else if (args[count].equals("-pdf")) {
- tc.setRenderType(Fop.RENDER_PDF);
+ tc.setOutputFormat(MimeConstants.MIME_PDF);
} else if (args[count].equals("-rtf")) {
- tc.setRenderType(Fop.RENDER_RTF);
+ tc.setOutputFormat(MimeConstants.MIME_RTF);
} else if (args[count].equals("-ps")) {
- tc.setRenderType(Fop.RENDER_PS);
+ tc.setOutputFormat(MimeConstants.MIME_POSTSCRIPT);
} else if (args[count].equals("-d")) {
tc.setDebug(true);
} else if (args[count].equals("-b")) {
@@ -115,11 +114,11 @@ public class TestConverter {
}
/**
- * Controls output type to generate
- * @param renderType fo.Constants output constant (RENDER_PDF, RENDER_XML, etc.)
+ * Controls output format to generate
+ * @param outputFormat the MIME type of the output format
*/
- public void setRenderType(int renderType) {
- this.renderType = renderType;
+ public void setOutputFormat(String outputFormat) {
+ this.outputFormat = outputFormat;
}
/**
@@ -169,8 +168,7 @@ public class TestConverter {
destdir = new File(baseDir + "/" + dest);
destdir.mkdirs();
File f = new File(baseDir + "/" + fname);
- DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
Document doc = db.parse(f);
@@ -183,8 +181,8 @@ public class TestConverter {
testsuite = doc.getDocumentElement();
if (testsuite.hasAttributes()) {
- String profile =
- testsuite.getAttributes().getNamedItem("profile").getNodeValue();
+ String profile
+ = testsuite.getAttributes().getNamedItem("profile").getNodeValue();
logger.debug("testing test suite:" + profile);
}
@@ -210,8 +208,8 @@ public class TestConverter {
*/
protected void runTestCase(Node tcase) {
if (tcase.hasAttributes()) {
- String profile =
- tcase.getAttributes().getNamedItem("profile").getNodeValue();
+ String profile
+ = tcase.getAttributes().getNamedItem("profile").getNodeValue();
logger.debug("testing profile:" + profile);
}
@@ -245,8 +243,8 @@ public class TestConverter {
Node result = locateResult(testcase, id);
boolean pass = false;
if (result != null) {
- String agreement =
- result.getAttributes().getNamedItem("agreement").getNodeValue();
+ String agreement
+ = result.getAttributes().getNamedItem("agreement").getNodeValue();
pass = agreement.equals("full");
}
@@ -288,7 +286,7 @@ public class TestConverter {
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(baseURL);
- Fop fop = new Fop(renderType, userAgent);
+ Fop fop = new Fop(outputFormat, userAgent);
userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
@@ -305,8 +303,7 @@ public class TestConverter {
OutputStream outStream = new java.io.BufferedOutputStream(
new java.io.FileOutputStream(outputFile));
fop.setOutputStream(outStream);
- logger.debug("ddir:" + destdir + " on:" +
- outputFile.getName());
+ logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
inputHandler.render(fop);
outStream.close();
@@ -327,11 +324,11 @@ public class TestConverter {
* Return a suitable file extension for the output format.
*/
private String makeResultExtension() {
- if (renderType == Fop.RENDER_PDF) {
+ if (MimeConstants.MIME_PDF.equals(outputFormat)) {
return ".pdf";
- } else if (renderType == Fop.RENDER_RTF) {
+ } else if (MimeConstants.MIME_RTF.equals(outputFormat)) {
return ".rtf";
- } else if (renderType == Fop.RENDER_PS) {
+ } else if (MimeConstants.MIME_POSTSCRIPT.equals(outputFormat)) {
return ".ps";
} else {
return ".at.xml";
@@ -359,8 +356,8 @@ public class TestConverter {
Node node = cases.item(count);
String nodename = node.getNodeName();
if (nodename.equals("result")) {
- String resultid =
- node.getAttributes().getNamedItem("id").getNodeValue();
+ String resultid
+ = node.getAttributes().getNamedItem("id").getNodeValue();
if (id.equals(resultid)) {
return node;
}
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index 49d64c961..af1496df2 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -34,9 +34,9 @@ import java.net.MalformedURLException;
import java.util.List;
// FOP
-import org.apache.fop.fo.Constants;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler;
import org.apache.commons.logging.impl.SimpleLog;
@@ -283,6 +283,7 @@ public class Fop extends Task {
case Project.MSG_WARN : logLevel = SimpleLog.LOG_LEVEL_WARN; break;
case Project.MSG_ERR : logLevel = SimpleLog.LOG_LEVEL_ERROR; break;
case Project.MSG_VERBOSE: logLevel = SimpleLog.LOG_LEVEL_DEBUG; break;
+ default: logLevel = SimpleLog.LOG_LEVEL_INFO;
}
SimpleLog logger = new SimpleLog("FOP/Anttask");
logger.setLevel(logLevel);
@@ -329,68 +330,62 @@ class FOPTaskStarter {
this.task = task;
}
- private int determineRenderer(String format) {
- if ((format == null)
- || format.equalsIgnoreCase("application/pdf")
- || format.equalsIgnoreCase("pdf")) {
- return Constants.RENDER_PDF;
- } else if (format.equalsIgnoreCase("application/postscript")
- || format.equalsIgnoreCase("ps")) {
- return Constants.RENDER_PS;
- } else if (format.equalsIgnoreCase("application/vnd.mif")
- || format.equalsIgnoreCase("mif")) {
- return Constants.RENDER_MIF;
- } else if (format.equalsIgnoreCase("application/msword")
- || format.equalsIgnoreCase("application/rtf")
- || format.equalsIgnoreCase("rtf")) {
- return Constants.RENDER_RTF;
- } else if (format.equalsIgnoreCase("application/vnd.hp-PCL")
- || format.equalsIgnoreCase("pcl")) {
- return Constants.RENDER_PCL;
- } else if (format.equalsIgnoreCase("text/plain")
- || format.equalsIgnoreCase("txt")) {
- return Constants.RENDER_TXT;
- } else if (format.equalsIgnoreCase("text/xml")
- || format.equalsIgnoreCase("at")
- || format.equalsIgnoreCase("xml")) {
- return Constants.RENDER_XML;
- } else if (format.equalsIgnoreCase("image/tiff")
- || format.equalsIgnoreCase("tiff")
- || format.equalsIgnoreCase("tif")) {
- return Constants.RENDER_TIFF;
- } else if (format.equalsIgnoreCase("image/png")
- || format.equalsIgnoreCase("png")) {
- return Constants.RENDER_PNG;
- } else {
- String err = "Couldn't determine renderer to use: " + format;
- throw new BuildException(err);
+ private static final String[][] SHORT_NAMES = {
+ {"pdf", MimeConstants.MIME_PDF},
+ {"ps", MimeConstants.MIME_POSTSCRIPT},
+ {"mif", MimeConstants.MIME_MIF},
+ {"rtf", MimeConstants.MIME_RTF},
+ {"pcl", MimeConstants.MIME_PCL},
+ {"txt", MimeConstants.MIME_PLAIN_TEXT},
+ {"at", MimeConstants.MIME_FOP_AREA_TREE},
+ {"xml", MimeConstants.MIME_FOP_AREA_TREE},
+ {"tiff", MimeConstants.MIME_TIFF},
+ {"tif", MimeConstants.MIME_TIFF},
+ {"png", MimeConstants.MIME_PNG}
+ };
+
+ private String normalizeOutputFormat(String format) {
+ for (int i = 0; i < SHORT_NAMES.length; i++) {
+ if (SHORT_NAMES[i][0].equals(format)) {
+ return SHORT_NAMES[i][1];
+ }
}
+ return format; //no change
}
- private String determineExtension(int renderer) {
- switch (renderer) {
- case Constants.RENDER_PDF:
- return ".pdf";
- case Constants.RENDER_PS:
- return ".ps";
- case Constants.RENDER_MIF:
- return ".mif";
- case Constants.RENDER_RTF:
- return ".rtf";
- case Constants.RENDER_PCL:
- return ".pcl";
- case Constants.RENDER_TXT:
- return ".txt";
- case Constants.RENDER_XML:
- return ".xml";
- case Constants.RENDER_TIFF:
- return ".tiff";
- case Constants.RENDER_PNG:
- return ".png";
- default:
- String err = "Unknown renderer: " + renderer;
- throw new BuildException(err);
+ private static final String[][] EXTENSIONS = {
+ {MimeConstants.MIME_FOP_AREA_TREE, ".at.xml"},
+ {MimeConstants.MIME_FOP_AWT_PREVIEW, null},
+ {MimeConstants.MIME_FOP_PRINT, null},
+ {MimeConstants.MIME_PDF, ".pdf"},
+ {MimeConstants.MIME_POSTSCRIPT, ".ps"},
+ {MimeConstants.MIME_PCL, ".pcl"},
+ {MimeConstants.MIME_PCL_ALT, ".pcl"},
+ {MimeConstants.MIME_PLAIN_TEXT, ".txt"},
+ {MimeConstants.MIME_RTF, ".rtf"},
+ {MimeConstants.MIME_RTF_ALT1, ".rtf"},
+ {MimeConstants.MIME_RTF_ALT2, ".rtf"},
+ {MimeConstants.MIME_MIF, ".mif"},
+ {MimeConstants.MIME_SVG, ".svg"},
+ {MimeConstants.MIME_PNG, ".png"},
+ {MimeConstants.MIME_JPEG, ".jpg"},
+ {MimeConstants.MIME_TIFF, ".tif"},
+ {MimeConstants.MIME_XSL_FO, ".fo"}
+ };
+
+ private String determineExtension(String outputFormat) {
+ for (int i = 0; i < EXTENSIONS.length; i++) {
+ if (EXTENSIONS[i][0].equals(outputFormat)) {
+ String ext = EXTENSIONS[i][1];
+ if (ext == null) {
+ throw new RuntimeException("Output format '"
+ + outputFormat + "' does not produce a file.");
+ } else {
+ return ext;
+ }
+ }
}
+ return ".unk"; //unknown
}
private File replaceExtension(File file, String expectedExt,
@@ -432,8 +427,8 @@ class FOPTaskStarter {
task.log("Using base URL: " + baseURL, Project.MSG_DEBUG);
- int rint = determineRenderer(task.getFormat());
- String newExtension = determineExtension(rint);
+ String outputFormat = normalizeOutputFormat(task.getFormat());
+ String newExtension = determineExtension(outputFormat);
// actioncount = # of fofiles actually processed through FOP
int actioncount = 0;
@@ -455,7 +450,7 @@ class FOPTaskStarter {
// output file is older than input file
if (task.getForce() || !outf.exists()
|| (task.getFofile().lastModified() > outf.lastModified() )) {
- render(task.getFofile(), outf, rint);
+ render(task.getFofile(), outf, outputFormat);
actioncount++;
} else if (outf.exists()
&& (task.getFofile().lastModified() <= outf.lastModified() )) {
@@ -507,7 +502,7 @@ class FOPTaskStarter {
// output file is older than input file
if (task.getForce() || !outf.exists()
|| (f.lastModified() > outf.lastModified() )) {
- render(f, outf, rint);
+ render(f, outf, outputFormat);
actioncount++;
} else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) {
skippedcount++;
@@ -526,7 +521,7 @@ class FOPTaskStarter {
}
private void render(File foFile, File outFile,
- int renderer) throws FOPException {
+ String outputFormat) throws FOPException {
InputHandler inputHandler = new InputHandler(foFile);
OutputStream out = null;
@@ -543,8 +538,8 @@ class FOPTaskStarter {
try {
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
- org.apache.fop.apps.Fop fop =
- new org.apache.fop.apps.Fop(renderer, userAgent);
+ org.apache.fop.apps.Fop fop = new org.apache.fop.apps.Fop(
+ outputFormat, userAgent);
fop.setOutputStream(out);
inputHandler.render(fop);
} catch (Exception ex) {