aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/intermediate
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-07-23 09:34:17 +0000
committerJeremias Maerki <jeremias@apache.org>2008-07-23 09:34:17 +0000
commit2d83907e2d37f04aa8bebd938b737189d59eb62d (patch)
treec42d29083d95e098f521591b156a3f1df55bf2b8 /src/java/org/apache/fop/render/intermediate
parent8091bd11210ac68aa3289532643e42b66545a495 (diff)
downloadxmlgraphics-fop-2d83907e2d37f04aa8bebd938b737189d59eb62d.tar.gz
xmlgraphics-fop-2d83907e2d37f04aa8bebd938b737189d59eb62d.zip
Improved/fixed font setup for painters. Reduced the whole thing to pass in a fully set-up FontInfo object to reduce dependencies on the font package to the necessary.
Fixed problem with some JAXP implementations for "lastProprties" in IFParser. Support for XMP parsing added in IFParser. Added round-trip testing for new IF. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@679047 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/intermediate')
-rw-r--r--src/java/org/apache/fop/render/intermediate/AbstractBinaryWritingIFPainter.java67
-rw-r--r--src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java12
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFPainter.java12
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFPainterConfigurator.java7
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFParser.java24
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFRenderer.java5
6 files changed, 50 insertions, 77 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/AbstractBinaryWritingIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractBinaryWritingIFPainter.java
index 860de7946..7f82f3d93 100644
--- a/src/java/org/apache/fop/render/intermediate/AbstractBinaryWritingIFPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/AbstractBinaryWritingIFPainter.java
@@ -23,7 +23,6 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
-import java.util.List;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
@@ -31,13 +30,11 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.fop.fonts.CustomFontCollection;
import org.apache.fop.fonts.FontCollection;
+import org.apache.fop.fonts.FontEventAdapter;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontManager;
-import org.apache.fop.fonts.FontResolver;
import org.apache.fop.fonts.base14.Base14FontCollection;
-import org.apache.fop.render.DefaultFontResolver;
/**
* Abstract base class for binary-writing IFPainter implementations.
@@ -52,12 +49,6 @@ public abstract class AbstractBinaryWritingIFPainter extends AbstractIFPainter {
/** Font configuration */
protected FontInfo fontInfo;
- /** Font resolver */
- protected FontResolver fontResolver = null;
-
- /** list of fonts */
- protected List/*<EmbedFontInfo>*/ embedFontInfoList = null;
-
/** {@inheritDoc} */
public void setResult(Result result) throws IFException {
if (result instanceof StreamResult) {
@@ -93,43 +84,6 @@ public abstract class AbstractBinaryWritingIFPainter extends AbstractIFPainter {
}
/**
- * Adds a font list to current list of fonts
- * @param fontList a font info list
- */
- public void addFontList(List/*<EmbedFontInfo>*/ fontList) {
- if (embedFontInfoList == null) {
- setFontList(fontList);
- } else {
- embedFontInfoList.addAll(fontList);
- }
- }
-
- /**
- * @param embedFontInfoList list of available fonts
- */
- public void setFontList(List/*<EmbedFontInfo>*/ embedFontInfoList) {
- this.embedFontInfoList = embedFontInfoList;
- }
-
- /**
- * @return list of available embedded fonts
- */
- public List/*<EmbedFontInfo>*/ getFontList() {
- return this.embedFontInfoList;
- }
-
- /**
- * Returns the {@code FontResolver} used by this painter.
- * @return the font resolver
- */
- public FontResolver getFontResolver() {
- if (this.fontResolver == null) {
- this.fontResolver = new DefaultFontResolver(getUserAgent());
- }
- return this.fontResolver;
- }
-
- /**
* Returns the {@code FontInfo} object.
* @return the font info
*/
@@ -137,23 +91,22 @@ public abstract class AbstractBinaryWritingIFPainter extends AbstractIFPainter {
return this.fontInfo;
}
+ /** {@inheritDoc} */
public void setFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
}
- /**
- * Set up the font info
- *
- * @param inFontInfo font info to set up
- */
- public void setupFontInfo(FontInfo inFontInfo) {
- setFontInfo(inFontInfo);
+ /** {@inheritDoc} */
+ public void setDefaultFontInfo() {
FontManager fontManager = getUserAgent().getFactory().getFontManager();
FontCollection[] fontCollections = new FontCollection[] {
- new Base14FontCollection(fontManager.isBase14KerningEnabled()),
- new CustomFontCollection(getFontResolver(), getFontList())
+ new Base14FontCollection(fontManager.isBase14KerningEnabled())
};
- fontManager.setup(getFontInfo(), fontCollections);
+
+ FontInfo fi = new FontInfo();
+ fi.setEventListener(new FontEventAdapter(getUserAgent().getEventBroadcaster()));
+ fontManager.setup(fi, fontCollections);
+ setFontInfo(fi);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
index bb226dd0c..4336b0bf9 100644
--- a/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
@@ -37,6 +37,8 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.fop.fonts.FontInfo;
+
/**
* Abstract base class for XML-writing IFPainter implementations.
*/
@@ -66,6 +68,16 @@ public abstract class AbstractXMLWritingIFPainter extends AbstractIFPainter {
}
}
+ /** {@inheritDoc} */
+ public void setFontInfo(FontInfo fontInfo) {
+ //nop, not used
+ }
+
+ /** {@inheritDoc} */
+ public void setDefaultFontInfo() {
+ //nop, not used
+ }
+
/**
* Returns the main namespace used for generated XML content.
* @return the main namespace
diff --git a/src/java/org/apache/fop/render/intermediate/IFPainter.java b/src/java/org/apache/fop/render/intermediate/IFPainter.java
index 44e02fe68..66d7a0750 100644
--- a/src/java/org/apache/fop/render/intermediate/IFPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/IFPainter.java
@@ -28,6 +28,7 @@ import java.awt.geom.AffineTransform;
import javax.xml.transform.Result;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fonts.FontInfo;
/**
* Interface used to paint whole documents layouted by Apache FOP.
@@ -90,6 +91,17 @@ public interface IFPainter {
void setResult(Result result) throws IFException;
/**
+ * Sets the font set to work with.
+ * @param fontInfo the font info object
+ */
+ void setFontInfo(FontInfo fontInfo);
+
+ /**
+ * Sets the default font set (with no custom configuration).
+ */
+ void setDefaultFontInfo();
+
+ /**
* Indicates whether the painter supports to handle the pages in mixed order rather than
* ascending order.
* @return true if out-of-order handling is supported
diff --git a/src/java/org/apache/fop/render/intermediate/IFPainterConfigurator.java b/src/java/org/apache/fop/render/intermediate/IFPainterConfigurator.java
index e42f52665..71a3a484a 100644
--- a/src/java/org/apache/fop/render/intermediate/IFPainterConfigurator.java
+++ b/src/java/org/apache/fop/render/intermediate/IFPainterConfigurator.java
@@ -32,4 +32,11 @@ public interface IFPainterConfigurator {
* @throws FOPException if an error occurs while configuring the object
*/
void configure(IFPainter painter) throws FOPException;
+
+ /**
+ * Sets up the {@code FontInfo} object for the IFPainter.
+ * @param painter the painter instance
+ * @throws FOPException if an error occurs while configuring the object
+ */
+ void setupFontInfo(IFPainter painter) throws FOPException;
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java
index ba0a6c60b..6f85c5801 100644
--- a/src/java/org/apache/fop/render/intermediate/IFParser.java
+++ b/src/java/org/apache/fop/render/intermediate/IFParser.java
@@ -41,6 +41,7 @@ import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
@@ -49,7 +50,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.util.ColorUtil;
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactoryRegistry;
@@ -167,7 +167,7 @@ public class IFParser implements IFConstants {
delegate.startDocument();
delegate.startElement(uri, localName, qName, attributes);
} else {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
boolean handled = true;
if (NAMESPACE.equals(uri)) {
ElementHandler elementHandler = (ElementHandler)elementHandlers.get(localName);
@@ -456,21 +456,13 @@ public class IFParser implements IFConstants {
* Handles objects created by "sub-parsers" that implement the ObjectSource interface.
* An example of object handled here are ExtensionAttachments.
* @param obj the Object to be handled.
+ * @throws SAXException if an error occurs while handling the extension object
*/
- protected void handleExternallyGeneratedObject(Object obj) {
- if (obj instanceof ExtensionAttachment) {
- ExtensionAttachment attachment = (ExtensionAttachment)obj;
- //TODO Implement me
- /*
- if (this.currentPageViewport == null) {
- this.treeModel.handleOffDocumentItem(
- new OffDocumentExtensionAttachment(attachment));
- } else {
- this.currentPageViewport.addExtensionAttachment(attachment);
- }
- */
- } else {
- log.warn("Don't know how to handle externally generated object: " + obj);
+ protected void handleExternallyGeneratedObject(Object obj) throws SAXException {
+ try {
+ painter.handleExtensionObject(obj);
+ } catch (IFException ife) {
+ handleIFException(ife);
}
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index c4243a86a..8df052663 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -165,10 +165,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
this.painter = new IFSerializer();
}
this.painter.setUserAgent(getUserAgent());
- if (this.painter instanceof AbstractBinaryWritingIFPainter) {
- //TODO THIS IS UGLY. FIX ME!!!
- ((AbstractBinaryWritingIFPainter)this.painter).setFontInfo(fontInfo);
- }
+ this.painter.setFontInfo(fontInfo);
this.painter.setResult(result);
}
super.startRenderer(null);