You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/05/24 11:41:32 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr FlowLayoutManager.java BlockStackingLayoutManager.java

jeremias    2005/05/24 02:41:32

  Modified:    src/java/org/apache/fop/layoutmgr/table
                        TableLayoutManager.java TableStepper.java
                        GridUnit.java Cell.java
                        TableContentLayoutManager.java
               src/java/org/apache/fop/layoutmgr/list
                        ListItemLayoutManager.java Item.java
                        ListBlockLayoutManager.java
               src/java/org/apache/fop/layoutmgr FlowLayoutManager.java
                        BlockStackingLayoutManager.java
  Log:
  Modify keep-with-next and keep-with-previous handling to support "level-hopping" (see keep-with-next1a and keep-with-previous1a)
  Full keep handling for tables (there's a remaning problem with keep-with-previous)
  keep-together support for lists.
  
  Revision  Changes    Path
  1.24      +8 -0      xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
  
  Index: TableLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- TableLayoutManager.java	23 May 2005 07:43:05 -0000	1.23
  +++ TableLayoutManager.java	24 May 2005 09:41:32 -0000	1.24
  @@ -182,6 +182,14 @@
   
           contentLM = new TableContentLayoutManager(this);
           returnedList = contentLM.getNextKnuthElements(childLC, alignment);
  +        if (childLC.isKeepWithNextPending()) {
  +            log.debug("TableContentLM signals pending keep-with-next");
  +            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +        }
  +        if (childLC.isKeepWithPreviousPending()) {
  +            log.debug("TableContentLM signals pending keep-with-previous");
  +            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +        }
           log.debug(returnedList);
           
           if (returnedList.size() == 1
  
  
  
  1.6       +43 -3     xml-fop/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
  
  Index: TableStepper.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableStepper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableStepper.java	23 May 2005 13:52:26 -0000	1.5
  +++ TableStepper.java	24 May 2005 09:41:32 -0000	1.6
  @@ -29,6 +29,7 @@
   import org.apache.fop.layoutmgr.KnuthBox;
   import org.apache.fop.layoutmgr.KnuthElement;
   import org.apache.fop.layoutmgr.KnuthPenalty;
  +import org.apache.fop.layoutmgr.LayoutContext;
   import org.apache.fop.layoutmgr.table.TableContentLayoutManager.GridUnitPart;
   import org.apache.fop.layoutmgr.table.TableContentLayoutManager.TableContentPosition;
   import org.apache.fop.layoutmgr.table.TableContentLayoutManager.TableHFPenaltyPosition;
  @@ -55,6 +56,7 @@
       private int[] borderBefore;
       private int[] borderAfter;
       private boolean rowBacktrackForLastStep;
  +    private boolean[] keepWithNextSignals;
       
       /**
        * Main constructor
  @@ -74,6 +76,7 @@
           baseWidth = new int[columnCount];
           borderBefore = new int[columnCount];
           borderAfter = new int[columnCount];
  +        keepWithNextSignals = new boolean[columnCount];
           Arrays.fill(end, -1);
       }
       
  @@ -165,6 +168,7 @@
               end[column] = -1;
               widths[column] = 0;
               startRow[column] = activeRow;
  +            keepWithNextSignals[column] = false;
           }
       }
       
  @@ -176,18 +180,21 @@
   
       /**
        * Creates the combined element list for a row group.
  +     * @param context Active LayoutContext
        * @param rowGroup the row group
        * @param maxColumnCount the maximum number of columns to expect
        * @param bodyType Indicates what type of body is processed (boder, header or footer)
        * @return the combined element list
        */
  -    public LinkedList getCombinedKnuthElementsForRowGroup( 
  +    public LinkedList getCombinedKnuthElementsForRowGroup(
  +            LayoutContext context,
               EffRow[] rowGroup, int maxColumnCount, int bodyType) {
           this.rowGroup = rowGroup;
           setup(maxColumnCount);
           initializeElementLists();
           calcTotalHeight();
           
  +        boolean signalKeepWithNext = false;
           int laststep = 0;
           int step;
           int addedBoxLen = 0;
  @@ -217,6 +224,30 @@
                       } else {
                           gridUnitParts.add(new GridUnitPart(pgu, start[i], end[i]));
                       }
  +                    if (end[i] + 1 == elementLists[i].size()) {
  +                        if (pgu.getFlag(GridUnit.KEEP_WITH_NEXT_PENDING)) {
  +                            log.debug("PGU has pending keep-with-next");
  +                            keepWithNextSignals[i] = true;
  +                        }
  +                        if (pgu.getRow() != null && pgu.getRow().mustKeepWithNext()) {
  +                            log.debug("table-row causes keep-with-next");
  +                            keepWithNextSignals[i] = true;
  +                        }
  +                    }
  +                    if (start[i] == 0 && end[i] >= 0) {
  +                        if (pgu.getFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING)) {
  +                            log.debug("PGU has pending keep-with-previous");
  +                            if (returnList.size() == 0) {
  +                                context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +                            }
  +                        }
  +                        if (pgu.getRow() != null && pgu.getRow().mustKeepWithPrevious()) {
  +                            log.debug("table-row causes keep-with-previous");
  +                            if (returnList.size() == 0) {
  +                                context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +                            }
  +                        }
  +                    }
                   }
               }
               //log.debug(">>> guPARTS: " + gridUnitParts);
  @@ -245,7 +276,11 @@
                   }
               }
               int p = 0;
  -            if (getTableLM().mustKeepTogether()) {
  +            signalKeepWithNext = false;
  +            for (int i = 0; i < start.length; i++) {
  +                signalKeepWithNext |= keepWithNextSignals[i];
  +            }
  +            if (signalKeepWithNext || getTableLM().mustKeepTogether()) {
                   p = KnuthPenalty.INFINITE;
               }
               returnList.add(new KnuthPenalty(effPenaltyLen, p, false, penaltyPos, false));
  @@ -261,6 +296,11 @@
                   activeRow++;
               }
           }
  +        if (signalKeepWithNext) {
  +            //Last step signalled a keep-with-next. Since the last penalty will be removed,
  +            //we have to signal the still pending last keep-with-next using the LayoutContext.
  +            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +        }
           return returnList;
       }
       
  
  
  
  1.3       +5 -1      xml-fop/src/java/org/apache/fop/layoutmgr/table/GridUnit.java
  
  Index: GridUnit.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/GridUnit.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GridUnit.java	13 May 2005 19:16:53 -0000	1.2
  +++ GridUnit.java	24 May 2005 09:41:32 -0000	1.3
  @@ -44,6 +44,10 @@
       public static final int LAST_IN_BODY = 4;
       /** Indicates that the grid unit is in the last row (context: table). */
       public static final int LAST_IN_TABLE = 5;
  +    /** Indicates that the primary grid unit has a pending keep-with-next. */
  +    public static final int KEEP_WITH_NEXT_PENDING = 6;
  +    /** Indicates that the primary grid unit has a pending keep-with-previous. */
  +    public static final int KEEP_WITH_PREVIOUS_PENDING = 7;
       
       /** Primary grid unit */
       private PrimaryGridUnit primary;
  
  
  
  1.31      +18 -2     xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java
  
  Index: Cell.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Cell.java	23 May 2005 13:02:41 -0000	1.30
  +++ Cell.java	24 May 2005 09:41:32 -0000	1.31
  @@ -168,6 +168,14 @@
   
               // get elements from curLM
               returnedList = curLM.getNextKnuthElements(childLC, alignment);
  +            if (childLC.isKeepWithNextPending()) {
  +                log.debug("child LM signals pending keep with next");
  +            }
  +            if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
  +                context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +                childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
  +            }
  +            
               if (returnedList.size() == 1
                       && ((KnuthElement) returnedList.getFirst()).isPenalty()
                       && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
  @@ -192,8 +200,11 @@
                       // there is a block handled by prevLM
                       // before the one handled by curLM
                       if (mustKeepTogether() 
  -                            || prevLM.mustKeepWithNext()
  -                            || curLM.mustKeepWithPrevious()) {
  +                            || context.isKeepWithNextPending()
  +                            || childLC.isKeepWithPreviousPending()) {
  +                        //Clear keep pending flag
  +                        context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                        childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
                           // add an infinite penalty to forbid a break between
                           // blocks
                           contentList.add(new KnuthPenalty(0,
  @@ -230,6 +241,11 @@
                       return returnList;
                   }
               }
  +            if (childLC.isKeepWithNextPending()) {
  +                //Clear and propagate
  +                childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +            }
               prevLM = curLM;
           }
   
  
  
  
  1.10      +27 -2     xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
  
  Index: TableContentLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TableContentLayoutManager.java	23 May 2005 13:52:26 -0000	1.9
  +++ TableContentLayoutManager.java	24 May 2005 09:41:32 -0000	1.10
  @@ -36,6 +36,7 @@
   import org.apache.fop.layoutmgr.ElementListUtils;
   import org.apache.fop.layoutmgr.KnuthBox;
   import org.apache.fop.layoutmgr.KnuthElement;
  +import org.apache.fop.layoutmgr.KnuthPenalty;
   import org.apache.fop.layoutmgr.KnuthPossPosIter;
   import org.apache.fop.layoutmgr.LayoutContext;
   import org.apache.fop.layoutmgr.LayoutManager;
  @@ -193,6 +194,20 @@
               }
               createElementsForRowGroup(context, alignment, bodyType, 
                           returnList, rowGroup);
  +            if (context.isKeepWithNextPending()) {
  +                log.debug("child LM (row group) signals pending keep-with-next");
  +            }
  +            if (context.isKeepWithPreviousPending()) {
  +                log.debug("child LM (row group) signals pending keep-with-previous");
  +                if (returnList.size() > 0) {
  +                    //Modify last penalty
  +                    KnuthElement last = (KnuthElement)returnList.getLast();
  +                    if (last.isPenalty()) {
  +                        KnuthPenalty pen = (KnuthPenalty)last;
  +                        pen.setP(KnuthPenalty.INFINITE);
  +                    }
  +                }
  +            }
           }
           
           if (returnList.size() > 0) {
  @@ -381,6 +396,15 @@
                                                   childLC, alignment);
                           primary.setElements(elems);
                           ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
  +                        
  +                        if (childLC.isKeepWithNextPending()) {
  +                            log.debug("child LM signals pending keep-with-next");
  +                            primary.setFlag(GridUnit.KEEP_WITH_NEXT_PENDING, true);
  +                        }
  +                        if (childLC.isKeepWithPreviousPending()) {
  +                            log.debug("child LM signals pending keep-with-previous");
  +                            primary.setFlag(GridUnit.KEEP_WITH_PREVIOUS_PENDING, true);
  +                        }
                       }
   
                       
  @@ -446,9 +470,10 @@
                   log.debug("  height=" + rowHeights[i] + " explicit=" + explicitRowHeights[i]);
               }
           }
  +        //TODO It may make sense to reuse the stepper since it allocates quite some space
           TableStepper stepper = new TableStepper(this);
           LinkedList returnedList = stepper.getCombinedKnuthElementsForRowGroup(
  -                rowGroup, maxColumnCount, bodyType);
  +                context, rowGroup, maxColumnCount, bodyType);
           if (returnedList != null) {
               returnList.addAll(returnedList);
           }
  
  
  
  1.22      +51 -19    xml-fop/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
  
  Index: ListItemLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ListItemLayoutManager.java	17 May 2005 17:00:24 -0000	1.21
  +++ ListItemLayoutManager.java	24 May 2005 09:41:32 -0000	1.22
  @@ -21,9 +21,9 @@
   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.LayoutManager;
  -import org.apache.fop.layoutmgr.LeafPosition;
   import org.apache.fop.layoutmgr.LayoutContext;
   import org.apache.fop.layoutmgr.PositionIterator;
   import org.apache.fop.layoutmgr.Position;
  @@ -48,8 +48,6 @@
    * The list item contains a list item label and a list item body.
    */
   public class ListItemLayoutManager extends BlockStackingLayoutManager {
  -    private ListItem fobj;
  -    
       private Item label;
       private Item body;
   
  @@ -64,13 +62,14 @@
       private MinOptMax spaceBefore;
       private MinOptMax spaceAfter;
       
  +    /*
       private class ItemPosition extends LeafPosition {
           protected List cellBreaks;
           protected ItemPosition(LayoutManager lm, int pos, List l) {
               super(lm, pos);
               cellBreaks = l;
           }
  -    }
  +    }*/
   
       private class ListItemPosition extends Position {
           private int iLabelFirstIndex;
  @@ -110,12 +109,19 @@
        */
       public ListItemLayoutManager(ListItem node) {
           super(node);
  -        fobj = node;
           setLabel(node.getLabel());
           setBody(node.getBody());
       }
   
       /**
  +     * Convenience method.
  +     * @return the ListBlock node
  +     */
  +    protected ListItem getListItemFO() {
  +        return (ListItem)fobj;
  +    }
  +
  +    /**
        * Create a LM for the fo:list-item-label object
        * @param node the fo:list-item-label FO
        */
  @@ -136,20 +142,18 @@
       /** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */
       protected void initProperties() {
           super.initProperties();
  -        spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
  -        spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
  +        spaceBefore = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceBefore).getSpace();
  +        spaceAfter = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceAfter).getSpace();
       }
   
       private int getIPIndents() {
           int iIndents = 0;
  -        iIndents += fobj.getCommonMarginBlock().startIndent.getValue();
  -        iIndents += fobj.getCommonMarginBlock().endIndent.getValue();
  +        iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue();
  +        iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue();
           return iIndents;
       }
       
  -    /**
  -     * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
  -     */
  +    /** @see org.apache.fop.layoutmgr.LayoutManager */
       public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
           referenceIPD = context.getRefIPD();
   
  @@ -207,7 +211,11 @@
                       start[0], end[0], start[1], end[1]);
               returnList.add(new KnuthBox(boxHeight, stepPosition, false));
               if (addedBoxHeight < totalHeight) {
  -                returnList.add(new KnuthPenalty(penaltyHeight, 0, false, stepPosition, false));
  +                int p = 0;
  +                if (mustKeepTogether()) {
  +                    p = KnuthPenalty.INFINITE;
  +                }
  +                returnList.add(new KnuthPenalty(penaltyHeight, p, false, stepPosition, false));
               }
           }
   
  @@ -373,7 +381,7 @@
           addBlockSpacing(adjust, spaceBefore);
           spaceBefore = null;
   
  -        getPSLM().addIDToPage(fobj.getId());
  +        getPSLM().addIDToPage(getListItemFO().getId());
   
           LayoutContext lc = new LayoutContext(0);
   
  @@ -469,13 +477,16 @@
               /*Area parentArea =*/ parentLM.getParentArea(curBlockArea);
               
               // set traits
  -            TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
  -            TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
  +            TraitSetter.addBorders(curBlockArea, 
  +                    getListItemFO().getCommonBorderPaddingBackground());
  +            TraitSetter.addBackground(curBlockArea, 
  +                    getListItemFO().getCommonBorderPaddingBackground());
               TraitSetter.addMargins(curBlockArea,
  -                    fobj.getCommonBorderPaddingBackground(), 
  -                    fobj.getCommonMarginBlock());
  +                    getListItemFO().getCommonBorderPaddingBackground(), 
  +                    getListItemFO().getCommonMarginBlock());
               TraitSetter.addBreaks(curBlockArea, 
  -                    fobj.getBreakBefore(), fobj.getBreakAfter());
  +                    getListItemFO().getBreakBefore(), 
  +                    getListItemFO().getBreakAfter());
               
               int contentIPD = referenceIPD - getIPIndents();
               curBlockArea.setIPD(contentIPD);
  @@ -508,5 +519,26 @@
               reset(null);
           }
       }
  +    
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() */
  +    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();
  +    }
  +
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious() */
  +    public boolean mustKeepWithPrevious() {
  +        return !getListItemFO().getKeepWithPrevious().getWithinPage().isAuto()
  +            || !getListItemFO().getKeepWithPrevious().getWithinColumn().isAuto();
  +    }
  +
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext() */
  +    public boolean mustKeepWithNext() {
  +        return !getListItemFO().getKeepWithNext().getWithinPage().isAuto()
  +                || !getListItemFO().getKeepWithNext().getWithinColumn().isAuto();
  +    }
  +
   }
   
  
  
  
  1.15      +24 -22    xml-fop/src/java/org/apache/fop/layoutmgr/list/Item.java
  
  Index: Item.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/list/Item.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Item.java	17 May 2005 17:00:24 -0000	1.14
  +++ Item.java	24 May 2005 09:41:32 -0000	1.15
  @@ -18,9 +18,10 @@
    
   package org.apache.fop.layoutmgr.list;
   
  -import org.apache.fop.fo.FObj;
  +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.LayoutManager;
   import org.apache.fop.layoutmgr.LayoutContext;
  @@ -30,17 +31,14 @@
   import org.apache.fop.area.Area;
   import org.apache.fop.area.Block;
   
  -import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
   import java.util.LinkedList;
   
   /**
  - * LayoutManager for a table-cell FO.
  - * A cell contains blocks. These blocks fill the cell.
  + * LayoutManager for a list-item-label or list-item-body FO.
    */
   public class Item extends BlockStackingLayoutManager {
  -    private FObj fobj;
   
       private Block curBlockArea;
   
  @@ -63,21 +61,29 @@
   
       /**
        * Create a new Cell layout manager.
  +     * @param node list-item-label node
        */
       public Item(ListItemLabel node) {
           super(node);
  -        fobj = node;
       }
   
       /**
        * Create a new Cell layout manager.
  +     * @param node list-item-body node
        */
       public Item(ListItemBody node) {
           super(node);
  -        fobj = node;
       }
   
       /**
  +     * Convenience method.
  +     * @return the ListBlock node
  +     */
  +    protected AbstractListItemPart getPartFO() {
  +        return (AbstractListItemPart)fobj;
  +    }
  +    
  +    /**
        * Set the x offset of this list item.
        * This offset is used to set the absolute position
        * of the list item within the parent block area.
  @@ -88,6 +94,7 @@
           xoffset = off;
       }
   
  +    /** @see org.apache.fop.layoutmgr.LayoutManager#getChangedKnuthElements(java.util.List, int) */
       public LinkedList getChangedKnuthElements(List oldList, int alignment) {
           //log.debug("  Item.getChanged>");
           return super.getChangedKnuthElements(oldList, alignment);
  @@ -105,12 +112,7 @@
                            LayoutContext layoutContext) {
           getParentArea(null);
           
  -        int nameId = fobj.getNameId();
  -        if (nameId == FO_LIST_ITEM_LABEL) {
  -            getPSLM().addIDToPage(((ListItemLabel) fobj).getId());
  -        } else if (nameId == FO_LIST_ITEM_BODY) {
  -            getPSLM().addIDToPage(((ListItemBody) fobj).getId());
  -        }
  +        getPSLM().addIDToPage(getPartFO().getId());
   
           LayoutManager childLM = null;
           LayoutContext lc = new LayoutContext(0);
  @@ -144,15 +146,6 @@
               childLM.addAreas(childPosIter, lc);
           }
   
  -        /*
  -        if (borderProps != null) {
  -            TraitSetter.addBorders(curBlockArea, borderProps);
  -        }
  -        if (backgroundProps != null) {
  -            TraitSetter.addBackground(curBlockArea, backgroundProps);
  -        }
  -        */
  -
           flush();
   
           curBlockArea = null;
  @@ -214,5 +207,14 @@
               //reset(resetPos);
           }
       }
  +    
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() */
  +    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();
  +    }
  +
   }
   
  
  
  
  1.15      +43 -13    xml-fop/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
  
  Index: ListBlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ListBlockLayoutManager.java	17 May 2005 17:00:24 -0000	1.14
  +++ ListBlockLayoutManager.java	24 May 2005 09:41:32 -0000	1.15
  @@ -19,6 +19,7 @@
   package org.apache.fop.layoutmgr.list;
   
   import org.apache.fop.fo.flow.ListBlock;
  +import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
   import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.LayoutContext;
  @@ -41,8 +42,6 @@
    * the list block area..
    */
   public class ListBlockLayoutManager extends BlockStackingLayoutManager {
  -    private ListBlock fobj;
  -    
       private Block curBlockArea;
   
       //TODO space-before|after: handle space-resolution rules
  @@ -78,20 +77,27 @@
        */
       public ListBlockLayoutManager(ListBlock node) {
           super(node);
  -        fobj = node;
  +    }
  +
  +    /**
  +     * Convenience method.
  +     * @return the ListBlock node
  +     */
  +    protected ListBlock getListBlockFO() {
  +        return (ListBlock)fobj;
       }
   
       /** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */
       protected void initProperties() {
           super.initProperties();
  -        spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
  -        spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
  +        spaceBefore = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceBefore).getSpace();
  +        spaceAfter = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceAfter).getSpace();
       }
   
       private int getIPIndents() {
           int iIndents = 0;
  -        iIndents += fobj.getCommonMarginBlock().startIndent.getValue();
  -        iIndents += fobj.getCommonMarginBlock().endIndent.getValue();
  +        iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue();
  +        iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue();
           return iIndents;
       }
       
  @@ -116,7 +122,7 @@
           addBlockSpacing(adjust, spaceBefore);
           spaceBefore = null;
           
  -        getPSLM().addIDToPage(fobj.getId());
  +        getPSLM().addIDToPage(getListBlockFO().getId());
   
           // the list block contains areas stacked from each list item
   
  @@ -181,13 +187,16 @@
               /*Area parentArea =*/ parentLM.getParentArea(curBlockArea);
   
               // set traits
  -            TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
  -            TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
  +            TraitSetter.addBorders(curBlockArea, 
  +                    getListBlockFO().getCommonBorderPaddingBackground());
  +            TraitSetter.addBackground(curBlockArea, 
  +                    getListBlockFO().getCommonBorderPaddingBackground());
               TraitSetter.addMargins(curBlockArea,
  -                    fobj.getCommonBorderPaddingBackground(), 
  -                    fobj.getCommonMarginBlock());
  +                    getListBlockFO().getCommonBorderPaddingBackground(), 
  +                    getListBlockFO().getCommonMarginBlock());
               TraitSetter.addBreaks(curBlockArea, 
  -                    fobj.getBreakBefore(), fobj.getBreakAfter());
  +                    getListBlockFO().getBreakBefore(), 
  +                    getListBlockFO().getBreakAfter());
               
               int contentIPD = referenceIPD - getIPIndents();
               curBlockArea.setIPD(contentIPD);
  @@ -220,5 +229,26 @@
               //TODO Something to put here?
           }
       }
  +    
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() */
  +    public boolean mustKeepTogether() {
  +        //TODO Keeps will have to be more sophisticated sooner or later
  +        return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() 
  +                || !getListBlockFO().getKeepTogether().getWithinPage().isAuto()
  +                || !getListBlockFO().getKeepTogether().getWithinColumn().isAuto();
  +    }
  +
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious() */
  +    public boolean mustKeepWithPrevious() {
  +        return !getListBlockFO().getKeepWithPrevious().getWithinPage().isAuto()
  +            || !getListBlockFO().getKeepWithPrevious().getWithinColumn().isAuto();
  +    }
  +
  +    /** @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext() */
  +    public boolean mustKeepWithNext() {
  +        return !getListBlockFO().getKeepWithNext().getWithinPage().isAuto()
  +                || !getListBlockFO().getKeepWithNext().getWithinColumn().isAuto();
  +    }
  +
   }
   
  
  
  
  1.17      +14 -2     xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
  
  Index: FlowLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FlowLayoutManager.java	18 May 2005 15:25:52 -0000	1.16
  +++ FlowLayoutManager.java	24 May 2005 09:41:32 -0000	1.17
  @@ -106,6 +106,10 @@
               // get elements from curLM
               returnedList = curLM.getNextKnuthElements(childLC, alignment);
               //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size());
  +            if (returnList.size() == 0 && childLC.isKeepWithPreviousPending()) {
  +                context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +                childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
  +            }
   
               // "wrap" the Position inside each element
               LinkedList tempList = returnedList;
  @@ -121,8 +125,11 @@
               } else {
                   if (returnList.size() > 0) {
                       // there is a block before this one
  -                    if (prevLM.mustKeepWithNext()
  -                        || curLM.mustKeepWithPrevious()) {
  +                    if (context.isKeepWithNextPending()
  +                            || childLC.isKeepWithPreviousPending()) {
  +                        //Clear pending keep flag
  +                        context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                        childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
                           // add an infinite penalty to forbid a break between blocks
                           returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, 
                                   new Position(this), false));
  @@ -142,6 +149,11 @@
                       }
                   }
               }
  +            if (childLC.isKeepWithNextPending()) {
  +                //Clear and propagate
  +                childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +            }
               prevLM = curLM;
           }
   
  
  
  
  1.18      +21 -2     xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
  
  Index: BlockStackingLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- BlockStackingLayoutManager.java	18 May 2005 15:23:09 -0000	1.17
  +++ BlockStackingLayoutManager.java	24 May 2005 09:41:32 -0000	1.18
  @@ -234,6 +234,10 @@
   
               // get elements from curLM
               returnedList = curLM.getNextKnuthElements(childLC, alignment);
  +            if (contentList.size() == 0 && childLC.isKeepWithPreviousPending()) {
  +                context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +                childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
  +            }
               if (returnedList != null
                       && returnedList.size() == 1
                       && ((KnuthElement) returnedList.getFirst()).isPenalty()
  @@ -267,8 +271,11 @@
                       // there is a block handled by prevLM
                       // before the one handled by curLM
                       if (mustKeepTogether() 
  -                            || prevLM.mustKeepWithNext()
  -                            || curLM.mustKeepWithPrevious()) {
  +                            || context.isKeepWithNextPending()
  +                            || childLC.isKeepWithPreviousPending()) {
  +                        //Clear keep pending flag
  +                        context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                        childLC.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING, false);
                           // add an infinite penalty to forbid a break between
                           // blocks
                           contentList.add(new KnuthPenalty(0,
  @@ -317,6 +324,11 @@
                       return returnList;
                   }*/
               }
  +            if (childLC.isKeepWithNextPending()) {
  +                //Clear and propagate
  +                childLC.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
  +                context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +            }
               prevLM = curLM;
           }
   
  @@ -339,6 +351,13 @@
           addKnuthElementsForSpaceAfter(returnList, returnPosition, alignment);
           addKnuthElementsForBreakAfter(returnList, returnPosition);
   
  +        if (mustKeepWithNext()) {
  +            context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  +        }
  +        if (mustKeepWithPrevious()) {
  +            context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
  +        }
  +        
           setFinished(true);
   
           return returnList;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org