From: arved Date: Mon, 18 Dec 2000 03:35:20 +0000 (+0000) Subject: Supports marker snapshots X-Git-Tag: fop-0_17_0~168 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f3bb854975e6558e3e89f570dfaaf62a00ed6d4;p=xmlgraphics-fop.git Supports marker snapshots git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193893 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index e4d22c2f6..87f7e55ce 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -230,4 +230,50 @@ abstract public class FONode { return(null); } + /** + * 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 ((FONode) 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.remove(0)).intValue(); + + 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(); + for (int i = this.marker + 1; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + fo.resetMarker(); + } + ((FONode) children.elementAt(this.marker)).rollback(snapshot); + } }