From: Glen Mazza Date: Tue, 11 Nov 2003 04:40:12 +0000 (+0000) Subject: fo:block space-before property now activated only on the first Area.Block object... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1013 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed0e5a7849dac9b78b1b8f3058a9ce212326a85a;p=xmlgraphics-fop.git fo:block space-before property now activated only on the first Area.Block object used in rendering the fo:block. (Previous implementation repeated space-before at the top of every page.) Suggestion from Chris Bowditch. (Space-after property still needs work: renders at the correct places but results in subsequent text overrunning region borders.) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197003 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 0681fdb27..bc82ca467 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -76,6 +76,17 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { private CommonBorderAndPadding borderProps; private CommonBackground backgroundProps; + /* holds the (one-time use) fo:block space-before + and -after properties. Large fo:blocks are split + into multiple Area.Blocks to accomodate the subsequent + regions (pages) they are placed on. space-before + is applied at the beginning of the first + Block and space-after at the end of the last Block + used in rendering the fo:block. + */ + private MinOptMax foBlockSpaceBefore = null; + private MinOptMax foBlockSpaceAfter = null; // not currently implemented + private int lead = 12000; private int lineHeight = 14000; private int follow = 2000; @@ -169,6 +180,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { layoutProps = pm.getLayoutProps(); borderProps = pm.getBorderAndPadding(); backgroundProps = pm.getBackgroundProps(); + foBlockSpaceBefore = layoutProps.spaceBefore.getSpace(); } public BreakPoss getNextBreakPoss(LayoutContext context) { @@ -177,9 +189,13 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { int ipd = context.getRefIPD(); MinOptMax stackSize = new MinOptMax(); - // if starting add space before - stackSize.add(layoutProps.spaceBefore.getSpace()); + if (foBlockSpaceBefore != null) { + // this function called before addAreas(), so + // setting foBlockSpaceBefore = null *in* addAreas() + stackSize.add(foBlockSpaceBefore); + } + BreakPoss lastPos = null; while ((curLM = getChildLM()) != null) { @@ -261,8 +277,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { // if adjusted space before double adjust = layoutContext.getSpaceAdjust(); - addBlockSpacing(adjust, layoutProps.spaceBefore.getSpace()); - + addBlockSpacing(adjust, foBlockSpaceBefore); + foBlockSpaceBefore = null; + addID(); addMarkers(true, true); diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index d712b52f0..3eb468492 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -106,6 +106,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager { * @param minoptmax the min/opt/max value of the spacing */ public void addBlockSpacing(double adjust, MinOptMax minoptmax) { + if (minoptmax == null) { + return; + } int sp = minoptmax.opt; if (adjust > 0) { sp = sp + (int)(adjust * (minoptmax.max - minoptmax.opt));