diff options
author | Keiron Liddle <keiron@apache.org> | 2001-11-06 08:34:53 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2001-11-06 08:34:53 +0000 |
commit | 31965968c68717055bbd096b709df3e72ceb8b40 (patch) | |
tree | 92820b3533809c21ea4decd0069edbb1e858f064 /src/org/apache/fop/extensions | |
parent | cfc0da75fcc187e6dd7596e7480c4941e278b9d5 (diff) | |
download | xmlgraphics-fop-31965968c68717055bbd096b709df3e72ceb8b40.tar.gz xmlgraphics-fop-31965968c68717055bbd096b709df3e72ceb8b40.zip |
changed the way that elements and properties are handled
the element makers are associated with the element mapping
attributes are passed to the element object the object can then
use the attributes to make the properties
added default value for element handling, makes it easier to
ensure all elements of an external xml markup are loaded (eg. svg)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194536 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/extensions')
-rw-r--r-- | src/org/apache/fop/extensions/ExtensionElementMapping.java | 26 | ||||
-rw-r--r-- | src/org/apache/fop/extensions/ExtensionObj.java | 21 | ||||
-rw-r--r-- | src/org/apache/fop/extensions/Label.java | 15 | ||||
-rw-r--r-- | src/org/apache/fop/extensions/Outline.java | 21 |
4 files changed, 39 insertions, 44 deletions
diff --git a/src/org/apache/fop/extensions/ExtensionElementMapping.java b/src/org/apache/fop/extensions/ExtensionElementMapping.java index c6c8ae402..70e72cd30 100644 --- a/src/org/apache/fop/extensions/ExtensionElementMapping.java +++ b/src/org/apache/fop/extensions/ExtensionElementMapping.java @@ -8,8 +8,6 @@ package org.apache.fop.extensions; import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.ExtensionPropertyMapping; -import org.apache.fop.fo.TreeBuilder; import java.util.Enumeration; import java.util.HashMap; @@ -21,24 +19,24 @@ public class ExtensionElementMapping implements ElementMapping { private static HashMap foObjs = null; - public synchronized void addToBuilder(TreeBuilder builder) { + public synchronized void addToBuilder(FOTreeBuilder builder) { if(foObjs == null) { foObjs = new HashMap(); - foObjs.put("outline", Outline.maker()); - foObjs.put("label", Label.maker()); + foObjs.put("outline", new O()); + foObjs.put("label", new L()); } builder.addMapping(URI, foObjs); + } - - builder.addPropertyList(ExtensionElementMapping.URI, - ExtensionPropertyMapping.getGenericMappings()); - /* Add any element mappings */ - for (Iterator iter = ExtensionPropertyMapping.getElementMappings().iterator(); - iter.hasNext(); ) { - String elem = (String)iter.next(); - builder.addElementPropertyList(ExtensionElementMapping.URI, elem, - ExtensionPropertyMapping.getElementMapping(elem)); + class O extends ElementMapping.Maker { + public FObj make(FObj parent) { + return new Outline(parent); } } + class L extends ElementMapping.Maker { + public FObj make(FObj parent) { + return new Label(parent); + } + } } diff --git a/src/org/apache/fop/extensions/ExtensionObj.java b/src/org/apache/fop/extensions/ExtensionObj.java index 9cfc091ef..170e198be 100644 --- a/src/org/apache/fop/extensions/ExtensionObj.java +++ b/src/org/apache/fop/extensions/ExtensionObj.java @@ -10,6 +10,9 @@ package org.apache.fop.extensions; import org.apache.fop.fo.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.ExtensionPropertyMapping; + +import org.xml.sax.Attributes; /** * base class for extension objects @@ -21,8 +24,8 @@ public abstract class ExtensionObj extends FObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public ExtensionObj(FObj parent, PropertyList propertyList) { - super(parent, propertyList); + public ExtensionObj(FObj parent) { + super(parent); } /** @@ -38,7 +41,6 @@ public abstract class ExtensionObj extends FObj { return new Status(Status.OK); } - /** * Called for root extensions. Root extensions aren't allowed to generate * any visible areas. They are used for extra items that don't show up in @@ -51,4 +53,17 @@ public abstract class ExtensionObj extends FObj { areaTree.addExtension(this); } + protected PropertyListBuilder getListBuilder() { + PropertyListBuilder plb = new PropertyListBuilder(); + plb.addList(ExtensionPropertyMapping.getGenericMappings()); + return plb; + } + + public void handleAttrs(Attributes attlist) throws FOPException { + String uri = ExtensionElementMapping.URI; + properties = + getListBuilder().makeList(uri, name, attlist, + (parent == null) ? null + : parent.properties, parent); + } } diff --git a/src/org/apache/fop/extensions/Label.java b/src/org/apache/fop/extensions/Label.java index aa6bf1c31..cbc274413 100644 --- a/src/org/apache/fop/extensions/Label.java +++ b/src/org/apache/fop/extensions/Label.java @@ -13,19 +13,8 @@ import org.apache.fop.fo.*; public class Label extends ExtensionObj { private String _label = ""; - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) { - return new Label(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Label.Maker(); - } - - public Label(FObj parent, PropertyList propertyList) { - super(parent, propertyList); + public Label(FObj parent) { + super(parent); } protected void addCharacters(char data[], int start, int end) { diff --git a/src/org/apache/fop/extensions/Outline.java b/src/org/apache/fop/extensions/Outline.java index e9c8a0ca2..eb5d9da0e 100644 --- a/src/org/apache/fop/extensions/Outline.java +++ b/src/org/apache/fop/extensions/Outline.java @@ -11,9 +11,11 @@ import org.apache.fop.fo.*; import org.apache.fop.pdf.PDFGoTo; import org.apache.fop.pdf.PDFAction; import org.apache.fop.datatypes.IDReferences; +import org.apache.fop.apps.FOPException; import java.util.*; +import org.xml.sax.Attributes; public class Outline extends ExtensionObj { private Label _label; @@ -32,21 +34,12 @@ public class Outline extends ExtensionObj { */ private Object _rendererObject; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) { - return new Outline(parent, propertyList); - } - + public Outline(FObj parent) { + super(parent); } - public static FObj.Maker maker() { - return new Outline.Maker(); - } - - public Outline(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - + public void handleAttrs(Attributes attlist) throws FOPException { + super.handleAttrs(attlist); _internalDestination = this.properties.get("internal-destination").getString(); _externalDestination = @@ -92,7 +85,7 @@ public class Outline extends ExtensionObj { } public Label getLabel() { - return _label == null ? new Label(this, this.properties) : _label; + return _label == null ? new Label(this) : _label; } public Vector getOutlines() { |