diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-04-16 08:21:34 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-04-16 08:21:34 +0000 |
commit | 592835167ab8951f61d1590197f646984588d070 (patch) | |
tree | d198bcce1ac27b7413448c765761e879191e52c0 /src/java/org/apache/fop/layoutmgr/list | |
parent | 2bcd566ece9ea8fd6ff996cdb0969d4db5c345a6 (diff) | |
download | xmlgraphics-fop-592835167ab8951f61d1590197f646984588d070.tar.gz xmlgraphics-fop-592835167ab8951f61d1590197f646984588d070.zip |
Merged revisions 648381 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r648381 | jeremias | 2008-04-15 20:18:46 +0100 (Tue, 15 Apr 2008) | 1 line
First part of the implementation of stage 1 for advanced keeps (see Wiki): Integer values are treated differently from "always" values in keep-together.within-column for all block-level FOs.
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@648611 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/list')
3 files changed, 39 insertions, 21 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index c17ddc711..eb64e0bf0 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -32,6 +32,7 @@ import org.apache.fop.fo.flow.ListBlock; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.ElementListUtils; +import org.apache.fop.layoutmgr.KeepUtil; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.NonLeafPosition; @@ -278,15 +279,19 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager } /** {@inheritDoc} */ - public boolean mustKeepTogether() { - //TODO Keeps will have to be more sophisticated sooner or later - return super.mustKeepTogether() - || !getListBlockFO().getKeepTogether().getWithinPage().isAuto() - || !getListBlockFO().getKeepTogether().getWithinColumn().isAuto(); + public int getKeepTogetherStrength() { + int strength = KEEP_AUTO; + strength = Math.max(strength, KeepUtil.getKeepStrength( + getListBlockFO().getKeepTogether().getWithinPage())); + strength = Math.max(strength, KeepUtil.getKeepStrength( + getListBlockFO().getKeepTogether().getWithinColumn())); + strength = Math.max(strength, getParentKeepTogetherStrength()); + return strength; } - + /** {@inheritDoc} */ public boolean mustKeepWithPrevious() { + //TODO Keeps will have to be more sophisticated sooner or later return !getListBlockFO().getKeepWithPrevious().getWithinPage().isAuto() || !getListBlockFO().getKeepWithPrevious().getWithinColumn().isAuto(); } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index 8b0028a8f..be7dbdbba 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java @@ -28,8 +28,8 @@ import org.apache.fop.area.Block; import org.apache.fop.fo.flow.AbstractListItemPart; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; -import org.apache.fop.layoutmgr.BlockLevelLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; +import org.apache.fop.layoutmgr.KeepUtil; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.NonLeafPosition; @@ -221,12 +221,15 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } /** {@inheritDoc} */ - public boolean mustKeepTogether() { - //TODO Keeps will have to be more sophisticated sooner or later - return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() - || !getPartFO().getKeepTogether().getWithinPage().isAuto() - || !getPartFO().getKeepTogether().getWithinColumn().isAuto(); + public int getKeepTogetherStrength() { + int strength = KEEP_AUTO; + strength = Math.max(strength, KeepUtil.getKeepStrength( + getPartFO().getKeepTogether().getWithinPage())); + strength = Math.max(strength, KeepUtil.getKeepStrength( + getPartFO().getKeepTogether().getWithinColumn())); + strength = Math.max(strength, getParentKeepTogetherStrength()); + return strength; } - + } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index c6b5b8cf9..b727f8860 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -32,12 +32,12 @@ import org.apache.fop.area.Block; import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; -import org.apache.fop.layoutmgr.BlockLevelLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListUtils; +import org.apache.fop.layoutmgr.KeepUtil; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPenalty; @@ -305,14 +305,17 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager //Additional penalty height from penalties in the source lists int additionalPenaltyHeight = 0; + int stepPenalty = 0; KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]); if (endEl instanceof KnuthPenalty) { additionalPenaltyHeight = endEl.getW(); + stepPenalty = Math.max(stepPenalty, endEl.getP()); } endEl = (KnuthElement)elementLists[1].get(end[1]); if (endEl instanceof KnuthPenalty) { additionalPenaltyHeight = Math.max( additionalPenaltyHeight, endEl.getW()); + stepPenalty = Math.max(stepPenalty, endEl.getP()); } int boxHeight = step - addedBoxHeight - penaltyHeight; @@ -324,10 +327,13 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager start[0], end[0], start[1], end[1]); returnList.add(new KnuthBox(boxHeight, stepPosition, false)); if (addedBoxHeight < totalHeight) { - int p = 0; - if (keepWithNextActive || mustKeepTogether()) { + int p = stepPenalty; + if (keepWithNextActive) { p = KnuthPenalty.INFINITE; } + if (mustKeepTogether()) { + p = Math.max(p, KeepUtil.getPenaltyForKeep(getKeepTogetherStrength())); + } returnList.add(new BreakElement(stepPosition, penaltyHeight, p, -1, context)); } } @@ -630,15 +636,19 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } /** {@inheritDoc} */ - public boolean mustKeepTogether() { - //TODO Keeps will have to be more sophisticated sooner or later - return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() - || !getListItemFO().getKeepTogether().getWithinPage().isAuto() - || !getListItemFO().getKeepTogether().getWithinColumn().isAuto(); + public int getKeepTogetherStrength() { + int strength = KEEP_AUTO; + strength = Math.max(strength, KeepUtil.getKeepStrength( + getListItemFO().getKeepTogether().getWithinPage())); + strength = Math.max(strength, KeepUtil.getKeepStrength( + getListItemFO().getKeepTogether().getWithinColumn())); + strength = Math.max(strength, getParentKeepTogetherStrength()); + return strength; } /** {@inheritDoc} */ public boolean mustKeepWithPrevious() { + //TODO Keeps will have to be more sophisticated sooner or later return !getListItemFO().getKeepWithPrevious().getWithinPage().isAuto() || !getListItemFO().getKeepWithPrevious().getWithinColumn().isAuto(); } |