From: Jeremias Maerki Date: Mon, 20 Mar 2006 07:32:22 +0000 (+0000) Subject: Bugzilla #39030: X-Git-Tag: fop-0_92-beta~66 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df5d57e4bfe413f53673cb8465ef9a88e90c6b0a;p=xmlgraphics-fop.git Bugzilla #39030: Output filenames with a space resulted in "%20" in the generated file. Looks like a bug in Xalan-J. We now open the OutputStream ourselves. The two practically identical write methods pulled up into the abstract base class. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@387161 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java index 35e103aad..0f8cfdb06 100644 --- a/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java +++ b/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2005 The Apache Software Foundation. + * Copyright 1999-2006 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. @@ -18,9 +18,16 @@ package org.apache.fop.fonts.apps; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import java.util.List; import java.util.Map; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.util.CommandLineLogger; @@ -101,5 +108,43 @@ public abstract class AbstractFontReader { setLogLevel("info"); } } + + /** + * Writes the generated DOM Document to a file. + * + * @param doc The DOM Document to save. + * @param target The target filename for the XML file. + * @throws TransformerException if an error occurs during serialization + */ + public void writeFontXML(org.w3c.dom.Document doc, String target) throws TransformerException { + writeFontXML(doc, new File(target)); + } + + /** + * Writes the generated DOM Document to a file. + * + * @param doc The DOM Document to save. + * @param target The target file for the XML file. + * @throws TransformerException if an error occurs during serialization + */ + public void writeFontXML(org.w3c.dom.Document doc, File target) throws TransformerException { + log.info("Writing xml font file " + target + "..."); + + try { + OutputStream out = new java.io.FileOutputStream(target); + out = new java.io.BufferedOutputStream(out); + try { + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer transformer = factory.newTransformer(); + transformer.transform( + new javax.xml.transform.dom.DOMSource(doc), + new javax.xml.transform.stream.StreamResult(out)); + } finally { + out.close(); + } + } catch (IOException ioe) { + throw new TransformerException("Error writing the output file", ioe); + } + } } diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java index ebf7bd2ba..0a14578d9 100644 --- a/src/java/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/java/org/apache/fop/fonts/apps/PFMReader.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2005 The Apache Software Foundation. + * Copyright 1999-2006 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. @@ -18,16 +18,12 @@ package org.apache.fop.fonts.apps; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import java.util.Map; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import org.apache.commons.logging.LogFactory; import org.apache.fop.Version; @@ -189,25 +185,6 @@ public class PFMReader extends AbstractFontReader { } } - /** - * Writes the generated DOM Document to a file. - * - * @param doc The DOM Document to save. - * @param target The target filename for the XML file. - * @throws TransformerException if an error occurs during serialization - */ - public void writeFontXML(org.w3c.dom.Document doc, String target) - throws TransformerException { - log.info("Writing xml font file " + target + "..."); - log.info(""); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - transformer.transform( - new javax.xml.transform.dom.DOMSource(doc), - new javax.xml.transform.stream.StreamResult(new File(target))); - } - /** * Generates the font metrics file from the PFM file. * diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java index 9358cab66..8b564bc3d 100644 --- a/src/java/org/apache/fop/fonts/apps/TTFReader.java +++ b/src/java/org/apache/fop/fonts/apps/TTFReader.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2005 The Apache Software Foundation. + * Copyright 1999-2006 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. @@ -18,15 +18,11 @@ package org.apache.fop.fonts.apps; -import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.Map; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import org.apache.commons.logging.LogFactory; import org.apache.fop.Version; @@ -208,24 +204,6 @@ public class TTFReader extends AbstractFontReader { } - /** - * Writes the generated DOM Document to a file. - * - * @param doc The DOM Document to save. - * @param target The target filename for the XML file. - * @throws TransformerException if an error occurs during serialization - */ - public void writeFontXML(org.w3c.dom.Document doc, String target) - throws TransformerException { - log.info("Writing xml font file " + target + "..."); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - transformer.transform( - new javax.xml.transform.dom.DOMSource(doc), - new javax.xml.transform.stream.StreamResult(new File(target))); - } - /** * Generates the font metrics file from the TTF/TTC file. *