From: Joerg Pietschmann Date: Fri, 19 Jul 2002 20:41:01 +0000 (+0000) Subject: Get logger from parent in FONode constructor. This allows logging X-Git-Tag: fop-0_20_5rc~123 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bfb92600b6d880678a236064d20eee95d9a4d32c;p=xmlgraphics-fop.git Get logger from parent in FONode constructor. This allows logging in FO constructors (except in fo:root). Moved fo:marker handlich from FONode to FObj. Create Hashtable for fo:marker lazily. Removed unused method getNextPage() from AreaTree git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195012 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 0aa5620b4..13dd8eef6 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -13,7 +13,6 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.layout.Area; import org.apache.fop.layout.AreaClass; import org.apache.fop.layout.LinkSet; -import org.apache.fop.fo.flow.Marker; // Avalon import org.apache.avalon.framework.logger.Logger; @@ -70,18 +69,15 @@ abstract public class FONode { // count of areas generated-by/returned-by public int areasGenerated = 0; - // markers - protected Hashtable markers; - protected Logger log; protected FONode(FObj parent) { this.parent = parent; - markers = new Hashtable(); - - if (null != parent) + if (parent != null) { this.areaClass = parent.areaClass; + log = parent.log; + } } public void setLogger(Logger logger) { @@ -218,25 +214,4 @@ abstract public class FONode { ((FONode)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/FObj.java b/src/org/apache/fop/fo/FObj.java index 02d305719..7d804dc9d 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -11,10 +11,12 @@ package org.apache.fop.fo; import org.apache.fop.layout.Area; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.IDReferences; +import org.apache.fop.fo.flow.Marker; // Java import java.util.Hashtable; import java.util.Enumeration; +import java.util.Vector; /** * base class for representation of formatting objects and their processing @@ -37,6 +39,9 @@ public class FObj extends FONode { public PropertyList properties; protected PropertyManager propMgr; + // markers + private Hashtable markers; + protected String name; protected FObj(FObj parent, PropertyList propertyList) { @@ -158,5 +163,36 @@ public class FObj extends FONode { this.properties.setWritingMode(p.getProperty("writing-mode").getEnum()); } + + public void addMarker(Marker marker) throws FOPException { + String mcname = marker.getMarkerClassName(); + if (!children.isEmpty()) { + throw new FOPException("A fo:marker must be an initial child of '" + + getName()); + } + if (markers==null) { + markers = new Hashtable(); + markers.put(mcname, marker); + } else if (!markers.containsKey(mcname) ) { + markers.put(mcname, marker); + } else { + throw new FOPException("marker-class-name '" + + mcname + + "' already exists for this parent"); + } + } + + public boolean hasMarkers() { + return markers!=null; + } + + public Vector getMarkers() { + if (markers==null) { + log.debug("GetMarkers failed (no markers). Should not happen."); + return null; + } else { + return new Vector(markers.values()); + } + } } diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java index 9846c86d7..2e1f042a8 100644 --- a/src/org/apache/fop/fo/flow/Flow.java +++ b/src/org/apache/fop/fo/flow/Flow.java @@ -96,8 +96,8 @@ public class Flow extends FObj { protected void setFlowName(String name) throws FOPException { if (name == null || name.equals("")) { log.warn("A 'flow-name' is required for " - + getElementName() - + ". This constraint will be enforced in future versions of FOP"); + + getElementName() + + ". This constraint will be enforced in future versions of FOP"); _flowName = "xsl-region-body"; } else { _flowName = name; diff --git a/src/org/apache/fop/layout/AreaTree.java b/src/org/apache/fop/layout/AreaTree.java index 85a987b45..d2f247c19 100644 --- a/src/org/apache/fop/layout/AreaTree.java +++ b/src/org/apache/fop/layout/AreaTree.java @@ -63,10 +63,10 @@ public class AreaTree { return this.fontInfo; } - public Page getNextPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - return streamRenderer.getNextPage(current, isWithinPageSequence,isFirstCall); - } +// public Page getNextPage(Page current, boolean isWithinPageSequence, +// boolean isFirstCall) { +// return streamRenderer.getNextPage(current, isWithinPageSequence,isFirstCall); +// } public Page getPreviousPage(Page current, boolean isWithinPageSequence, boolean isFirstCall) {