Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -32,6 +32,7 @@
 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;
@@ -80,8 +81,8 @@
     private MinOptMax effSpaceBefore;
     private MinOptMax effSpaceAfter;
     
-    private boolean keepWithNextPendingOnLabel;
-    private boolean keepWithNextPendingOnBody;
+    private int keepWithNextPendingOnLabel;
+    private int keepWithNextPendingOnBody;
 
     private int listItemHeight;
     
@@ -223,10 +224,8 @@
         SpaceResolver.resolveElementList(labelList);
         ElementListObserver.observe(labelList, "list-item-label", 
label.getPartFO().getId());
         
-        if (childLC.isKeepWithPreviousPending()) {
-            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
-        }
-        this.keepWithNextPendingOnLabel = childLC.isKeepWithNextPending();
+        
context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+        this.keepWithNextPendingOnLabel = childLC.getKeepWithNextPending();
 
         // body
         childLC = new LayoutContext(0);
@@ -239,10 +238,8 @@
         SpaceResolver.resolveElementList(bodyList);
         ElementListObserver.observe(bodyList, "list-item-body", 
body.getPartFO().getId());
         
-        if (childLC.isKeepWithPreviousPending()) {
-            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
-        }
-        this.keepWithNextPendingOnBody = childLC.isKeepWithNextPending();
+        
context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+        this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending();
 
         // create a combined list
         LinkedList returnedList = 
getCombinedKnuthElementsForListItem(labelList, bodyList, context);
@@ -254,12 +251,10 @@
         addKnuthElementsForSpaceAfter(returnList, alignment);
         addKnuthElementsForBreakAfter(returnList, context);
 
-        if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || 
mustKeepWithNext()) {
-            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
-        }
-        if (mustKeepWithPrevious()) {
-            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
-        }
+        context.updateKeepWithNextPending(this.keepWithNextPendingOnLabel);
+        context.updateKeepWithNextPending(this.keepWithNextPendingOnBody);
+        context.updateKeepWithNextPending(getKeepWithNextStrength());
+        context.updateKeepWithPreviousPending(getKeepWithPreviousStrength());
 
         setFinished(true);
         resetSpaces();
@@ -281,21 +276,17 @@
         int totalHeight = Math.max(fullHeights[0], fullHeights[1]);
         int step;
         int addedBoxHeight = 0;
-        boolean keepWithNextActive = false;
+        int keepWithNextActive = BlockLevelLayoutManager.KEEP_AUTO;
 
         LinkedList returnList = new LinkedList();
         while ((step = getNextStep(elementLists, start, end, partialHeights))
                > 0) {
             
             if (end[0] + 1 == elementLists[0].size()) {
-                if (keepWithNextPendingOnLabel) {
-                    keepWithNextActive = true;
-                }
+                keepWithNextActive = Math.max(keepWithNextActive, 
keepWithNextPendingOnLabel);
             }
             if (end[1] + 1 == elementLists[1].size()) {
-                if (keepWithNextPendingOnBody) {
-                    keepWithNextActive = true;
-                }
+                keepWithNextActive = Math.max(keepWithNextActive, 
keepWithNextPendingOnBody);
             }
             
             // compute penalty height and box height
@@ -327,12 +318,12 @@
                     start[0], end[0], start[1], end[1]);
             returnList.add(new KnuthBox(boxHeight, stepPosition, false));
             if (addedBoxHeight < totalHeight) {
+                int strength = BlockLevelLayoutManager.KEEP_AUTO;
+                strength = Math.max(strength, keepWithNextActive);
+                strength = Math.max(strength, getKeepTogetherStrength());
                 int p = stepPenalty;
-                if (keepWithNextActive) {
-                    p = KnuthPenalty.INFINITE;
-                }
-                if (mustKeepTogether()) {
-                    p = Math.max(p, 
KeepUtil.getPenaltyForKeep(getKeepTogetherStrength()));
+                if (p > -KnuthElement.INFINITE) {
+                    p = Math.max(p, KeepUtil.getPenaltyForKeep(strength));
                 }
                 returnList.add(new BreakElement(stepPosition, penaltyHeight, 
p, -1, context));
             }
@@ -637,26 +628,20 @@
 
     /** [EMAIL PROTECTED] */
     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()));
