]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix for special case when markers weren't added correctly. This happens when a...
authorJeremias Maerki <jeremias@apache.org>
Tue, 1 Feb 2005 14:18:28 +0000 (14:18 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 1 Feb 2005 14:18:28 +0000 (14:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198356 13f79535-47bb-0310-9956-ffa450edef68

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

index 81208cdc8aed90d4a37821289c7764cb086c9a98..0cc6a557af5afc7d158064a708e9570977395b8b 100644 (file)
@@ -33,6 +33,9 @@ import org.apache.fop.traits.MinOptMax;
  * LayoutManager for a block FO.
  */
 public class BlockLayoutManager extends BlockStackingLayoutManager {
+    
+    private static final int FINISHED_LEAF_POS = -2;
+    
     private org.apache.fop.fo.flow.Block fobj;
     
     private Block curBlockArea;
@@ -270,7 +273,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             }
         }
         setFinished(true);
-        BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, -2));
+        BreakPoss breakPoss = new BreakPoss(new LeafPosition(this, FINISHED_LEAF_POS));
         breakPoss.setStackingSize(stackSize);
         return breakPoss;
     }
@@ -290,34 +293,32 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         addID(fobj.getId());
         addMarkers(true, true);
 
-        LayoutManager childLM;
-        LayoutContext lc = new LayoutContext(0);
-        while (parentIter.hasNext()) {
-            LeafPosition lfp = (LeafPosition) parentIter.next();
-            if (lfp.getLeafPos() == -2) {
-                curBlockArea = null;
-                flush();
-                return;
-            }
-            // Add the block areas to Area
-            PositionIterator breakPosIter =
-              new BreakPossPosIter(childBreaks, iStartPos,
-                                   lfp.getLeafPos() + 1);
-            iStartPos = lfp.getLeafPos() + 1;
-            while ((childLM = breakPosIter.getNextChildLM()) != null) {
-                childLM.addAreas(breakPosIter, lc);
+        try {
+            LayoutManager childLM;
+            LayoutContext lc = new LayoutContext(0);
+            while (parentIter.hasNext()) {
+                LeafPosition lfp = (LeafPosition) parentIter.next();
+                if (lfp.getLeafPos() == FINISHED_LEAF_POS) {
+                    return;
+                }
+                // Add the block areas to Area
+                PositionIterator breakPosIter 
+                    = new BreakPossPosIter(childBreaks, iStartPos,
+                                       lfp.getLeafPos() + 1);
+                iStartPos = lfp.getLeafPos() + 1;
+                while ((childLM = breakPosIter.getNextChildLM()) != null) {
+                    childLM.addAreas(breakPosIter, lc);
+                }
             }
+        } finally {
+            addMarkers(false, true);
+            flush();
+
+            // if adjusted space after
+            foBlockSpaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
+            addBlockSpacing(adjust, foBlockSpaceAfter);
+            curBlockArea = null;
         }
-
-        addMarkers(false, true);
-
-        flush();
-
-        // if adjusted space after
-        foBlockSpaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
-        addBlockSpacing(adjust, foBlockSpaceAfter);
-
-        curBlockArea = null;
     }
 
     /**