]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Supports marker snapshots
authorarved <arved@unknown>
Mon, 18 Dec 2000 03:35:20 +0000 (03:35 +0000)
committerarved <arved@unknown>
Mon, 18 Dec 2000 03:35:20 +0000 (03:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193893 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/FONode.java

index e4d22c2f6693d800d5408c6acc3a599032bdec19..87f7e55ce8fb5a18520fb3c19b1d03f103a7d4c3 100644 (file)
@@ -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);
+       }
 }