+        int strength = KeepUtil.getCombinedBlockLevelKeepStrength(
+                getListItemFO().getKeepTogether());
         strength = Math.max(strength, getParentKeepTogetherStrength());
         return strength;
     }
 
     /** [EMAIL PROTECTED] */
-    public boolean mustKeepWithPrevious() {
-        //TODO Keeps will have to be more sophisticated sooner or later
-        return !getListItemFO().getKeepWithPrevious().getWithinPage().isAuto()
-            || 
!getListItemFO().getKeepWithPrevious().getWithinColumn().isAuto();
+    public int getKeepWithNextStrength() {
+        return 
KeepUtil.getCombinedBlockLevelKeepStrength(getListItemFO().getKeepWithNext());
     }
 
     /** [EMAIL PROTECTED] */
-    public boolean mustKeepWithNext() {
-        return !getListItemFO().getKeepWithNext().getWithinPage().isAuto()
-                || 
!getListItemFO().getKeepWithNext().getWithinColumn().isAuto();
+    public int getKeepWithPreviousStrength() {
+        return 
KeepUtil.getCombinedBlockLevelKeepStrength(getListItemFO().getKeepWithPrevious());
     }
 
     /** [EMAIL PROTECTED] */

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
 Fri Apr 25 03:56:53 2008
@@ -24,11 +24,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.ConditionalBorder;
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
@@ -70,7 +72,7 @@
     /** True if the next CellPart that will be created will be the last one 
for this cell. */
     private boolean lastCellPart;
 
-    private boolean keepWithNextSignal;
+    private int keepWithNextStrength;
 
     private int spanIndex = 0;
 
@@ -202,7 +204,7 @@
         includedLength = -1;  // Avoid troubles with cells having content of 
zero length
         totalLength = previousRowsLength + 
ElementListUtils.calcContentLength(elementList);
         endRowIndex = rowIndex + pgu.getCell().getNumberRowsSpanned() - 1;
-        keepWithNextSignal = false;
+        keepWithNextStrength = BlockLevelLayoutManager.KEEP_AUTO;
         remainingLength = totalLength - previousRowsLength;
 
         afterNextStep = new Step(previousRowsLength);
@@ -506,14 +508,14 @@
      */
     CellPart createCellPart() {
         if (nextStep.end + 1 == elementList.size()) {
-            keepWithNextSignal = pgu.mustKeepWithNext();
+            keepWithNextStrength = pgu.getKeepWithNextStrength();
             // TODO if keep-with-next is set on the row, must every cell of 
the row
             // contribute some content from children blocks?
             // see 
http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-dev/200802.mbox/
             // [EMAIL PROTECTED]
             // Assuming no, but if yes the following code should enable this 
behaviour
 //            if (pgu.getRow() != null && pgu.getRow().mustKeepWithNext()) {
-//                keepWithNextSignal = true;
+//                keepWithNextSignal = true; //to be converted to integer 
strengths
 //            }
         }
         int bpBeforeFirst;
@@ -536,8 +538,8 @@
         }
     }
 
-    boolean keepWithNextSignal() {
-        return keepWithNextSignal;
+    int getKeepWithNextStrength() {
+        return keepWithNextStrength;
     }
 
 

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
 Fri Apr 25 03:56:53 2008
@@ -29,6 +29,7 @@
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.expr.RelativeNumericProperty;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.properties.TableColLength;
@@ -196,7 +197,9 @@
             Length colWidth = (Length) i.next();
             if (colWidth != null) {
                 sumCols += colWidth.getValue(tlm);
-                if (colWidth instanceof TableColLength) {
+                if (colWidth instanceof RelativeNumericProperty) {
+                    factors += ((RelativeNumericProperty) 
colWidth).getTableUnits();
+                } else if (colWidth instanceof TableColLength) {
                     factors += ((TableColLength) colWidth).getTableUnits();
                 }
             }

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -33,7 +33,6 @@
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.LengthRangeProperty;
-import org.apache.fop.layoutmgr.BlockLevelEventProducer;
 import org.apache.fop.layoutmgr.ElementListObserver;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.MinOptMaxUtil;
@@ -61,10 +60,8 @@
         LinkedList returnList = new LinkedList();
         createElementsForRowGroup(context, alignment, bodyType, returnList);
 
-        context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING,
-                rowGroup[0].mustKeepWithPrevious());
-        context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING,
-                rowGroup[rowGroup.length - 1].mustKeepWithNext());
+        
context.updateKeepWithPreviousPending(rowGroup[0].getKeepWithPreviousStrength());
+        context.updateKeepWithNextPending(rowGroup[rowGroup.length - 
1].getKeepWithNextStrength());
 
         int breakBefore = Constants.EN_AUTO;
         TableRow firstRow = rowGroup[0].getTableRow();

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -49,6 +49,14 @@
     }
 
     /**
+     * Returns the table-and-caption formatting object.
+     * @return the table-and-caption formatting object
+     */
+    public TableAndCaption getTableAndCaptionFO() {
+        return (TableAndCaption)this.fobj;
+    }
+    
+    /**
      * Get the next break possibility.
      *
      * @param context the layout context for getting breaks
@@ -196,13 +204,29 @@
     public int getKeepTogetherStrength() {
         int strength = KEEP_AUTO;
         /* TODO Complete me!
-        strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTableAndCaption().getKeepTogether().getWithinPage()));
-        strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTableAndCaption().getKeepTogether().getWithinColumn()));
+        int strength = KeepUtil.getCombinedBlockLevelKeepStrength(
+                getTableAndCaptionFO().getKeepTogether());
         */
         strength = Math.max(strength, getParentKeepTogetherStrength());
         return strength;
     }    
     
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithNextStrength() {
+        return KEEP_AUTO;
+        /* TODO Complete me!
+        return KeepUtil.getCombinedBlockLevelKeepStrength(
+                getTableAndCaptionFO().getKeepWithNext());
+        */
+    }
+
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithPreviousStrength() {
+        return KEEP_AUTO;
+        /* TODO Complete me!
+        return KeepUtil.getCombinedBlockLevelKeepStrength(
+                getTableAndCaptionFO().getKeepWithPrevious());
+        */
+    }
+
 }

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -47,7 +47,7 @@
     }
 
     /** @return the table-caption FO */
