Browse Source

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
pull/30/head
Glen Mazza 20 years ago
parent
commit
04e32fbc58

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

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

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

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

+ 64
- 0
src/java/org/apache/fop/apps/FOUserAgent.java View File

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

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

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


+ 0
- 35
src/java/org/apache/fop/apps/Version.java View File

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

}

+ 14
- 0
src/java/org/apache/fop/fo/pagination/RegionBody.java View File

@@ -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)
*/

+ 2
- 2
src/java/org/apache/fop/fonts/apps/PFMReader.java View File

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

+ 2
- 2
src/java/org/apache/fop/fonts/apps/TTFReader.java View File

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

+ 0
- 34
src/java/org/apache/fop/render/AbstractRenderer.java View File

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

}

/**

+ 0
- 28
src/java/org/apache/fop/render/Renderer.java View File

@@ -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. <p>
*

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

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

+ 3
- 5
src/java/org/apache/fop/render/pdf/PDFRenderer.java View File

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


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

@@ -20,7 +20,7 @@ package org.apache.fop.render.ps;

import java.io.IOException;

import org.apache.fop.apps.Version;
import org.apache.fop.apps.Fop;

/**
* This class is a wrapper for the <tt>AbstractPSDocumentGraphics2D</tt> 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()});

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

@@ -24,7 +24,7 @@ import java.io.OutputStream;
import java.io.IOException;

//FOP
import org.apache.fop.apps.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()});

+ 1
- 1
src/java/org/apache/fop/render/ps/PSRenderer.java View File

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

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

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

Loading…
Cancel
Save