diff options
author | Keiron Liddle <keiron@apache.org> | 2001-11-09 11:32:42 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2001-11-09 11:32:42 +0000 |
commit | d4fcf5b78def6bbc2a310621848f110c0611e7f4 (patch) | |
tree | 564f1b623a3ce1333fc35ed21600d53274a0a6d8 /src | |
parent | 31965968c68717055bbd096b709df3e72ceb8b40 (diff) | |
download | xmlgraphics-fop-d4fcf5b78def6bbc2a310621848f110c0611e7f4.tar.gz xmlgraphics-fop-d4fcf5b78def6bbc2a310621848f110c0611e7f4.zip |
changed the parent to FONode
changed a few more vector and hashtable
change master-name to master-reference for page-sequence, single-page-master-reference, repeatable-page-masterreference,conditional-page-master-reference
added pdf text element bridge for simple text
some other changes that will hopefully make things simpler to handle in the future
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194537 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
109 files changed, 993 insertions, 863 deletions
diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 3aa93e725..d9144270a 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -19,8 +19,6 @@ import org.apache.fop.tools.DocumentReader; import org.apache.fop.render.pdf.PDFRenderer; -import org.apache.fop.system.BufferManager; - import org.apache.log.*; import org.apache.log.format.*; import org.apache.log.output.io.*; @@ -173,8 +171,6 @@ public class Driver { /** * the system resources that FOP will use */ - private BufferManager _bufferManager; - private Logger log; public static final String getParserClassName() { @@ -194,9 +190,7 @@ public class Driver { */ public Driver() { _stream = null; - _bufferManager = new BufferManager(); _treeBuilder = new FOTreeBuilder(); - _treeBuilder.setBufferManager(_bufferManager); setupDefaultMappings(); } @@ -522,7 +516,6 @@ public class Driver { /* Set up the system buffers */ public void setBufferFile(File bufferFile) { - this._bufferManager.addBufferFile(bufferFile); } /** diff --git a/src/org/apache/fop/apps/Options.java b/src/org/apache/fop/apps/Options.java index 133dd0c11..9253c32c6 100644 --- a/src/org/apache/fop/apps/Options.java +++ b/src/org/apache/fop/apps/Options.java @@ -80,7 +80,6 @@ public class Options { if (dumpConfiguration) { Configuration.put("dumpConfiguration", "true"); Configuration.dumpConfiguration(); - System.exit(0); } // quiet mode diff --git a/src/org/apache/fop/area/Area.java b/src/org/apache/fop/area/Area.java index 6a0318275..c6a763b3e 100644 --- a/src/org/apache/fop/area/Area.java +++ b/src/org/apache/fop/area/Area.java @@ -9,6 +9,14 @@ package org.apache.fop.area; import java.io.Serializable; +// If the area appears more than once in the output +// or if the area has external data it is cached +// to keep track of it and to minimize rendered output +// renderers can render the output once and display it +// for every occurence +// this should also extend to all outputs (including PDFGraphics2D) +// and all types of renderers + /** * Base object for all areas. */ diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java index 18e8ba4ff..b31ce3030 100644 --- a/src/org/apache/fop/area/PageViewport.java +++ b/src/org/apache/fop/area/PageViewport.java @@ -28,6 +28,11 @@ public class PageViewport { // the information is kept for future reference ArrayList idReferences = null; + // this keeps a list of currently unresolved areas or extensions + // once the things is resolved it is removed + // when this is empty the page can be rendered + ArrayList unresolved = null; + public void setClip(boolean c) { clip = c; } diff --git a/src/org/apache/fop/datatypes/LengthBase.java b/src/org/apache/fop/datatypes/LengthBase.java index 539467e95..31eee8802 100644 --- a/src/org/apache/fop/datatypes/LengthBase.java +++ b/src/org/apache/fop/datatypes/LengthBase.java @@ -8,6 +8,7 @@ package org.apache.fop.datatypes; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.messaging.MessageHandler; @@ -75,10 +76,11 @@ public class LengthBase implements PercentBase { return parentFO.getContentWidth(); case CONTAINING_REFAREA: // example: start-indent, end-indent { - FObj fo; - for (fo = parentFO; fo != null &&!fo.generatesReferenceAreas(); - fo = fo.getParent()); - return (fo != null ? fo.getContentWidth() : 0); + //FONode fo; + //for (fo = parentFO; fo != null && !fo.generatesReferenceAreas(); + // fo = fo.getParent()); + //return (((fo != null) && (fo instanceof FObj)) ? ((FObj)fo).getContentWidth() : 0); + return 0; } case CUSTOM_BASE: MessageHandler.errorln("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!"); diff --git a/src/org/apache/fop/extensions/ExtensionElementMapping.java b/src/org/apache/fop/extensions/ExtensionElementMapping.java index 70e72cd30..c14d0d353 100644 --- a/src/org/apache/fop/extensions/ExtensionElementMapping.java +++ b/src/org/apache/fop/extensions/ExtensionElementMapping.java @@ -7,11 +7,11 @@ package org.apache.fop.extensions; -import org.apache.fop.fo.*; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.ElementMapping; +import org.apache.fop.fo.FOTreeBuilder; -import java.util.Enumeration; import java.util.HashMap; -import java.util.Iterator; public class ExtensionElementMapping implements ElementMapping { @@ -29,13 +29,13 @@ public class ExtensionElementMapping implements ElementMapping { } class O extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Outline(parent); } } class L extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Label(parent); } } diff --git a/src/org/apache/fop/extensions/ExtensionObj.java b/src/org/apache/fop/extensions/ExtensionObj.java index 170e198be..3ae492d18 100644 --- a/src/org/apache/fop/extensions/ExtensionObj.java +++ b/src/org/apache/fop/extensions/ExtensionObj.java @@ -10,9 +10,6 @@ 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 @@ -24,7 +21,7 @@ public abstract class ExtensionObj extends FObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public ExtensionObj(FObj parent) { + public ExtensionObj(FONode parent) { super(parent); } @@ -32,7 +29,6 @@ public abstract class ExtensionObj extends FObj { * Called for extensions within a page sequence or flow. These extensions * are allowed to generate visible areas within the layout. * - * * @param area */ public Status layout(Area area) throws FOPException { @@ -52,18 +48,5 @@ public abstract class ExtensionObj extends FObj { ExtensionArea extArea = new ExtensionArea(this); 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 cbc274413..fc645d4aa 100644 --- a/src/org/apache/fop/extensions/Label.java +++ b/src/org/apache/fop/extensions/Label.java @@ -9,11 +9,10 @@ package org.apache.fop.extensions; import org.apache.fop.fo.*; - public class Label extends ExtensionObj { private String _label = ""; - public Label(FObj parent) { + public Label(FONode parent) { super(parent); } @@ -25,5 +24,4 @@ public class Label extends ExtensionObj { return _label; } - } diff --git a/src/org/apache/fop/extensions/Outline.java b/src/org/apache/fop/extensions/Outline.java index eb5d9da0e..48efad0f4 100644 --- a/src/org/apache/fop/extensions/Outline.java +++ b/src/org/apache/fop/extensions/Outline.java @@ -19,7 +19,7 @@ import org.xml.sax.Attributes; public class Outline extends ExtensionObj { private Label _label; - private Vector _outlines = new Vector(); + private ArrayList _outlines = new ArrayList(); private String _internalDestination; private String _externalDestination; @@ -34,16 +34,15 @@ public class Outline extends ExtensionObj { */ private Object _rendererObject; - public Outline(FObj parent) { + public Outline(FONode parent) { super(parent); } public void handleAttrs(Attributes attlist) throws FOPException { - super.handleAttrs(attlist); _internalDestination = - this.properties.get("internal-destination").getString(); + attlist.getValue(null, "internal-destination"); _externalDestination = - this.properties.get("external-destination").getString(); + attlist.getValue(null, "external-destination"); if (_externalDestination != null &&!_externalDestination.equals("")) { log.warn("fox:outline external-destination not supported currently."); } @@ -66,12 +65,10 @@ public class Outline extends ExtensionObj { if (obj instanceof Label) { _label = (Label)obj; } else if (obj instanceof Outline) { - _outlines.addElement(obj); + _outlines.add(obj); } - super.addChild(obj); } - public void setRendererObject(Object o) { _rendererObject = o; } @@ -88,7 +85,7 @@ public class Outline extends ExtensionObj { return _label == null ? new Label(this) : _label; } - public Vector getOutlines() { + public ArrayList getOutlines() { return _outlines; } @@ -96,7 +93,5 @@ public class Outline extends ExtensionObj { return _internalDestination; } - - } diff --git a/src/org/apache/fop/fo/ColorProfile.java b/src/org/apache/fop/fo/ColorProfile.java index d3cb86eba..e58dd18e5 100644 --- a/src/org/apache/fop/fo/ColorProfile.java +++ b/src/org/apache/fop/fo/ColorProfile.java @@ -15,14 +15,12 @@ import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; /** - * The fo:root formatting object. Contains page masters, root extensions, - * page-sequences. + * The fo:color-profile formatting object. */ public class ColorProfile extends ToBeImplementedElement { - protected ColorProfile(FObj parent) { + protected ColorProfile(FONode parent) { super(parent); - this.name = "fo:color-profile"; // this.properties.get("src"); // this.properties.get("color-profile-name"); diff --git a/src/org/apache/fop/fo/Declarations.java b/src/org/apache/fop/fo/Declarations.java index b7bcb7b7f..1c4e783d0 100644 --- a/src/org/apache/fop/fo/Declarations.java +++ b/src/org/apache/fop/fo/Declarations.java @@ -18,9 +18,8 @@ import org.apache.fop.apps.FOPException; */ public class Declarations extends ToBeImplementedElement { - protected Declarations(FObj parent) { + protected Declarations(FONode parent) { super(parent); - this.name = "fo:declarations"; } } diff --git a/src/org/apache/fop/fo/ElementMapping.java b/src/org/apache/fop/fo/ElementMapping.java index d9e86be9a..591412be4 100644 --- a/src/org/apache/fop/fo/ElementMapping.java +++ b/src/org/apache/fop/fo/ElementMapping.java @@ -12,10 +12,12 @@ package org.apache.fop.fo; * the given builder. */ public interface ElementMapping { + public static final String DEFAULT = "<default>"; + public void addToBuilder(FOTreeBuilder builder); public static class Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return null; } } diff --git a/src/org/apache/fop/fo/FOElementMapping.java b/src/org/apache/fop/fo/FOElementMapping.java index 978a909d4..5c4e248e7 100644 --- a/src/org/apache/fop/fo/FOElementMapping.java +++ b/src/org/apache/fop/fo/FOElementMapping.java @@ -7,7 +7,6 @@ package org.apache.fop.fo; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -112,337 +111,337 @@ public class FOElementMapping implements ElementMapping { } class R extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Root(parent); } } class Dec extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Declarations(parent); } } class CP extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ColorProfile(parent); } } class PS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new PageSequence(parent); } } class LMS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new LayoutMasterSet(parent); } } class PSM extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new PageSequenceMaster(parent); } } class SPMR extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new SinglePageMasterReference(parent); } } class RPMR extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RepeatablePageMasterReference(parent); } } class RPMA extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RepeatablePageMasterAlternatives(parent); } } class CPMR extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ConditionalPageMasterReference(parent); } } class SPM extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new SimplePageMaster(parent); } } class RB extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RegionBody(parent); } } class RBefore extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RegionBefore(parent); } } class RA extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RegionAfter(parent); } } class RS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RegionStart(parent); } } class RE extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RegionEnd(parent); } } class Fl extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Flow(parent); } } class SC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new StaticContent(parent); } } class T extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Title(parent); } } class B extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Block(parent); } } class BC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new BlockContainer(parent); } } class BO extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new BidiOverride(parent); } } class Ch extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new org.apache.fop.fo.flow.Character(parent); } } class IPS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new InitialPropertySet(parent); } } class EG extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ExternalGraphic(parent); } } class IFO extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new InstreamForeignObject(parent); } } class In extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Inline(parent); } } class IC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new InlineContainer(parent); } } class L extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Leader(parent); } } class PN extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new PageNumber(parent); } } class PNC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new PageNumberCitation(parent); } } class TAC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableAndCaption(parent); } } class Ta extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Table(parent); } } class TC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableColumn(parent); } } class TCaption extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableCaption(parent); } } class TH extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableHeader(parent); } } class TF extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableFooter(parent); } } class TB extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableBody(parent); } } class TR extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableRow(parent); } } class TCell extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new TableCell(parent); } } class LB extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ListBlock(parent); } } class LI extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ListItem(parent); } } class LIB extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ListItemBody(parent); } } class LIL extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new ListItemLabel(parent); } } class BL extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new BasicLink(parent); } } class MS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new MultiSwitch(parent); } } class MC extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new MultiCase(parent); } } class MT extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new MultiToggle(parent); } } class MP extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new MultiProperties(parent); } } class MPS extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new MultiPropertySet(parent); } } class F extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new org.apache.fop.fo.flow.Float(parent); } } class Foot extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Footnote(parent); } } class FB extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new FootnoteBody(parent); } } class W extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Wrapper(parent); } } class M extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Marker(parent); } } class RM extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new RetrieveMarker(parent); } } diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 0843f51e1..911020b9e 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -5,256 +5,97 @@ * LICENSE file included with these sources. */ - package org.apache.fop.fo; // FOP import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.StreamRenderer; import org.apache.fop.layout.Area; -import org.apache.fop.layout.AreaClass; -import org.apache.fop.layout.LinkSet; -import org.apache.fop.system.BufferManager; -import org.apache.fop.fo.flow.Marker; import org.apache.log.Logger; -// Java -import java.util.Vector; -import java.util.Hashtable; - import org.xml.sax.Attributes; /** - * base class for nodes in the formatting object tree + * base class for nodes in the XML tree * - * Modified by Mark Lillywhite mark-fop@inomial.com. Made - * Vector a protected member. (/me things this should be - * a private member with an API for adding children; - * this woudl save a lot of memory because the Vector - * would not have to be instantiated unless the node had - * children). */ abstract public class FONode { - - protected FObj parent; - - protected String areaClass = AreaClass.UNASSIGNED; - - public BufferManager bufferManager; - - protected Vector children = new Vector(); // made public for searching for id's - - /** - * value of marker before layout begins - */ - public final static int START = -1000; - - /** - * value of marker after break-after - */ - public final static int BREAK_AFTER = -1001; - - /** - * where the layout was up to. - * for FObjs it is the child number - * for FOText it is the character number - */ - protected int marker = START; - - protected boolean isInTableCell = false; - - protected int forcedStartOffset = 0; - protected int forcedWidth = 0; - - protected int widows = 0; - protected int orphans = 0; - - protected LinkSet linkSet; - - // count of areas generated-by/returned-by - public int areasGenerated = 0; - - // markers - protected Hashtable markers; + protected FONode parent; + protected String name; protected Logger log; - protected FONode(FObj parent) { + protected FONode(FONode parent) { this.parent = parent; - if (parent != null) { - this.bufferManager = parent.bufferManager; - } - - markers = new Hashtable(); + } - if (null != parent) - this.areaClass = parent.areaClass; + public void setName(String str) { + name = str; } public void setLogger(Logger logger) { log = logger; } - public void handleAttrs(Attributes attlist) throws FOPException { + public void setUserAgent(FOUserAgent ua) { } - public void setIsInTableCell() { - this.isInTableCell = true; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); - child.setIsInTableCell(); - } + public void setStreamRenderer(StreamRenderer st) { } - public void forceStartOffset(int offset) { - this.forcedStartOffset = offset; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); - child.forceStartOffset(offset); - } - } - - public void forceWidth(int width) { - this.forcedWidth = width; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); - child.forceWidth(width); - } - } - - public void resetMarker() { - this.marker = START; - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - ((FONode)children.elementAt(i)).resetMarker(); - } - } - - public void setWidows(int wid) { - widows = wid; - } - - public void setOrphans(int orph) { - orphans = orph; - } - - public void removeAreas() { - // still to do - } - - - protected void addChild(FONode child) { - children.addElement(child); - } - - public FObj getParent() { - return this.parent; - } - - public void setBufferManager(BufferManager bufferManager) { - this.bufferManager = bufferManager; - } - - public BufferManager getBufferManager() { - return this.bufferManager; - } - - public void setLinkSet(LinkSet linkSet) { - this.linkSet = linkSet; - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); - child.setLinkSet(linkSet); - } + public void handleAttrs(Attributes attlist) throws FOPException { } - public LinkSet getLinkSet() { - return this.linkSet; + /** + * returns the name of the object + * @return the name of this object + */ + public String getName() { + return this.name; } - abstract public Status layout(Area area) throws FOPException; - /** - * lets outside sources access the property list - * first used by PageNumberCitation to find the "id" property - * returns null by default, overide this function when there is a property list - * @param name - the name of the desired property to obtain - * @returns the property + * adds characters (does nothing here) + * @param data text + * @param start start position + * @param length length of the text */ - public Property getProperty(String name) { - return (null); + protected void addCharacters(char data[], int start, int length) { + // ignore } /** - * At the start of a new span area layout may be partway through a - * nested FO, and balancing requires rollback to this known point. - * The snapshot records exactly where layout is at. - * @param snapshot a Vector of markers (Integer) - * @returns the updated Vector of markers (Integers) + * generates the area or areas for this formatting object + * and adds these to the area. This method should always be + * overridden by all sub classes + * + * @param area */ - public Vector getMarkerSnapshot(Vector snapshot) { - snapshot.addElement(new Integer(this.marker)); - - // terminate if no kids or child not yet accessed - if (this.marker < 0) - return snapshot; - else if (children.isEmpty()) - return snapshot; - else - return ((FONode)children.elementAt(this.marker)).getMarkerSnapshot(snapshot); + public Status layout(Area area) throws FOPException { + // should always be overridden + return new Status(Status.OK); } /** - * When balancing occurs, the flow layout() method restarts at the - * point specified by the current marker snapshot, which is retrieved - * and restored using this method. - * @param snapshot the Vector of saved markers (Integers) + * */ - public void rollback(Vector snapshot) { - this.marker = ((Integer)snapshot.elementAt(0)).intValue(); - snapshot.removeElementAt(0); - - if (this.marker == START) { - // make sure all the children of this FO are also reset - resetMarker(); - return; - } else if ((this.marker == -1) || children.isEmpty()) - return; - - int numChildren = this.children.size(); - - if (this.marker <= START) { - return; - } - - for (int i = this.marker + 1; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - fo.resetMarker(); - } - ((FONode)children.elementAt(this.marker)).rollback(snapshot); + protected void start() { + // do nothing by default } - - public void addMarker(Marker marker) throws FOPException { - String mcname = marker.getMarkerClassName(); - if (!markers.containsKey(mcname) && children.isEmpty()) { - markers.put(mcname, marker); - } else { - log.error("fo:marker must be an initial child," - + "and 'marker-class-name' must be unique for same parent"); - throw new FOPException("fo:marker must be an initial child," - + "and 'marker-class-name' must be unique for same parent"); - } + /** + * + */ + protected void end() { + // do nothing by default } - public boolean hasMarkers() { - return !markers.isEmpty(); + protected void addChild(FONode child) { } - public Vector getMarkers() { - return new Vector(markers.values()); + public FONode getParent() { + return this.parent; } } diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index bc86aba20..b0ebd2b4b 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -26,67 +26,42 @@ import org.apache.fop.system.BufferManager; * longer than the lifetime of the object itself, causing * excessive memory consumption and OOM errors. */ -public class FOText extends FONode { +public class FOText extends FObj { protected char[] ca; protected int start; protected int length; - - FontState fs; - float red; - float green; - float blue; - int wrapOption; - int whiteSpaceCollapse; - int verticalAlign; - - // Textdecoration - protected boolean underlined = false; - protected boolean overlined = false; - protected boolean lineThrough = false; + TextInfo textInfo; + + public static class TextInfo { + FontState fs; + float red; + float green; + float blue; + int wrapOption; + int whiteSpaceCollapse; + int verticalAlign; + + // Textdecoration + protected boolean underlined = false; + protected boolean overlined = false; + protected boolean lineThrough = false; + } TextState ts; - - public FOText(char[] chars, int s, int e, FObj parent) { - super(parent); + public FOText(char[] chars, int s, int e, TextInfo ti) { + super(null); this.start = 0; this.ca = new char[e - s]; for (int i = s; i < e; i++) ca[i - s] = chars[i]; this.length = e - s; - - /* ML - remove refs to BufferManager - this.bufferManager = parent.bufferManager; - if (this.bufferManager != null) { - bufferManager.writeBuffer((Object)this, ca); - } else { - System.out.println("abnormal exit"); - System.exit(0); - } - */ - } - - public void setUnderlined(boolean ul) { - this.underlined = ul; - } - - public void setOverlined(boolean ol) { - this.overlined = ol; + textInfo = ti; } - public void setLineThrough(boolean lt) { - this.lineThrough = lt; - } - - public boolean willCreateArea() { - // ML - remove refs to BufferManager - //char ca[] = this.bufferManager.readBuffer((Object)this); - - this.whiteSpaceCollapse = - this.parent.properties.get("white-space-collapse").getEnum(); - if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE + if (textInfo.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE && length > 0) { return true; } @@ -102,55 +77,24 @@ public class FOText extends FONode { } public Status layout(Area area) throws FOPException { - // ML - remove refs to BufferManager - // char ca[] = this.bufferManager.readBuffer((Object)this); if (!(area instanceof BlockArea)) { log.error("text outside block area" + new String(ca, start, length)); return new Status(Status.OK); } if (this.marker == START) { - String fontFamily = - this.parent.properties.get("font-family").getString(); - String fontStyle = - this.parent.properties.get("font-style").getString(); - String fontWeight = - this.parent.properties.get("font-weight").getString(); - int fontSize = - this.parent.properties.get("font-size").getLength().mvalue(); - // font-variant support - // added by Eric SCHAEFFER - int fontVariant = - this.parent.properties.get("font-variant").getEnum(); - - this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize, - fontVariant); - - ColorType c = this.parent.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.verticalAlign = - this.parent.properties.get("vertical-align").getEnum(); - - this.wrapOption = - this.parent.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.parent.properties.get("white-space-collapse").getEnum(); this.ts = new TextState(); - ts.setUnderlined(underlined); - ts.setOverlined(overlined); - ts.setLineThrough(lineThrough); + ts.setUnderlined(textInfo.underlined); + ts.setOverlined(textInfo.overlined); + ts.setLineThrough(textInfo.lineThrough); this.marker = this.start; } int orig_start = this.marker; - this.marker = addText((BlockArea)area, fs, red, green, blue, - wrapOption, this.getLinkSet(), - whiteSpaceCollapse, ca, this.marker, length, - ts, verticalAlign); + this.marker = addText((BlockArea)area, textInfo.fs, textInfo.red, textInfo.green, textInfo.blue, + textInfo.wrapOption, this.getLinkSet(), + textInfo.whiteSpaceCollapse, ca, this.marker, length, + ts, textInfo.verticalAlign); if (this.marker == -1) { @@ -290,5 +234,5 @@ public class FOText extends FONode { return -1; } - } + diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java index 6d6fd4172..16d4bdc8a 100644 --- a/src/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/org/apache/fop/fo/FOTreeBuilder.java @@ -12,7 +12,6 @@ import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.StreamRenderer; import org.apache.fop.fo.pagination.Root; -import org.apache.fop.system.BufferManager; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.extensions.ExtensionObj; @@ -53,15 +52,13 @@ public class FOTreeBuilder extends DefaultHandler { /** * current formatting object being handled */ - protected FObj currentFObj = null; + protected FONode currentFObj = null; /** * the root of the formatting object tree */ protected FObj rootFObj = null; - public BufferManager bufferManager; - /** * set of names of formatting objects encountered but unknown */ @@ -73,8 +70,8 @@ public class FOTreeBuilder extends DefaultHandler { * (mark-fop@inomial.com) */ private StreamRenderer streamRenderer; - private Logger log; + private FOUserAgent userAgent; public FOTreeBuilder() {} @@ -114,7 +111,7 @@ public class FOTreeBuilder extends DefaultHandler { throws SAXException { currentFObj.end(); - currentFObj = (FObj)currentFObj.getParent(); + currentFObj = currentFObj.getParent(); } /** @@ -139,7 +136,7 @@ public class FOTreeBuilder extends DefaultHandler { public void startElement(String uri, String localName, String rawName, Attributes attlist) throws SAXException { /* the formatting object started */ - FObj fobj; + FONode fobj; /* the maker for the formatting object started */ ElementMapping.Maker fobjMaker = null; @@ -149,7 +146,7 @@ public class FOTreeBuilder extends DefaultHandler { fobjMaker = (ElementMapping.Maker)table.get(localName); // try default if(fobjMaker == null) { - fobjMaker = (ElementMapping.Maker)table.get("<default>"); + fobjMaker = (ElementMapping.Maker)table.get(ElementMapping.DEFAULT); } } @@ -158,7 +155,7 @@ public class FOTreeBuilder extends DefaultHandler { String fullName = uri + "^" + localName; if (!this.unknownFOs.containsKey(fullName)) { this.unknownFOs.put(fullName, ""); - log.error("Unknown formatting object " + log.warn("Unknown formatting object " + fullName); } if(namespaces.contains(uri.intern())) { @@ -174,20 +171,25 @@ public class FOTreeBuilder extends DefaultHandler { fobj = fobjMaker.make(currentFObj); fobj.setName(localName); fobj.setLogger(log); + // set the user agent for resolving user agent values + fobj.setUserAgent(userAgent); + // set the stream renderer so that appropriate + // elements can add pages and handle resolving references + fobj.setStreamRenderer(streamRenderer); + fobj.handleAttrs(attlist); } catch (FOPException e) { throw new SAXException(e); } if (rootFObj == null) { - rootFObj = fobj; - rootFObj.setBufferManager(this.bufferManager); if (!fobj.getName().equals("fo:root")) { throw new SAXException(new FOPException("Root element must" - + " be root, not " + + " be fo:root, not " + fobj.getName())); } - } else if(!(fobj instanceof org.apache.fop.fo.pagination.PageSequence)) { + rootFObj = (FObj)fobj; + } else { currentFObj.addChild(fobj); } @@ -204,8 +206,4 @@ public class FOTreeBuilder extends DefaultHandler { return (rootFObj != null); } - public void setBufferManager(BufferManager bufferManager) { - this.bufferManager = bufferManager; - } - } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index 1f626a5ba..4c5cb910f 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -9,33 +9,89 @@ package org.apache.fop.fo; // FOP import org.apache.fop.layout.Area; +import org.apache.fop.layout.AreaClass; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.IDReferences; import org.apache.fop.fo.properties.FOPropertyMapping; +import org.apache.fop.layout.Area; +import org.apache.fop.layout.AreaClass; +import org.apache.fop.layout.LinkSet; +import org.apache.fop.system.BufferManager; +import org.apache.fop.fo.flow.Marker; import org.xml.sax.Attributes; +import java.util.Iterator; +import java.util.Vector; +import java.util.Hashtable; + /** * base class for representation of formatting objects and their processing */ public class FObj extends FONode { - public PropertyList properties; protected PropertyManager propMgr; + protected String areaClass = AreaClass.UNASSIGNED; + + /** + * value of marker before layout begins + */ + public final static int START = -1000; + + /** + * value of marker after break-after + */ + public final static int BREAK_AFTER = -1001; + + /** + * where the layout was up to. + * for FObjs it is the child number + * for FOText it is the character number + */ + protected int marker = START; + + protected Vector children = new Vector(); // made public for searching for id's - protected String name; + protected boolean isInTableCell = false; - public FObj(FObj parent) { + protected int forcedStartOffset = 0; + protected int forcedWidth = 0; + + protected int widows = 0; + protected int orphans = 0; + + protected LinkSet linkSet; + + // count of areas generated-by/returned-by + public int areasGenerated = 0; + + // markers + protected Hashtable markers; + + public FObj(FONode parent) { super(parent); + markers = new Hashtable(); + if (parent instanceof FObj) + this.areaClass = ((FObj)parent).areaClass; } public void setName(String str) { name = "fo:" + str; } + protected static PropertyListBuilder plb = null; + protected PropertyListBuilder getListBuilder() { - PropertyListBuilder plb = new PropertyListBuilder(); + if(plb == null) { + plb = new PropertyListBuilder(); plb.addList(FOPropertyMapping.getGenericMappings()); + + for (Iterator iter = FOPropertyMapping.getElementMappings().iterator(); + iter.hasNext(); ) { + String elem = (String)iter.next(); + plb.addElementList(elem, FOPropertyMapping.getElementMapping(elem)); + } + } return plb; } @@ -46,10 +102,17 @@ public class FObj extends FONode { */ public void handleAttrs(Attributes attlist) throws FOPException { String uri = "http://www.w3.org/1999/XSL/Format"; + FONode par = parent; + while(par != null && !(par instanceof FObj)) { + par = par.parent; + } + PropertyList props = null; + if(par != null) { + props = ((FObj)par).properties; + } properties = getListBuilder().makeList(uri, name, attlist, - (parent == null) ? null - : parent.properties, parent); + props, (FObj)par); properties.setFObj(this); this.propMgr = makePropertyManager(properties); setWritingMode(); @@ -59,48 +122,8 @@ public class FObj extends FONode { return new PropertyManager(propertyList); } - /** - * adds characters (does nothing here) - * @param data text - * @param start start position - * @param length length of the text - */ - protected void addCharacters(char data[], int start, int length) { - // ignore - } - - /** - * generates the area or areas for this formatting object - * and adds these to the area. This method should always be - * overridden by all sub classes - * - * @param area - */ - public Status layout(Area area) throws FOPException { - // should always be overridden - return new Status(Status.OK); - } - - /** - * returns the name of the formatting object - * @return the name of this formatting objects - */ - public String getName() { - return this.name; - } - - /** - * - */ - protected void start() { - // do nothing by default - } - - /** - * - */ - protected void end() { - // do nothing by default + protected void addChild(FONode child) { + children.addElement(child); } /** @@ -113,7 +136,6 @@ public class FObj extends FONode { return (properties.get(name)); } - /** * Return the "content width" of the areas generated by this FO. * This is used by percent-based properties to get the dimension of @@ -158,12 +180,159 @@ public class FObj extends FONode { */ protected void setWritingMode() { FObj p; - FObj parent; + FONode parent; for (p = this; - !p.generatesReferenceAreas() && (parent = p.getParent()) != null; - p = parent); + !p.generatesReferenceAreas() && (parent = p.getParent()) != null && (parent instanceof FObj); + p = (FObj)parent); this.properties.setWritingMode(p.getProperty("writing-mode").getEnum()); } + public void setIsInTableCell() { + this.isInTableCell = true; + // made recursive by Eric Schaeffer + for (int i = 0; i < this.children.size(); i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.setIsInTableCell(); + } + } + } + + public void forceStartOffset(int offset) { + this.forcedStartOffset = offset; + // made recursive by Eric Schaeffer + for (int i = 0; i < this.children.size(); i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.forceStartOffset(offset); + } + } + } + + public void forceWidth(int width) { + this.forcedWidth = width; + // made recursive by Eric Schaeffer + for (int i = 0; i < this.children.size(); i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.forceWidth(width); + } + } + } + + public void resetMarker() { + this.marker = START; + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.resetMarker(); + } + } + } + + public void setWidows(int wid) { + widows = wid; + } + + public void setOrphans(int orph) { + orphans = orph; + } + + public void removeAreas() { + // still to do + } + + public void setLinkSet(LinkSet linkSet) { + this.linkSet = linkSet; + for (int i = 0; i < this.children.size(); i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.setLinkSet(linkSet); + } + } + } + + public LinkSet getLinkSet() { + return this.linkSet; + } + + /** + * At the start of a new span area layout may be partway through a + * nested FO, and balancing requires rollback to this known point. + * The snapshot records exactly where layout is at. + * @param snapshot a Vector of markers (Integer) + * @returns the updated Vector of markers (Integers) + */ + public Vector getMarkerSnapshot(Vector snapshot) { + snapshot.addElement(new Integer(this.marker)); + + // terminate if no kids or child not yet accessed + if (this.marker < 0) + return snapshot; + else if (children.isEmpty()) + return snapshot; + else + return ((FObj)children.elementAt(this.marker)).getMarkerSnapshot(snapshot); + } + + /** + * When balancing occurs, the flow layout() method restarts at the + * point specified by the current marker snapshot, which is retrieved + * and restored using this method. + * @param snapshot the Vector of saved markers (Integers) + */ + public void rollback(Vector snapshot) { + this.marker = ((Integer)snapshot.elementAt(0)).intValue(); + snapshot.removeElementAt(0); + + if (this.marker == START) { + // make sure all the children of this FO are also reset + resetMarker(); + return; + } else if ((this.marker == -1) || children.isEmpty()) + return; + + int numChildren = this.children.size(); + + if (this.marker <= START) { + return; + } + + for (int i = this.marker + 1; i < numChildren; i++) { + Object obj = this.children.elementAt(i); + if(obj instanceof FObj) { + FObj child = (FObj)obj; + child.resetMarker(); + } + } + ((FObj)children.elementAt(this.marker)).rollback(snapshot); + } + + + public void addMarker(Marker marker) throws FOPException { + String mcname = marker.getMarkerClassName(); + if (!markers.containsKey(mcname) && children.isEmpty()) { + markers.put(mcname, marker); + } else { + log.error("fo:marker must be an initial child," + + "and 'marker-class-name' must be unique for same parent"); + throw new FOPException("fo:marker must be an initial child," + + "and 'marker-class-name' must be unique for same parent"); + } + } + + public boolean hasMarkers() { + return !markers.isEmpty(); + } + + public Vector getMarkers() { + return new Vector(markers.values()); + } } diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index 607211d07..b3c99d8a8 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -8,20 +8,58 @@ package org.apache.fop.fo; import org.apache.fop.layout.Area; +import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.ColorType; /** * base class for representation of mixed content formatting objects * and their processing */ public class FObjMixed extends FObj { + FOText.TextInfo textInfo = null; - public FObjMixed(FObj parent) { + public FObjMixed(FONode parent) { super(parent); } protected void addCharacters(char data[], int start, int length) { - addChild(new FOText(data, start, length, this)); + if(textInfo == null) { + String fontFamily = + getProperty("font-family").getString(); + String fontStyle = + getProperty("font-style").getString(); + String fontWeight = + getProperty("font-weight").getString(); + int fontSize = + getProperty("font-size").getLength().mvalue(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + getProperty("font-variant").getEnum(); + + //textInfo.fs = new FontState(area.getFontInfo(), fontFamily, + // fontStyle, fontWeight, fontSize, + // fontVariant); + + ColorType c = getProperty("color").getColorType(); + textInfo.red = c.red(); + textInfo.green = c.green(); + textInfo.blue = c.blue(); + + textInfo.verticalAlign = + getProperty("vertical-align").getEnum(); + + textInfo.wrapOption = + getProperty("wrap-option").getEnum(); + textInfo.whiteSpaceCollapse = + getProperty("white-space-collapse").getEnum(); + + } + + FOText ft = new FOText(data, start, length, textInfo); + ft.setLogger(log); + addChild(ft); } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/Title.java b/src/org/apache/fop/fo/Title.java index f5f4648a8..b394d84e3 100644 --- a/src/org/apache/fop/fo/Title.java +++ b/src/org/apache/fop/fo/Title.java @@ -20,9 +20,8 @@ import org.apache.fop.apps.FOPException; */ public class Title extends ToBeImplementedElement { - public Title(FObj parent) { + public Title(FONode parent) { super(parent); - this.name = "fo:title"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/ToBeImplementedElement.java b/src/org/apache/fop/fo/ToBeImplementedElement.java index 3243cd522..d214af8e0 100644 --- a/src/org/apache/fop/fo/ToBeImplementedElement.java +++ b/src/org/apache/fop/fo/ToBeImplementedElement.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class ToBeImplementedElement extends FObj { - protected ToBeImplementedElement(FObj parent) { + protected ToBeImplementedElement(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/Unknown.java b/src/org/apache/fop/fo/Unknown.java index 0ab6c80e7..9d7c819d6 100644 --- a/src/org/apache/fop/fo/Unknown.java +++ b/src/org/apache/fop/fo/Unknown.java @@ -21,15 +21,15 @@ import org.apache.fop.apps.FOPException; * This prevents any further problems arising from the unknown * data. */ -public class Unknown extends FObj { +public class Unknown extends FONode { public static class Maker extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new Unknown(parent); } } - public Unknown(FObj parent) { + public Unknown(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/UnknownXMLObj.java b/src/org/apache/fop/fo/UnknownXMLObj.java index 97a3f6e87..b3ba56a53 100644 --- a/src/org/apache/fop/fo/UnknownXMLObj.java +++ b/src/org/apache/fop/fo/UnknownXMLObj.java @@ -25,7 +25,7 @@ public class UnknownXMLObj extends XMLObj { space = sp; } - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new UnknownXMLObj(parent, space); } } @@ -36,7 +36,7 @@ public class UnknownXMLObj extends XMLObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - protected UnknownXMLObj(FObj parent, String space) { + protected UnknownXMLObj(FONode parent, String space) { super(parent); this.namespace = space; } diff --git a/src/org/apache/fop/fo/XMLElement.java b/src/org/apache/fop/fo/XMLElement.java index 0db6997ed..f852601c8 100644 --- a/src/org/apache/fop/fo/XMLElement.java +++ b/src/org/apache/fop/fo/XMLElement.java @@ -27,7 +27,7 @@ public class XMLElement extends XMLObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public XMLElement(FObj parent) { + public XMLElement(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index 9658f8552..db4dd3962 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -22,11 +22,11 @@ import javax.xml.parsers.DocumentBuilderFactory; import java.util.*; /** - * Since SVG objects are not layed out then this class checks - * that this element is not being layed out inside some incorrect - * element. + * Generic XML object. + * This is used by xml objects (other than fo) than will build a DOM + * with each element. */ -public abstract class XMLObj extends FObj { +public abstract class XMLObj extends FONode { // temp reference for attributes Attributes attr = null; @@ -39,7 +39,7 @@ public abstract class XMLObj extends FObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public XMLObj(FObj parent) { + public XMLObj(FONode parent) { super(parent); } @@ -52,9 +52,9 @@ public abstract class XMLObj extends FObj { } public abstract String getNameSpace(); - protected static Hashtable ns = new Hashtable(); + protected static HashMap ns = new HashMap(); - public void addGraphic(Document doc, Element parent) { + public void addElement(Document doc, Element parent) { this.doc = doc; element = doc.createElementNS(getNameSpace(), name); @@ -121,7 +121,12 @@ public abstract class XMLObj extends FObj { protected void addChild(FONode child) { if (child instanceof XMLObj) { - ((XMLObj)child).addGraphic(doc, element); + ((XMLObj)child).addElement(doc, element); + } else { + // in theory someone might want to embed some defined + // xml (eg. fo) inside the foreign xml + // they could use a different namespace + log.debug("Invalid element: " + child.getName() + " inside foreign xml markup"); } } @@ -139,33 +144,10 @@ public abstract class XMLObj extends FObj { */ public Status layout(Area area) throws FOPException { /* generate a warning */ - log.error("" + this.name + " outside foreign xml"); + log.warn("" + this.name + " outside foreign xml"); /* return status */ return new Status(Status.OK); } - - public void removeID(IDReferences idReferences) {} - - /** - * These method overrides prevent problems with the different types. - */ - public void setIsInTableCell() {} - - public void forceStartOffset(int offset) {} - - public void forceWidth(int width) {} - - public void resetMarker() {} - - public void setLinkSet(LinkSet linkSet) {} - - public Vector getMarkerSnapshot(Vector snapshot) { - return snapshot; - } - - public void rollback(Vector snapshot) {} - - protected void setWritingMode() {} } diff --git a/src/org/apache/fop/fo/expr/BodyStartFunction.java b/src/org/apache/fop/fo/expr/BodyStartFunction.java index 41c47ee55..0e311de77 100644 --- a/src/org/apache/fop/fo/expr/BodyStartFunction.java +++ b/src/org/apache/fop/fo/expr/BodyStartFunction.java @@ -9,6 +9,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.fo.Property; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.ListItem; public class BodyStartFunction extends FunctionBase { @@ -22,7 +23,7 @@ public class BodyStartFunction extends FunctionBase { Numeric distance = pInfo.getPropertyList().get("provisional-distance-between-starts").getNumeric(); - FObj item = pInfo.getFO(); + FONode item = pInfo.getFO(); while (item != null &&!(item instanceof ListItem)) { item = item.getParent(); } @@ -31,7 +32,7 @@ public class BodyStartFunction extends FunctionBase { } Numeric startIndent = - item.properties.get("start-indent").getNumeric(); + ((ListItem)item).properties.get("start-indent").getNumeric(); return new NumericProperty(distance.add(startIndent)); } diff --git a/src/org/apache/fop/fo/expr/LabelEndFunction.java b/src/org/apache/fop/fo/expr/LabelEndFunction.java index 46ec29160..8a8350886 100644 --- a/src/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/org/apache/fop/fo/expr/LabelEndFunction.java @@ -11,6 +11,7 @@ import org.apache.fop.datatypes.*; import org.apache.fop.fo.Property; import org.apache.fop.fo.LengthProperty; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.ListItem; public class LabelEndFunction extends FunctionBase { @@ -27,19 +28,19 @@ public class LabelEndFunction extends FunctionBase { Length separation = pInfo.getPropertyList().getNearestSpecified("provisional-label-separation").getLength(); - FObj item = pInfo.getFO(); + FONode item = pInfo.getFO(); while (item != null &&!(item instanceof ListItem)) { item = item.getParent(); } if (item == null) { throw new PropertyException("label-end() called from outside an fo:list-item"); } - Length startIndent = item.properties.get("start-indent").getLength(); + Length startIndent = ((ListItem)item).properties.get("start-indent").getLength(); LinearCombinationLength labelEnd = new LinearCombinationLength(); // Should be CONTAINING_REFAREA but that doesn't work - LengthBase base = new LengthBase(item, pInfo.getPropertyList(), + LengthBase base = new LengthBase((ListItem)item, pInfo.getPropertyList(), LengthBase.CONTAINING_BOX); PercentLength refWidth = new PercentLength(1.0, base); diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java index e8d19d6e7..0530385cd 100644 --- a/src/org/apache/fop/fo/flow/BasicLink.java +++ b/src/org/apache/fop/fo/flow/BasicLink.java @@ -20,9 +20,8 @@ import java.awt.Rectangle; public class BasicLink extends Inline { - public BasicLink(FObj parent) { + public BasicLink(FONode parent) { super(parent); - this.name = "fo:basic-link"; } public Status layout(Area area) throws FOPException { @@ -94,7 +93,8 @@ public class BasicLink extends Inline { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FONode fo = (FONode)children.elementAt(i); - fo.setLinkSet(ls); + if(fo instanceof FObj) + ((FObj)fo).setLinkSet(ls); Status status; if ((status = fo.layout(area)).isIncomplete()) { diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java index 4127cbe00..208f2ae0f 100644 --- a/src/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/org/apache/fop/fo/flow/BidiOverride.java @@ -19,9 +19,8 @@ import org.apache.fop.apps.FOPException; */ public class BidiOverride extends ToBeImplementedElement { - public BidiOverride(FObj parent) { + public BidiOverride(FONode parent) { super(parent); - this.name = "fo:bidi-override"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 687d08bc7..6cb9fac90 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -56,9 +56,8 @@ public class Block extends FObjMixed { // this may be helpful on other FOs too boolean anythingLaidOut = false; - public Block(FObj parent) { + public Block(FONode parent) { super(parent); - this.name = "fo:block"; } public void handleAttrs(Attributes attlist) throws FOPException { @@ -153,8 +152,6 @@ public class Block extends FObjMixed { this.blockOrphans = this.properties.get("orphans").getNumber().intValue(); - - this.id = this.properties.get("id").getString(); if (area instanceof BlockArea) { @@ -178,7 +175,7 @@ public class Block extends FObjMixed { FONode fo = (FONode)children.elementAt(i); if (fo instanceof FOText) { if (((FOText)fo).willCreateArea()) { - fo.setWidows(blockWidows); + //fo.setWidows(blockWidows); break; } else { children.removeElementAt(i); @@ -186,7 +183,7 @@ public class Block extends FObjMixed { i--; } } else { - fo.setWidows(blockWidows); + //fo.setWidows(blockWidows); break; } } @@ -195,11 +192,11 @@ public class Block extends FObjMixed { FONode fo = (FONode)children.elementAt(i); if (fo instanceof FOText) { if (((FOText)fo).willCreateArea()) { - fo.setOrphans(blockOrphans); + //fo.setOrphans(blockOrphans); break; } } else { - fo.setOrphans(blockOrphans); + //fo.setOrphans(blockOrphans); break; } } diff --git a/src/org/apache/fop/fo/flow/BlockContainer.java b/src/org/apache/fop/fo/flow/BlockContainer.java index 57084d570..fc218cb76 100644 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/org/apache/fop/fo/flow/BlockContainer.java @@ -39,9 +39,8 @@ public class BlockContainer extends FObj { PageSequence pageSequence; - public BlockContainer(FObj parent) { + public BlockContainer(FONode parent) { super(parent); - this.name = "fo:block-container"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java index ee325b949..46507bf9a 100644 --- a/src/org/apache/fop/fo/flow/Character.java +++ b/src/org/apache/fop/fo/flow/Character.java @@ -37,7 +37,7 @@ public class Character extends FObj { public final static int OK = 0; public final static int DOESNOT_FIT = 1; - public Character(FObj parent) { + public Character(FONode parent) { super(parent); this.name = "fo:character"; } @@ -102,7 +102,7 @@ public class Character extends FObj { int whiteSpaceCollapse = this.properties.get("white-space-collapse").getEnum(); - int wrapOption = this.parent.properties.get("wrap-option").getEnum(); + int wrapOption = ((FObj)this.parent).properties.get("wrap-option").getEnum(); int tmp = this.properties.get("text-decoration").getEnum(); if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) { diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index 5a988f7a0..2f36956a1 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -36,9 +36,8 @@ public class ExternalGraphic extends FObj { ImageArea imageArea; - public ExternalGraphic(FObj parent) { + public ExternalGraphic(FONode parent) { super(parent); - this.name = "fo:external-graphic"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/Float.java b/src/org/apache/fop/fo/flow/Float.java index d77c0d635..fd85bcc3f 100644 --- a/src/org/apache/fop/fo/flow/Float.java +++ b/src/org/apache/fop/fo/flow/Float.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class Float extends ToBeImplementedElement { - public Float(FObj parent) { + public Float(FONode parent) { super(parent); this.name = "fo:float"; } diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java index d705d9cd2..869729cf9 100644 --- a/src/org/apache/fop/fo/flow/Flow.java +++ b/src/org/apache/fop/fo/flow/Flow.java @@ -52,7 +52,7 @@ public class Flow extends FObj { private Status _status = new Status(Status.AREA_FULL_NONE); - public Flow(FObj parent) { + public Flow(FONode parent) { super(parent); this.name = getElementName(); } diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java index 4cdea7820..913b4060e 100644 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ b/src/org/apache/fop/fo/flow/Footnote.java @@ -20,7 +20,7 @@ import java.util.Vector; public class Footnote extends FObj { - public Footnote(FObj parent) { + public Footnote(FONode parent) { super(parent); this.name = "fo:footnote"; } diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java index 5a2487126..9f78a1326 100644 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/org/apache/fop/fo/flow/FootnoteBody.java @@ -27,7 +27,7 @@ public class FootnoteBody extends FObj { int endIndent; int textIndent; - public FootnoteBody(FObj parent) { + public FootnoteBody(FONode parent) { super(parent); this.name = "fo:footnote-body"; } diff --git a/src/org/apache/fop/fo/flow/InitialPropertySet.java b/src/org/apache/fop/fo/flow/InitialPropertySet.java index 3c081007d..c24fea35e 100644 --- a/src/org/apache/fop/fo/flow/InitialPropertySet.java +++ b/src/org/apache/fop/fo/flow/InitialPropertySet.java @@ -19,9 +19,8 @@ import org.apache.fop.apps.FOPException; */ public class InitialPropertySet extends ToBeImplementedElement { - public InitialPropertySet(FObj parent) { + public InitialPropertySet(FONode parent) { super(parent); - this.name = "fo:initial-property-set"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java index e954aa86c..e161b3f9a 100644 --- a/src/org/apache/fop/fo/flow/Inline.java +++ b/src/org/apache/fop/fo/flow/Inline.java @@ -26,9 +26,8 @@ public class Inline extends FObjMixed { protected boolean lineThrough = false; - public Inline(FObj parent) { + public Inline(FONode parent) { super(parent); - this.name = "fo:inline"; } public void handleAttrs(Attributes attlist) throws FOPException { @@ -88,13 +87,4 @@ public class Inline extends FObjMixed { } } - protected void addCharacters(char data[], int start, int length) { - FOText ft = new FOText(data, start, length, this); - ft.setLogger(log); - ft.setUnderlined(underlined); - ft.setOverlined(overlined); - ft.setLineThrough(lineThrough); - children.addElement(ft); - } - } diff --git a/src/org/apache/fop/fo/flow/InlineContainer.java b/src/org/apache/fop/fo/flow/InlineContainer.java index 0f003208a..78bbbce04 100644 --- a/src/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/org/apache/fop/fo/flow/InlineContainer.java @@ -20,9 +20,8 @@ import org.xml.sax.Attributes; */ public class InlineContainer extends ToBeImplementedElement { - public InlineContainer(FObj parent) { + public InlineContainer(FONode parent) { super(parent); - this.name = "fo:inline-container"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 6a6e56e87..2f1da6625 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -45,9 +45,8 @@ public class InstreamForeignObject extends FObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public InstreamForeignObject(FObj parent) { + public InstreamForeignObject(FONode parent) { super(parent); - this.name = "fo:instream-foreign-object"; } /** @@ -164,7 +163,6 @@ public class InstreamForeignObject extends FObj { if (this.children.size() > 0) { FONode fo = (FONode)children.elementAt(0); Status status; - // currently FONode must be an SVG if ((status = fo.layout(this.areaCurrent)).isIncomplete()) { return status; diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index 20a82b24d..dc3ca017a 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -25,9 +25,8 @@ import org.apache.fop.apps.FOPException; */ public class Leader extends FObjMixed { - public Leader(FObj parent) { + public Leader(FONode parent) { super(parent); - this.name = "fo:leader"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index ce82cc3b0..f66c7ab25 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -33,9 +33,8 @@ public class ListBlock extends FObj { int spaceBetweenListRows = 0; ColorType backgroundColor; - public ListBlock(FObj parent) { + public ListBlock(FONode parent) { super(parent); - this.name = "fo:list-block"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index 06d802cfe..e16d59ce2 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -32,7 +32,7 @@ public class ListItem extends FObj { String id; BlockArea blockArea; - public ListItem(FObj parent) { + public ListItem(FONode parent) { super(parent); this.name = "fo:list-item"; } diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index 40ed3a35b..7fc592019 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -19,7 +19,7 @@ import java.util.Enumeration; public class ListItemBody extends FObj { - public ListItemBody(FObj parent) { + public ListItemBody(FONode parent) { super(parent); this.name = "fo:list-item-body"; } diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java index 890247f57..9f8bc76ee 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -19,7 +19,7 @@ import java.util.Enumeration; public class ListItemLabel extends FObj { - public ListItemLabel(FObj parent) { + public ListItemLabel(FONode parent) { super(parent); this.name = "fo:list-item-label"; } diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java index 8267dcdf5..5d0a73a68 100644 --- a/src/org/apache/fop/fo/flow/Marker.java +++ b/src/org/apache/fop/fo/flow/Marker.java @@ -21,9 +21,8 @@ public class Marker extends FObjMixed { private String markerClassName; private Area registryArea; - public Marker(FObj parent) { + public Marker(FONode parent) { super(parent); - this.name = "fo:marker"; } public void handleAttrs(Attributes attlist) throws FOPException { @@ -36,11 +35,10 @@ public class Marker extends FObjMixed { // check to ensure that no other marker with same parent // has this 'marker-class-name' is in addMarker() method try { - parent.addMarker(this); + ((FObj)parent).addMarker(this); } catch (FOPException fopex) { - // log is null in constructor - //log.error("marker cannot be added to '" + parent - // + "'"); + log.error("marker cannot be added to '" + parent + + "'"); } } diff --git a/src/org/apache/fop/fo/flow/MultiCase.java b/src/org/apache/fop/fo/flow/MultiCase.java index 5111cadf3..5466ae270 100644 --- a/src/org/apache/fop/fo/flow/MultiCase.java +++ b/src/org/apache/fop/fo/flow/MultiCase.java @@ -18,9 +18,8 @@ import org.apache.fop.apps.FOPException; */ public class MultiCase extends ToBeImplementedElement { - public MultiCase(FObj parent) { + public MultiCase(FONode parent) { super(parent); - this.name = "fo:multi-case"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/MultiProperties.java b/src/org/apache/fop/fo/flow/MultiProperties.java index c0262a95b..6215b1d03 100644 --- a/src/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/org/apache/fop/fo/flow/MultiProperties.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class MultiProperties extends ToBeImplementedElement { - public MultiProperties(FObj parent) { + public MultiProperties(FONode parent) { super(parent); this.name = "fo:multi-properties"; } diff --git a/src/org/apache/fop/fo/flow/MultiPropertySet.java b/src/org/apache/fop/fo/flow/MultiPropertySet.java index aebff3405..8fab59adb 100644 --- a/src/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/org/apache/fop/fo/flow/MultiPropertySet.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class MultiPropertySet extends ToBeImplementedElement { - public MultiPropertySet(FObj parent) { + public MultiPropertySet(FONode parent) { super(parent); this.name = "fo:multi-property-set"; } diff --git a/src/org/apache/fop/fo/flow/MultiSwitch.java b/src/org/apache/fop/fo/flow/MultiSwitch.java index 505efef29..4d2c00551 100644 --- a/src/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/org/apache/fop/fo/flow/MultiSwitch.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class MultiSwitch extends ToBeImplementedElement { - public MultiSwitch(FObj parent) { + public MultiSwitch(FONode parent) { super(parent); this.name = "fo:multi-switch"; } diff --git a/src/org/apache/fop/fo/flow/MultiToggle.java b/src/org/apache/fop/fo/flow/MultiToggle.java index 6605c4fb5..6eb42b102 100644 --- a/src/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/org/apache/fop/fo/flow/MultiToggle.java @@ -18,7 +18,7 @@ import org.apache.fop.apps.FOPException; */ public class MultiToggle extends ToBeImplementedElement { - public MultiToggle(FObj parent) { + public MultiToggle(FONode parent) { super(parent); this.name = "fo:multi-toggle"; } diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index b67f569fd..b1eb6a696 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -27,9 +27,8 @@ public class PageNumber extends FObj { int whiteSpaceCollapse; TextState ts; - public PageNumber(FObj parent) { + public PageNumber(FONode parent) { super(parent); - this.name = "fo:page-number"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index b0881783e..af9d1eeaf 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -84,9 +84,8 @@ public class PageNumberCitation extends FObj { TextState ts; - public PageNumberCitation(FObj parent) { + public PageNumberCitation(FONode parent) { super(parent); - this.name = "fo:page-number-citation"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java index b7f322522..859fa18e6 100644 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java @@ -25,7 +25,7 @@ public class RetrieveMarker extends FObjMixed { private int retrievePosition; private int retrieveBoundary; - public RetrieveMarker(FObj parent) { + public RetrieveMarker(FONode parent) { super(parent); this.name = "fo:retrieve-marker"; } diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index dd02ff0d3..643da833a 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -19,7 +19,7 @@ import java.util.Enumeration; public class StaticContent extends Flow { - public StaticContent(FObj parent) { + public StaticContent(FONode parent) { super(parent); ((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts } diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index 9349b3f91..8ab0d3ce1 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -47,7 +47,7 @@ public class Table extends FObj { AreaContainer areaContainer; - public Table(FObj parent) { + public Table(FONode parent) { super(parent); this.name = "fo:table"; } @@ -228,8 +228,8 @@ public class Table extends FObj { addedFooter = true; tableFooter.resetMarker(); } - fo.setWidows(widows); - fo.setOrphans(orphans); + //fo.setWidows(widows); + //fo.setOrphans(orphans); ((TableBody)fo).setColumns(columns); if ((status = fo.layout(areaContainer)).isIncomplete()) { diff --git a/src/org/apache/fop/fo/flow/TableAndCaption.java b/src/org/apache/fop/fo/flow/TableAndCaption.java index 22db586c1..33dae362c 100644 --- a/src/org/apache/fop/fo/flow/TableAndCaption.java +++ b/src/org/apache/fop/fo/flow/TableAndCaption.java @@ -18,9 +18,8 @@ import org.apache.fop.apps.FOPException; */ public class TableAndCaption extends ToBeImplementedElement { - public TableAndCaption(FObj parent) { + public TableAndCaption(FONode parent) { super(parent); - this.name = "fo:table-and-caption"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 3b85e0754..930f2a76a 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -30,7 +30,7 @@ public class TableBody extends FObj { AreaContainer areaContainer; - public TableBody(FObj parent) { + public TableBody(FONode parent) { super(parent); this.name = "fo:table-body"; } diff --git a/src/org/apache/fop/fo/flow/TableCaption.java b/src/org/apache/fop/fo/flow/TableCaption.java index ef4ccc62e..fef34d462 100644 --- a/src/org/apache/fop/fo/flow/TableCaption.java +++ b/src/org/apache/fop/fo/flow/TableCaption.java @@ -18,9 +18,8 @@ import org.apache.fop.apps.FOPException; */ public class TableCaption extends ToBeImplementedElement { - public TableCaption(FObj parent) { + public TableCaption(FONode parent) { super(parent); - this.name = "fo:table-caption"; } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index 87fc89fef..98913d3e8 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -86,7 +86,7 @@ public class TableCell extends FObj { AreaContainer cellArea; - public TableCell(FObj parent) { + public TableCell(FONode parent) { super(parent); this.name = "fo:table-cell"; } diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 358fc10a5..f86c107fa 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -28,7 +28,7 @@ public class TableColumn extends FObj { AreaContainer areaContainer; - public TableColumn(FObj parent) { + public TableColumn(FONode parent) { super(parent); this.name = "fo:table-column"; } diff --git a/src/org/apache/fop/fo/flow/TableFooter.java b/src/org/apache/fop/fo/flow/TableFooter.java index f69a47308..128d8cc13 100644 --- a/src/org/apache/fop/fo/flow/TableFooter.java +++ b/src/org/apache/fop/fo/flow/TableFooter.java @@ -24,7 +24,7 @@ public class TableFooter extends TableBody { areaContainer.setYPosition(value + 2 * spaceBefore); } - public TableFooter(FObj parent) { + public TableFooter(FONode parent) { super(parent); this.name = "fo:table-footer"; } diff --git a/src/org/apache/fop/fo/flow/TableHeader.java b/src/org/apache/fop/fo/flow/TableHeader.java index c103b6da1..703abc31f 100644 --- a/src/org/apache/fop/fo/flow/TableHeader.java +++ b/src/org/apache/fop/fo/flow/TableHeader.java @@ -16,7 +16,7 @@ import org.apache.fop.apps.FOPException; public class TableHeader extends TableBody { - public TableHeader(FObj parent) { + public TableHeader(FONode parent) { super(parent); this.name = "fo:table-header"; } diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 316d1d814..f4b5b75e6 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -160,9 +160,8 @@ public class TableRow extends FObj { } - public TableRow(FObj parent) { + public TableRow(FONode parent) { super(parent); - this.name = "fo:table-row"; } public void setColumns(Vector columns) { diff --git a/src/org/apache/fop/fo/flow/Wrapper.java b/src/org/apache/fop/fo/flow/Wrapper.java index 9eb8e56df..f31e4764e 100644 --- a/src/org/apache/fop/fo/flow/Wrapper.java +++ b/src/org/apache/fop/fo/flow/Wrapper.java @@ -23,15 +23,9 @@ import org.apache.fop.layout.*; */ public class Wrapper extends FObjMixed { - public Wrapper(FObj parent) { + public Wrapper(FONode parent) { super(parent); // check that this occurs inside an fo:flow } - protected void addCharacters(char data[], int start, int length) { - FOText ft = new FOText(data, start, length, this); - ft.setLogger(log); - children.addElement(ft); - } - } diff --git a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index 26ad3ccb9..a614fe21c 100644 --- a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -23,7 +23,7 @@ public class ConditionalPageMasterReference extends FObj { private int oddOrEven; private int blankOrNotBlank; - public ConditionalPageMasterReference(FObj parent) { + public ConditionalPageMasterReference(FONode parent) { super(parent); this.name = getElementName(); @@ -132,7 +132,7 @@ public class ConditionalPageMasterReference extends FObj { } - protected void validateParent(FObj parent) throws FOPException { + protected void validateParent(FONode parent) throws FOPException { if (parent.getName().equals("fo:repeatable-page-master-alternatives")) { this.repeatablePageMasterAlternatives = (RepeatablePageMasterAlternatives)parent; diff --git a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java index 8ac2e8fc9..82dfd1801 100644 --- a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -26,9 +26,8 @@ public class LayoutMasterSet extends FObj { private Root root; - public LayoutMasterSet(FObj parent) { + public LayoutMasterSet(FONode parent) { super(parent); - this.name = "fo:layout-master-set"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/pagination/PageMasterReference.java b/src/org/apache/fop/fo/pagination/PageMasterReference.java index 1c9a2f722..3092429a1 100644 --- a/src/org/apache/fop/fo/pagination/PageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/PageMasterReference.java @@ -15,7 +15,7 @@ import org.xml.sax.Attributes; /** * Base PageMasterReference class. Provides implementation for handling the - * master-name attribute and containment within a PageSequenceMaster + * master-reference attribute and containment within a PageSequenceMaster */ public abstract class PageMasterReference extends FObj implements SubSequenceSpecifier { @@ -23,15 +23,15 @@ public abstract class PageMasterReference extends FObj private String _masterName; private PageSequenceMaster _pageSequenceMaster; - public PageMasterReference(FObj parent) { + public PageMasterReference(FONode parent) { super(parent); this.name = getElementName(); } public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); - if (getProperty("master-name") != null) { - setMasterName(getProperty("master-name").getString()); + if (getProperty("master-reference") != null) { + setMasterName(getProperty("master-reference").getString()); } validateParent(parent); @@ -42,7 +42,7 @@ public abstract class PageMasterReference extends FObj } /** - * Returns the "master-name" attribute of this page master reference + * Returns the "master-reference" attribute of this page master reference */ public String getMasterName() { return _masterName; @@ -61,9 +61,11 @@ public abstract class PageMasterReference extends FObj boolean isEmptyPage); /** - * Gets the formating object name for this object. Subclasses must provide this. + * Gets the formating object name for this object. + * Subclasses must provide this. * - * @return the element name of this reference. e.g. fo:repeatable-page-master-reference + * @return the element name of this reference. + * e.g. fo:repeatable-page-master-reference */ protected abstract String getElementName(); @@ -71,13 +73,13 @@ public abstract class PageMasterReference extends FObj * Checks that the parent is the right element. The default implementation * checks for fo:page-sequence-master */ - protected void validateParent(FObj parent) throws FOPException { + protected void validateParent(FONode parent) throws FOPException { if (parent.getName().equals("fo:page-sequence-master")) { _pageSequenceMaster = (PageSequenceMaster)parent; if (getMasterName() == null) { log.warn("" + getElementName() - + " does not have a master-name and so is being ignored"); + + " does not have a master-reference and so is being ignored"); } else { _pageSequenceMaster.addSubsequenceSpecifier(this); } @@ -90,7 +92,4 @@ public abstract class PageMasterReference extends FObj public abstract void reset(); - - - } diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 67d55212e..bcdb40e28 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -69,7 +69,7 @@ public class PageSequence extends FObj { private Hashtable _flowMap; /** - * the "master-name" attribute + * the "master-reference" attribute */ private String masterName; @@ -121,9 +121,8 @@ public class PageSequence extends FObj { private String currentPageMasterName; - public PageSequence(FObj parent) { + public PageSequence(FONode parent) { super(parent); - this.name = "fo:page-sequence"; } public void handleAttrs(Attributes attlist) throws FOPException { @@ -166,7 +165,7 @@ public class PageSequence extends FObj { } } - masterName = this.properties.get("master-name").getString(); + masterName = this.properties.get("master-reference").getString(); // get the 'format' properties this.pageNumberGenerator = @@ -517,7 +516,7 @@ public class PageSequence extends FObj { SimplePageMaster simpleMaster = this.layoutMasterSet.getSimplePageMaster(pageSequenceName); if (simpleMaster == null) { - throw new FOPException("'master-name' for 'fo:page-sequence'" + throw new FOPException("'master-reference' for 'fo:page-sequence'" + "matches no 'simple-page-master' or 'page-sequence-master'"); } currentPageMasterName = pageSequenceName; diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java index 6be32ac1e..8ffcbb9b1 100644 --- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -30,9 +30,8 @@ public class PageSequenceMaster extends FObj { // references to page-masters. So the methods use the former // terminology ('sub-sequence-specifiers', or SSS), // but the actual FO's are MasterReferences. - public PageSequenceMaster(FObj parent) { + public PageSequenceMaster(FONode parent) { super(parent); - this.name = "fo:page-sequence-master"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/pagination/Region.java b/src/org/apache/fop/fo/pagination/Region.java index f0c8be477..c46745f84 100644 --- a/src/org/apache/fop/fo/pagination/Region.java +++ b/src/org/apache/fop/fo/pagination/Region.java @@ -9,6 +9,7 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.apps.FOPException; import org.apache.fop.layout.RegionArea; @@ -24,7 +25,7 @@ public abstract class Region extends FObj { private SimplePageMaster _layoutMaster; private String _regionName; - protected Region(FObj parent) { + protected Region(FONode parent) { super(parent); this.name = getElementName(); } diff --git a/src/org/apache/fop/fo/pagination/RegionAfter.java b/src/org/apache/fop/fo/pagination/RegionAfter.java index e57034161..a1eb587d8 100644 --- a/src/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/org/apache/fop/fo/pagination/RegionAfter.java @@ -23,7 +23,7 @@ public class RegionAfter extends Region { private int precedence; - public RegionAfter(FObj parent) { + public RegionAfter(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/RegionBefore.java b/src/org/apache/fop/fo/pagination/RegionBefore.java index 6d96aa365..ab275d3f0 100644 --- a/src/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/org/apache/fop/fo/pagination/RegionBefore.java @@ -23,7 +23,7 @@ public class RegionBefore extends Region { private int precedence; - public RegionBefore(FObj parent) { + public RegionBefore(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 97f55127d..5cf97352c 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -9,6 +9,7 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.Overflow; import org.apache.fop.datatypes.ColorType; @@ -25,7 +26,7 @@ public class RegionBody extends Region { ColorType backgroundColor; - public RegionBody(FObj parent) { + public RegionBody(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/RegionEnd.java b/src/org/apache/fop/fo/pagination/RegionEnd.java index b1fecf325..5a077a86b 100644 --- a/src/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/org/apache/fop/fo/pagination/RegionEnd.java @@ -20,7 +20,7 @@ public class RegionEnd extends Region { public static final String REGION_CLASS = "end"; - public RegionEnd(FObj parent) { + public RegionEnd(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/RegionStart.java b/src/org/apache/fop/fo/pagination/RegionStart.java index bbd262df3..a4ef1df5a 100644 --- a/src/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/org/apache/fop/fo/pagination/RegionStart.java @@ -20,7 +20,7 @@ public class RegionStart extends Region { public static final String REGION_CLASS = "start"; - public RegionStart(FObj parent) { + public RegionStart(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 3a6dd83bf..de211a05f 100644 --- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -31,9 +31,8 @@ public class RepeatablePageMasterAlternatives extends FObj private Vector conditionalPageMasterRefs; - public RepeatablePageMasterAlternatives(FObj parent) { + public RepeatablePageMasterAlternatives(FONode parent) { super(parent); - this.name = "fo:repeatable-page-master-alternatives"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index 521fd02c9..77ae63367 100644 --- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -22,7 +22,7 @@ public class RepeatablePageMasterReference extends PageMasterReference private int maximumRepeats; private int numberConsumed = 0; - public RepeatablePageMasterReference(FObj parent) { + public RepeatablePageMasterReference(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java index 4a16a7fd1..197bb54bc 100644 --- a/src/org/apache/fop/fo/pagination/Root.java +++ b/src/org/apache/fop/fo/pagination/Root.java @@ -33,7 +33,7 @@ public class Root extends FObj { */ private int runningPageNumberCounter = 0; - public Root(FObj parent) { + public Root(FONode parent) { super(parent); // this.properties.get("media-usage"); @@ -53,13 +53,6 @@ public class Root extends FObj { this.runningPageNumberCounter = count; } - /** - * @deprecated handled by addChild now - */ - public void addPageSequence(PageSequence pageSequence) { - this.pageSequences.addElement(pageSequence); - } - public int getPageSequenceCount() { return pageSequences.size(); } diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index d50194889..853aaada9 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -37,9 +37,8 @@ public class SimplePageMaster extends FObj { boolean afterPrecedence; int afterHeight; - public SimplePageMaster(FObj parent) { + public SimplePageMaster(FONode parent) { super(parent); - this.name = "fo:simple-page-master"; } public void handleAttrs(Attributes attlist) throws FOPException { diff --git a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java index c22afb672..39dfe0bb2 100644 --- a/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/SinglePageMasterReference.java @@ -17,7 +17,7 @@ public class SinglePageMasterReference extends PageMasterReference private int state; - public SinglePageMasterReference(FObj parent) { + public SinglePageMasterReference(FONode parent) { super(parent); this.state = FIRST; } diff --git a/src/org/apache/fop/fonts/TTFSubSetFile.java b/src/org/apache/fop/fonts/TTFSubSetFile.java index 149f78290..4ecdb7289 100644 --- a/src/org/apache/fop/fonts/TTFSubSetFile.java +++ b/src/org/apache/fop/fonts/TTFSubSetFile.java @@ -7,9 +7,9 @@ package org.apache.fop.fonts; import java.io.*; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; +import java.util.Iterator; +import java.util.HashMap; +import java.util.ArrayList; import org.apache.fop.messaging.MessageHandler; /** @@ -300,7 +300,7 @@ public class TTFSubSetFile extends TTFFile { * Create the glyf table and fill in loca table */ private void createGlyf(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf"); int size = 0; int start = 0; @@ -309,9 +309,9 @@ public class TTFSubSetFile extends TTFFile { pad4(); start = currentPos; - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { int glyphLength = 0; - Integer origIndex = (Integer)e.nextElement(); + Integer origIndex = (Integer)e.next(); Integer subsetIndex = (Integer)glyphs.get(origIndex); int nextOffset = 0; @@ -367,7 +367,7 @@ public class TTFSubSetFile extends TTFFile { * metric (key) to the subset metric (value) */ private void createHmtx(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("hmtx"); int longHorMetricSize = glyphs.size() * 2; @@ -377,8 +377,8 @@ public class TTFSubSetFile extends TTFFile { if (entry != null) { pad4(); int offset = (int)entry.offset; - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { - Integer origIndex = (Integer)e.nextElement(); + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { + Integer origIndex = (Integer)e.next(); Integer subsetIndex = (Integer)glyphs.get(origIndex); writeUShort(currentPos + subsetIndex.intValue() * 4, @@ -399,13 +399,13 @@ public class TTFSubSetFile extends TTFFile { } /** - * Returns a Vector containing the glyph itself plus all glyphs + * Returns a List containing the glyph itself plus all glyphs * that this composite glyph uses */ - private Vector getIncludedGlyphs(FontFileReader in, int glyphOffset, + private ArrayList getIncludedGlyphs(FontFileReader in, int glyphOffset, Integer glyphIdx) throws IOException { - Vector ret = new Vector(); - ret.addElement(glyphIdx); + ArrayList ret = new ArrayList(); + ret.add(glyphIdx); int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset + 10; Integer compositeIdx = null; @@ -414,7 +414,7 @@ public class TTFSubSetFile extends TTFFile { while (moreComposites) { flags = in.readTTFUShort(offset); compositeIdx = new Integer(in.readTTFUShort(offset + 2)); - ret.addElement(compositeIdx); + ret.add(compositeIdx); offset += 4; if ((flags & 1) > 0) { @@ -445,7 +445,7 @@ public class TTFSubSetFile extends TTFFile { * Rewrite all compositepointers in glyphindex glyphIdx * */ - private void remapComposite(FontFileReader in, Hashtable glyphs, + private void remapComposite(FontFileReader in, HashMap glyphs, int glyphOffset, Integer glyphIdx) throws IOException { int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset @@ -503,36 +503,36 @@ public class TTFSubSetFile extends TTFFile { * mapping */ private void scanGlyphs(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf"); - Hashtable newComposites = null; - Hashtable allComposites = new Hashtable(); + HashMap newComposites = null; + HashMap allComposites = new HashMap(); int newIndex = glyphs.size(); if (entry != null) { while (newComposites == null || newComposites.size() > 0) { // Inefficient to iterate through all glyphs - newComposites = new Hashtable(); + newComposites = new HashMap(); - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { - Integer origIndex = (Integer)e.nextElement(); + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { + Integer origIndex = (Integer)e.next(); if (in.readTTFShort(entry.offset + mtx_tab[origIndex.intValue()].offset) < 0) { // origIndex is a composite glyph allComposites.put(origIndex, glyphs.get(origIndex)); - Vector composites = + ArrayList composites = getIncludedGlyphs(in, (int)entry.offset, origIndex); // Iterate through all composites pointed to // by this composite and check if they exists // in the glyphs map, add them if not. - for (Enumeration cps = composites.elements(); - cps.hasMoreElements(); ) { + for (Iterator cps = composites.iterator(); + cps.hasNext(); ) { - Integer cIdx = (Integer)cps.nextElement(); + Integer cIdx = (Integer)cps.next(); if (glyphs.get(cIdx) == null && newComposites.get(cIdx) == null) { newComposites.put(cIdx, @@ -544,19 +544,19 @@ public class TTFSubSetFile extends TTFFile { } // Add composites to glyphs - for (Enumeration m = newComposites.keys(); - m.hasMoreElements(); ) { - Integer im = (Integer)m.nextElement(); + for (Iterator m = newComposites.keySet().iterator(); + m.hasNext(); ) { + Integer im = (Integer)m.next(); glyphs.put(im, newComposites.get(im)); } } // Iterate through all composites to remap their composite index - for (Enumeration ce = allComposites.keys(); - ce.hasMoreElements(); ) { + for (Iterator ce = allComposites.keySet().iterator(); + ce.hasNext(); ) { remapComposite(in, glyphs, (int)entry.offset, - (Integer)ce.nextElement()); + (Integer)ce.next()); } } else { @@ -572,7 +572,7 @@ public class TTFSubSetFile extends TTFFile { */ public byte[] readFont(FontFileReader in, String name, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { /* * Check if TrueType collection, and that the name diff --git a/src/org/apache/fop/image/FopImageFactory.java b/src/org/apache/fop/image/FopImageFactory.java index 4e1ea97e6..cd777f2e2 100644 --- a/src/org/apache/fop/image/FopImageFactory.java +++ b/src/org/apache/fop/image/FopImageFactory.java @@ -66,7 +66,7 @@ public class FopImageFactory { try { absoluteURL = new URL(href); } catch (MalformedURLException mue) { - // if the href contains onl a path then file is assumed + // if the href contains only a path then file is assumed absoluteURL = new URL("file:" + href); } imgIS = absoluteURL.openStream(); diff --git a/src/org/apache/fop/image/ImageArea.java b/src/org/apache/fop/image/ImageArea.java index c5d46dc87..311e1769a 100644 --- a/src/org/apache/fop/image/ImageArea.java +++ b/src/org/apache/fop/image/ImageArea.java @@ -88,8 +88,5 @@ public class ImageArea extends InlineArea { xOffset = startIndent; } - - } - diff --git a/src/org/apache/fop/layout/FontDescriptor.java b/src/org/apache/fop/layout/FontDescriptor.java index 513eaacd5..fb818631b 100644 --- a/src/org/apache/fop/layout/FontDescriptor.java +++ b/src/org/apache/fop/layout/FontDescriptor.java @@ -20,7 +20,7 @@ public interface FontDescriptor { public int getStemV(); public boolean hasKerningInfo(); - public java.util.Hashtable getKerningInfo(); + public java.util.HashMap getKerningInfo(); public boolean isEmbeddable(); public byte getSubType(); public org.apache.fop.pdf.PDFStream getFontFile(int objNum); diff --git a/src/org/apache/fop/layout/FontState.java b/src/org/apache/fop/layout/FontState.java index 498db1000..16264d6a1 100644 --- a/src/org/apache/fop/layout/FontState.java +++ b/src/org/apache/fop/layout/FontState.java @@ -7,7 +7,7 @@ package org.apache.fop.layout; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.FontVariant; @@ -24,7 +24,7 @@ public class FontState { private FontMetric _metric; - private static Hashtable EMPTY_HASHTABLE = new Hashtable(); + private static HashMap EMPTY_HASHTABLE = new HashMap(); public FontState(FontInfo fontInfo, String fontFamily, String fontStyle, @@ -84,9 +84,9 @@ public class FontState { return _metric.getXHeight(_fontSize) / 1000; } - public Hashtable getKerning() { + public HashMap getKerning() { if (_metric instanceof FontDescriptor) { - Hashtable ret = ((FontDescriptor)_metric).getKerningInfo(); + HashMap ret = ((FontDescriptor)_metric).getKerningInfo(); if (ret != null) return ret; } diff --git a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java index d2c0f16bf..380b4b67e 100644 --- a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java +++ b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java @@ -8,8 +8,8 @@ package org.apache.fop.layout.hyphenation; import java.io.*; -import java.util.Vector; -import java.util.Hashtable; +import java.util.ArrayList; +import java.util.HashMap; /** * This tree structure stores the hyphenation patterns in an efficient @@ -29,7 +29,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, /** * This map stores hyphenation exceptions */ - protected Hashtable stoplist; + protected HashMap stoplist; /** * This map stores the character classes @@ -42,7 +42,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, private transient TernaryTree ivalues; public HyphenationTree() { - stoplist = new Hashtable(23); // usually a small table + stoplist = new HashMap(23); // usually a small table classmap = new TernaryTree(); vspace = new ByteVector(); vspace.alloc(1); // this reserves index 0, which we don't use @@ -282,10 +282,10 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, String sw = new String(word, 1, len); if (stoplist.containsKey(sw)) { // assume only simple hyphens (Hyphen.pre="-", Hyphen.post = Hyphen.no = null) - Vector hw = (Vector)stoplist.get(sw); + ArrayList hw = (ArrayList)stoplist.get(sw); int j = 0; for (i = 0; i < hw.size(); i++) { - Object o = hw.elementAt(i); + Object o = hw.get(i); if (o instanceof String) { j += ((String)o).length(); if (j >= remainCharCount && j < (len - pushCharCount)) @@ -354,7 +354,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, * @param hyphenatedword a vector of alternating strings and * {@link Hyphen hyphen} objects. */ - public void addException(String word, Vector hyphenatedword) { + public void addException(String word, ArrayList hyphenatedword) { stoplist.put(word, hyphenatedword); } diff --git a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java index 2eacd16a7..025d82b0f 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java +++ b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java @@ -7,7 +7,7 @@ package org.apache.fop.layout.hyphenation; -import java.util.Vector; +import java.util.ArrayList; /** * This interface is used to connect the XML pattern file parser to @@ -32,7 +32,7 @@ public interface PatternConsumer { * A hyphenatedword is a vector of alternating String's and * {@link Hyphen Hyphen} instances */ - public void addException(String word, Vector hyphenatedword); + public void addException(String word, ArrayList hyphenatedword); /** * Add hyphenation patterns. diff --git a/src/org/apache/fop/layout/hyphenation/PatternParser.java b/src/org/apache/fop/layout/hyphenation/PatternParser.java index 76d0d36f7..6581b7216 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternParser.java +++ b/src/org/apache/fop/layout/hyphenation/PatternParser.java @@ -22,7 +22,7 @@ import java.io.FileWriter; import java.io.PrintWriter; import java.io.IOException; import java.io.FileNotFoundException; -import java.util.Vector; +import java.util.ArrayList; import java.net.URL; /** @@ -37,7 +37,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { int currElement; PatternConsumer consumer; StringBuffer token; - Vector exception; + ArrayList exception; char hyphenChar; String errMsg; @@ -183,10 +183,10 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { return pat.toString(); } - protected Vector normalizeException(Vector ex) { - Vector res = new Vector(); + protected ArrayList normalizeException(ArrayList ex) { + ArrayList res = new ArrayList(); for (int i = 0; i < ex.size(); i++) { - Object item = ex.elementAt(i); + Object item = ex.get(i); if (item instanceof String) { String str = (String)item; StringBuffer buf = new StringBuffer(); @@ -195,27 +195,27 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { if (c != hyphenChar) buf.append(c); else { - res.addElement(buf.toString()); + res.add(buf.toString()); buf.setLength(0); char[] h = new char[1]; h[0] = hyphenChar; // we use here hyphenChar which is not necessarily // the one to be printed - res.addElement(new Hyphen(new String(h), null, null)); + res.add(new Hyphen(new String(h), null, null)); } } if (buf.length() > 0) - res.addElement(buf.toString()); + res.add(buf.toString()); } else - res.addElement(item); + res.add(item); } return res; } - protected String getExceptionWord(Vector ex) { + protected String getExceptionWord(ArrayList ex) { StringBuffer res = new StringBuffer(); for (int i = 0; i < ex.size(); i++) { - Object item = ex.elementAt(i); + Object item = ex.get(i); if (item instanceof String) res.append((String)item); else { @@ -260,12 +260,12 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { currElement = ELEM_PATTERNS; else if (local.equals("exceptions")) { currElement = ELEM_EXCEPTIONS; - exception = new Vector(); + exception = new ArrayList(); } else if (local.equals("hyphen")) { if (token.length() > 0) { - exception.addElement(token.toString()); + exception.add(token.toString()); } - exception.addElement(new Hyphen(attrs.getValue("pre"), + exception.add(new Hyphen(attrs.getValue("pre"), attrs.getValue("no"), attrs.getValue("post"))); currElement = ELEM_HYPHEN; @@ -282,10 +282,10 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { consumer.addClass(word); break; case ELEM_EXCEPTIONS: - exception.addElement(word); + exception.add(word); exception = normalizeException(exception); consumer.addException(getExceptionWord(exception), - (Vector)exception.clone()); + (ArrayList)exception.clone()); break; case ELEM_PATTERNS: consumer.addPattern(getPattern(word), @@ -319,11 +319,11 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { consumer.addClass(word); break; case ELEM_EXCEPTIONS: - exception.addElement(word); + exception.add(word); exception = normalizeException(exception); consumer.addException(getExceptionWord(exception), - (Vector)exception.clone()); - exception.removeAllElements(); + (ArrayList)exception.clone()); + exception.clear(); break; case ELEM_PATTERNS: consumer.addPattern(getPattern(word), @@ -391,7 +391,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { System.out.println("class: " + c); } - public void addException(String w, Vector e) { + public void addException(String w, ArrayList e) { System.out.println("exception: " + w + " : " + e.toString()); } diff --git a/src/org/apache/fop/pdf/PDFNumber.java b/src/org/apache/fop/pdf/PDFNumber.java index deed898ac..66a43d999 100644 --- a/src/org/apache/fop/pdf/PDFNumber.java +++ b/src/org/apache/fop/pdf/PDFNumber.java @@ -72,7 +72,6 @@ public class PDFNumber { } public static String doubleOut(double doubleDown, int dec) { - StringBuffer p = new StringBuffer(); if (doubleDown < 0) { doubleDown = -doubleDown; diff --git a/src/org/apache/fop/pdf/PDFPages.java b/src/org/apache/fop/pdf/PDFPages.java index 4035fc2eb..a2f3c91bb 100644 --- a/src/org/apache/fop/pdf/PDFPages.java +++ b/src/org/apache/fop/pdf/PDFPages.java @@ -10,7 +10,7 @@ package org.apache.fop.pdf; // Java import java.io.PrintWriter; import org.apache.fop.messaging.MessageHandler; -import java.util.Vector; +import java.util.ArrayList; /** * class representing a /Pages object. @@ -24,7 +24,7 @@ public class PDFPages extends PDFObject { /** * the /Page objects */ - protected Vector kids = new Vector(); + protected ArrayList kids = new ArrayList(); /** * the number of /Page objects @@ -53,7 +53,7 @@ public class PDFPages extends PDFObject { * @param page the PDFPage to add. */ public void addPage(PDFPage page) { - this.kids.addElement(page.referencePDF()); + this.kids.add(page.referencePDF()); page.setParent(this); this.incrementCount(); } @@ -85,7 +85,7 @@ public class PDFPages extends PDFObject { + " obj\n<< /Type /Pages\n/Count " + this.getCount() + "\n/Kids ["); for (int i = 0; i < kids.size(); i++) { - p = p.append(kids.elementAt(i) + " "); + p = p.append(kids.get(i) + " "); } p = p.append("] >>\nendobj\n"); return p.toString().getBytes(); diff --git a/src/org/apache/fop/pdf/PDFState.java b/src/org/apache/fop/pdf/PDFState.java index add7d7aeb..ddc66993d 100644 --- a/src/org/apache/fop/pdf/PDFState.java +++ b/src/org/apache/fop/pdf/PDFState.java @@ -11,6 +11,9 @@ import java.awt.Shape; import java.util.ArrayList; import java.util.HashMap; +import java.awt.Color; +import java.awt.Paint; + /** * This keeps information about the current state when writing to pdf. * It allows for creating new graphics states with the q operator. @@ -29,8 +32,8 @@ import java.util.HashMap; public class PDFState { private final static String COLOR = "color"; private final static String BACKCOLOR = "backcolor"; - private final static String PATTERN = "pattern"; - private final static String BACKPATTERN = "backpattern"; + private final static String PAINT = "paint"; + private final static String BACKPAINT = "backpaint"; private final static String LINECAP = "lineCap"; private final static String LINEJOIN = "lineJoin"; private final static String LINEWIDTH = "lineWidth"; @@ -43,10 +46,10 @@ public class PDFState { private final static String FONTNAME = "fontName"; private final static String CLIP = "clip"; - PDFColor color = new PDFColor(0, 0, 0); - PDFColor backcolor = new PDFColor(255, 255, 255); - PDFPattern pattern = null; - PDFPattern backPattern = null; + Color color = Color.black; + Color backcolor = Color.white; + Paint paint = null; + Paint backPaint = null; int lineCap = 0; int lineJoin = 0; float lineWidth = 1; @@ -68,13 +71,45 @@ public class PDFState { // this call should be used when the q operator is used // so that the state is known when popped public void push() { - HashMap changedMap = new HashMap(); + HashMap saveMap = new HashMap(); + saveMap.put(COLOR, color); + saveMap.put(BACKCOLOR, backcolor); + saveMap.put(PAINT, paint); + saveMap.put(BACKPAINT, backPaint); + saveMap.put(LINECAP, new Integer(lineCap)); + saveMap.put(LINEJOIN, new Integer(lineJoin)); + saveMap.put(LINEWIDTH, new Float(lineWidth)); + saveMap.put(MITERLIMIT, new Float(miterLimit)); + saveMap.put(TEXT, new Boolean(text)); + saveMap.put(DASHOFFSET, new Integer(dashOffset)); + saveMap.put(DASHARRAY, dashArray); + saveMap.put(TRANSFORM, transform); + saveMap.put(FONTSIZE, new Float(fontSize)); + saveMap.put(FONTNAME, fontName); + saveMap.put(CLIP, clip); + stateStack.add(saveMap); } public void pop() { if (getStackLevel() > 0) { + HashMap saveMap = (HashMap)stateStack.get(stateStack.size() - 1); stateStack.remove(stateStack.size() - 1); + color = (Color)saveMap.get(COLOR); + backcolor = (Color)saveMap.get(BACKCOLOR); + paint = (Paint)saveMap.get(PAINT); + backPaint = (Paint)saveMap.get(BACKPAINT); + lineCap = ((Integer)saveMap.get(LINECAP)).intValue(); + lineJoin = ((Integer)saveMap.get(LINEJOIN)).intValue(); + lineWidth = ((Float)saveMap.get(LINEWIDTH)).floatValue(); + miterLimit = ((Float)saveMap.get(MITERLIMIT)).floatValue(); + text = ((Boolean)saveMap.get(TEXT)).booleanValue(); + dashOffset = ((Integer)saveMap.get(DASHOFFSET)).intValue(); + dashArray = (int[])saveMap.get(DASHARRAY); + transform = (double[])saveMap.get(TRANSFORM); + fontSize = ((Float)saveMap.get(FONTSIZE)).floatValue(); + fontName = (String)saveMap.get(FONTNAME); + clip = (Shape)saveMap.get(CLIP); } } @@ -86,5 +121,61 @@ public class PDFState { return false; } + public boolean setColor(Color col) { + if(!col.equals(color)) { + color = col; + return true; + } + return false; + } + + public boolean setBackColor(Color col) { + if(!col.equals(backcolor)) { + backcolor = col; + return true; + } + return false; + } + + public boolean setPaint(Paint p) { + if(paint == null) { + if(p != null) { + paint = p; + return true; + } + } else if(!paint.equals(p)) { + paint = p; + return true; + } + return false; + } + + public boolean checkClip(Shape cl) { + if(clip == null) { + if(cl != null) { + return true; + } + } else if(!clip.equals(cl)) { + return true; + } + return false; + } + + public void setClip(Shape cl) { + clip = cl; + } + + public boolean checkTransform(double[] vals) { + for(int count = 0; count < transform.length; count++) { + if(transform[count] != vals[count]) { + return true; + } + } + return false; + } + + public void setTransform(double[] vals) { + transform = vals; + } } diff --git a/src/org/apache/fop/render/awt/AWTFontMetrics.java b/src/org/apache/fop/render/awt/AWTFontMetrics.java index 33a79fe8b..c88493ca2 100644 --- a/src/org/apache/fop/render/awt/AWTFontMetrics.java +++ b/src/org/apache/fop/render/awt/AWTFontMetrics.java @@ -8,7 +8,6 @@ package org.apache.fop.render.awt; // FOP -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.layout.FontInfo; import org.apache.fop.layout.FontDescriptor; import org.apache.fop.layout.FontState; @@ -37,7 +36,6 @@ import java.awt.font.TextLayout; * Since FontState and FontInfo multiply all factors by * size, we assume a "standard" font of FONT_SIZE. */ - public class AWTFontMetrics { /** diff --git a/src/org/apache/fop/render/pdf/FontSetup.java b/src/org/apache/fop/render/pdf/FontSetup.java index 33d7ffe7e..83ea71e8b 100644 --- a/src/org/apache/fop/render/pdf/FontSetup.java +++ b/src/org/apache/fop/render/pdf/FontSetup.java @@ -9,7 +9,6 @@ package org.apache.fop.render.pdf; // FOP import org.apache.fop.render.pdf.fonts.*; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.layout.FontInfo; import org.apache.fop.layout.FontDescriptor; import org.apache.fop.pdf.PDFDocument; @@ -39,7 +38,6 @@ public class FontSetup { * @param fontInfo the font info object to set up */ public static void setup(FontInfo fontInfo) { - MessageHandler.logln("setting up fonts"); fontInfo.addMetrics("F1", new Helvetica()); fontInfo.addMetrics("F2", new HelveticaOblique()); @@ -178,9 +176,9 @@ public class FontSetup { } } } catch (Exception ex) { - MessageHandler.error("Failed to read font metrics file " - + configFontInfo.getMetricsFile() - + " : " + ex.getMessage()); + //MessageHandler.error("Failed to read font metrics file " + // + configFontInfo.getMetricsFile() + // + " : " + ex.getMessage()); } } } diff --git a/src/org/apache/fop/render/pdf/fonts/LazyFont.java b/src/org/apache/fop/render/pdf/fonts/LazyFont.java index e9fc2caee..062d03f83 100644 --- a/src/org/apache/fop/render/pdf/fonts/LazyFont.java +++ b/src/org/apache/fop/render/pdf/fonts/LazyFont.java @@ -11,7 +11,7 @@ import org.apache.fop.render.pdf.Font; import org.apache.fop.layout.FontDescriptor; import org.apache.fop.pdf.PDFStream; import org.apache.fop.messaging.MessageHandler; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.render.pdf.FontReader; @@ -158,7 +158,7 @@ public class LazyFont extends Font implements FontDescriptor { return realFontDescriptor.hasKerningInfo(); } - public Hashtable getKerningInfo(){ + public HashMap getKerningInfo(){ load(); return realFontDescriptor.getKerningInfo(); } diff --git a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java index 7a667d79b..4f8769fc2 100644 --- a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java +++ b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java @@ -24,7 +24,7 @@ import java.io.IOException; import java.io.FileInputStream; import java.io.File; import java.io.BufferedInputStream; -import java.util.Hashtable; +import java.util.HashMap; /** * Generic MultiByte (CID) font @@ -53,7 +53,7 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { public int defaultWidth = 0; public byte cidType = PDFCIDFont.CID_TYPE2; - public Hashtable kerning = new Hashtable(); + public HashMap kerning = new HashMap(); public boolean useKerning = true; private String namePrefix = null; // Quasi unique prefix private static int uniqueCounter = 1; @@ -66,12 +66,12 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { /** * usedGlyphs contains orginal, new glyph index */ - private Hashtable usedGlyphs = new Hashtable(); + private HashMap usedGlyphs = new HashMap(); /** * usedGlyphsIndex contains new glyph, original index */ - private Hashtable usedGlyphsIndex = new Hashtable(); + private HashMap usedGlyphsIndex = new HashMap(); int usedGlyphsCount = 0; public MultiByteFont() { @@ -99,11 +99,11 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { return (useKerning & kerning.isEmpty()); } - public final java.util.Hashtable getKerningInfo() { + public final java.util.HashMap getKerningInfo() { if (useKerning) return kerning; else - return new Hashtable(); + return new HashMap(); } public byte getSubType() { diff --git a/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java b/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java index e780594f0..7200b92f7 100644 --- a/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java +++ b/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java @@ -16,7 +16,7 @@ import org.apache.fop.pdf.PDFT1Stream; import java.io.InputStream; import java.io.FileInputStream; import java.io.BufferedInputStream; -import java.util.Hashtable; +import java.util.HashMap; /** * Generic SingleByte font @@ -44,7 +44,7 @@ public class SingleByteFont extends Font implements FontDescriptor { public int italicAngle = 0; public int missingWidth = 0; - public Hashtable kerning = new Hashtable(); + public HashMap kerning = new HashMap(); public boolean useKerning = true; public int width[] = null; @@ -54,11 +54,11 @@ public class SingleByteFont extends Font implements FontDescriptor { return (useKerning & kerning.isEmpty()); } - public final java.util.Hashtable getKerningInfo() { + public final java.util.HashMap getKerningInfo() { if (useKerning) return kerning; else - return new Hashtable(); + return new HashMap(); } public byte getSubType() { diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index e0a35fd36..1f7976cb4 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -77,6 +77,8 @@ public class XMLRenderer extends AbstractRenderer { public void setUserAgent(FOUserAgent agent) { super.setUserAgent(agent); + + // //userAgent.addExtensionHandler(); XMLHandler handler = new XMLXMLHandler(); userAgent.setDefaultXMLHandler(mimeType, handler); diff --git a/src/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/org/apache/fop/svg/PDFDocumentGraphics2D.java index a1ffe980d..5c65c8eb0 100644 --- a/src/org/apache/fop/svg/PDFDocumentGraphics2D.java +++ b/src/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -45,21 +45,19 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { /** * Create a new PDFDocumentGraphics2D. - * This is used to create a new pdf document of the given height - * and width. + * This is used to create a new pdf document, the height, + * width and output stream can be setup later. + * For use by the transcoder which needs font information + * for the bridge before the document size is known. * The resulting document is written to the stream after rendering. * * @param textAsShapes set this to true so that text will be rendered * using curves and not the font. - * @param stream the stream that the final document should be written to. - * @param width the width of the document - * @param height the height of the document */ - public PDFDocumentGraphics2D(boolean textAsShapes, OutputStream stream, - int width, int height) { + PDFDocumentGraphics2D(boolean textAsShapes) { super(textAsShapes); - - if (!textAsShapes) { + + if(!textAsShapes) { fontInfo = new FontInfo(); FontSetup.setup(fontInfo); try { @@ -67,21 +65,43 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { "normal", 12, 0); } catch (FOPException e) {} } + standalone = true; - this.stream = stream; this.pdfDoc = new PDFDocument(); this.pdfDoc.setProducer("FOP SVG Renderer"); pdfStream = this.pdfDoc.makeStream(); - this.width = width; - this.height = height; + + graphicsState = new PDFState(); currentFontName = ""; currentFontSize = 0; currentYPosition = 0; currentXPosition = 0; + } + void setupDocument(OutputStream stream, int width, int height) { + this.width = width; + this.height = height; + this.stream = stream; currentStream.write("1 0 0 -1 0 " + height + " cm\n"); + } + /** + * Create a new PDFDocumentGraphics2D. + * This is used to create a new pdf document of the given height + * and width. + * The resulting document is written to the stream after rendering. + * + * @param textAsShapes set this to true so that text will be rendered + * using curves and not the font. + * @param stream the stream that the final document should be written to. + * @param width the width of the document + * @param height the height of the document + */ + public PDFDocumentGraphics2D(boolean textAsShapes, OutputStream stream, + int width, int height) { + this(textAsShapes); + setupDocument(stream, width, height); } public FontState getFontState() { @@ -110,7 +130,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { */ public void setBackgroundColor(Color col) { Color c = col; - currentColour = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); + PDFColor currentColour = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); currentStream.write("q\n"); currentStream.write(currentColour.getColorSpaceOut(true)); diff --git a/src/org/apache/fop/svg/PDFGraphics2D.java b/src/org/apache/fop/svg/PDFGraphics2D.java index 296ef8768..45bc493c1 100644 --- a/src/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/org/apache/fop/svg/PDFGraphics2D.java @@ -32,15 +32,12 @@ import java.io.*; import java.util.Map; import java.util.ArrayList; -import java.util.Hashtable; +import java.util.HashMap; /** - * This concrete implementation of <tt>AbstractGraphics2D</tt> is a - * simple help to programmers to get started with their own - * implementation of <tt>Graphics2D</tt>. - * <tt>DefaultGraphics2D</tt> implements all the abstract methods - * is <tt>AbstractGraphics2D</tt> and makes it easy to start - * implementing a <tt>Graphic2D</tt> piece-meal. + * PDF Graphics 2D. + * Used for drawing into a pdf document as if it is a graphics object. + * This takes a pdf document and draws into it. * * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a> * @version $Id$ @@ -55,6 +52,11 @@ public class PDFGraphics2D extends AbstractGraphics2D { protected PDFDocument pdfDoc; /** + * the current state of the pdf graphics + */ + PDFState graphicsState; + + /** * the current annotation list to add annotations to */ PDFAnnotList currentAnnotList = null; @@ -88,11 +90,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { protected int currentXPosition = 0; /** - * the current colour for use in svg - */ - PDFColor currentColour = new PDFColor(0, 0, 0); - - /** * Create a new PDFGraphics2D with the given pdf document info. * This is used to create a Graphics object for use inside an already * existing document. @@ -108,7 +105,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { fontState = fs; } - public PDFGraphics2D(boolean textAsShapes) { + protected PDFGraphics2D(boolean textAsShapes) { super(textAsShapes); } @@ -476,7 +473,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { fontState = null; currentStream = null; currentFontName = null; - currentColour = null; } /** @@ -503,50 +499,60 @@ public class PDFGraphics2D extends AbstractGraphics2D { return; } - currentStream.write("q\n"); + AffineTransform trans = getTransform(); + double[] tranvals = new double[6]; + trans.getMatrix(tranvals); + Shape imclip = getClip(); - writeClip(imclip); + boolean newClip = graphicsState.checkClip(imclip); + boolean newTransform = graphicsState.checkTransform(tranvals); + + if(newClip || newTransform) { + currentStream.write("q\n"); + graphicsState.push(); + if(newClip) { + writeClip(imclip); + } + if(newTransform) { + currentStream.write(PDFNumber.doubleOut(tranvals[0], 5) + " " + + PDFNumber.doubleOut(tranvals[1], 5) + " " + + PDFNumber.doubleOut(tranvals[2], 5) + " " + + PDFNumber.doubleOut(tranvals[3], 5) + " " + + PDFNumber.doubleOut(tranvals[4], 5) + " " + + PDFNumber.doubleOut(tranvals[5], 5) + " cm\n"); + } + } applyColor(c, false); applyPaint(getPaint(), false); applyStroke(getStroke()); - AffineTransform trans = getTransform(); - double[] tranvals = new double[6]; - trans.getMatrix(tranvals); - currentStream.write(PDFNumber.doubleOut(tranvals[0]) + " " - + PDFNumber.doubleOut(tranvals[1]) + " " - + PDFNumber.doubleOut(tranvals[2]) + " " - + PDFNumber.doubleOut(tranvals[3]) + " " - + PDFNumber.doubleOut(tranvals[4]) + " " - + PDFNumber.doubleOut(tranvals[5]) + " cm\n"); - PathIterator iter = s.getPathIterator(new AffineTransform()); while (!iter.isDone()) { double vals[] = new double[6]; int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " c\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " " + + PDFNumber.doubleOut(vals[2], 5) + " " + + PDFNumber.doubleOut(vals[3], 5) + " " + + PDFNumber.doubleOut(vals[4], 5) + " " + + PDFNumber.doubleOut(vals[5], 5) + " c\n"); break; case PathIterator.SEG_LINETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " l\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " l\n"); break; case PathIterator.SEG_MOVETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " m\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " y\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " " + + PDFNumber.doubleOut(vals[2], 5) + " " + + PDFNumber.doubleOut(vals[3], 5) + " y\n"); break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); @@ -557,7 +563,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { iter.next(); } doDrawing(false, true, false); - currentStream.write("Q\n"); + if(newClip || newTransform) { + currentStream.write("Q\n"); + graphicsState.pop(); + } } protected void writeClip(Shape s) { @@ -608,7 +617,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { Color c = col; if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_RGB) { - currentColour = new PDFColor(c.getRed(), c.getGreen(), + PDFColor currentColour = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); currentStream.write(currentColour.getColorSpaceOut(fill)); } else if (c.getColorSpace().getType() @@ -619,7 +628,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { // convert the float elements to doubles for pdf cmyk[i] = cComps[i]; } - currentColour = new PDFColor(cmyk[0], cmyk[1], cmyk[2], cmyk[3]); + PDFColor currentColour = new PDFColor(cmyk[0], cmyk[1], cmyk[2], cmyk[3]); currentStream.write(currentColour.getColorSpaceOut(fill)); } else if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_2CLR) { @@ -629,8 +638,8 @@ public class PDFGraphics2D extends AbstractGraphics2D { for (int i = 0; i < 1; i++) { blackMagenta[i] = cComps[i]; } - // currentColour = new PDFColor(blackMagenta[0], blackMagenta[1]); - currentStream.write(currentColour.getColorSpaceOut(fill)); + //PDFColor currentColour = new PDFColor(blackMagenta[0], blackMagenta[1]); + //currentStream.write(currentColour.getColorSpaceOut(fill)); } else { System.err.println("Color Space not supported by PDFGraphics2D"); } @@ -875,7 +884,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write("BT\n"); - Hashtable kerning = null; + HashMap kerning = null; boolean kerningAvailable = false; kerning = fontState.getKerning(); @@ -952,9 +961,9 @@ public class PDFGraphics2D extends AbstractGraphics2D { } private void addKerning(StringWriter buf, Integer ch1, Integer ch2, - Hashtable kerning, String startText, + HashMap kerning, String startText, String endText) { - Hashtable kernPair = (Hashtable)kerning.get(ch1); + HashMap kernPair = (HashMap)kerning.get(ch1); if (kernPair != null) { Integer width = (Integer)kernPair.get(ch2); @@ -1086,15 +1095,28 @@ public class PDFGraphics2D extends AbstractGraphics2D { return; } } - currentStream.write("q\n"); Shape imclip = getClip(); - writeClip(imclip); + boolean newState = graphicsState.checkClip(imclip); + + if(newState) { + currentStream.write("q\n"); + graphicsState.push(); + writeClip(imclip); + graphicsState.setClip(imclip); + } c = getColor(); - applyColor(c, true); + if(graphicsState.setColor(c)) { + applyColor(c, true); + } c = getBackground(); - applyColor(c, false); + if(graphicsState.setBackColor(c)) { + applyColor(c, false); + } - applyPaint(getPaint(), true); + Paint paint = getPaint(); + if(graphicsState.setPaint(paint)) { + applyPaint(paint, true); + } PathIterator iter = s.getPathIterator(getTransform()); while (!iter.isDone()) { @@ -1102,26 +1124,26 @@ public class PDFGraphics2D extends AbstractGraphics2D { int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " c\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " " + + PDFNumber.doubleOut(vals[2], 5) + " " + + PDFNumber.doubleOut(vals[3], 5) + " " + + PDFNumber.doubleOut(vals[4], 5) + " " + + PDFNumber.doubleOut(vals[5], 5) + " c\n"); break; case PathIterator.SEG_LINETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " l\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " l\n"); break; case PathIterator.SEG_MOVETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " m\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " y\n"); + currentStream.write(PDFNumber.doubleOut(vals[0], 5) + " " + + PDFNumber.doubleOut(vals[1], 5) + " " + + PDFNumber.doubleOut(vals[2], 5) + " " + + PDFNumber.doubleOut(vals[3], 5) + " y\n"); break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); @@ -1133,7 +1155,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { } doDrawing(true, false, iter.getWindingRule() == PathIterator.WIND_EVEN_ODD); - currentStream.write("Q\n"); + if(newState) { + currentStream.write("Q\n"); + graphicsState.pop(); + } } protected void doDrawing(boolean fill, boolean stroke, boolean nonzero) { diff --git a/src/org/apache/fop/svg/PDFTextElementBridge.java b/src/org/apache/fop/svg/PDFTextElementBridge.java new file mode 100644 index 000000000..a4a3759ed --- /dev/null +++ b/src/org/apache/fop/svg/PDFTextElementBridge.java @@ -0,0 +1,102 @@ +/* + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. + */ + +package org.apache.fop.svg; + +import org.apache.batik.gvt.TextNode; +import org.apache.batik.bridge.*; + +import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration; +import org.apache.batik.gvt.CompositeGraphicsNode; +import org.apache.batik.gvt.GraphicsNode; + +import org.apache.fop.layout.FontState; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.apache.batik.gvt.GraphicsNode; + +/** + * Bridge class for the <text> element. + * This bridge will use the direct text painter if the text + * for the element is simple. + * + * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a> + */ +public class PDFTextElementBridge extends SVGTextElementBridge { + private PDFTextPainter pdfTextPainter; + + /** + * Constructs a new bridge for the <text> element. + */ + public PDFTextElementBridge(FontState fs) { + pdfTextPainter = new PDFTextPainter(fs); + } + + public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { + GraphicsNode node = super.createGraphicsNode(ctx, e); + if(isSimple(ctx, e, node)) { + ((TextNode)node).setTextPainter(getTextPainter()); + } + return node; + } + + private PDFTextPainter getTextPainter() { + return pdfTextPainter; + } + + /** + * Check if text element contains simple text. + * This checks the children of the text element to determine + * if the text is simple. The text is simple if it can be rendered + * with basic text drawing algorithms. This means there are no + * alternate characters, the font is known and there are no effects + * applied to the text. + */ + private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) { + CSSOMReadOnlyStyleDeclaration cssDecl + = CSSUtilities.getComputedStyle(element); + UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element); + + // Font size, in user space units. + float fs = TextUtilities.convertFontSize(element, ctx, cssDecl, uctx); + if(((int)fs) != fs) { + return false; + } + + Element nodeElement; + for (Node n = element.getFirstChild(); + n != null; + n = n.getNextSibling()) { + + switch (n.getNodeType()) { + case Node.ELEMENT_NODE: + + nodeElement = (Element)n; + + if (n.getLocalName().equals(SVG_TSPAN_TAG) + || n.getLocalName().equals(SVG_ALT_GLYPH_TAG)) { + return false; + } else if (n.getLocalName().equals(SVG_TEXT_PATH_TAG)) { + return false; + } else if (n.getLocalName().equals(SVG_TREF_TAG)) { + return false; + } + break; + case Node.TEXT_NODE: + case Node.CDATA_SECTION_NODE: + } + } + + if(CSSUtilities.convertFilter(element, node, ctx) != null) { + return false; + } + + return true; + } +} diff --git a/src/org/apache/fop/svg/PDFTextPainter.java b/src/org/apache/fop/svg/PDFTextPainter.java index 1e55e7bfd..dce7d5231 100644 --- a/src/org/apache/fop/svg/PDFTextPainter.java +++ b/src/org/apache/fop/svg/PDFTextPainter.java @@ -103,10 +103,10 @@ public class PDFTextPainter implements TextPainter { String name = fam.getFamilyName(); if (fi.hasFont(name, weight, style)) { try { - int fsize = (int)size.floatValue(); + int fsize = (int)(size.floatValue() * 1000); fontState = new FontState(fontState.getFontInfo(), name, style, weight, - fsize * 1000, 0); + fsize, 0); } catch (org.apache.fop.apps.FOPException fope) { fope.printStackTrace(); } @@ -117,9 +117,9 @@ public class PDFTextPainter implements TextPainter { } if (!found) { try { - int fsize = (int)size.floatValue(); + int fsize = (int)(size.floatValue() * 1000); fontState = new FontState(fontState.getFontInfo(), "any", - style, weight, fsize * 1000, 0); + style, weight, fsize, 0); } catch (org.apache.fop.apps.FOPException fope) { fope.printStackTrace(); } @@ -230,13 +230,14 @@ public class PDFTextPainter implements TextPainter { } public Shape getDecoratedShape(TextNode node) { - System.out.println("PDFText getDecoratedShape"); + //System.out.println("PDFText getDecoratedShape"); return new Rectangle(1, 1); } public Rectangle2D getBounds(TextNode node) { - System.out.println("PDFText getBounds"); - return null; + //System.out.println("PDFText getBounds"); + Rectangle2D bounds = new Rectangle2D.Float(0, 0, 100, 12); + return bounds; } public Rectangle2D getDecoratedBounds(TextNode node) { diff --git a/src/org/apache/fop/svg/PDFTranscoder.java b/src/org/apache/fop/svg/PDFTranscoder.java index 568a6ec9c..9d5ab9ff8 100644 --- a/src/org/apache/fop/svg/PDFTranscoder.java +++ b/src/org/apache/fop/svg/PDFTranscoder.java @@ -169,10 +169,11 @@ public class PDFTranscoder extends XMLAbstractTranscoder { svgCtx.setPixelToMM(userAgent.getPixelToMM()); ((SVGOMDocument)document).setSVGContext(svgCtx); - boolean stroke = true; + /*boolean stroke = true; if (hints.containsKey(KEY_STROKE_TEXT)) { stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue(); - } + }*/ + PDFDocumentGraphics2D graphics = new PDFDocumentGraphics2D(false); // build the GVT tree GVTBuilder builder = new GVTBuilder(); @@ -181,7 +182,10 @@ public class PDFTranscoder extends XMLAbstractTranscoder { TextPainter textPainter = null; textPainter = new StrokingTextPainter(); ctx.setTextPainter(textPainter); - + + PDFTextElementBridge pdfTextElementBridge = new PDFTextElementBridge(graphics.getFontState()); + ctx.putBridge(pdfTextElementBridge); + PDFAElementBridge pdfAElementBridge = new PDFAElementBridge(); AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0); pdfAElementBridge.setCurrentTransform(currentTransform); @@ -267,14 +271,13 @@ public class PDFTranscoder extends XMLAbstractTranscoder { int w = (int)width; int h = (int)height; - PDFDocumentGraphics2D graphics = new PDFDocumentGraphics2D(stroke, - output.getOutputStream(), w, h); + graphics.setupDocument(output.getOutputStream(), w, h); graphics.setSVGDimension(docWidth, docHeight); currentTransform.setTransform(1, 0, 0, -1, 0, height); - if (!stroke) { + /*if (!stroke) { textPainter = new PDFTextPainter(graphics.getFontState()); ctx.setTextPainter(textPainter); - } + }*/ if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { graphics.setBackgroundColor((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR)); diff --git a/src/org/apache/fop/svg/SVGArea.java b/src/org/apache/fop/svg/SVGArea.java index ca8d2164a..8935b42ac 100644 --- a/src/org/apache/fop/svg/SVGArea.java +++ b/src/org/apache/fop/svg/SVGArea.java @@ -12,7 +12,7 @@ import org.apache.fop.render.Renderer; import org.apache.fop.layout.FontState; import org.apache.fop.layout.Area; -import java.util.*; +//import java.util.*; import org.w3c.dom.svg.*; import org.w3c.dom.*; diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java index 4c49334ef..cf4fd9c63 100644 --- a/src/org/apache/fop/svg/SVGElement.java +++ b/src/org/apache/fop/svg/SVGElement.java @@ -52,7 +52,7 @@ public class SVGElement extends SVGObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public SVGElement(FObj parent) { + public SVGElement(FONode parent) { super(parent); } @@ -75,12 +75,8 @@ public class SVGElement extends SVGObj { throw new FOPException("SVG not in fo:instream-foreign-object"); } - if (this.marker == START) { this.fs = area.getFontState(); - this.marker = 0; - } - final Element svgRoot = element; /* create an SVG area */ /* if width and height are zero, get the bounds of the content. */ diff --git a/src/org/apache/fop/svg/SVGElementMapping.java b/src/org/apache/fop/svg/SVGElementMapping.java index cea2ea287..a4db558e0 100644 --- a/src/org/apache/fop/svg/SVGElementMapping.java +++ b/src/org/apache/fop/svg/SVGElementMapping.java @@ -7,10 +7,9 @@ package org.apache.fop.svg; -import java.util.Enumeration; import java.util.HashMap; -import org.apache.fop.fo.FObj; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.fo.ElementMapping; import org.apache.fop.apps.Driver; @@ -33,7 +32,7 @@ public class SVGElementMapping implements ElementMapping { foObjs = new HashMap(); foObjs.put("svg", new SE()); - foObjs.put("<default>", new SVGMaker()); + foObjs.put(DEFAULT, new SVGMaker()); } String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; @@ -44,13 +43,13 @@ public class SVGElementMapping implements ElementMapping { } class SVGMaker extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new SVGObj(parent); } } class SE extends ElementMapping.Maker { - public FObj make(FObj parent) { + public FONode make(FONode parent) { return new SVGElement(parent); } } diff --git a/src/org/apache/fop/svg/SVGObj.java b/src/org/apache/fop/svg/SVGObj.java index f3f72b12a..8d6406ce5 100644 --- a/src/org/apache/fop/svg/SVGObj.java +++ b/src/org/apache/fop/svg/SVGObj.java @@ -8,11 +8,6 @@ package org.apache.fop.svg; import org.apache.fop.fo.*; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -import org.w3c.dom.Element; public class SVGObj extends XMLObj { /** @@ -21,7 +16,7 @@ public class SVGObj extends XMLObj { * @param parent the parent formatting object * @param propertyList the explicit properties of this object */ - public SVGObj(FObj parent) { + public SVGObj(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/svg/SVGUserAgent.java b/src/org/apache/fop/svg/SVGUserAgent.java index 7766a1ea4..9c3808568 100644 --- a/src/org/apache/fop/svg/SVGUserAgent.java +++ b/src/org/apache/fop/svg/SVGUserAgent.java @@ -115,7 +115,6 @@ public class SVGUserAgent implements UserAgent { public void openLink(SVGAElement elt) { } - public Point getClientAreaLocationOnScreen() { return new Point(0, 0); } @@ -146,6 +145,5 @@ public class SVGUserAgent implements UserAgent { public void handleElement(Element elt, Object data) {} - } diff --git a/src/org/apache/fop/system/BufferManager.java b/src/org/apache/fop/system/BufferManager.java index 75959de49..2e8b8c4fc 100644 --- a/src/org/apache/fop/system/BufferManager.java +++ b/src/org/apache/fop/system/BufferManager.java @@ -134,7 +134,6 @@ public class BufferManager { if (csize < values.length) { System.out.println("Cache size too small"); - System.exit(0); } |