Browse Source

Deprecated constructors Fop(int) and Fop(int, FOUserAgent).

Deprecated Fop.getVersion() in favor for Version.getVersion().
Changed every place the newly deprecated methods were called.
Ant task and TestConverter changed to fully use MIME types.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@332791 13f79535-47bb-0310-9956-ffa450edef68
pull/34/head
Jeremias Maerki 18 years ago
parent
commit
9913f585a8
29 changed files with 160 additions and 142 deletions
  1. 2
    1
      examples/embedding/java/embedding/ExampleAWTViewer.java
  2. 2
    1
      examples/embedding/java/embedding/ExampleDOM2PDF.java
  3. 2
    1
      examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
  4. 2
    1
      examples/embedding/java/embedding/ExampleFO2PDF.java
  5. 2
    1
      examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java
  6. 2
    1
      examples/embedding/java/embedding/ExampleFO2RTF.java
  7. 3
    1
      examples/embedding/java/embedding/ExampleObj2PDF.java
  8. 3
    2
      examples/embedding/java/embedding/ExampleXML2PDF.java
  9. 2
    1
      src/java/org/apache/fop/apps/FOUserAgent.java
  10. 10
    1
      src/java/org/apache/fop/apps/Fop.java
  11. 2
    1
      src/java/org/apache/fop/cli/CommandLineOptions.java
  12. 3
    3
      src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java
  13. 2
    2
      src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
  14. 2
    2
      src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
  15. 2
    2
      src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
  16. 5
    4
      src/java/org/apache/fop/servlet/FopPrintServlet.java
  17. 4
    3
      src/java/org/apache/fop/servlet/FopServlet.java
  18. 23
    26
      src/java/org/apache/fop/tools/TestConverter.java
  19. 61
    66
      src/java/org/apache/fop/tools/anttasks/Fop.java
  20. 5
    4
      test/java/org/apache/fop/BasicDriverTestCase.java
  21. 2
    1
      test/java/org/apache/fop/GenericFOPTestCase.java
  22. 3
    2
      test/java/org/apache/fop/URIResolutionTestCase.java
  23. 2
    2
      test/java/org/apache/fop/fotreetest/FOTreeTester.java
  24. 2
    2
      test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
  25. 2
    2
      test/java/org/apache/fop/threading/FOProcessorImpl.java
  26. 2
    2
      test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
  27. 2
    1
      test/java/org/apache/fop/visual/BitmapProducerJava2D.java
  28. 3
    3
      test/java/org/apache/fop/visual/BitmapProducerPDF.java
  29. 3
    3
      test/java/org/apache/fop/visual/BitmapProducerPS.java

+ 2
- 1
examples/embedding/java/embedding/ExampleAWTViewer.java View File

