]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Decommission AreaAdditionUtil.StackingIter + minor fixups
authorAndreas L. Delmelle <adelmelle@apache.org>
Sat, 5 Feb 2011 00:40:35 +0000 (00:40 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sat, 5 Feb 2011 00:40:35 +0000 (00:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1067360 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java

index 755be91d11ce4e8766074d81dcc5d235f0e36c16..1bacbd29bebd6dfc0182178611e9a984c6aae06c 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 
 import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
@@ -32,20 +31,6 @@ public final class AreaAdditionUtil {
     private AreaAdditionUtil() {
     }
 
-    private static class StackingIter extends PositionIterator {
-        StackingIter(Iterator parentIter) {
-            super(parentIter);
-        }
-
-        protected LayoutManager getLM(Object nextObj) {
-            return ((Position) nextObj).getLM();
-        }
-
-        protected Position getPos(Object nextObj) {
-            return ((Position) nextObj);
-        }
-    }
-
     /**
      * Creates the child areas for the given layout manager.
      * @param bslm the BlockStackingLayoutManager instance for which "addAreas" is performed.
@@ -54,19 +39,23 @@ public final class AreaAdditionUtil {
      */
     public static void addAreas(BlockStackingLayoutManager bslm,
             PositionIterator parentIter, LayoutContext layoutContext) {
-        LayoutManager childLM = null;
+        LayoutManager childLM;
         LayoutContext lc = new LayoutContext(0);
         LayoutManager firstLM = null;
         LayoutManager lastLM = null;
         Position firstPos = null;
         Position lastPos = null;
 
+        if (bslm != null) {
+            bslm.addId();
+        }
+        
         // "unwrap" the NonLeafPositions stored in parentIter
         // and put them in a new list;
-        LinkedList positionList = new LinkedList();
+        LinkedList<Position> positionList = new LinkedList<Position>();
         Position pos;
         while (parentIter.hasNext()) {
-            pos = (Position)parentIter.next();
+            pos = parentIter.next();
             if (pos == null) {
                 continue;
             }
@@ -78,8 +67,8 @@ public final class AreaAdditionUtil {
             }
             if (pos instanceof NonLeafPosition) {
                 // pos was created by a child of this FlowLM
-                positionList.add(((NonLeafPosition) pos).getPosition());
-                lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+                positionList.add(pos.getPosition());
+                lastLM = (pos.getPosition().getLM());
                 if (firstLM == null) {
                     firstLM = lastLM;
                 }
@@ -104,7 +93,7 @@ public final class AreaAdditionUtil {
                     bslm.isLast(lastPos));
         }
 
-        StackingIter childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
 
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             // TODO vh: the test above might be problematic in some cases. See comment in
@@ -129,6 +118,7 @@ public final class AreaAdditionUtil {
                     false,
                     bslm.isFirst(firstPos),
                     bslm.isLast(lastPos));
+            bslm.checkEndOfLayout(lastPos);
         }