From: Glen Mazza Date: Wed, 23 Jun 2004 00:25:27 +0000 (+0000) Subject: 1.) Moving renderer-specific customization variables (producer, creator, create date... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~696 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f575d5d538b1e9d2ff86a44f81247466d78ee77c;p=xmlgraphics-fop.git 1.) Moving renderer-specific customization variables (producer, creator, create date) to FOUserAgent, those renderers which can work with these values can read them from passed-in FOUserAgent instance. 2.) Version.getVersion() moved to Fop.getVersion(). 3.) Validation added for fo:region-body. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197743 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/CommandLineOptions.java b/src/java/org/apache/fop/apps/CommandLineOptions.java index 14b7f610c..6a3adbfc2 100644 --- a/src/java/org/apache/fop/apps/CommandLineOptions.java +++ b/src/java/org/apache/fop/apps/CommandLineOptions.java @@ -177,7 +177,7 @@ public class CommandLineOptions { } else if (args[i].equals("-at")) { i = i + parseAreaTreeOption(args, i); } else if (args[i].equals("-v")) { - System.out.println("FOP Version " + Version.getVersion()); + System.out.println("FOP Version " + Fop.getVersion()); } else if (args[i].equals("-param")) { if (i + 2 < args.length) { if (xsltParams == null) { diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index edf138ee6..0dd53cff8 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -350,8 +350,8 @@ public class Driver { if (renderer instanceof AWTRenderer) { rendererType = RENDER_AWT; } - renderer.setProducer(Version.getVersion()); renderer.setUserAgent(getUserAgent()); + userAgent.setProducer("FOP Version" + Fop.getVersion()); this.renderer = renderer; } @@ -375,8 +375,8 @@ public class Driver { throws IllegalArgumentException { try { renderer = (Renderer)Class.forName(rendererClassName).newInstance(); - renderer.setProducer(Version.getVersion()); renderer.setUserAgent(getUserAgent()); + userAgent.setProducer("FOP Version" + Fop.getVersion()); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Could not find " + rendererClassName); diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 56854e0e9..15bc99628 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -19,6 +19,7 @@ package org.apache.fop.apps; // Java +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.io.IOException; @@ -58,6 +59,69 @@ public class FOUserAgent { private float px2mm = 0.35277777777777777778f; //72dpi (=25.4/dpi) private HashMap rendererOptions = new java.util.HashMap(); + /** Producer: Metadata element for the system/software that produces + * the document. (Some renderers can store this in the document.) + */ + protected String producer = "FOP " + Fop.getVersion(); + + /** Creator: Metadata element for the user that created the + * document. (Some renderers can store this in the document.) + */ + protected String creator = null; + + /** Creation Date: Override of the date the document was created. + * (Some renderers can store this in the document.) + */ + protected Date creationDate = null; + + /** + * Sets the producer of the document. + * @param producer source of document + */ + public void setProducer(String producer) { + this.producer = producer; + } + + /** + * Returns the producer of the document + * @return producer name + */ + public String getProducer() { + return producer; + } + + /** + * Sets the creator of the document. + * @param creator of document + */ + public void setCreator(String creator) { + this.creator = creator; + } + + /** + * Returns the creator of the document + * @return creator name + */ + public String getCreator() { + return creator; + } + + /** + * Sets the creation date of the document. + * @param creation date of document + */ + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + /** + * Returns the creation date of the document + * @return creation date of document + */ + public Date getCreationDate() { + return creationDate; + } + /** * Returns the renderer options * @return renderer options diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java index 7e75f4ab7..a7b8eb06e 100644 --- a/src/java/org/apache/fop/apps/Fop.java +++ b/src/java/org/apache/fop/apps/Fop.java @@ -39,7 +39,6 @@ public class Fop { CommandLineOptions options = null; InputHandler inputHandler = null; BufferedOutputStream bos = null; - String version = Version.getVersion(); try { Driver driver = new Driver(); @@ -96,5 +95,13 @@ public class Fop { System.exit(1); } } + + /** + * Get the version of FOP + * @return the version string + */ + public static String getVersion() { + return "1.0dev"; + } } diff --git a/src/java/org/apache/fop/apps/Version.java b/src/java/org/apache/fop/apps/Version.java deleted file mode 100644 index 125bee41e..000000000 --- a/src/java/org/apache/fop/apps/Version.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 1999-2004 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. - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.apps; - -/** - * Class representing the version of FOP. - */ -public class Version { - - /** - * Get the version of FOP - * - * @return the version string - */ - public static String getVersion() { - return "1.0dev"; - } - -} diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 427ed33b6..15ed0cc39 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -18,8 +18,14 @@ package org.apache.fop.fo.pagination; +// Java import java.awt.Rectangle; +// XML +import org.xml.sax.Attributes; +import org.xml.sax.Locator; + +// FOP import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.FODimension; import org.apache.fop.fo.FONode; @@ -44,6 +50,14 @@ public class RegionBody extends Region { super(parent, Region.BODY_CODE); } + /** + * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) + * XSL/FOP Content Model: empty + */ + protected void validateChildNode(Locator loc, String nsURI, String localName) { + invalidChildError(loc, nsURI, localName); + } + /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java index b58a8ec23..822945a03 100644 --- a/src/java/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/java/org/apache/fop/fonts/apps/PFMReader.java @@ -36,7 +36,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //FOP -import org.apache.fop.apps.Version; +import org.apache.fop.apps.Fop; import org.apache.fop.fonts.type1.PFMFile; /** @@ -144,7 +144,7 @@ public class PFMReader { PFMReader app = new PFMReader(); - System.out.println("PFM Reader for Apache FOP " + Version.getVersion() + "\n"); + System.out.println("PFM Reader for Apache FOP " + Fop.getVersion() + "\n"); if (options.get("-ef") != null) { embFile = (String)options.get("-ef"); diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java index 12ad63b30..940eb4c08 100644 --- a/src/java/org/apache/fop/fonts/apps/TTFReader.java +++ b/src/java/org/apache/fop/fonts/apps/TTFReader.java @@ -35,7 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //FOP -import org.apache.fop.apps.Version; +import org.apache.fop.apps.Fop; import org.apache.fop.fonts.truetype.FontFileReader; import org.apache.fop.fonts.truetype.TTFCmapEntry; import org.apache.fop.fonts.truetype.TTFFile; @@ -160,7 +160,7 @@ public class TTFReader { TTFReader app = new TTFReader(); - System.out.println("TTF Reader for Apache FOP " + Version.getVersion() + "\n"); + System.out.println("TTF Reader for Apache FOP " + Fop.getVersion() + "\n"); if (options.get("-enc") != null) { String enc = (String)options.get("-enc"); diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index f3fd05848..813cbf90c 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -89,21 +89,6 @@ public abstract class AbstractRenderer */ protected static Log logger = LogFactory.getLog("FOP"); - /** - * producer (usually "FOP") - */ - protected String producer = "FOP"; - - /** - * creator of document - */ - protected String creator = null; - - /** - * creation time - */ - protected Date creationDate = null; - /** * block progression position */ @@ -145,16 +130,6 @@ public abstract class AbstractRenderer return logger; } - /** @see org.apache.fop.render.Renderer */ - public void setProducer(String inProducer) { - producer = inProducer; - } - - /** @see org.apache.fop.render.Renderer */ - public void setCreator(String inCreator) { - creator = inCreator; - } - /** * @see org.apache.fop.render.Renderer */ @@ -167,13 +142,6 @@ public abstract class AbstractRenderer userAgent = agent; } - /** - * @param date - */ - public void setCreationDate(Date date) { - creationDate = date; - } - /** @see org.apache.fop.render.Renderer */ public void startRenderer(OutputStream outputStream) throws IOException { } @@ -344,9 +312,7 @@ public abstract class AbstractRenderer */ protected void renderRegion(RegionReference region) { List blocks = region.getBlocks(); - renderBlocks(null, blocks); - } /** diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java index dda6788e4..8c0bca1e9 100644 --- a/src/java/org/apache/fop/render/Renderer.java +++ b/src/java/org/apache/fop/render/Renderer.java @@ -96,34 +96,6 @@ public interface Renderer { */ void setupFontInfo(FontInfo fontInfo); - /** - * Set the producer of the rendering. If this method isn't called the - * renderer uses a default. Note: Not all renderers support this feature. - * - * @param producer The name of the producer (normally "FOP") to be - * embedded in the generated file. - */ - void setProducer(String producer); - - /** - * Set the creator of the document to be rendered. - * If this method isn't called the renderer uses a default. - * Note: Not all renderers support this feature. - * - * @param creator The name of the document creator - */ - void setCreator(String creator); - - /** - * Set the creator date/timeof the document to be rendered. - * If this method isn't called the renderer uses the current date/time - * as default. - * Note: Not all renderers support this feature. - * - * @param date The name of the document creator - */ - void setCreationDate(Date date); - /** * Reports if out of order rendering is supported.

* diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java index f7052d9a4..9974f841e 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java @@ -36,7 +36,7 @@ import java.awt.event.WindowEvent; import java.awt.event.ActionEvent; //FOP -import org.apache.fop.apps.Version; +import org.apache.fop.apps.Fop; /** * 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") - + " " + Version.getVersion()); + + " " + Fop.getVersion()); JLabel label3 = new JLabel(translator.getString("About.Copyright")); panel1.setLayout(new BorderLayout()); panel2.setLayout(new BorderLayout()); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index b542f23ce..a9cd5608a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -37,7 +37,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException; // FOP import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Version; import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.BlockViewport; @@ -247,10 +246,9 @@ public class PDFRenderer extends PrintRenderer { */ public void startRenderer(OutputStream stream) throws IOException { ostream = stream; - producer = "FOP " + Version.getVersion(); - this.pdfDoc = new PDFDocument(producer); - this.pdfDoc.setCreator(creator); - this.pdfDoc.setCreationDate(creationDate); + this.pdfDoc = new PDFDocument(userAgent.getProducer()); + this.pdfDoc.setCreator(userAgent.getCreator()); + this.pdfDoc.setCreationDate(userAgent.getCreationDate()); this.pdfDoc.setFilterMap(filterMap); this.pdfDoc.outputHeader(stream); diff --git a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java index c52f5ef8d..7a8eacce9 100644 --- a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java @@ -20,7 +20,7 @@ package org.apache.fop.render.ps; import java.io.IOException; -import org.apache.fop.apps.Version; +import org.apache.fop.apps.Fop; /** * This class is a wrapper for the AbstractPSDocumentGraphics2D that @@ -55,7 +55,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 " + Version.getVersion() + new String[] {"Apache FOP " + Fop.getVersion() + ": EPS Transcoder for SVG"}); gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()}); diff --git a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java index 29e85603e..4a3a05801 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java @@ -24,7 +24,7 @@ import java.io.OutputStream; import java.io.IOException; //FOP -import org.apache.fop.apps.Version; +import org.apache.fop.apps.Fop; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; @@ -92,7 +92,7 @@ public class PSDocumentGraphics2D extends AbstractPSDocumentGraphics2D { //PostScript Header gen.writeln(DSCConstants.PS_ADOBE_30); gen.writeDSCComment(DSCConstants.CREATOR, - new String[] {"Apache FOP " + Version.getVersion() + new String[] {"Apache FOP " + Fop.getVersion() + ": PostScript Transcoder for SVG"}); gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()}); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index ad61fd658..a3d4aabe4 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -320,7 +320,7 @@ public class PSRenderer extends AbstractRenderer { //PostScript Header writeln(DSCConstants.PS_ADOBE_30); - gen.writeDSCComment(DSCConstants.CREATOR, new String[] {"FOP " + this.producer}); + gen.writeDSCComment(DSCConstants.CREATOR, new String[] { userAgent.getProducer() }); gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()}); gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, new Integer(gen.getPSLevel())); gen.writeDSCComment(DSCConstants.PAGES, new Object[] {PSGenerator.ATEND}); diff --git a/src/java/org/apache/fop/tools/TestConverter.java b/src/java/org/apache/fop/tools/TestConverter.java index 8b4ce8cc4..a1ffe0f81 100644 --- a/src/java/org/apache/fop/tools/TestConverter.java +++ b/src/java/org/apache/fop/tools/TestConverter.java @@ -317,7 +317,7 @@ public class TestConverter { userAgent.getRendererOptions().put("fineDetail", new Boolean(false)); userAgent.getRendererOptions().put("consistentOutput", new Boolean(true)); - driver.getRenderer().setProducer("Testsuite Converter"); + userAgent.setProducer("Testsuite Converter"); String outname = res; if (outname.endsWith(".xml") || outname.endsWith(".pdf")) {