From 4662ada252d10bbba32c9922fa7b8074916fc05a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 1 Feb 2005 14:18:28 +0000 Subject: [PATCH] Bugfix for special case when markers weren't added correctly. This happens when a block is empty except for marker elements. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198356 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/BlockLayoutManager.java | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 81208cdc8..0cc6a557a 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -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; } /** -- 2.39.5