-    public TableCaption getTableCaption() {
+    public TableCaption getTableCaptionFO() {
         return (TableCaption)this.fobj;
     }
     
@@ -201,13 +201,31 @@
         int strength = KEEP_AUTO;
         /* TODO Complete me!
         strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTableCaption().getKeepTogether().getWithinPage()));
+                getTableCaptionFO().getKeepTogether().getWithinPage()));
         strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTableCaption().getKeepTogether().getWithinColumn()));
+                getTableCaptionFO().getKeepTogether().getWithinColumn()));
         */
         strength = Math.max(strength, getParentKeepTogetherStrength());
         return strength;
     }
     
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithNextStrength() {
+        return KEEP_AUTO;
+        /* TODO Complete me!
+        return KeepUtil.getCombinedBlockLevelKeepStrength(
+                getTableCaptionFO().getKeepWithNext());
+        */
+    }
+
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithPreviousStrength() {
+        return KEEP_AUTO;
+        /* TODO Complete me!
+        return KeepUtil.getCombinedBlockLevelKeepStrength(
+                getTableCaptionFO().getKeepWithPrevious());
+        */
+    }
+
 }
 

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -153,8 +153,8 @@
                 log.debug("child LM signals pending keep with next");
             }
             if (contentList.size() == 0 && 
childLC.isKeepWithPreviousPending()) {
-                primaryGridUnit.setKeepWithPrevious();
-                childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, 
false);
+                
primaryGridUnit.setKeepWithPreviousStrength(childLC.getKeepWithPreviousPending());
+                childLC.clearKeepWithPreviousPending();
             }
 
             if (prevLM != null) {
@@ -169,14 +169,12 @@
             }
             if (childLC.isKeepWithNextPending()) {
                 //Clear and propagate
-                childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
-                context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
+                
context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
+                childLC.clearKeepWithNextPending();
             }
             prevLM = curLM;
         }
-        if (context.isKeepWithNextPending()) {
-            primaryGridUnit.setKeepWithNext();
-        }
+        
primaryGridUnit.setKeepWithNextStrength(context.getKeepWithNextPending());
 
         returnedList = new LinkedList();
         if (contentList.size() > 0) {
@@ -569,24 +567,15 @@
     }
     
     /** [EMAIL PROTECTED] */
