]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
keep-with-next|previous on lists.
authorJeremias Maerki <jeremias@apache.org>
Tue, 24 May 2005 13:42:30 +0000 (13:42 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 24 May 2005 13:42:30 +0000 (13:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198686 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java

index af58646b49ee2f7215724386b706cd97d3d3b9de..848d1500205f0256c2a0481846c696300f0871f2 100644 (file)
@@ -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);
index e2d8712a9e5d52e262cb333d3c6bd374d662fd20..05efd5548a55770d2b367fab121de365335775f8 100644 (file)
@@ -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));