diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-05-24 13:42:30 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-05-24 13:42:30 +0000 |
commit | 76ac8eb6ba14b24b6209d97d9b665365115fc955 (patch) | |
tree | 9df891c7da260c3ba33fac7acafcdc1b300b1591 /src/java/org/apache/fop/layoutmgr/list | |
parent | a12cdded3fc23c225222a966926d65671dc0593d (diff) | |
download | xmlgraphics-fop-76ac8eb6ba14b24b6209d97d9b665365115fc955.tar.gz xmlgraphics-fop-76ac8eb6ba14b24b6209d97d9b665365115fc955.zip |
keep-with-next|previous on lists.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198686 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/list')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java | 1 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java | 44 |
2 files changed, 41 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index af58646b4..848d15002 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -101,6 +101,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { return iIndents; } + /** @see org.apache.fop.layoutmgr.LayoutManager#getChangedKnuthElements(java.util.List, int) */ public LinkedList getChangedKnuthElements(List oldList, int alignment) { //log.debug("LBLM.getChangedKnuthElements>"); return super.getChangedKnuthElements(oldList, alignment); diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index e2d8712a9..05efd5548 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -62,6 +62,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { private MinOptMax spaceBefore; private MinOptMax spaceAfter; + private boolean keepWithNextPendingOnLabel; + private boolean keepWithNextPendingOnBody; + /* private class ItemPosition extends LeafPosition { protected List cellBreaks; @@ -156,12 +159,25 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { /** @see org.apache.fop.layoutmgr.LayoutManager */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { referenceIPD = context.getRefIPD(); - + LayoutContext childLC; + // label - labelList = label.getNextKnuthElements(context, alignment); + childLC = new LayoutContext(0); + childLC.setRefIPD(context.getRefIPD()); + labelList = label.getNextKnuthElements(childLC, alignment); + if (childLC.isKeepWithPreviousPending()) { + context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); + } + this.keepWithNextPendingOnLabel = childLC.isKeepWithNextPending(); // body - bodyList = body.getNextKnuthElements(context, alignment); + childLC = new LayoutContext(0); + childLC.setRefIPD(context.getRefIPD()); + bodyList = body.getNextKnuthElements(childLC, alignment); + if (childLC.isKeepWithPreviousPending()) { + context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); + } + this.keepWithNextPendingOnBody = childLC.isKeepWithNextPending(); // create a combined list LinkedList returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList); @@ -176,6 +192,13 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition())); returnedList.add(tempElement); } + + if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || mustKeepWithNext()) { + context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING); + } + if (mustKeepWithPrevious()) { + context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); + } setFinished(true); return returnedList; @@ -195,10 +218,23 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { int totalHeight = Math.max(fullHeights[0], fullHeights[1]); int step; int addedBoxHeight = 0; + boolean keepWithNextActive = false; LinkedList returnList = new LinkedList(); while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) { + + if (end[0] + 1 == elementLists[0].size()) { + if (keepWithNextPendingOnLabel) { + keepWithNextActive = true; + } + } + if (end[1] + 1 == elementLists[1].size()) { + if (keepWithNextPendingOnBody) { + keepWithNextActive = true; + } + } + // compute penalty height and box height int penaltyHeight = step + getMaxRemainingHeight(fullHeights, partialHeights) @@ -212,7 +248,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { returnList.add(new KnuthBox(boxHeight, stepPosition, false)); if (addedBoxHeight < totalHeight) { int p = 0; - if (mustKeepTogether()) { + if (keepWithNextActive || mustKeepTogether()) { p = KnuthPenalty.INFINITE; } returnList.add(new KnuthPenalty(penaltyHeight, p, false, stepPosition, false)); |