aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-07-17 14:24:53 +0000
committerJeremias Maerki <jeremias@apache.org>2008-07-17 14:24:53 +0000
commitcd64af07c5661e82a7121a2ac6ad756a3b2e91e9 (patch)
treed4c6eb96410cc3ff48ee2de302995fd0d1002e40 /src
parent78e8e5a1dcc692afbae1456ce8fb7acd3cb97fe8 (diff)
parent1867bcc73af7bbb10a7729ff01184a1909abbb4d (diff)
downloadxmlgraphics-fop-cd64af07c5661e82a7121a2ac6ad756a3b2e91e9.tar.gz
xmlgraphics-fop-cd64af07c5661e82a7121a2ac6ad756a3b2e91e9.zip
Merge from Trunk up to revision 677588.
Switched from svnmerge to SVN 1.5 merge tracking manually for this branch only. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@677594 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java89
-rw-r--r--src/java/org/apache/fop/apps/FOURIResolver.java6
-rw-r--r--src/java/org/apache/fop/cli/CommandLineOptions.java147
-rw-r--r--src/java/org/apache/fop/cli/InputHandler.java69
-rw-r--r--src/java/org/apache/fop/cli/Main.java36
-rw-r--r--src/java/org/apache/fop/events/EventFormatter.xml2
-rw-r--r--src/java/org/apache/fop/events/model/EventMethodModel.java58
-rw-r--r--src/java/org/apache/fop/events/model/EventModel.java31
-rw-r--r--src/java/org/apache/fop/events/model/EventProducerModel.java24
-rw-r--r--src/java/org/apache/fop/fo/extensions/svg/SVGElement.java2
-rw-r--r--src/java/org/apache/fop/fonts/CustomFontCollection.java37
-rw-r--r--src/java/org/apache/fop/fonts/FontManager.java60
-rw-r--r--src/java/org/apache/fop/hyphenation/HyphenationTree.java2
-rw-r--r--src/java/org/apache/fop/hyphenation/PatternParser.java2
-rw-r--r--src/java/org/apache/fop/render/PrintRenderer.java29
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java8
-rw-r--r--src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java45
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderer.java34
-rw-r--r--src/java/org/apache/fop/tools/TestConverter.java2
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java8
-rw-r--r--src/java/org/apache/fop/tools/anttasks/RunTest.java4
22 files changed, 402 insertions, 302 deletions
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
index 60ffaf103..e00b05b55 100644
--- a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
@@ -22,6 +22,7 @@ package org.apache.fop.tools;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
@@ -38,6 +39,7 @@ import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Node;
+import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -56,13 +58,17 @@ public class EventProducerCollectorTask extends Task {
private List filesets = new java.util.ArrayList();
private File modelFile;
private File translationFile;
-
+
/** {@inheritDoc} */
public void execute() throws BuildException {
try {
EventProducerCollector collector = new EventProducerCollector();
processFileSets(collector);
- getModelFile().getParentFile().mkdirs();
+ File parentDir = getModelFile().getParentFile();
+ if (!parentDir.exists() && !parentDir.mkdirs()) {
+ throw new BuildException(
+ "Could not create target directory for event model file: " + parentDir);
+ }
collector.saveModelToXML(getModelFile());
log("Event model written to " + getModelFile());
if (getTranslationFile() != null) {
@@ -76,10 +82,10 @@ public class EventProducerCollectorTask extends Task {
throw new BuildException(ioe);
}
}
-
+
private static final String MODEL2TRANSLATION = "model2translation.xsl";
private static final String MERGETRANSLATION = "merge-translation.xsl";
-
+
/**
* Updates the translation file with new entries for newly found event producer methods.
* @throws IOException if an I/O error occurs
@@ -89,9 +95,9 @@ public class EventProducerCollectorTask extends Task {
boolean resultExists = getTranslationFile().exists();
SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
+
//Generate fresh generated translation file as template
- Source src = new StreamSource(getModelFile());
+ Source src = new StreamSource(getModelFile().toURI().toURL().toExternalForm());
StreamSource xslt1 = new StreamSource(
getClass().getResourceAsStream(MODEL2TRANSLATION));
if (xslt1.getInputStream() == null) {
@@ -101,11 +107,11 @@ public class EventProducerCollectorTask extends Task {
Transformer transformer = tFactory.newTransformer(xslt1);
transformer.transform(src, domres);
final Node generated = domres.getNode();
-
+
Node sourceDocument;
if (resultExists) {
//Load existing translation file into memory (because we overwrite it later)
- src = new StreamSource(getTranslationFile());
+ src = new StreamSource(getTranslationFile().toURI().toURL().toExternalForm());
domres = new DOMResult();
transformer = tFactory.newTransformer();
transformer.transform(src, domres);
@@ -117,29 +123,38 @@ public class EventProducerCollectorTask extends Task {
//Generate translation file (with potentially new translations)
src = new DOMSource(sourceDocument);
- Result res = new StreamResult(getTranslationFile());
- StreamSource xslt2 = new StreamSource(
- getClass().getResourceAsStream(MERGETRANSLATION));
- if (xslt2.getInputStream() == null) {
- throw new FileNotFoundException(MERGETRANSLATION + " not found");
- }
- transformer = tFactory.newTransformer(xslt2);
- transformer.setURIResolver(new URIResolver() {
- public Source resolve(String href, String base) throws TransformerException {
- if ("my:dom".equals(href)) {
- return new DOMSource(generated);
+
+ //The following triggers a bug in older Xalan versions
+ //Result res = new StreamResult(getTranslationFile());
+ OutputStream out = new java.io.FileOutputStream(getTranslationFile());
+ out = new java.io.BufferedOutputStream(out);
+ Result res = new StreamResult(out);
+ try {
+ StreamSource xslt2 = new StreamSource(
+ getClass().getResourceAsStream(MERGETRANSLATION));
+ if (xslt2.getInputStream() == null) {
+ throw new FileNotFoundException(MERGETRANSLATION + " not found");
+ }
+ transformer = tFactory.newTransformer(xslt2);
+ transformer.setURIResolver(new URIResolver() {
+ public Source resolve(String href, String base) throws TransformerException {
+ if ("my:dom".equals(href)) {
+ return new DOMSource(generated);
+ }
+ return null;
}
- return null;
+ });
+ if (resultExists) {
+ transformer.setParameter("generated-url", "my:dom");
}
- });
- if (resultExists) {
- transformer.setParameter("generated-url", "my:dom");
- }
- transformer.transform(src, res);
- if (resultExists) {
- log("Translation file updated: " + getTranslationFile());
- } else {
- log("Translation file generated: " + getTranslationFile());
+ transformer.transform(src, res);
+ if (resultExists) {
+ log("Translation file updated: " + getTranslationFile());
+ } else {
+ log("Translation file generated: " + getTranslationFile());
+ }
+ } finally {
+ IOUtils.closeQuietly(out);
}
} catch (TransformerException te) {
throw new IOException(te.getMessage());
@@ -176,7 +191,7 @@ public class EventProducerCollectorTask extends Task {
public void addFileset(FileSet set) {
filesets.add(set);
}
-
+
/**
* Sets the model file to be written.
* @param f the model file
@@ -184,7 +199,7 @@ public class EventProducerCollectorTask extends Task {
public void setModelFile(File f) {
this.modelFile = f;
}
-
+
/**
* Returns the model file to be written.
* @return the model file
@@ -192,7 +207,7 @@ public class EventProducerCollectorTask extends Task {
public File getModelFile() {
return this.modelFile;
}
-
+
/**
* Sets the translation file for the event producer methods.
* @param f the translation file
@@ -200,7 +215,7 @@ public class EventProducerCollectorTask extends Task {
public void setTranslationFile(File f) {
this.translationFile = f;
}
-
+
/**
* Returns the translation file for the event producer methods.
* @return the translation file
@@ -208,7 +223,7 @@ public class EventProducerCollectorTask extends Task {
public File getTranslationFile() {
return this.translationFile;
}
-
+
/**
* Command-line interface for testing purposes.
* @param args the command-line arguments
@@ -222,15 +237,15 @@ public class EventProducerCollectorTask extends Task {
project.setName("Test");
FileSet fileset = new FileSet();
fileset.setDir(new File("test/java"));
-
+
FilenameSelector selector = new FilenameSelector();
selector.setName("**/*.java");
fileset.add(selector);
generator.addFileset(fileset);
-
+
File targetDir = new File("build/codegen1");
targetDir.mkdirs();
-
+
generator.setModelFile(new File("D:/out.xml"));
generator.setTranslationFile(new File("D:/out1.xml"));
generator.execute();
diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java
index 76b0bedd5..878a2745a 100644
--- a/src/java/org/apache/fop/apps/FOURIResolver.java
+++ b/src/java/org/apache/fop/apps/FOURIResolver.java
@@ -77,7 +77,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver {
}
File dir = new File(base);
try {
- base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm();
+ base = (dir.isDirectory() ? dir.toURI().toURL() : new URL(base)).toExternalForm();
} catch (MalformedURLException mfue) {
if (throwExceptions) {
throw mfue;
@@ -173,9 +173,9 @@ public class FOURIResolver implements javax.xml.transform.URIResolver {
if (file.canRead() && file.isFile()) {
try {
if (fragment != null) {
- absoluteURL = new URL(file.toURL().toExternalForm() + fragment);
+ absoluteURL = new URL(file.toURI().toURL().toExternalForm() + fragment);
} else {
- absoluteURL = file.toURL();
+ absoluteURL = file.toURI().toURL();
}
} catch (MalformedURLException mfue) {
handleException(mfue, "Could not convert filename '" + href
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java
index 5d2ea7915..7faea532e 100644
--- a/src/java/org/apache/fop/cli/CommandLineOptions.java
+++ b/src/java/org/apache/fop/cli/CommandLineOptions.java
@@ -60,7 +60,7 @@ public class CommandLineOptions {
/** Used to indicate that only the result of the XSL transformation should be output */
public static final int RENDER_NONE = -1;
- /* These following constants are used to describe the input (either .FO, .XML/.XSL or
+ /* These following constants are used to describe the input (either .FO, .XML/.XSL or
* intermediate format)
*/
@@ -97,11 +97,15 @@ public class CommandLineOptions {
private int inputmode = NOT_SET;
/* output mode */
private String outputmode = null;
+ /* true if System.in (stdin) should be used for the input file */
+ private boolean useStdIn = false;
+ /* true if System.out (stdout) should be used for the output file */
+ private boolean useStdOut = false;
/* rendering options (for the user agent) */
private Map renderingOptions = new java.util.HashMap();
/* target resolution (for the user agent) */
private int targetResolution = 0;
-
+
private FopFactory factory = FopFactory.newInstance();
private FOUserAgent foUserAgent;
@@ -150,7 +154,7 @@ public class CommandLineOptions {
}
checkSettings();
setUserConfig();
-
+
//Factory config is set up, now we can create the user agent
foUserAgent = factory.newFOUserAgent();
foUserAgent.getRendererOptions().putAll(renderingOptions);
@@ -382,7 +386,12 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the fo file for the '-fo' option");
} else {
- fofile = new File(args[i + 1]);
+ String filename = args[i + 1];
+ if (isSystemInOutFile(filename)) {
+ this.useStdIn = true;
+ } else {
+ fofile = new File(filename);
+ }
return 1;
}
}
@@ -406,7 +415,12 @@ public class CommandLineOptions {
throw new FOPException("you must specify the input file "
+ "for the '-xml' option");
} else {
- xmlfile = new File(args[i + 1]);
+ String filename = args[i + 1];
+ if (isSystemInOutFile(filename)) {
+ this.useStdIn = true;
+ } else {
+ xmlfile = new File(filename);
+ }
return 1;
}
}
@@ -422,7 +436,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the PDF output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
if (pdfAMode != null) {
if (renderingOptions.get("pdf-a-mode") != null) {
throw new FOPException("PDF/A mode already set");
@@ -433,13 +447,25 @@ public class CommandLineOptions {
}
}
+ private void setOutputFile(String filename) {
+ if (isSystemInOutFile(filename)) {
+ this.useStdOut = true;
+ } else {
+ outfile = new File(filename);
+ }
+ }
+
+ private boolean isSystemInOutFile(String filename) {
+ return "#".equals(filename);
+ }
+
private int parseMIFOutputOption(String[] args, int i) throws FOPException {
setOutputMode(MimeConstants.MIME_MIF);
if ((i + 1 == args.length)
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the MIF output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -450,7 +476,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the RTF output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -461,7 +487,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the TIFF output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -472,7 +498,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the PNG output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -518,7 +544,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the PDF output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -529,7 +555,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the PostScript output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -540,7 +566,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the text output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -551,7 +577,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the SVG output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -562,7 +588,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the AFP output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -573,7 +599,7 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the FO output file");
} else {
- outfile = new File(args[i + 1]);
+ setOutputFile(args[i + 1]);
return 1;
}
}
@@ -598,7 +624,7 @@ public class CommandLineOptions {
throw new FOPException("you must specify the output format and the output file");
} else {
setOutputMode(mime);
- outfile = new File(args[i + 2]);
+ setOutputFile(args[i + 2]);
return 2;
}
}
@@ -609,7 +635,7 @@ public class CommandLineOptions {
fofile = new File(args[i]);
} else if (outputmode == null) {
outputmode = MimeConstants.MIME_PDF;
- outfile = new File(args[i]);
+ setOutputFile(args[i]);
} else {
throw new FOPException("Don't know what to do with "
+ args[i]);
@@ -625,12 +651,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
mimicRenderer = args[i + 1];
- outfile = new File(args[i + 2]);
+ setOutputFile(args[i + 2]);
return 2;
}
}
@@ -658,7 +684,12 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the Area Tree file for the '-atin' option");
} else {
- areatreefile = new File(args[i + 1]);
+ String filename = args[i + 1];
+ if (isSystemInOutFile(filename)) {
+ this.useStdIn = true;
+ } else {
+ areatreefile = new File(filename);
+ }
return 1;
}
}
@@ -669,14 +700,19 @@ public class CommandLineOptions {
|| (args[i + 1].charAt(0) == '-')) {
throw new FOPException("you must specify the image file for the '-imagein' option");
} else {
- imagefile = new File(args[i + 1]);
+ String filename = args[i + 1];
+ if (isSystemInOutFile(filename)) {
+ this.useStdIn = true;
+ } else {
+ imagefile = new File(filename);
+ }
return 1;
}
}
private PDFEncryptionParams getPDFEncryptionParams() throws FOPException {
PDFEncryptionParams params = (PDFEncryptionParams)renderingOptions.get(
- PDFRenderer.ENCRYPTION_PARAMS);
+ PDFRenderer.ENCRYPTION_PARAMS);
if (params == null) {
if (!PDFEncryptionManager.checkAvailableAlgorithms()) {
throw new FOPException("PDF encryption requested but it is not available."
@@ -787,7 +823,7 @@ public class CommandLineOptions {
if (inputmode == XSLT_INPUT) {
// check whether xml *and* xslt file have been set
- if (xmlfile == null) {
+ if (xmlfile == null && !this.useStdIn) {
throw new FOPException("XML file must be specified for the transform mode");
}
if (xsltfile == null) {
@@ -804,7 +840,7 @@ public class CommandLineOptions {
+ "\n fofile: "
+ fofile.getAbsolutePath());
}
- if (!xmlfile.exists()) {
+ if (xmlfile != null && !xmlfile.exists()) {
throw new FileNotFoundException("Error: xml file "
+ xmlfile.getAbsolutePath()
+ " not found ");
@@ -822,10 +858,10 @@ public class CommandLineOptions {
}
if (xmlfile != null || xsltfile != null) {
log.warn("fo input mode, but xmlfile or xslt file are set:");
- log.error("xml file: " + xmlfile.toString());
- log.error("xslt file: " + xsltfile.toString());
+ log.error("xml file: " + xmlfile);
+ log.error("xslt file: " + xsltfile);
}
- if (!fofile.exists()) {
+ if (fofile != null && !fofile.exists()) {
throw new FileNotFoundException("Error: fo file "
+ fofile.getAbsolutePath()
+ " not found ");
@@ -840,10 +876,10 @@ public class CommandLineOptions {
}
if (xmlfile != null || xsltfile != null) {
log.warn("area tree input mode, but xmlfile or xslt file are set:");
- log.error("xml file: " + xmlfile.toString());
- log.error("xslt file: " + xsltfile.toString());
+ log.error("xml file: " + xmlfile);
+ log.error("xslt file: " + xsltfile);
}
- if (!areatreefile.exists()) {
+ if (areatreefile != null && !areatreefile.exists()) {
throw new FileNotFoundException("Error: area tree file "
+ areatreefile.getAbsolutePath()
+ " not found ");
@@ -857,7 +893,7 @@ public class CommandLineOptions {
log.warn("image input mode, but XML file is set:");
log.error("XML file: " + xmlfile.toString());
}
- if (!imagefile.exists()) {
+ if (imagefile != null && !imagefile.exists()) {
throw new FileNotFoundException("Error: image file "
+ imagefile.getAbsolutePath()
+ " not found ");
@@ -972,6 +1008,22 @@ public class CommandLineOptions {
}
/**
+ * Indicates whether input comes from standard input (stdin).
+ * @return true if input comes from standard input (stdin)
+ */
+ public boolean isInputFromStdIn() {
+ return this.useStdIn;
+ }
+
+ /**
+ * Indicates whether output is sent to standard output (stdout).
+ * @return true if output is sent to standard output (stdout)
+ */
+ public boolean isOutputToStdOut() {
+ return this.useStdOut;
+ }
+
+ /**
* Returns the input file.
* @return either the fofile or the xmlfile
*/
@@ -1013,15 +1065,17 @@ public class CommandLineOptions {
+ " (Examples for prof: PDF/A-1b or PDF/X-3:2003)\n\n"
+ " [INPUT] \n"
+ " infile xsl:fo input file (the same as the next) \n"
+ + " (use # for infile to pipe input from stdin)\n"
+ " -fo infile xsl:fo input file \n"
+ " -xml infile xml input file, must be used together with -xsl \n"
+ " -atin infile area tree input file \n"
- + " -imagein infile image input file \n"
+ + " -imagein infile image input file (piping through stdin not supported)\n"
+ " -xsl stylesheet xslt stylesheet \n \n"
+ " -param name value <value> to use for parameter <name> in xslt stylesheet\n"
+ " (repeat '-param name value' for each parameter)\n \n"
+ " [OUTPUT] \n"
+ " outfile input will be rendered as PDF into outfile\n"
+ + " (use # for outfile to pipe output to stdout)\n"
+ " -pdf outfile input will be rendered as PDF (outfile req'd)\n"
+ " -pdfa1b outfile input will be rendered as PDF/A-1b compliant PDF\n"
+ " (outfile req'd, same as \"-pdf outfile -pdfprofile PDF/A-1b\")\n"
@@ -1055,6 +1109,7 @@ public class CommandLineOptions {
+ " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
+ " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n"
+ " Fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n"
+ + " Fop -xml # -xsl foo.xsl -pdf #\n"
+ " Fop foo.fo -mif foo.mif\n"
+ " Fop foo.fo -rtf foo.rtf\n"
+ " Fop foo.fo -print\n"
@@ -1085,11 +1140,19 @@ public class CommandLineOptions {
break;
case FO_INPUT:
log.info("FO ");
- log.info("fo input file: " + fofile.toString());
+ if (this.useStdIn) {
+ log.info("fo input file: from stdin");
+ } else {
+ log.info("fo input file: " + fofile.toString());
+ }
break;
case XSLT_INPUT:
log.info("xslt transformation");
- log.info("xml input file: " + xmlfile.toString());
+ if (this.useStdIn) {
+ log.info("xml input file: from stdin");
+ } else {
+ log.info("xml input file: " + xmlfile.toString());
+ }
log.info("xslt stylesheet: " + xsltfile.toString());
break;
default:
@@ -1102,7 +1165,7 @@ public class CommandLineOptions {
log.info("awt on screen");
if (outfile != null) {
log.error("awt mode, but outfile is set:");
- log.info("out file: " + outfile.toString());
+ log.error("out file: " + outfile.toString());
}
} else if (MimeConstants.MIME_FOP_PRINT.equals(outputmode)) {
log.info("print directly");
@@ -1115,13 +1178,21 @@ public class CommandLineOptions {
if (mimicRenderer != null) {
log.info("mimic renderer: " + mimicRenderer);
}
- log.info("output file: " + outfile.toString());
+ if (this.useStdOut) {
+ log.info("output file: to stdout");
+ } else {
+ log.info("output file: " + outfile.toString());
+ }
} else if (MimeConstants.MIME_FOP_IF.equals(outputmode)) {
log.info("intermediate format");
log.info("output file: " + outfile.toString());
} else {
log.info(outputmode);
- log.info("output file: " + outfile.toString());
+ if (this.useStdOut) {
+ log.info("output file: to stdout");
+ } else {
+ log.info("output file: " + outfile.toString());
+ }
}
log.info("OPTIONS");
diff --git a/src/java/org/apache/fop/cli/InputHandler.java b/src/java/org/apache/fop/cli/InputHandler.java
index 7ad89bfab..5e38b803a 100644
--- a/src/java/org/apache/fop/cli/InputHandler.java
+++ b/src/java/org/apache/fop/cli/InputHandler.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,8 +21,8 @@ package org.apache.fop.cli;
// Imported java.io classes
import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;
@@ -58,7 +58,7 @@ import org.apache.fop.render.awt.viewer.Renderable;
* parameters) or FO File input alone
*/
public class InputHandler implements ErrorListener, Renderable {
-
+
/** original source file */
protected File sourcefile = null;
private File stylesheet = null; // for XML/XSLT usage
@@ -66,12 +66,12 @@ public class InputHandler implements ErrorListener, Renderable {
/** the logger */
protected Log log = LogFactory.getLog(InputHandler.class);
-
+
/**
* Constructor for XML->XSLT->FO input
* @param xmlfile XML file
* @param xsltfile XSLT file
- * @param params Vector of command-line parameters (name, value,
+ * @param params Vector of command-line parameters (name, value,
* name, value, ...) for XSL stylesheet, null if none
*/
public InputHandler(File xmlfile, File xsltfile, Vector params) {
@@ -95,7 +95,7 @@ public class InputHandler implements ErrorListener, Renderable {
* @param out the output stream to write the generated output to (may be null if not applicable)
* @throws FOPException in case of an error during processing
*/
- public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
+ public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
throws FOPException {
FopFactory factory = userAgent.getFactory();
@@ -107,12 +107,12 @@ public class InputHandler implements ErrorListener, Renderable {
}
// if base URL was not explicitly set in FOUserAgent, obtain here
- if (fop.getUserAgent().getBaseURL() == null) {
+ if (fop.getUserAgent().getBaseURL() == null && sourcefile != null) {
String baseURL = null;
try {
baseURL = new File(sourcefile.getAbsolutePath()).
- getParentFile().toURL().toExternalForm();
+ getParentFile().toURI().toURL().toExternalForm();
} catch (Exception e) {
baseURL = "";
}
@@ -124,7 +124,7 @@ public class InputHandler implements ErrorListener, Renderable {
transformTo(res);
}
-
+
/** {@inheritDoc} */
public void renderTo(FOUserAgent userAgent, String outputFormat) throws FOPException {
renderTo(userAgent, outputFormat, null);
@@ -140,34 +140,53 @@ public class InputHandler implements ErrorListener, Renderable {
Result res = new StreamResult(out);
transformTo(res);
}
-
+
/**
* Creates a Source for the main input file. Processes XInclude if
* available in the XML parser.
- *
+ *
* @return the Source for the main input file
*/
protected Source createMainSource() {
Source result;
+ InputStream in;
+ String uri;
+ if (this.sourcefile != null) {
+ try {
+ in = new java.io.FileInputStream(this.sourcefile);
+ uri = this.sourcefile.toURI().toASCIIString();
+ } catch (FileNotFoundException e) {
+ //handled elsewhere
+ return new StreamSource(this.sourcefile);
+ }
+ } else {
+ in = System.in;
+ uri = null;
+ }
try {
- InputSource is = new InputSource(new FileInputStream(
- this.sourcefile));
- is.setSystemId(this.sourcefile.toURI().toASCIIString());
+ InputSource is = new InputSource(in);
+ is.setSystemId(uri);
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature("http://xml.org/sax/features/namespaces", true);
spf.setFeature("http://apache.org/xml/features/xinclude", true);
XMLReader xr = spf.newSAXParser().getXMLReader();
result = new SAXSource(xr, is);
} catch (SAXException e) {
- result = new StreamSource(this.sourcefile);
- } catch (IOException e) {
- result = new StreamSource(this.sourcefile);
+ if (this.sourcefile != null) {
+ result = new StreamSource(this.sourcefile);
+ } else {
+ result = new StreamSource(in, uri);
+ }
} catch (ParserConfigurationException e) {
- result = new StreamSource(this.sourcefile);
+ if (this.sourcefile != null) {
+ result = new StreamSource(this.sourcefile);
+ } else {
+ result = new StreamSource(in, uri);
+ }
}
return result;
}
-
+
/**
* Creates a Source for the selected stylesheet.
* @return the Source for the selected stylesheet or null if there's no stylesheet
@@ -179,7 +198,7 @@ public class InputHandler implements ErrorListener, Renderable {
return null;
}
}
-
+
/**
* Transforms the input document to the input format expected by FOP using XSLT.
* @param result the Result object where the result of the XSL transformation is sent to
@@ -190,15 +209,15 @@ public class InputHandler implements ErrorListener, Renderable {
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer;
-
+
Source xsltSource = createXSLTSource();
if (xsltSource == null) { // FO Input
transformer = factory.newTransformer();
} else { // XML/XSLT input
transformer = factory.newTransformer(xsltSource);
-
+
// Set the value of parameters, if any, defined for stylesheet
- if (xsltParams != null) {
+ if (xsltParams != null) {
for (int i = 0; i < xsltParams.size(); i += 2) {
transformer.setParameter((String) xsltParams.elementAt(i),
(String) xsltParams.elementAt(i + 1));
diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java
index 43da8d966..f1a23ea46 100644
--- a/src/java/org/apache/fop/cli/Main.java
+++ b/src/java/org/apache/fop/cli/Main.java
@@ -62,11 +62,11 @@ public class Main {
fopJar = new File(baseDir, "fop.jar");
}
if (!fopJar.exists()) {
- throw new RuntimeException("fop.jar not found in directory: "
+ throw new RuntimeException("fop.jar not found in directory: "
+ baseDir.getAbsolutePath() + " (or below)");
}
List jars = new java.util.ArrayList();
- jars.add(fopJar.toURL());
+ jars.add(fopJar.toURI().toURL());
File[] files;
FileFilter filter = new FileFilter() {
public boolean accept(File pathname) {
@@ -80,7 +80,7 @@ public class Main {
files = libDir.listFiles(filter);
if (files != null) {
for (int i = 0, size = files.length; i < size; i++) {
- jars.add(files[i].toURL());
+ jars.add(files[i].toURI().toURL());
}
}
String optionalLib = System.getProperty("fop.optional.lib");
@@ -88,7 +88,7 @@ public class Main {
files = new File(optionalLib).listFiles(filter);
if (files != null) {
for (int i = 0, size = files.length; i < size; i++) {
- jars.add(files[i].toURL());
+ jars.add(files[i].toURI().toURL());
}
}
}
@@ -99,7 +99,7 @@ public class Main {
}*/
return urls;
}
-
+
/**
* @return true if FOP's dependecies are available in the current ClassLoader setup.
*/
@@ -115,7 +115,7 @@ public class Main {
return false;
}
}
-
+
/**
* Dynamically builds a ClassLoader and executes FOP.
* @param args command-line arguments
@@ -123,7 +123,7 @@ public class Main {
public static void startFOPWithDynamicClasspath(String[] args) {
try {
URL[] urls = getJARList();
- //System.out.println("CCL: "
+ //System.out.println("CCL: "
// + Thread.currentThread().getContextClassLoader().toString());
ClassLoader loader = new java.net.URLClassLoader(urls, null);
Thread.currentThread().setContextClassLoader(loader);
@@ -137,13 +137,13 @@ public class Main {
System.exit(-1);
}
}
-
+
/**
* Executes FOP with the given ClassLoader setup.
* @param args command-line arguments
*/
public static void startFOP(String[] args) {
- //System.out.println("static CCL: "
+ //System.out.println("static CCL: "
// + Thread.currentThread().getContextClassLoader().toString());
//System.out.println("static CL: " + Fop.class.getClassLoader().toString());
CommandLineOptions options = null;
@@ -155,7 +155,7 @@ public class Main {
if (!options.parse(args)) {
System.exit(1);
}
-
+
foUserAgent = options.getFOUserAgent();
String outputFormat = options.getOutputFormat();
@@ -164,15 +164,17 @@ public class Main {
out = new java.io.BufferedOutputStream(
new java.io.FileOutputStream(options.getOutputFile()));
foUserAgent.setOutputFile(options.getOutputFile());
+ } else if (options.isOutputToStdOut()) {
+ out = new java.io.BufferedOutputStream(System.out);
}
if (!MimeConstants.MIME_XSL_FO.equals(outputFormat)) {
options.getInputHandler().renderTo(foUserAgent, outputFormat, out);
} else {
options.getInputHandler().transformTo(out);
}
- } finally {
- IOUtils.closeQuietly(out);
- }
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
// System.exit(0) called to close AWT/SVG-created threads, if any.
// AWTRenderer closes with window shutdown, so exit() should not
@@ -183,14 +185,14 @@ public class Main {
} catch (Exception e) {
if (options != null) {
options.getLogger().error("Exception", e);
- }
- if (options.getOutputFile() != null) {
- options.getOutputFile().delete();
+ if (options.getOutputFile() != null) {
+ options.getOutputFile().delete();
+ }
}
System.exit(1);
}
}
-
+
/**
* The main routine for the command line interface
* @param args the command line parameters
diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml
index 3e6cc181e..1f08456c9 100644
--- a/src/java/org/apache/fop/events/EventFormatter.xml
+++ b/src/java/org/apache/fop/events/EventFormatter.xml
@@ -81,7 +81,7 @@ Any reference to it will be considered a reference to the first occurrence in th
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.rowTooTall">The contents of table-row {row} are taller than they should be (there is a block-progression-dimension or height constraint on the indicated row). Due to its contents the row grows to {effCellBPD} millipoints, but the row shouldn't get any taller than {maxCellBPD} millipoints.{{locator}}</message>
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.tableFixedAutoWidthNotSupported">table-layout="fixed" and width="auto", but auto-layout not supported =&gt; assuming width="100%".{{locator}}</message>
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.objectTooWide">The extent in inline-progression-direction (width) of a {elementName} is bigger than the available space ({effIPD}mpt &gt; {maxIPD}mpt).{{locator}}</message>
- <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.overconstrainedAdjustEndIndent">Adjusting end-indent based on overconstrained geometry rules for {elementName}.{{locator}}</message>
+ <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.overconstrainedAdjustEndIndent">An {elementName} {{locator}} is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4)</message>
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.viewportOverflow">Content overflows the viewport of an {elementName} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.regionOverflow">Content overflows the viewport of the {elementName} on page {page} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
<message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.flowNotMappingToRegionBody">Flow "{flowName}" does not map to the region-body in page-master "{masterName}". FOP presently does not support this.{{locator}}</message>
diff --git a/src/java/org/apache/fop/events/model/EventMethodModel.java b/src/java/org/apache/fop/events/model/EventMethodModel.java
index 930cda53d..b9c62f8ab 100644
--- a/src/java/org/apache/fop/events/model/EventMethodModel.java
+++ b/src/java/org/apache/fop/events/model/EventMethodModel.java
@@ -37,12 +37,12 @@ import org.apache.xmlgraphics.util.XMLizable;
public class EventMethodModel implements Serializable, XMLizable {
private static final long serialVersionUID = -7548882973341444354L;
-
+
private String methodName;
private EventSeverity severity;
private List params = new java.util.ArrayList();
private String exceptionClass;
-
+
/**
* Creates an new instance.
* @param methodName the event method's name
@@ -52,7 +52,7 @@ public class EventMethodModel implements Serializable, XMLizable {
this.methodName = methodName;
this.severity = severity;
}
-
+
/**
* Adds a method parameter.
* @param param the method parameter
@@ -60,7 +60,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public void addParameter(Parameter param) {
this.params.add(param);
}
-
+
/**
* Adds a method parameter.
* @param type the type of the parameter
@@ -68,11 +68,11 @@ public class EventMethodModel implements Serializable, XMLizable {
* @return the resulting Parameter instance
*/
public Parameter addParameter(Class type, String name) {
- Parameter param = new Parameter(type, name);
+ Parameter param = new Parameter(type, name);
addParameter(param);
return param;
}
-
+
/**
* Sets the event method name.
* @param name the event name
@@ -80,7 +80,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public void setMethodName(String name) {
this.methodName = name;
}
-
+
/**
* Returns the event method name
* @return the event name
@@ -88,7 +88,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public String getMethodName() {
return this.methodName;
}
-
+
/**
* Sets the event's severity level.
* @param severity the severity
@@ -96,7 +96,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public void setSeverity(EventSeverity severity) {
this.severity = severity;
}
-
+
/**
* Returns the event's severity level.
* @return the severity
@@ -104,7 +104,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public EventSeverity getSeverity() {
return this.severity;
}
-
+
/**
* Returns an unmodifiable list of parameters for this event method.
* @return the list of parameters
@@ -112,7 +112,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public List getParameters() {
return Collections.unmodifiableList(this.params);
}
-
+
/**
* Sets the primary exception class for this event method. Note: Not all event methods throw
* exceptions!
@@ -121,7 +121,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public void setExceptionClass(String exceptionClass) {
this.exceptionClass = exceptionClass;
}
-
+
/**
* Returns the primary exception class for this event method. This method returns null if
* the event is only informational or just a warning.
@@ -130,34 +130,34 @@ public class EventMethodModel implements Serializable, XMLizable {
public String getExceptionClass() {
return this.exceptionClass;
}
-
+
/** {@inheritDoc} */
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(null, "name", "name", "CDATA", getMethodName());
- atts.addAttribute(null, "severity", "severity", "CDATA", getSeverity().getName());
+ atts.addAttribute("", "name", "name", "CDATA", getMethodName());
+ atts.addAttribute("", "severity", "severity", "CDATA", getSeverity().getName());
if (getExceptionClass() != null) {
- atts.addAttribute(null, "exception", "exception", "CDATA", getExceptionClass());
+ atts.addAttribute("", "exception", "exception", "CDATA", getExceptionClass());
}
String elName = "method";
- handler.startElement(null, elName, elName, atts);
+ handler.startElement("", elName, elName, atts);
Iterator iter = this.params.iterator();
while (iter.hasNext()) {
((XMLizable)iter.next()).toSAX(handler);
}
- handler.endElement(null, elName, elName);
+ handler.endElement("", elName, elName);
}
-
+
/**
* Represents an event parameter.
*/
public static class Parameter implements Serializable, XMLizable {
-
+
private static final long serialVersionUID = 6062500277953887099L;
-
+
private Class type;
private String name;
-
+
/**
* Creates a new event parameter.
* @param type the parameter type
@@ -167,7 +167,7 @@ public class EventMethodModel implements Serializable, XMLizable {
this.type = type;
this.name = name;
}
-
+
/**
* Returns the parameter type.
* @return the parameter type
@@ -175,7 +175,7 @@ public class EventMethodModel implements Serializable, XMLizable {
public Class getType() {
return this.type;
}
-
+
/**
* Returns the parameter name.
* @return the parameter name
@@ -187,12 +187,12 @@ public class EventMethodModel implements Serializable, XMLizable {
/** {@inheritDoc} */
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(null, "type", "type", "CDATA", getType().getName());
- atts.addAttribute(null, "name", "name", "CDATA", getName());
+ atts.addAttribute("", "type", "type", "CDATA", getType().getName());
+ atts.addAttribute("", "name", "name", "CDATA", getName());
String elName = "parameter";
- handler.startElement(null, elName, elName, atts);
- handler.endElement(null, elName, elName);
+ handler.startElement("", elName, elName, atts);
+ handler.endElement("", elName, elName);
}
-
+
}
}
diff --git a/src/java/org/apache/fop/events/model/EventModel.java b/src/java/org/apache/fop/events/model/EventModel.java
index 61e221b3b..9c11b79a3 100644
--- a/src/java/org/apache/fop/events/model/EventModel.java
+++ b/src/java/org/apache/fop/events/model/EventModel.java
@@ -21,6 +21,7 @@ package org.apache.fop.events.model;
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
@@ -38,6 +39,8 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.commons.io.IOUtils;
+
import org.apache.xmlgraphics.util.XMLizable;
/**
@@ -46,15 +49,15 @@ import org.apache.xmlgraphics.util.XMLizable;
public class EventModel implements Serializable, XMLizable {
private static final long serialVersionUID = 7468592614934605082L;
-
+
private Map producers = new java.util.LinkedHashMap();
-
+
/**
* Creates a new, empty event model
*/
public EventModel() {
}
-
+
/**
* Adds the model of an event producer to the event model.
* @param producer the event producer model
@@ -62,7 +65,7 @@ public class EventModel implements Serializable, XMLizable {
public void addProducer(EventProducerModel producer) {
this.producers.put(producer.getInterfaceName(), producer);
}
-
+
/**
* Returns an iterator over the contained event producer models.
* @return an iterator (Iterator&lt;EventProducerModel&gt;)
@@ -79,7 +82,7 @@ public class EventModel implements Serializable, XMLizable {
public EventProducerModel getProducer(String interfaceName) {
return (EventProducerModel)this.producers.get(interfaceName);
}
-
+
/**
* Returns the model of an event producer with the given interface.
* @param clazz the interface of the event producer
@@ -88,22 +91,28 @@ public class EventModel implements Serializable, XMLizable {
public EventProducerModel getProducer(Class clazz) {
return getProducer(clazz.getName());
}
-
+
/** {@inheritDoc} */
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
String elName = "event-model";
- handler.startElement(null, elName, elName, atts);
+ handler.startElement("", elName, elName, atts);
Iterator iter = getProducers();
while (iter.hasNext()) {
((XMLizable)iter.next()).toSAX(handler);
}
- handler.endElement(null, elName, elName);
+ handler.endElement("", elName, elName);
}
private void writeXMLizable(XMLizable object, File outputFile) throws IOException {
- Result res = new StreamResult(outputFile);
-
+ //These two approaches do not seem to work in all environments:
+ //Result res = new StreamResult(outputFile);
+ //Result res = new StreamResult(outputFile.toURI().toURL().toExternalForm());
+ //With an old Xalan version: file:/C:/.... --> file:\C:\.....
+ OutputStream out = new java.io.FileOutputStream(outputFile);
+ out = new java.io.BufferedOutputStream(out);
+ Result res = new StreamResult(out);
+
try {
SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
@@ -120,6 +129,8 @@ public class EventModel implements Serializable, XMLizable {
throw new IOException(e.getMessage());
} catch (SAXException e) {
throw new IOException(e.getMessage());
+ } finally {
+ IOUtils.closeQuietly(out);
}
}
diff --git a/src/java/org/apache/fop/events/model/EventProducerModel.java b/src/java/org/apache/fop/events/model/EventProducerModel.java
index 938609cd9..b0d334e99 100644
--- a/src/java/org/apache/fop/events/model/EventProducerModel.java
+++ b/src/java/org/apache/fop/events/model/EventProducerModel.java
@@ -35,18 +35,18 @@ import org.apache.xmlgraphics.util.XMLizable;
public class EventProducerModel implements Serializable, XMLizable {
private static final long serialVersionUID = 122267104123721902L;
-
+
private String interfaceName;
private Map methods = new java.util.LinkedHashMap();
-
+
/**
* Creates a new instance.
- * @param interfaceName the fully qualified interface name of the event producer
+ * @param interfaceName the fully qualified interface name of the event producer
*/
public EventProducerModel(String interfaceName) {
this.interfaceName = interfaceName;
}
-
+
/**
* Returns the fully qualified interface name of the event producer.
* @return the fully qualified interface name
@@ -54,7 +54,7 @@ public class EventProducerModel implements Serializable, XMLizable {
public String getInterfaceName() {
return this.interfaceName;
}
-
+
/**
* Sets the fully qualified interface name of the event producer.
* @param name the fully qualified interface name
@@ -62,7 +62,7 @@ public class EventProducerModel implements Serializable, XMLizable {
public void setInterfaceName(String name) {
this.interfaceName = name;
}
-
+
/**
* Adds a model instance of an event method.
* @param method the event method model
@@ -70,7 +70,7 @@ public class EventProducerModel implements Serializable, XMLizable {
public void addMethod(EventMethodModel method) {
this.methods.put(method.getMethodName(), method);
}
-
+
/**
* Returns the model instance of an event method for the given method name.
* @param methodName the method name
@@ -79,7 +79,7 @@ public class EventProducerModel implements Serializable, XMLizable {
public EventMethodModel getMethod(String methodName) {
return (EventMethodModel)this.methods.get(methodName);
}
-
+
/**
* Returns an iterator over the contained event producer methods.
* @return an iterator (Iterator&lt;EventMethodModel&gt;)
@@ -91,15 +91,15 @@ public class EventProducerModel implements Serializable, XMLizable {
/** {@inheritDoc} */
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(null, "name", "name", "CDATA", getInterfaceName());
+ atts.addAttribute("", "name", "name", "CDATA", getInterfaceName());
String elName = "producer";
- handler.startElement(null, elName, elName, atts);
+ handler.startElement("", elName, elName, atts);
Iterator iter = getMethods();
while (iter.hasNext()) {
((XMLizable)iter.next()).toSAX(handler);
}
- handler.endElement(null, elName, elName);
+ handler.endElement("", elName, elName);
}
-
+
}
diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
index 521f3b81b..7711130b1 100644
--- a/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
+++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElement.java
@@ -92,7 +92,7 @@ public class SVGElement extends SVGObj {
try {
URL baseURL = new URL(getUserAgent().getBaseURL() == null
- ? new java.io.File("").toURL().toExternalForm()
+ ? new java.io.File("").toURI().toURL().toExternalForm()
: getUserAgent().getBaseURL());
if (baseURL != null) {
SVGOMDocument svgdoc = (SVGOMDocument)doc;
diff --git a/src/java/org/apache/fop/fonts/CustomFontCollection.java b/src/java/org/apache/fop/fonts/CustomFontCollection.java
index 5e5a61189..5a0bba782 100644
--- a/src/java/org/apache/fop/fonts/CustomFontCollection.java
+++ b/src/java/org/apache/fop/fonts/CustomFontCollection.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,38 +21,35 @@ package org.apache.fop.fonts;
import java.util.List;
-import org.apache.fop.render.PrintRenderer;
-
/**
* Sets up a set of custom (embedded) fonts
*/
public class CustomFontCollection implements FontCollection {
- private PrintRenderer renderer = null;
+ private FontResolver fontResolver;
+ private List/*<EmbedFontInfo>*/ embedFontInfoList;
/**
- * A print renderer to configure
- * @param renderer a print renderer
+ * Main constructor.
+ * @param fontResolver a font resolver
+ * @param customFonts the list of custom fonts
*/
- public CustomFontCollection(PrintRenderer renderer) {
- this.renderer = renderer;
+ public CustomFontCollection(FontResolver fontResolver,
+ List/*<EmbedFontInfo>*/ customFonts) {
+ this.fontResolver = fontResolver;
+ if (this.fontResolver == null) {
+ //Ensure that we have minimal font resolution capabilities
+ this.fontResolver = FontManager.createMinimalFontResolver();
+ }
+ this.embedFontInfoList = customFonts;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int setup(int num, FontInfo fontInfo) {
- List/*<EmbedFontInfo>*/ embedFontInfoList = renderer.getFontList();
if (embedFontInfoList == null) {
return num; //No fonts to process
}
- FontResolver resolver = renderer.getFontResolver();
- if (resolver == null) {
- //Ensure that we have minimal font resolution capabilities
- resolver = FontManager.createMinimalFontResolver();
- }
-
String internalName = null;
//FontReader reader = null;
@@ -69,7 +66,7 @@ public class CustomFontCollection implements FontCollection {
fontInfo.addMetrics(internalName, reader.getFont());
*/
- LazyFont font = new LazyFont(embedFontInfo, resolver);
+ LazyFont font = new LazyFont(embedFontInfo, this.fontResolver);
fontInfo.addMetrics(internalName, font);
List triplets = embedFontInfo.getFontTriplets();
diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java
index c180fbcc9..b3833cf50 100644
--- a/src/java/org/apache/fop/fonts/FontManager.java
+++ b/src/java/org/apache/fop/fonts/FontManager.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,6 @@
package org.apache.fop.fonts;
-import java.awt.Graphics2D;
import java.net.MalformedURLException;
import javax.xml.transform.Source;
@@ -27,7 +26,6 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.fop.fonts.FontTriplet.Matcher;
import org.apache.fop.fonts.substitute.FontSubstitutions;
-import org.apache.fop.render.PrintRenderer;
// TODO: Refactor fonts package so major font activities (autodetection etc)
// are all centrally managed and delegated from this class, also remove dependency on FopFactory
@@ -144,55 +142,17 @@ public class FontManager {
}
/**
- * Sets up the fonts on a given PrintRenderer
- * @param renderer a print renderer
+ * Sets up the fonts on a given FontInfo object. The fonts to setup are defined by an
+ * array of {@code FontCollection} objects.
+ * @param fontInfo the FontInfo object to set up
+ * @param fontCollections the array of font collections/sources
*/
- public void setupRenderer(PrintRenderer renderer) {
- FontInfo fontInfo = renderer.getFontInfo();
-
+ public void setup(FontInfo fontInfo, FontCollection[] fontCollections) {
int startNum = 1;
- // Configure base 14 fonts
- org.apache.fop.fonts.base14.Base14FontCollection base14FontCollection
- = new org.apache.fop.fonts.base14.Base14FontCollection(this.enableBase14Kerning);
- startNum = base14FontCollection.setup(startNum, fontInfo);
-
- // Configure any custom font collection
- org.apache.fop.fonts.CustomFontCollection customFontCollection
- = new org.apache.fop.fonts.CustomFontCollection(renderer);
- startNum = customFontCollection.setup(startNum, fontInfo);
-
- // Make any defined substitutions in the font info
- getFontSubstitutions().adjustFontInfo(fontInfo);
- }
-
- /**
- * Sets up the fonts on a given PrintRenderer with Graphics2D
- * @param renderer a print renderer
- * @param graphics2D a graphics 2D
- */
- public void setupRenderer(PrintRenderer renderer, Graphics2D graphics2D) {
- FontInfo fontInfo = renderer.getFontInfo();
-
- int startNum = 1;
-
- // setup base 14 fonts
- org.apache.fop.render.java2d.Base14FontCollection base14FontCollection
- = new org.apache.fop.render.java2d.Base14FontCollection(graphics2D);
-
- // setup any custom font collection
- startNum = base14FontCollection.setup(startNum, fontInfo);
-
- // setup any installed fonts
- org.apache.fop.render.java2d.InstalledFontCollection installedFontCollection
- = new org.apache.fop.render.java2d.InstalledFontCollection(graphics2D);
- startNum = installedFontCollection.setup(startNum, fontInfo);
-
- // setup any configured fonts
- org.apache.fop.render.java2d.ConfiguredFontCollection configuredFontCollection
- = new org.apache.fop.render.java2d.ConfiguredFontCollection(renderer);
- startNum = configuredFontCollection.setup(startNum, fontInfo);
-
+ for (int i = 0, c = fontCollections.length; i < c; i++) {
+ startNum = fontCollections[i].setup(startNum, fontInfo);
+ }
// Make any defined substitutions in the font info
getFontSubstitutions().adjustFontInfo(fontInfo);
}
diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTree.java b/src/java/org/apache/fop/hyphenation/HyphenationTree.java
index 67488c5b5..d145936c6 100644
--- a/src/java/org/apache/fop/hyphenation/HyphenationTree.java
+++ b/src/java/org/apache/fop/hyphenation/HyphenationTree.java
@@ -125,7 +125,7 @@ public class HyphenationTree extends TernaryTree
public void loadPatterns(String filename) throws HyphenationException {
File f = new File(filename);
try {
- InputSource src = new InputSource(f.toURL().toExternalForm());
+ InputSource src = new InputSource(f.toURI().toURL().toExternalForm());
loadPatterns(src);
} catch (MalformedURLException e) {
throw new HyphenationException("Error converting the File '" + f + "' to a URL: "
diff --git a/src/java/org/apache/fop/hyphenation/PatternParser.java b/src/java/org/apache/fop/hyphenation/PatternParser.java
index b0378a40b..2edf64676 100644
--- a/src/java/org/apache/fop/hyphenation/PatternParser.java
+++ b/src/java/org/apache/fop/hyphenation/PatternParser.java
@@ -92,7 +92,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
*/
public void parse(File file) throws HyphenationException {
try {
- InputSource src = new InputSource(file.toURL().toExternalForm());
+ InputSource src = new InputSource(file.toURI().toURL().toExternalForm());
parse(src);
} catch (MalformedURLException e) {
throw new HyphenationException("Error converting the File '" + file + "' to a URL: "
diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java
index 35630d628..44b0a211d 100644
--- a/src/java/org/apache/fop/render/PrintRenderer.java
+++ b/src/java/org/apache/fop/render/PrintRenderer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,19 +20,23 @@
package org.apache.fop.render;
// FOP
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
+import org.apache.fop.fonts.CustomFontCollection;
import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontResolver;
import org.apache.fop.fonts.FontTriplet;
-import org.w3c.dom.Document;
-
-// Java
-import java.awt.Color;
-import java.awt.geom.Rectangle2D;
-import java.util.List;
-import java.util.Map;
+import org.apache.fop.fonts.base14.Base14FontCollection;
/** Abstract base class of "Print" type renderers. */
public abstract class PrintRenderer extends AbstractRenderer {
@@ -79,7 +83,12 @@ public abstract class PrintRenderer extends AbstractRenderer {
*/
public void setupFontInfo(FontInfo inFontInfo) {
this.fontInfo = inFontInfo;
- userAgent.getFactory().getFontManager().setupRenderer(this);
+ FontManager fontManager = userAgent.getFactory().getFontManager();
+ FontCollection[] fontCollections = new FontCollection[] {
+ new Base14FontCollection(fontManager.isBase14KerningEnabled()),
+ new CustomFontCollection(getFontResolver(), getFontList())
+ };
+ fontManager.setup(getFontInfo(), fontCollections);
}
/**
diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
index 77792267c..7951be26c 100644
--- a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
+++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
@@ -157,7 +157,7 @@ public final class AFPFontReader {
if (url == null) {
try {
File file = new File(path);
- url = file.toURL();
+ url = file.toURI().toURL();
if (url == null) {
String msg = "CharacterSet file not found for "
+ characterset + " in classpath: " + path;
@@ -194,7 +194,7 @@ public final class AFPFontReader {
log.warn(msg);
}
- inputStream = csfont[0].toURL().openStream();
+ inputStream = csfont[0].toURI().toURL().openStream();
if (inputStream == null) {
String msg = "Failed to open character set resource "
+ characterset;
@@ -258,7 +258,7 @@ public final class AFPFontReader {
if (url == null) {
try {
File file = new File(path);
- url = file.toURL();
+ url = file.toURI().toURL();
if (url == null) {
String msg = "CodePage file not found for " + codePage
+ " in classpath: " + path;
@@ -300,7 +300,7 @@ public final class AFPFontReader {
log.warn(msg);
}
- InputStream is = codepage[0].toURL().openStream();
+ InputStream is = codepage[0].toURI().toURL().openStream();
if (is == null) {
String msg = "AFPFontReader:: loadCodePage(String):: code page file not found for "
diff --git a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
index 843ab8413..26d64af74 100644
--- a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
+++ b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,6 @@ import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontResolver;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.LazyFont;
-import org.apache.fop.render.PrintRenderer;
/**
* A java2d configured font collection
@@ -44,37 +43,36 @@ public class ConfiguredFontCollection implements FontCollection {
private static Log log = LogFactory.getLog(ConfiguredFontCollection.class);
- private PrintRenderer renderer = null;
+ private FontResolver fontResolver;
+ private List/*<EmbedFontInfo>*/ embedFontInfoList;
/**
* Main constructor
- *
- * @param renderer a print renderer
+ * @param fontResolver a font resolver
+ * @param customFonts the list of custom fonts
*/
- public ConfiguredFontCollection(PrintRenderer renderer) {
- this.renderer = renderer;
+ public ConfiguredFontCollection(FontResolver fontResolver,
+ List/*<EmbedFontInfo>*/ customFonts) {
+ this.fontResolver = fontResolver;
+ if (this.fontResolver == null) {
+ //Ensure that we have minimal font resolution capabilities
+ this.fontResolver = FontManager.createMinimalFontResolver();
+ }
+ this.embedFontInfoList = customFonts;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int setup(int start, FontInfo fontInfo) {
- List/*<EmbedFontInfo>*/ fontList = renderer.getFontList();
- FontResolver resolver = renderer.getFontResolver();
int num = start;
- if (fontList == null || fontList.size() < 1) {
+ if (embedFontInfoList == null || embedFontInfoList.size() < 1) {
log.debug("No user configured fonts found.");
return num;
}
- if (resolver == null) {
- // Ensure that we have minimal font resolution capabilities
- resolver = FontManager.createMinimalFontResolver();
- }
String internalName = null;
- for (int i = 0; i < fontList.size(); i++) {
+ for (int i = 0; i < embedFontInfoList.size(); i++) {
- EmbedFontInfo configFontInfo = (EmbedFontInfo) fontList.get(i);
+ EmbedFontInfo configFontInfo = (EmbedFontInfo) embedFontInfoList.get(i);
String fontFile = configFontInfo.getEmbedFile();
internalName = "F" + num;
num++;
@@ -84,11 +82,12 @@ public class ConfiguredFontCollection implements FontCollection {
// If the user specified an XML-based metrics file, we'll use it
// Otherwise, calculate metrics directly from the font file.
if (metricsUrl != null) {
- LazyFont fontMetrics = new LazyFont(configFontInfo, resolver);
- Source fontSource = resolver.resolve(configFontInfo.getEmbedFile());
+ LazyFont fontMetrics = new LazyFont(configFontInfo, fontResolver);
+ Source fontSource = fontResolver.resolve(configFontInfo.getEmbedFile());
font = new CustomFontMetricsMapper(fontMetrics, fontSource);
} else {
- CustomFont fontMetrics = FontLoader.loadFont(fontFile, null, true, resolver);
+ CustomFont fontMetrics = FontLoader.loadFont(
+ fontFile, null, true, fontResolver);
font = new CustomFontMetricsMapper(fontMetrics);
}
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
index ed6f29ab9..1dd353b3b 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -69,6 +69,7 @@ import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.Typeface;
import org.apache.fop.render.AbstractPathOrientedRenderer;
@@ -176,7 +177,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
- userAgent.getFactory().getFontManager().setupRenderer(this, graphics2D);
+ FontCollection[] fontCollections = new FontCollection[] {
+ new Base14FontCollection(graphics2D),
+ new InstalledFontCollection(graphics2D),
+ new ConfiguredFontCollection(getFontResolver(), getFontList())
+ };
+ userAgent.getFactory().getFontManager().setup(
+ getFontInfo(), fontCollections);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
index 7ab46c24e..11366f985 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -82,6 +82,7 @@ import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.render.Graphics2DAdapter;
@@ -89,7 +90,10 @@ import org.apache.fop.render.PrintRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.render.RendererEventProducer;
+import org.apache.fop.render.java2d.Base14FontCollection;
+import org.apache.fop.render.java2d.ConfiguredFontCollection;
import org.apache.fop.render.java2d.FontMetricsMapper;
+import org.apache.fop.render.java2d.InstalledFontCollection;
import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.pcl.extensions.PCLElementMapping;
import org.apache.fop.traits.BorderProps;
@@ -207,7 +211,13 @@ public class PCLRenderer extends PrintRenderer {
graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
- userAgent.getFactory().getFontManager().setupRenderer(this, graphics2D);
+ FontCollection[] fontCollections = new FontCollection[] {
+ new Base14FontCollection(graphics2D),
+ new InstalledFontCollection(graphics2D),
+ new ConfiguredFontCollection(getFontResolver(), getFontList())
+ };
+ userAgent.getFactory().getFontManager().setup(
+ getFontInfo(), fontCollections);
}
/**
@@ -1035,7 +1045,7 @@ public class PCLRenderer extends PrintRenderer {
//So there's some optimization potential but not otherwise PCLRenderer is a little
//difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer
//between PrintRenderer and AbstractPathOrientedRenderer is necessary.
-
+
// save position and offset
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
@@ -1045,7 +1055,7 @@ public class PCLRenderer extends PrintRenderer {
at.translate(currentIPPosition, currentBPPosition);
at.translate(block.getXOffset(), block.getYOffset());
at.translate(0, block.getSpaceBefore());
-
+
if (!at.isIdentity()) {
saveGraphicsState();
concatenateTransformationMatrix(mptToPt(at));
@@ -1063,12 +1073,12 @@ public class PCLRenderer extends PrintRenderer {
if (!at.isIdentity()) {
restoreGraphicsState();
}
-
+
// stacked and relative blocks effect stacking
currentIPPosition = saveIP;
currentBPPosition = saveBP;
}
-
+
/** {@inheritDoc} */
protected void renderFlow(NormalFlow flow) {
//TODO This is the same code as in AbstractPathOrientedRenderer
@@ -1083,7 +1093,7 @@ public class PCLRenderer extends PrintRenderer {
//Establish a new coordinate system
AffineTransform at = new AffineTransform();
at.translate(currentIPPosition, currentBPPosition);
-
+
if (!at.isIdentity()) {
saveGraphicsState();
concatenateTransformationMatrix(mptToPt(at));
@@ -1092,16 +1102,16 @@ public class PCLRenderer extends PrintRenderer {
currentIPPosition = 0;
currentBPPosition = 0;
super.renderFlow(flow);
-
+
if (!at.isIdentity()) {
restoreGraphicsState();
}
-
+
// stacked and relative blocks effect stacking
currentIPPosition = saveIP;
currentBPPosition = saveBP;
}
-
+
/**
* Concatenates the current transformation matrix with the given one, therefore establishing
* a new coordinate system.
@@ -1225,7 +1235,7 @@ public class PCLRenderer extends PrintRenderer {
renderDocument(doc, ns, pos, fo.getForeignAttributes());
}
- /**
+ /**
* Common method to render the background and borders for any inline area.
* The all borders and padding are drawn outside the specified area.
* @param area the inline area for which the background, border and padding is to be
diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java
index 145f88187..5cbd3c095 100644
--- a/src/java/org/apache/fop/tools/TestConverter.java
+++ b/src/java/org/apache/fop/tools/TestConverter.java
@@ -274,7 +274,7 @@ public class TestConverter {
File xmlFile = new File(baseDir + "/" + xml);
String baseURL = null;
try {
- baseURL = xmlFile.getParentFile().toURL().toExternalForm();
+ baseURL = xmlFile.getParentFile().toURI().toURL().toExternalForm();
} catch (Exception e) {
logger.error("Error setting base directory");
}
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index 83217651e..da25478c3 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -444,14 +444,14 @@ class FOPTaskStarter {
//Set base directory
if (task.getBasedir() != null) {
try {
- this.baseURL = task.getBasedir().toURL().toExternalForm();
+ this.baseURL = task.getBasedir().toURI().toURL().toExternalForm();
} catch (MalformedURLException mfue) {
logger.error("Error creating base URL from base directory", mfue);
}
} else {
try {
if (task.getFofile() != null) {
- this.baseURL = task.getFofile().getParentFile().toURL().
+ this.baseURL = task.getFofile().getParentFile().toURI().toURL().
toExternalForm();
}
} catch (MalformedURLException mfue) {
@@ -519,11 +519,11 @@ class FOPTaskStarter {
try {
if (task.getRelativebase()) {
- this.baseURL = f.getParentFile().toURL().
+ this.baseURL = f.getParentFile().toURI().toURL().
toExternalForm();
}
if (this.baseURL == null) {
- this.baseURL = fs.getDir(task.getProject()).toURL().
+ this.baseURL = fs.getDir(task.getProject()).toURI().toURL().
toExternalForm();
}
diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java
index b11c75242..2bc13e8b2 100644
--- a/src/java/org/apache/fop/tools/anttasks/RunTest.java
+++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java
@@ -224,11 +224,11 @@ public class RunTest extends Task {
*/
private URL[] createUrls(String mainJar) throws MalformedURLException {
ArrayList urls = new ArrayList();
- urls.add(new File(mainJar).toURL());
+ urls.add(new File(mainJar).toURI().toURL());
File[] libFiles = new File("lib").listFiles();
for (int i = 0; i < libFiles.length; i++) {
if (libFiles[i].getPath().endsWith(".jar")) {
- urls.add(libFiles[i].toURL());
+ urls.add(libFiles[i].toURI().toURL());
}
}
return (URL[]) urls.toArray(new URL[urls.size()]);