-    public boolean mustKeepWithPrevious() {
-        //TODO Keeps will have to be more sophisticated sooner or later
-        return false; //TODO FIX ME
-        /*
-        return !fobj.getKeepWithPrevious().getWithinPage().isAuto()
-            || !fobj.getKeepWithPrevious().getWithinColumn().isAuto();
-            */
+    public int getKeepWithNextStrength() {
+        return KEEP_AUTO; //TODO FIX ME (table-cell has no keep-with-next!)
     }
 
     /** [EMAIL PROTECTED] */
-    public boolean mustKeepWithNext() {
-        return false; //TODO FIX ME
-        /*
-        return !fobj.getKeepWithNext().getWithinPage().isAuto()
-            || !fobj.getKeepWithNext().getWithinColumn().isAuto();
-            */
+    public int getKeepWithPreviousStrength() {
+        return KEEP_AUTO; //TODO FIX ME (table-cell has no keep-with-previous!)
     }
-
+    
     // --------- Property Resolution related functions --------- //
 
     /**

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -35,6 +35,7 @@
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KeepUtil;
@@ -208,31 +209,37 @@
         LinkedList returnList = new LinkedList();
         EffRow[] rowGroup = iter.getNextRowGroup();
         // TODO homogenize the handling of keeps and breaks
-        context.unsetFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING
-                | LayoutContext.KEEP_WITH_NEXT_PENDING);
+        context.clearKeepsPending();
         context.setBreakBefore(Constants.EN_AUTO);
         context.setBreakAfter(Constants.EN_AUTO);
-        boolean keepWithPrevious = false;
+        int keepWithPrevious = BlockLevelLayoutManager.KEEP_AUTO;
         int breakBefore = Constants.EN_AUTO;
         if (rowGroup != null) {
             RowGroupLayoutManager rowGroupLM = new 
RowGroupLayoutManager(getTableLM(), rowGroup,
                     stepper);
             List nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, 
alignment, bodyType);
-            keepWithPrevious = context.isKeepWithPreviousPending();
-            boolean keepBetween = context.isKeepWithNextPending();
+            keepWithPrevious = Math.max(keepWithPrevious, 
context.getKeepWithPreviousPending());
             breakBefore = context.getBreakBefore();
             int breakBetween = context.getBreakAfter();
             returnList.addAll(nextRowGroupElems);
             while ((rowGroup = iter.getNextRowGroup()) != null) {
                 rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup, 
stepper);
+                
+                //Note previous pending keep-with-next and clear the strength
+                //(as the layout context is reused)
+                int keepWithNextPending = context.getKeepWithNextPending();
+                context.clearKeepWithNextPending();
+                
+                //Get elements for next row group
                 nextRowGroupElems = rowGroupLM.getNextKnuthElements(context, 
alignment, bodyType);
-                int penaltyValue = 0;
-                keepBetween |= context.isKeepWithPreviousPending();
-                if (keepBetween) {
-                    penaltyValue = KnuthElement.INFINITE;
-                }
-                penaltyValue = Math.max(penaltyValue,
-                        
KeepUtil.getPenaltyForKeep(getTableLM().getKeepTogetherStrength()));
+                
+                //Determine keep constraints
+                int penaltyStrength = BlockLevelLayoutManager.KEEP_AUTO;
+                penaltyStrength = Math.max(penaltyStrength, 
keepWithNextPending);
+                penaltyStrength = Math.max(penaltyStrength, 
context.getKeepWithPreviousPending());
+                context.clearKeepWithPreviousPending();
+                penaltyStrength = Math.max(penaltyStrength, 
getTableLM().getKeepTogetherStrength());
+                int penaltyValue = KeepUtil.getPenaltyForKeep(penaltyStrength);
                 
                 breakBetween = BreakUtil.compareBreakClasses(breakBetween,
                         context.getBreakBefore());
@@ -255,10 +262,9 @@
                         penaltyLen, penaltyValue, breakBetween, context));
                 returnList.addAll(nextRowGroupElems);
                 breakBetween = context.getBreakAfter();
-                keepBetween = context.isKeepWithNextPending();
             }
         }
-        context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, 
keepWithPrevious);
+        context.updateKeepWithPreviousPending(keepWithPrevious);
         context.setBreakBefore(breakBefore);
 
         //fox:widow-content-limit

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
 Fri Apr 25 03:56:53 2008
@@ -256,12 +256,11 @@
         log.debug(contentKnuthElements);
         wrapPositionElements(contentKnuthElements, returnList);
 
-        if (mustKeepWithPrevious() || childLC.isKeepWithPreviousPending()) {
-            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
-        }
-        if (mustKeepWithNext() || childLC.isKeepWithNextPending()) {
-            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
-        }
+        context.updateKeepWithPreviousPending(getKeepWithPreviousStrength());
+        
context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
+
+        context.updateKeepWithNextPending(getKeepWithNextStrength());
+        context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
 
         if (getTable().isSeparateBorderModel()) {
             addKnuthElementsForBorderPaddingAfter(returnList, true);
@@ -448,29 +447,19 @@
 
     /** [EMAIL PROTECTED] */
     public int getKeepTogetherStrength() {
-        int strength = KEEP_AUTO;
-        strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTable().getKeepTogether().getWithinPage()));
-        strength = Math.max(strength, KeepUtil.getKeepStrength(
-                getTable().getKeepTogether().getWithinColumn()));
+        int strength = 
KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepTogether());
         strength = Math.max(strength, getParentKeepTogetherStrength());
         return strength;
     }
     