@@ -37,6 +37,7 @@ import org.apache.avalon.framework.ExceptionUtil;
//FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fo.Constants;
/**
@@ -48,7 +49,7 @@ public class ExampleAWTViewer {
throws IOException, FOPException, TransformerException {
//Setup FOP
Fop fop = new Fop(Constants.RENDER_AWT);
Fop fop = new Fop(MimeConstants.MIME_FOP_AWT_PREVIEW);
try {

+ 2
- 1
examples/embedding/java/embedding/ExampleDOM2PDF.java View File

@@ -41,6 +41,7 @@ import org.w3c.dom.Text;

// FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;


/**
@@ -62,7 +63,7 @@ public class ExampleDOM2PDF {
public void convertDOM2PDF(Document xslfoDoc, File pdf) {
try {
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2OldStylePrint.java View File

@@ -36,6 +36,7 @@ import javax.xml.transform.sax.SAXResult;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.print.PrintRenderer;
/**
@@ -63,7 +64,7 @@ public class ExampleFO2OldStylePrint {
userAgent.setRendererOverride(renderer);
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PRINT, userAgent);
Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT, userAgent);
//Note: the first parameter here has no effect if we use
//FOUserAgent.setRendererOverride()

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2PDF.java View File

@@ -38,6 +38,7 @@ import javax.xml.transform.sax.SAXResult;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FormattingResults;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PageSequenceResults;

/**
@@ -58,7 +59,7 @@ public class ExampleFO2PDF {
try {
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java View File

@@ -38,6 +38,7 @@ import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an FO file to PDF using FOP.
@@ -64,7 +65,7 @@ public class ExampleFO2PDFUsingSAXParser {
try {
// Construct fop and setup output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2RTF.java View File

@@ -36,6 +36,7 @@ import javax.xml.transform.sax.SAXResult;
// FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an FO file to RTF using FOP.
@@ -58,7 +59,7 @@ public class ExampleFO2RTF {
try {
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_RTF);
Fop fop = new Fop(MimeConstants.MIME_RTF);
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).

+ 3
- 1
examples/embedding/java/embedding/ExampleObj2PDF.java View File

@@ -35,6 +35,8 @@ import javax.xml.transform.sax.SAXResult;
// FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;

import embedding.model.ProjectTeam;

/**
@@ -56,7 +58,7 @@ public class ExampleObj2PDF {
throws IOException, FOPException, TransformerException {
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);

// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);

+ 3
- 2
examples/embedding/java/embedding/ExampleXML2PDF.java View File

@@ -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.
@@ -32,6 +32,7 @@ import javax.xml.transform.sax.SAXResult;

//FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an XML file to PDF using
@@ -65,7 +66,7 @@ public class ExampleXML2PDF {
System.out.println("Transforming...");
// Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);

+ 2
- 1
src/java/org/apache/fop/apps/FOUserAgent.java View File

@@ -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.)

+ 10
- 1
src/java/org/apache/fop/apps/Fop.java View File

@@ -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();

+ 2
- 1
src/java/org/apache/fop/cli/CommandLineOptions.java View File

@@ -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) {

+ 3
- 3
src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java View File

@@ -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());

+ 2
- 2
src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java View File

@@ -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;


+ 2
- 2
src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java View File

@@ -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()});

+ 2
- 2
src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java View File

@@ -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()});

+ 5
- 4
src/java/org/apache/fop/servlet/FopPrintServlet.java View File

@@ -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();

+ 4
- 3
src/java/org/apache/fop/servlet/FopServlet.java View File

@@ -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();

+ 23
- 26
src/java/org/apache/fop/tools/TestConverter.java View File

@@ -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;
}

+ 61
- 66
src/java/org/apache/fop/tools/anttasks/Fop.java View File

@@ -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) {

+ 5
- 4
test/java/org/apache/fop/BasicDriverTestCase.java View File

@@ -29,6 +29,7 @@ import javax.xml.transform.stream.StreamSource;

import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler;

/**
@@ -51,7 +52,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase {
public void testFO2PDFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
@@ -70,7 +71,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase {
public void testFO2PSWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PS);
Fop fop = new Fop(MimeConstants.MIME_POSTSCRIPT);
fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
@@ -89,7 +90,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase {
public void testFO2RTFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_RTF);
Fop fop = new Fop(MimeConstants.MIME_RTF);
fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance();
@@ -109,7 +110,7 @@ public class BasicDriverTestCase extends AbstractFOPTestCase {
File xmlFile = new File(getBaseDir(), "test/xml/1.xml");
File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(baout);
InputHandler handler = new InputHandler(xmlFile, xsltFile, null);

+ 2
- 1
test/java/org/apache/fop/GenericFOPTestCase.java View File

@@ -32,6 +32,7 @@ import junit.framework.TestSuite;

import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.util.DigestFilter;
import org.xml.sax.InputSource;

@@ -114,7 +115,7 @@ public final class GenericFOPTestCase extends TestCase {
MessageDigest outDigest = MessageDigest.getInstance("MD5");
DigestOutputStream out =
new DigestOutputStream(new ByteArrayOutputStream(), outDigest);
Fop fop = new Fop(Fop.RENDER_PDF, foUserAgent);
Fop fop = new Fop(MimeConstants.MIME_PDF, foUserAgent);
fop.setOutputStream(out);
InputSource source = new InputSource(new StringReader(fo));
DigestFilter filter = new DigestFilter("MD5");

+ 3
- 2
test/java/org/apache/fop/URIResolutionTestCase.java View File

@@ -40,6 +40,7 @@ import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.render.xml.XMLRenderer;
import org.apache.xpath.XPathAPI;
@@ -115,7 +116,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase {
ua.setURIResolver(resolver);
ua.setBaseURL(foFile.getParentFile().toURL().toString());

Fop fop = new Fop(Fop.RENDER_PDF, ua);
Fop fop = new Fop(MimeConstants.MIME_PDF, ua);

ByteArrayOutputStream baout = new ByteArrayOutputStream();
fop.setOutputStream(baout);
@@ -155,7 +156,7 @@ public class URIResolutionTestCase extends AbstractFOPTestCase {
atrenderer.setTransformerHandler(athandler);
ua.setRendererOverride(atrenderer);
Fop fop = new Fop(Fop.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);

Transformer transformer = tfactory.newTransformer(); //Identity transf.
Source src = new StreamSource(fo);

+ 2
- 2
test/java/org/apache/fop/fotreetest/FOTreeTester.java View File

@@ -29,7 +29,7 @@ import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;

import org.apache.fop.fotreetest.ext.TestElementMapping;

@@ -59,7 +59,7 @@ public class FOTreeTester {
ua.setBaseURL(testFile.getParentFile().toURL().toString());
ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
ua.addElementMapping(new TestElementMapping());
Fop fop = new Fop(Constants.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);
SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores);

+ 2
- 2
test/java/org/apache/fop/layoutengine/LayoutEngineTester.java View File

@@ -42,7 +42,7 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.render.xml.XMLRenderer;
import org.w3c.dom.Document;
@@ -129,7 +129,7 @@ public class LayoutEngineTester {
atrenderer.setUserAgent(ua);
atrenderer.setTransformerHandler(athandler);
ua.setRendererOverride(atrenderer);
Fop fop = new Fop(Constants.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);
SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores);

+ 2
- 2
test/java/org/apache/fop/threading/FOProcessorImpl.java View File

@@ -37,7 +37,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException;

import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;
import org.apache.avalon.framework.activity.Initializable;

public class FOProcessorImpl extends AbstractLogEnabled
@@ -84,7 +84,7 @@ public class FOProcessorImpl extends AbstractLogEnabled

public void process(InputStream in, Templates templates, OutputStream out)
throws org.apache.fop.apps.FOPException, java.io.IOException {
Fop fop = new Fop(Constants.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(out);

try {

+ 2
- 2
test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java View File

@@ -99,9 +99,9 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer
protected abstract String getTargetExtension();
/**
* @return the output format constant for the FOP renderer, i.e. one of Constants.RENDER_*.
* @return the output format for the FOP renderer, i.e. a MIME type.
*/
protected abstract int getTargetFormat();
protected abstract String getTargetFormat();
/** @see org.apache.fop.visual.BitmapProducer */
public BufferedImage produce(File src, ProducerContext context) {

+ 2
- 1
test/java/org/apache/fop/visual/BitmapProducerJava2D.java View File

@@ -34,6 +34,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fo.Constants;

/**
@@ -69,7 +70,7 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf
OutputStream out = new FileOutputStream(outputFile);
out = new BufferedOutputStream(out);
try {
Fop fop = new Fop(Constants.RENDER_PNG, userAgent);
Fop fop = new Fop(MimeConstants.MIME_PNG, userAgent);
fop.setOutputStream(out);
SAXResult res = new SAXResult(fop.getDefaultHandler());

+ 3
- 3
test/java/org/apache/fop/visual/BitmapProducerPDF.java View File

@@ -18,7 +18,7 @@

package org.apache.fop.visual;

import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;

/**
* BitmapProducer implementation that uses the PDFRenderer and an external converter
@@ -34,8 +34,8 @@ public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer {
}
/** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
protected int getTargetFormat() {
return Constants.RENDER_PDF;
protected String getTargetFormat() {
return MimeConstants.MIME_PDF;
}
}

+ 3
- 3
test/java/org/apache/fop/visual/BitmapProducerPS.java View File

@@ -18,7 +18,7 @@

package org.apache.fop.visual;

import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;

/**
* BitmapProducer implementation that uses the PSRenderer and an external converter
@@ -34,8 +34,8 @@ public class BitmapProducerPS extends AbstractPSPDFBitmapProducer {
}
/** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
protected int getTargetFormat() {
return Constants.RENDER_PS;
protected String getTargetFormat() {
return MimeConstants.MIME_POSTSCRIPT;
}


Loading…
Cancel
Save