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 15:42:30 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/list ListItemLayoutManager.java ListBlockLayoutManager.java

jeremias    2005/05/24 06:42:30

  Modified:    src/java/org/apache/fop/layoutmgr/list
                        ListItemLayoutManager.java
                        ListBlockLayoutManager.java
  Log:
  keep-with-next|previous on lists.
  
  Revision  Changes    Path
  1.23      +40 -4     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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ListItemLayoutManager.java	24 May 2005 09:41:32 -0000	1.22
  +++ ListItemLayoutManager.java	24 May 2005 13:42:30 -0000	1.23
  @@ -62,6 +62,9 @@
       private MinOptMax spaceBefore;
       private MinOptMax spaceAfter;
       
  +    private boolean keepWithNextPendingOnLabel;
  +    private boolean keepWithNextPendingOnBody;
  +    
       /*
       private class ItemPosition extends LeafPosition {
           protected List cellBreaks;
  @@ -156,12 +159,25 @@
       /** @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 @@
               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 @@
           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 @@
               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));
  
  
  
  1.16      +1 -0      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ListBlockLayoutManager.java	24 May 2005 09:41:32 -0000	1.15
  +++ ListBlockLayoutManager.java	24 May 2005 13:42:30 -0000	1.16
  @@ -101,6 +101,7 @@
           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);
  
  
  

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