-    /**
-     * [EMAIL PROTECTED]
-     */
-    public boolean mustKeepWithPrevious() {
-        return !getTable().getKeepWithPrevious().getWithinPage().isAuto()
-                || 
!getTable().getKeepWithPrevious().getWithinColumn().isAuto();
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithNextStrength() {
+        return 
KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepWithNext());
     }
 
-    /**
-     * [EMAIL PROTECTED]
-     */
-    public boolean mustKeepWithNext() {
-        return !getTable().getKeepWithNext().getWithinPage().isAuto()
-                || !getTable().getKeepWithNext().getWithinColumn().isAuto();
+    /** [EMAIL PROTECTED] */
+    public int getKeepWithPreviousStrength() {
+        return 
KeepUtil.getCombinedBlockLevelKeepStrength(getTable().getKeepWithPrevious());
     }
 
     // --------- Property Resolution related functions --------- //

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
 Fri Apr 25 03:56:53 2008
@@ -30,9 +30,11 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.KeepUtil;
 import org.apache.fop.layoutmgr.KnuthBox;
+import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.LayoutContext;
@@ -198,11 +200,20 @@
             }
 
             //Put all involved grid units into a list
+            int stepPenalty = 0;
             List cellParts = new java.util.ArrayList(columnCount);
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
                 CellPart part = activeCell.createCellPart();
                 cellParts.add(part);
+                
+                //Record highest penalty value of part
+                if (part.end >= 0) {
+                    KnuthElement endEl = 
(KnuthElement)part.pgu.getElements().get(part.end);
+                    if (endEl instanceof KnuthPenalty) {
+                        stepPenalty = Math.max(stepPenalty, endEl.getP());
+                    }
+                }
             }
 
             //Create elements for step
@@ -230,38 +241,36 @@
                 }
             }
 
-            int p = 0;
-            boolean keepWithNext = false;
+            int strength = BlockLevelLayoutManager.KEEP_AUTO;
             for (Iterator iter = activeCells.iterator(); iter.hasNext();) {
                 ActiveCell activeCell = (ActiveCell) iter.next();
-                keepWithNext |= activeCell.keepWithNextSignal();
-            }
-            if (keepWithNext) {
-                p = KnuthPenalty.INFINITE;
+                strength = Math.max(strength, 
activeCell.getKeepWithNextStrength());
             }
             if (!rowFinished) {
-                p = Math.max(p, KeepUtil.getPenaltyForKeep(
-                        rowGroup[activeRowIndex].getKeepTogetherStrength()));
+                strength = Math.max(strength, 
rowGroup[activeRowIndex].getKeepTogetherStrength());
                 //The above call doesn't take the penalty from the table into 
account, so...
-                p = Math.max(p, KeepUtil.getPenaltyForKeep(
-                        getTableLM().getKeepTogetherStrength()));
+                strength = Math.max(strength, 
getTableLM().getKeepTogetherStrength());
             } else if (activeRowIndex < rowGroup.length - 1) {
-                if (rowGroup[activeRowIndex].mustKeepWithNext()
-                        || rowGroup[activeRowIndex + 
1].mustKeepWithPrevious()) {
-                    p = KnuthPenalty.INFINITE;
-                }
+                strength = Math.max(strength,
+                        rowGroup[activeRowIndex].getKeepWithNextStrength());
+                strength = Math.max(strength,
+                        rowGroup[activeRowIndex + 
1].getKeepWithPreviousStrength());
                 nextBreakClass = BreakUtil.compareBreakClasses(nextBreakClass,
                         rowGroup[activeRowIndex].getBreakAfter());
                 nextBreakClass = BreakUtil.compareBreakClasses(nextBreakClass,
                         rowGroup[activeRowIndex + 1].getBreakBefore());
             }
-            if (nextBreakClass != Constants.EN_AUTO) {
-                log.trace("Forced break encountered");
-                p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in 
XSL 1.0)
-            }
+            int p = KeepUtil.getPenaltyForKeep(strength);
             if (rowHeightSmallerThanFirstStep) {
                 rowHeightSmallerThanFirstStep = false;
                 p = KnuthPenalty.INFINITE;
+            }
+            if (p > -KnuthElement.INFINITE) {
+                p = Math.max(p, stepPenalty);
+            }
+            if (nextBreakClass != Constants.EN_AUTO) {
+                log.trace("Forced break encountered");
+                p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in 
XSL 1.0)
             }
             returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, 
nextBreakClass, context));
             if (penaltyOrGlueLen < 0) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml Fri Apr 25 
03:56:53 2008
@@ -59,6 +59,11 @@
       <action context="Renderers" dev="AC" importance="high" type="add">
         Added de-duplication and externalization support for IOCA and GOCA 
data resource objects.
       </action>
+      <action context="Layout" dev="JM" type="add">
+        Added minimal support for integer keep values on the various keep 
properties on block-level
+        FOs. For now, all integer values are treated the same (i.e. without 
strength distinction).
+        Using integers allows to avoid overflows that can happen when "always" 
is used extensively.
+      </action>
       <action context="Renderers" dev="JM" type="add">
         Added support for rendering pages using JPS (Java Printing System). 
See new example:
         examples/embedding/java/ExamplesFO2JPSPrint.java

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
 Fri Apr 25 03:56:53 2008
@@ -165,18 +165,6 @@
     
<reference>http://www.nabble.com/leaders-with-leader-pattern%3D%22use-content%22-t546244.html</reference>
   </testcase>
   <testcase>
-    <name>keep-with-previous doesn't work in lists</name>
-    <file>list-block_keep-with-previous.xml</file>
-    <description>Keep-with-previous doesn't work inside tables and
-    lists, yet.</description>
-  </testcase>
-  <testcase>
-    <name>keep-with-previous doesn't work in lists</name>
-    <file>list-item_block_keep-with-previous.xml</file>
-    <description>Keep-with-previous doesn't work inside tables and
-    lists, yet.</description>
-  </testcase>
-  <testcase>
     <name>Page breaking doesn't deal with IPD changes</name>
     <file>page-breaking_4.xml</file>
     <description>Page breaking currently doesn't support changing available 
IPD 

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-with-previous.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-with-previous.xml?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-with-previous.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-block_keep-with-previous.xml
 Fri Apr 25 03:56:53 2008
@@ -63,7 +63,6 @@
               </fo:list-item-label>
               <fo:list-item-body start-indent="body-start()">
                 <fo:block>item1</fo:block>
-                <fo:block>item1</fo:block>
               </fo:list-item-body>
             </fo:list-item>
             <fo:list-item keep-with-previous.within-page="always">
@@ -114,8 +113,6 @@
       <box w="14400"/>
       <penalty w="0" p="0"/>
       <!-- list 2 starts -->
-      <box w="14400"/>
-      <penalty w="0" p="INF"/>
       <box w="14400"/>
       <penalty w="0" p="INF"/>
       <box w="14400"/>

Modified: 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-item_block_keep-with-previous.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-item_block_keep-with-previous.xml?rev=651570&r1=651569&r2=651570&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-item_block_keep-with-previous.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/list-item_block_keep-with-previous.xml
 Fri Apr 25 03:56:53 2008
@@ -41,7 +41,6 @@
               </fo:list-item-label>
               <fo:list-item-body start-indent="body-start()">
                 <fo:block>item1</fo:block>
-                <fo:block>item2</fo:block>
               </fo:list-item-body>
             </fo:list-item>
             <fo:list-item>
@@ -85,8 +84,6 @@
       <box w="14400"/>
       <penalty w="0" p="0"/>
       <!-- list 1 starts -->
-      <box w="14400"/>
-      <penalty w="0" p="INF"/>
       <box w="14400"/>
       <penalty w="0" p="INF"/>
       <box w="14400"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to