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/30 11:11:11 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/table GridUnit.java Cell.java TableLayoutManager.java TableStepper.java EffRow.java TableContentLayoutManager.java

jeremias    2005/05/30 02:11:10

  Modified:    src/java/org/apache/fop/layoutmgr/list
                        ListItemLayoutManager.java Item.java
                        ListBlockLayoutManager.java
               src/java/org/apache/fop/layoutmgr AbstractLayoutManager.java
                        BlockContainerLayoutManager.java
                        FlowLayoutManager.java NonLeafPosition.java
                        BlockStackingLayoutManager.java LayoutManager.java
                        LeafPosition.java Position.java
                        AreaAdditionUtil.java BlockLayoutManager.java
                        BlockLevelLayoutManager.java
                        StaticContentLayoutManager.java
               src/java/org/apache/fop/layoutmgr/table GridUnit.java
                        Cell.java TableLayoutManager.java TableStepper.java
                        EffRow.java TableContentLayoutManager.java
  Log:
  New member variable "index" on Position (used for first/last checks).
  Position numbering implemented in BlockStackingLayoutManager (see member variables: lastGeneratedPosition and smallestPosNumberChecked)
  Use notifyPos to give a Position an index (Don't reuse Position instances that get an index!)
  Flags on TableContentPosition indicating first and last status (see TableStepper).
  New way of determining first/last area implemented on all currently implemented block-level FOs.
  Removed obsolete isBogus() method from LayoutManager.
  Removed duplicate wrapPositionElements() method in FlowLayoutManager.
  Some javadocs here and there.
  
  Revision  Changes    Path
  1.25      +27 -7     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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ListItemLayoutManager.java	25 May 2005 19:16:00 -0000	1.24
  +++ ListItemLayoutManager.java	30 May 2005 09:11:09 -0000	1.25
  @@ -104,6 +104,16 @@
           public int getBodyLastIndex() {
               return iBodyLastIndex;
           }
  +        
  +        /** @see java.lang.Object#toString() */
  +        public String toString() {
  +            StringBuffer sb = new StringBuffer("ListItemPosition:");
  +            sb.append(getIndex()).append("(");
  +            sb.append("label:").append(iLabelFirstIndex).append("-").append(iLabelLastIndex);
  +            sb.append(" body:").append(iBodyFirstIndex).append("-").append(iBodyLastIndex);
  +            sb.append(")");
  +            return sb.toString();
  +        }
       }
   
       /**
  @@ -184,14 +194,8 @@
   
           // "wrap" the Position inside each element
           LinkedList tempList = returnedList;
  -        KnuthElement tempElement;
           returnedList = new LinkedList();
  -        ListIterator listIter = tempList.listIterator();
  -        while (listIter.hasNext()) {
  -            tempElement = (KnuthElement)listIter.next();
  -            tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition()));
  -            returnedList.add(tempElement);
  -        }
  +        wrapPositionElements(tempList, returnedList, true);
           
           if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || mustKeepWithNext()) {
               context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  @@ -422,18 +426,30 @@
           getPSLM().addIDToPage(getListItemFO().getId());
   
           LayoutContext lc = new LayoutContext(0);
  +        Position firstPos = null;
  +        Position lastPos = null;
   
           // "unwrap" the NonLeafPositions stored in parentIter
           LinkedList positionList = new LinkedList();
           Position pos;
           while (parentIter.hasNext()) {
               pos = (Position) parentIter.next();
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               if (pos instanceof NonLeafPosition) {
                   // pos contains a ListItemPosition created by this ListBlockLM
                   positionList.add(((NonLeafPosition) pos).getPosition());
               }
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           // use the first and the last ListItemPosition to determine the 
           // corresponding indexes in the original labelList and bodyList
           int labelFirstIndex = ((ListItemPosition) positionList.getFirst()).getLabelFirstIndex();
  @@ -476,6 +492,10 @@
               curBlockArea.setBPD(savedBPD);
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           flush();
   
           // if adjusted space after
  
  
  
  1.16      +16 -0     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Item.java	24 May 2005 09:41:32 -0000	1.15
  +++ Item.java	30 May 2005 09:11:09 -0000	1.16
  @@ -118,6 +118,8 @@
           LayoutContext lc = new LayoutContext(0);
           LayoutManager firstLM = null;
           LayoutManager lastLM = null;
  +        Position firstPos = null;
  +        Position lastPos = null;
   
           // "unwrap" the NonLeafPositions stored in parentIter
           // and put them in a new list; 
  @@ -125,6 +127,12 @@
           Position pos;
           while (parentIter.hasNext()) {
               pos = (Position)parentIter.next();
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               if (pos instanceof NonLeafPosition) {
                   // pos was created by a child of this ListBlockLM
                   positionList.add(((NonLeafPosition) pos).getPosition());
  @@ -137,6 +145,10 @@
               }
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
  +        }
  +        
           StackingIter childPosIter = new StackingIter(positionList.listIterator());
           while ((childLM = childPosIter.getNextChildLM()) != null) {
               // Add the block areas to Area
  @@ -146,6 +158,10 @@
               childLM.addAreas(childPosIter, lc);
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           flush();
   
           curBlockArea = null;
  
  
  
  1.17      +16 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ListBlockLayoutManager.java	24 May 2005 13:42:30 -0000	1.16
  +++ ListBlockLayoutManager.java	30 May 2005 09:11:09 -0000	1.17
  @@ -131,6 +131,8 @@
           LayoutContext lc = new LayoutContext(0);
           LayoutManager firstLM = null;
           LayoutManager lastLM = null;
  +        Position firstPos = null;
  +        Position lastPos = null;
   
           // "unwrap" the NonLeafPositions stored in parentIter
           // and put them in a new list; 
  @@ -138,6 +140,12 @@
           Position pos;
           while (parentIter.hasNext()) {
               pos = (Position)parentIter.next();
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               if (pos instanceof NonLeafPosition
                   && ((NonLeafPosition) pos).getPosition().getLM() != this) {
                   // pos was created by a child of this ListBlockLM
  @@ -149,6 +157,10 @@
               }
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           StackingIter childPosIter = new StackingIter(positionList.listIterator());
           while ((childLM = childPosIter.getNextChildLM()) != null) {
               // Add the block areas to Area
  @@ -158,6 +170,10 @@
               childLM.addAreas(childPosIter, lc);
           }
   
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           flush();
   
           // if adjusted space after
  
  
  
  1.46      +0 -16     xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
  
  Index: AbstractLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- AbstractLayoutManager.java	17 May 2005 17:00:24 -0000	1.45
  +++ AbstractLayoutManager.java	30 May 2005 09:11:09 -0000	1.46
  @@ -47,13 +47,6 @@
       private boolean bFinished = false;
       protected boolean bInited = false;
       
  -    /**
  -     * Used during addAreas(): signals that a BreakPoss is not generating areas
  -     * and therefore shouldn't add IDs and markers to the current page.
  -     * @see org.apache.fop.layoutmgr.AbstractLayoutManager#isBogus
  -     */
  -    protected boolean bBogus = false;
  -
       /** child LM and child LM iterator during getNextBreakPoss phase */
       protected LayoutManager curChildLM = null;
       protected ListIterator childLMiter = null;
  @@ -114,15 +107,6 @@
           return false;
       }
   
  -    /** @see org.apache.fop.layoutmgr.LayoutManager#isBogus() */
  -    public boolean isBogus() {
  -        if (getParent().isBogus()) {
  -            return true;
  -        } else {
  -            return bBogus;
  -        }
  -    }
  -    
       /**
        * Return currently active child LayoutManager or null if
        * all children have finished layout.
  
  
  
  1.42      +26 -16    xml-fop/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
  
  Index: BlockContainerLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- BlockContainerLayoutManager.java	18 May 2005 16:03:38 -0000	1.41
  +++ BlockContainerLayoutManager.java	30 May 2005 09:11:09 -0000	1.42
  @@ -195,11 +195,10 @@
           LinkedList returnedList = null;
           LinkedList contentList = new LinkedList();
           LinkedList returnList = new LinkedList();
  -        Position returnPosition = new NonLeafPosition(this, null);
           
           if (!bBreakBeforeServed) {
               try {
  -                if (addKnuthElementsForBreakBefore(returnList, returnPosition)) {
  +                if (addKnuthElementsForBreakBefore(returnList)) {
                       return returnList;
                   }
               } finally {
  @@ -208,11 +207,11 @@
           }
   
           if (!bSpaceBeforeServed) {
  -            addKnuthElementsForSpaceBefore(returnList, returnPosition, alignment);
  +            addKnuthElementsForSpaceBefore(returnList, alignment);
               bSpaceBeforeServed = true;
           }
           
  -        addKnuthElementsForBorderPaddingBefore(returnList, returnPosition);
  +        addKnuthElementsForBorderPaddingBefore(returnList);
   
           if (autoHeight) {
               BlockLevelLayoutManager curLM; // currently active LM
  @@ -306,7 +305,7 @@
               }
   
               Position bcPosition = new BlockContainerPosition(this, breaker);
  -            returnList.add(new KnuthBox(vpContentBPD, bcPosition, false));
  +            returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false));
               //TODO Handle min/opt/max for block-progression-dimension
               /* These two elements will be used to add stretchability to the above box
               returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, 
  @@ -325,9 +324,9 @@
                   }
               }
           }
  -        addKnuthElementsForBorderPaddingAfter(returnList, returnPosition);
  -        addKnuthElementsForSpaceAfter(returnList, returnPosition, alignment);
  -        addKnuthElementsForBreakAfter(returnList, returnPosition);
  +        addKnuthElementsForBorderPaddingAfter(returnList);
  +        addKnuthElementsForSpaceAfter(returnList, alignment);
  +        addKnuthElementsForBreakAfter(returnList);
   
           setFinished(true);
           return returnList;
  @@ -402,7 +401,7 @@
           LinkedList returnList = new LinkedList();
           if (!breaker.isEmpty()) {
               Position bcPosition = new BlockContainerPosition(this, breaker);
  -            returnList.add(new KnuthBox(0, bcPosition, false));
  +            returnList.add(new KnuthBox(0, notifyPos(bcPosition), false));
       
               //TODO Maybe check for page overflow when autoHeight=true
               if (!autoHeight & (contentOverflows/*usedBPD > relDims.bpd*/)) {
  @@ -504,7 +503,7 @@
           }
           
           protected void addAreas(PositionIterator posIter, LayoutContext context) {
  -            AreaAdditionUtil.addAreas(posIter, context);    
  +            AreaAdditionUtil.addAreas(bclm, posIter, context);    
           }
           
           protected void doPhase3(PageBreakingAlgorithm alg, int partCount, 
  @@ -562,10 +561,6 @@
               addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
           }
   
  -        getPSLM().addIDToPage(getBlockContainerFO().getId());
  -        //addMarkersToPV(true, bp1.isFirstArea(), bp1.isLastArea());
  -        getCurrentPV().addMarkers(markers, true, true, false);
  -
           LayoutManager childLM = null;
           LayoutManager lastLM = null;
           LayoutContext lc = new LayoutContext(0);
  @@ -582,9 +577,17 @@
           Position pos;
           boolean bSpaceBefore = false;
           boolean bSpaceAfter = false;
  +        Position firstPos = null;
  +        Position lastPos = null;
           while (parentIter.hasNext()) {
               pos = (Position) parentIter.next();
  -            /* LF *///System.out.println("pos = " + pos.getClass().getName());
  +            //System.out.println("pos = " + pos.getClass().getName());
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               Position innerPosition = null;
               if (pos instanceof NonLeafPosition) {
                   innerPosition = ((NonLeafPosition)pos).getPosition();
  @@ -626,6 +629,11 @@
               }
           }
   
  +        getPSLM().addIDToPage(getBlockContainerFO().getId());
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           if (bcpos == null) {
               if (bpUnit == 0) {
                   // the Positions in positionList were inside the elements
  @@ -726,7 +734,9 @@
           //int bIndents = getBlockContainerFO().getCommonBorderPaddingBackground()
           //    .getBPPaddingAndBorder(false);
   
  -        getCurrentPV().addMarkers(markers, false, false, true);
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
  +        }
   
           flush();
   
  
  
  
  1.18      +1 -20     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FlowLayoutManager.java	24 May 2005 09:41:32 -0000	1.17
  +++ FlowLayoutManager.java	30 May 2005 09:11:09 -0000	1.18
  @@ -57,25 +57,6 @@
           fobj = node;
       }
   
  -    /**
  -     * "wrap" the Position inside each element moving the elements from 
  -     * SourceList to targetList
  -     * @param sourceList source list
  -     * @param targetList target list receiving the wrapped position elements
  -     */
  -    protected void wrapPositionElements(List sourceList, List targetList) {
  -        ListIterator listIter = sourceList.listIterator();
  -        while (listIter.hasNext()) {
  -            KnuthElement tempElement;
  -            tempElement = (KnuthElement) listIter.next();
  -            //if (tempElement.getLayoutManager() != this) {
  -            tempElement.setPosition(new NonLeafPosition(this,
  -                    tempElement.getPosition()));
  -            //}
  -            targetList.add(tempElement);
  -        }
  -    }
  -
       /** @see org.apache.fop.layoutmgr.LayoutManager */
       public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
           // set layout dimensions
  @@ -296,7 +277,7 @@
        * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(PositionIterator, LayoutContext)
        */
       public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
  -        AreaAdditionUtil.addAreas(parentIter, layoutContext);
  +        AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
           flush();
       }
   
  
  
  
  1.5       +7 -1      xml-fop/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java
  
  Index: NonLeafPosition.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NonLeafPosition.java	13 May 2005 19:16:51 -0000	1.4
  +++ NonLeafPosition.java	30 May 2005 09:11:09 -0000	1.5
  @@ -31,10 +31,16 @@
           return subPos;
       }
       
  +    public boolean generatesAreas() {
  +        return (subPos != null ? subPos.generatesAreas() : false);
  +    }
  +    
       /** @see java.lang.Object#toString() */
       public String toString() {
           StringBuffer sb = new StringBuffer();
  -        sb.append("NonLeafPos(");
  +        sb.append("NonLeafPos:").append(getIndex()).append("(");
  +        sb.append(getShortLMName());
  +        sb.append(", ");
           if (getPosition() != null) {
               sb.append(getPosition().toString());
           } else {
  
  
  
  1.19      +107 -34   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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- BlockStackingLayoutManager.java	24 May 2005 09:41:32 -0000	1.18
  +++ BlockStackingLayoutManager.java	30 May 2005 09:11:09 -0000	1.19
  @@ -61,7 +61,12 @@
       protected boolean bSpaceBeforeServed = false;
       /** Reference IPD available */
       protected int referenceIPD = 0;
  +    
  +    private int lastGeneratedPosition = -1;
  +    private int smallestPosNumberChecked = Integer.MAX_VALUE;
   
  +    private Position auxiliaryPosition;
  +    
       public BlockStackingLayoutManager(FObj node) {
           super(node);
           fobj = node;
  @@ -159,6 +164,63 @@
       }
   
       /**
  +     * Adds a Position to the Position participating in the first|last determination by assigning
  +     * it a unique position index.
  +     * @param pos the Position
  +     * @return the same Position but with a position index
  +     */
  +    protected Position notifyPos(Position pos) {
  +        if (pos.getIndex() >= 0) {
  +            throw new IllegalStateException("Position already got its index");
  +        }
  +        lastGeneratedPosition++;
  +        pos.setIndex(lastGeneratedPosition);
  +        return pos;
  +    }
  +    
  +    /**
  +     * Indicates whether the given Position is the first area-generating Position of this LM.
  +     * @param pos the Position (must be one with a position index)
  +     * @return True if it is the first Position
  +     */
  +    public boolean isFirst(Position pos) {
  +        //log.trace("isFirst() smallestPosNumberChecked=" + smallestPosNumberChecked + " " + pos);
  +        if (pos.getIndex() < 0) {
  +            throw new IllegalArgumentException("Only Positions with an index can be checked");
  +        }
  +        if (pos.getIndex() == this.smallestPosNumberChecked) {
  +            return true;
  +        } else if (pos.getIndex() < this.smallestPosNumberChecked) {
  +            this.smallestPosNumberChecked = pos.getIndex();
  +            return true;
  +        } else {
  +            return false;
  +        }
  +    }
  +    
  +    /**
  +     * Indicates whether the given Position is the last area-generating Position of this LM.
  +     * @param pos the Position (must be one with a position index)
  +     * @return True if it is the last Position
  +     */
  +    public boolean isLast(Position pos) {
  +        //log.trace("isLast() lastGenPos=" + lastGeneratedPosition + " " + pos);
  +        if (pos.getIndex() < 0) {
  +            throw new IllegalArgumentException("Only Positions with an index can be checked");
  +        }
  +        return (pos.getIndex() == this.lastGeneratedPosition
  +                && isFinished());
  +    }
  +
  +    /** @return a cached auxiliary Position instance used for things like spaces. */
  +    protected Position getAuxiliaryPosition() {
  +        if (this.auxiliaryPosition == null) {
  +            this.auxiliaryPosition = new NonLeafPosition(this, null);
  +        }
  +        return this.auxiliaryPosition;
  +    }
  +    
  +    /**
        * @param len length in millipoints to span with bp units
        * @return the minimum integer n such that n * bpUnit >= len
        */
  @@ -196,11 +258,10 @@
           LinkedList returnedList = null;
           LinkedList contentList = new LinkedList();
           LinkedList returnList = new LinkedList();
  -        Position returnPosition = new NonLeafPosition(this, null);
   
           if (!bBreakBeforeServed) {
               try {
  -                if (addKnuthElementsForBreakBefore(returnList, returnPosition)) {
  +                if (addKnuthElementsForBreakBefore(returnList)) {
                       return returnList;
                   }
               } finally {
  @@ -209,11 +270,11 @@
           }
   
           if (!bSpaceBeforeServed) {
  -            addKnuthElementsForSpaceBefore(returnList, returnPosition, alignment);
  +            addKnuthElementsForSpaceBefore(returnList, alignment);
               bSpaceBeforeServed = true;
           }
           
  -        addKnuthElementsForBorderPaddingBefore(returnList, returnPosition);
  +        addKnuthElementsForBorderPaddingBefore(returnList);
           
           while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
               LayoutContext childLC = new LayoutContext(0);
  @@ -344,12 +405,12 @@
               wrapPositionElements(contentList, returnList);
           } else {
               //Empty fo:block, zero-length box makes sure the IDs are registered.
  -            returnList.add(new KnuthBox(0, new Position(this), true));
  +            returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
           }
   
  -        addKnuthElementsForBorderPaddingAfter(returnList, returnPosition);
  -        addKnuthElementsForSpaceAfter(returnList, returnPosition, alignment);
  -        addKnuthElementsForBreakAfter(returnList, returnPosition);
  +        addKnuthElementsForBorderPaddingAfter(returnList);
  +        addKnuthElementsForSpaceAfter(returnList, alignment);
  +        addKnuthElementsForBreakAfter(returnList);
   
           if (mustKeepWithNext()) {
               context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
  @@ -701,8 +762,8 @@
        * @param returnList return list to add the additional elements to
        * @param returnPosition applicable return position
        */
  -    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, 
  -            Position returnPosition) {
  +    protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList/*, 
  +            Position returnPosition*/) {
           //Border and Padding (before)
           CommonBorderPaddingBackground borderAndPadding = null;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
  @@ -717,7 +778,7 @@
               int bpBefore = borderAndPadding.getBorderBeforeWidth(false)
                            + borderAndPadding.getPaddingBefore(false);
               if (bpBefore > 0) {
  -                returnList.add(new KnuthBox(bpBefore, returnPosition, true));
  +                returnList.add(new KnuthBox(bpBefore, getAuxiliaryPosition(), true));
               }
           }
       }
  @@ -727,8 +788,8 @@
        * @param returnList return list to add the additional elements to
        * @param returnPosition applicable return position
        */
  -    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, 
  -            Position returnPosition) {
  +    protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList/*, 
  +            Position returnPosition*/) {
           //Border and Padding (after)
           CommonBorderPaddingBackground borderAndPadding = null;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
  @@ -743,7 +804,7 @@
               int bpAfter = borderAndPadding.getBorderAfterWidth(false)
                           + borderAndPadding.getPaddingAfter(false);
               if (bpAfter > 0) {
  -                returnList.add(new KnuthBox(bpAfter, returnPosition, true));
  +                returnList.add(new KnuthBox(bpAfter, getAuxiliaryPosition(), true));
               }
           }
       }
  @@ -754,8 +815,8 @@
        * @param returnPosition applicable return position
        * @return true if an element has been added due to a break-before.
        */
  -    protected boolean addKnuthElementsForBreakBefore(LinkedList returnList, 
  -            Position returnPosition) {
  +    protected boolean addKnuthElementsForBreakBefore(LinkedList returnList/*, 
  +            Position returnPosition*/) {
           int breakBefore = -1;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
               breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore();
  @@ -768,7 +829,7 @@
                   || breakBefore == EN_ODD_PAGE) {
               // return a penalty element, representing a forced page break
               returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
  -                    breakBefore, returnPosition, false));
  +                    breakBefore, getAuxiliaryPosition(), false));
               return true;
           } else {
               return false;
  @@ -781,8 +842,8 @@
        * @param returnPosition applicable return position
        * @return true if an element has been added due to a break-after.
        */
  -    protected boolean addKnuthElementsForBreakAfter(LinkedList returnList, 
  -            Position returnPosition) {
  +    protected boolean addKnuthElementsForBreakAfter(LinkedList returnList/*, 
  +            Position returnPosition*/) {
           int breakAfter = -1;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
               breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter();
  @@ -795,7 +856,7 @@
                   || breakAfter == EN_ODD_PAGE) {
               // add a penalty element, representing a forced page break
               returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
  -                    breakAfter, returnPosition, false));
  +                    breakAfter, getAuxiliaryPosition(), false));
               return true;
           } else {
               return false;
  @@ -808,8 +869,8 @@
        * @param returnPosition applicable return position
        * @param alignment vertical alignment
        */
  -    protected void addKnuthElementsForSpaceBefore(LinkedList returnList, 
  -            Position returnPosition, int alignment) {
  +    protected void addKnuthElementsForSpaceBefore(LinkedList returnList/*, 
  +            Position returnPosition*/, int alignment) {
           SpaceProperty spaceBefore = null;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
               spaceBefore = ((org.apache.fop.fo.flow.Block)fobj)
  @@ -825,14 +886,14 @@
                           && spaceBefore.getMaximum().getLength().getValue() == 0)) {
               if (spaceBefore != null && !spaceBefore.getSpace().isDiscard()) {
                   // add elements to prevent the glue to be discarded
  -                returnList.add(new KnuthBox(0, returnPosition, false));
  +                returnList.add(new KnuthBox(0, getAuxiliaryPosition(), false));
                   returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
  -                        false, returnPosition, false));
  +                        false, getAuxiliaryPosition(), false));
               }
               if (bpUnit > 0) {
                   returnList.add(new KnuthGlue(0, 0, 0,
                           BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, 
  -                        returnPosition, true));
  +                        getAuxiliaryPosition(), true));
               } else /*if (alignment == EN_JUSTIFY)*/ {
                   returnList.add(new KnuthGlue(
                           spaceBefore.getOptimum().getLength().getValue(),
  @@ -841,7 +902,7 @@
                           spaceBefore.getOptimum().getLength().getValue()
                                   - spaceBefore.getMinimum().getLength().getValue(),
                           BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, 
  -                        returnPosition, true));
  +                        getAuxiliaryPosition(), true));
               } /*else {
                   returnList.add(new KnuthGlue(
                           spaceBefore.getOptimum().getLength().getValue(), 
  @@ -857,7 +918,7 @@
        * @param returnPosition applicable return position
        * @param alignment vertical alignment
        */
  -    protected void addKnuthElementsForSpaceAfter(LinkedList returnList, Position returnPosition, 
  +    protected void addKnuthElementsForSpaceAfter(LinkedList returnList/*, Position returnPosition*/, 
                   int alignment) {
           SpaceProperty spaceAfter = null;
           if (fobj instanceof org.apache.fop.fo.flow.Block) {
  @@ -874,12 +935,12 @@
                           && spaceAfter.getMaximum().getLength().getValue() == 0)) {
               if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) {
                   returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE,
  -                        false, returnPosition, false));
  +                        false, getAuxiliaryPosition(), false));
               }
               if (bpUnit > 0) {
                   returnList.add(new KnuthGlue(0, 0, 0, 
                           BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT,
  -                        returnPosition, true));
  +                        getAuxiliaryPosition(), true));
               } else /*if (alignment == EN_JUSTIFY)*/ {
                   returnList.add(new KnuthGlue(
                           spaceAfter.getOptimum().getLength().getValue(),
  @@ -887,7 +948,7 @@
                                   - spaceAfter.getOptimum().getLength().getValue(),
                           spaceAfter.getOptimum().getLength().getValue()
                                   - spaceAfter.getMinimum().getLength().getValue(),
  -                        BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, returnPosition,
  +                        BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(),
                           (!spaceAfter.getSpace().isDiscard()) ? false : true));
               } /*else {
                   returnList.add(new KnuthGlue(
  @@ -896,7 +957,7 @@
                           (!spaceAfter.getSpace().isDiscard()) ? false : true));
               }*/
               if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) {
  -                returnList.add(new KnuthBox(0, returnPosition, true));
  +                returnList.add(new KnuthBox(0, getAuxiliaryPosition(), true));
               }
           }
       }
  @@ -1262,13 +1323,25 @@
        * @param targetList target list receiving the wrapped position elements
        */
       protected void wrapPositionElements(List sourceList, List targetList) {
  +        wrapPositionElements(sourceList, targetList, false);
  +    }
  +    
  +    /**
  +     * "wrap" the Position inside each element moving the elements from 
  +     * SourceList to targetList
  +     * @param sourceList source list
  +     * @param targetList target list receiving the wrapped position elements
  +     * @param force if true, every Position is wrapper regardless of its LM of origin
  +     */
  +    protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
  +          
           ListIterator listIter = sourceList.listIterator();
           while (listIter.hasNext()) {
               KnuthElement tempElement;
               tempElement = (KnuthElement) listIter.next();
  -            if (tempElement.getLayoutManager() != this) {
  -                tempElement.setPosition(new NonLeafPosition(this,
  -                        tempElement.getPosition()));
  +            if (force || tempElement.getLayoutManager() != this) {
  +                tempElement.setPosition(notifyPos(new NonLeafPosition(this,
  +                        tempElement.getPosition())));
               }
               targetList.add(tempElement);
           }
  
  
  
  1.25      +2 -12     xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java
  
  Index: LayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManager.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- LayoutManager.java	17 May 2005 17:00:24 -0000	1.24
  +++ LayoutManager.java	30 May 2005 09:11:09 -0000	1.25
  @@ -50,6 +50,7 @@
       /**
        * Get the active PageSequenceLayoutManager instance for this
        * layout process.
  +     * @return the PageSequenceLayoutManager
        */
       PageSequenceLayoutManager getPSLM();
   
  @@ -63,17 +64,6 @@
       boolean generatesInlineAreas();
   
       /**
  -     * This method is used during the stage where addAreas() converts BreakPoss
  -     * instances to areas. It is used to skip adding IDs and markers to a page
  -     * when the current BreakPoss/area was only generated to signal a break
  -     * situation. This avoids adding IDs and markers to the wrong pages.
  -     * @todo This is a hack. This should be handled differently in the long term.
  -     * @return true if the current BreakPoss/area was only generated to signal
  -     *     break situations.
  -     */
  -    boolean isBogus();
  -    
  -    /**
        * Return true if the next area which would be generated by this
        * LayoutManager could start a new line (or flow for block-level FO).
        *
  @@ -85,7 +75,7 @@
       /**
        * Reset to the position.
        *
  -     * @param position
  +     * @param position the Position to reset to
        */
       void resetPosition(Position position);
   
  
  
  
  1.5       +8 -3      xml-fop/src/java/org/apache/fop/layoutmgr/LeafPosition.java
  
  Index: LeafPosition.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LeafPosition.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LeafPosition.java	26 Jan 2005 14:54:52 -0000	1.4
  +++ LeafPosition.java	30 May 2005 09:11:09 -0000	1.5
  @@ -31,11 +31,16 @@
           return iLeafPos;
       }
       
  +    public boolean generatesAreas() {
  +        return getLM() != null;
  +    }
  +    
       /** @see java.lang.Object#toString()*/
       public String toString() {
  -        StringBuffer sb = new StringBuffer(super.toString());
  -        sb.append(" {pos=").append(getLeafPos());
  -        sb.append(", lm=").append(getLM()).append("}");
  +        StringBuffer sb = new StringBuffer();
  +        sb.append("LeafPos:").append(getIndex()).append("(");
  +        sb.append("pos=").append(getLeafPos());
  +        sb.append(", lm=").append(getShortLMName()).append(")");
           return sb.toString();
       }
   }
  
  
  
  1.5       +29 -6     xml-fop/src/java/org/apache/fop/layoutmgr/Position.java
  
  Index: Position.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/Position.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Position.java	13 May 2005 19:16:52 -0000	1.4
  +++ Position.java	30 May 2005 09:11:09 -0000	1.5
  @@ -21,6 +21,7 @@
   public class Position {
       
       private LayoutManager layoutManager;
  +    private int index = -1;
   
       public Position(LayoutManager lm) {
           layoutManager = lm;
  @@ -38,16 +39,38 @@
           return null;
       }
       
  +    public boolean generatesAreas() {
  +        return false;
  +    }
  +    
  +    public void setIndex(int value) {
  +        this.index = value;
  +    }
  +    
  +    public int getIndex() {
  +        return this.index;
  +    }
  +    
  +    public String getShortLMName() {
  +        if (getLM() != null) {
  +            String lm = getLM().toString();
  +            int idx = lm.lastIndexOf('.');
  +            if (idx >= 0 && lm.indexOf('@') > 0) {
  +                return(lm.substring(idx + 1));
  +            } else {
  +                return lm;
  +            }
  +        } else {
  +            return "null";
  +        }
  +    }
       
       /** @see java.lang.Object#toString() */
       public String toString() {
           StringBuffer sb = new StringBuffer();
  -        sb.append("Position");
  -        if (getLM() != null) {
  -            sb.append(" {");
  -            sb.append(getLM());
  -            sb.append("}");
  -        }
  +        sb.append("Position:").append(getIndex()).append("(");
  +        sb.append(getShortLMName());
  +        sb.append(")");
           return sb.toString();
       }
   }
  
  
  
  1.3       +21 -2     xml-fop/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
  
  Index: AreaAdditionUtil.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AreaAdditionUtil.java	13 May 2005 19:16:52 -0000	1.2
  +++ AreaAdditionUtil.java	30 May 2005 09:11:09 -0000	1.3
  @@ -37,11 +37,14 @@
           }
       }
   
  -    public static void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
  +    public static void addAreas(BlockStackingLayoutManager bslm, 
  +            PositionIterator parentIter, LayoutContext layoutContext) {
           LayoutManager childLM = null;
           LayoutContext lc = new LayoutContext(0);
           LayoutManager firstLM = null;
           LayoutManager lastLM = null;
  +        Position firstPos = null;
  +        Position lastPos = null;
   
           // "unwrap" the NonLeafPositions stored in parentIter
           // and put them in a new list; 
  @@ -49,6 +52,12 @@
           Position pos;
           while (parentIter.hasNext()) {
               pos = (Position)parentIter.next();
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               if (pos instanceof NonLeafPosition) {
                   // pos was created by a child of this FlowLM
                   positionList.add(((NonLeafPosition) pos).getPosition());
  @@ -60,6 +69,11 @@
                   // pos was created by this LM, so it must be ignored
               }
           }
  +        
  +        if (bslm.markers != null) {
  +            bslm.getCurrentPV().addMarkers(bslm.markers, true, 
  +                    bslm.isFirst(firstPos), bslm.isLast(lastPos));
  +        }
   
           StackingIter childPosIter = new StackingIter(positionList.listIterator());
           while ((childLM = childPosIter.getNextChildLM()) != null) {
  @@ -75,6 +89,11 @@
               lc.setStackLimit(layoutContext.getStackLimit());
               childLM.addAreas(childPosIter, lc);
           }
  +        if (bslm.markers != null) {
  +            bslm.getCurrentPV().addMarkers(bslm.markers, false, 
  +                    bslm.isFirst(firstPos), bslm.isLast(lastPos));
  +        }
  +        
       }
       
   }
  
  
  
  1.47      +30 -13    xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
  
  Index: BlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- BlockLayoutManager.java	17 May 2005 17:00:24 -0000	1.46
  +++ BlockLayoutManager.java	30 May 2005 09:11:09 -0000	1.47
  @@ -201,7 +201,7 @@
   
       public void addAreas(PositionIterator parentIter,
               LayoutContext layoutContext) {
  -        /* LF *///System.out.println(" BLM.addAreas>");
  +        //System.out.println(" BLM.addAreas>");
           getParentArea(null);
   
           // if this will create the first block area in a page
  @@ -210,18 +210,14 @@
               addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
           }
   
  -        getPSLM().addIDToPage(getBlockFO().getId());
  -        //addMarkersToPV(true, bp1.isFirstArea(), bp1.isLastArea());
  -        getCurrentPV().addMarkers(markers, true, true, false);
  -
           LayoutManager childLM = null;
           LayoutManager lastLM = null;
           LayoutContext lc = new LayoutContext(0);
  -        /* LF */// set space after in the LayoutContext for children
  -        /* LF */if (layoutContext.getSpaceAfter() > 0) {
  -            /* LF */lc.setSpaceAfter(layoutContext.getSpaceAfter());
  -            /* LF */}
  -        /* LF */PositionIterator childPosIter;
  +        // set space after in the LayoutContext for children
  +        if (layoutContext.getSpaceAfter() > 0) {
  +            lc.setSpaceAfter(layoutContext.getSpaceAfter());
  +        }
  +        PositionIterator childPosIter;
   
           // "unwrap" the NonLeafPositions stored in parentIter
           // and put them in a new list;
  @@ -229,9 +225,17 @@
           Position pos;
           boolean bSpaceBefore = false;
           boolean bSpaceAfter = false;
  +        Position firstPos = null;
  +        Position lastPos = null;
           while (parentIter.hasNext()) {
               pos = (Position) parentIter.next();
               //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
  +            if (pos.getIndex() >= 0) {
  +                if (firstPos == null) {
  +                    firstPos = pos;
  +                }
  +                lastPos = pos;
  +            }
               Position innerPosition = pos;
               if (pos instanceof NonLeafPosition) {
                   //Not all elements are wrapped
  @@ -264,6 +268,17 @@
               }
           }
   
  +        getPSLM().addIDToPage(getBlockFO().getId());
  +        /* TODO remove when markers are really ok
  +        log.debug("Checking on " + this);
  +        log.debug("Checking first=" + firstPos);
  +        log.debug("Checking last=" + lastPos);
  +        log.debug("->" + isFirst(firstPos) + "/" + isLast(lastPos));
  +        */
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, true, isFirst(firstPos), isLast(lastPos));
  +        }
  +
           if (bpUnit == 0) {
               // the Positions in positionList were inside the elements
               // created by the LineLM
  @@ -345,14 +360,16 @@
               // set last area flag
               lc.setFlags(LayoutContext.LAST_AREA,
                       (layoutContext.isLastArea() && childLM == lastLM));
  -            /*LF*/lc.setStackLimit(layoutContext.getStackLimit());
  +            lc.setStackLimit(layoutContext.getStackLimit());
               // Add the line areas to Area
               childLM.addAreas(childPosIter, lc);
           }
   
  -        int bIndents = getBlockFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
  +        //int bIndents = getBlockFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false);
   
  -        getCurrentPV().addMarkers(markers, false, false, true);
  +        if (markers != null) {
  +            getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos));
  +        }
   
           flush();
   
  
  
  
  1.3       +11 -6     xml-fop/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
  
  Index: BlockLevelLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BlockLevelLayoutManager.java	13 May 2005 19:16:51 -0000	1.2
  +++ BlockLevelLayoutManager.java	30 May 2005 09:11:10 -0000	1.3
  @@ -23,11 +23,16 @@
    */
   public interface BlockLevelLayoutManager extends LayoutManager {
   
  -    static final int NO_ADJUSTMENT = -1;
  -    static final int SPACE_BEFORE_ADJUSTMENT = 0;
  -    static final int SPACE_AFTER_ADJUSTMENT = 1;
  -    static final int LINE_NUMBER_ADJUSTMENT = 2;
  -    static final int LINE_HEIGHT_ADJUSTMENT = 3;
  +    /** Adjustment class: no adjustment */
  +    int NO_ADJUSTMENT = -1;
  +    /** Adjustment class: adjustment for space-before */
  +    int SPACE_BEFORE_ADJUSTMENT = 0;
  +    /** Adjustment class: adjustment for space-after */
  +    int SPACE_AFTER_ADJUSTMENT = 1;
  +    /** Adjustment class: adjustment for number of lines */
  +    int LINE_NUMBER_ADJUSTMENT = 2;
  +    /** Adjustment class: adjustment for line height */
  +    int LINE_HEIGHT_ADJUSTMENT = 3;
   
       int negotiateBPDAdjustment(int adj, KnuthElement lastElement);
   
  
  
  
  1.14      +2 -2      xml-fop/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
  
  Index: StaticContentLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StaticContentLayoutManager.java	17 May 2005 17:00:24 -0000	1.13
  +++ StaticContentLayoutManager.java	30 May 2005 09:11:10 -0000	1.14
  @@ -155,7 +155,7 @@
        * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(PositionIterator, LayoutContext)
        */
       public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
  -        AreaAdditionUtil.addAreas(parentIter, layoutContext);
  +        AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
   
           flush();
           targetRegion = null;
  @@ -267,7 +267,7 @@
           }
           
           protected void addAreas(PositionIterator posIter, LayoutContext context) {
  -            AreaAdditionUtil.addAreas(posIter, context);    
  +            AreaAdditionUtil.addAreas(lm, posIter, context);    
           }
           
           protected void doPhase3(PageBreakingAlgorithm alg, int partCount, 
  
  
  
  1.4       +11 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GridUnit.java	24 May 2005 09:41:32 -0000	1.3
  +++ GridUnit.java	30 May 2005 09:11:10 -0000	1.4
  @@ -244,10 +244,20 @@
                           side, resFlags), side);
       }
       
  +    /**
  +     * Returns a flag for this GridUnit.
  +     * @param which the requested flag
  +     * @return the value of the flag
  +     */
       public boolean getFlag(int which) {
           return (flags & (1 << which)) != 0;
       }
       
  +    /**
  +     * Sets a flag on a GridUnit.
  +     * @param which the flag to set
  +     * @param value the new value for the flag
  +     */
       public void setFlag(int which, boolean value) {
           if (value) {
               flags |= (1 << which); //set flag
  
  
  
  1.32      +2 -20     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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Cell.java	24 May 2005 09:41:32 -0000	1.31
  +++ Cell.java	30 May 2005 09:11:10 -0000	1.32
  @@ -19,7 +19,6 @@
   package org.apache.fop.layoutmgr.table;
   
   import java.util.LinkedList;
  -import java.util.List;
   
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.flow.Table;
  @@ -63,9 +62,6 @@
       private int borderAndPaddingBPD;
       private boolean emptyCell = true;
   
  -    /** List of Lists containing OldGridUnit instances, one List per row. */
  -    private List rows = new java.util.ArrayList(); 
  -    
       /**
        * Create a new Cell layout manager.
        * @param node table-cell FO for which to create the LM
  @@ -113,16 +109,6 @@
       }
       
   
  -    /**
  -     * Called by Row LM to register the grid units occupied by this cell for a row.
  -     * @param spannedGridUnits a List of GridUnits
  -     */
  -    public void addGridUnitsFromRow(List spannedGridUnits) {
  -        log.debug("Getting another row, " + spannedGridUnits.size() + " grid units");
  -        this.rows.add(spannedGridUnits);
  -        
  -    }
  -
       private int getIPIndents() {
           int iIndents = 0;
           int[] startEndBorderWidths = gridUnit.getStartEndBorderWidths();
  @@ -331,11 +317,8 @@
       public void addAreas(PositionIterator parentIter,
                            LayoutContext layoutContext) {
           getParentArea(null);
  -        bBogus = false; //!bp1.generatesAreas(); 
   
  -        if (!isBogus()) {
  -            getPSLM().addIDToPage(fobj.getId());
  -        }
  +        getPSLM().addIDToPage(fobj.getId());
   
           if (isSeparateBorderModel()) {
               if (!emptyCell || fobj.showEmptyCells()) {
  @@ -381,7 +364,6 @@
                                       - (gu.getBorders().getBorderAfterWidth(false) / 2);
                           }
                           block.setBPD(bpd);
  -                        //TODO This needs to be fixed for row spanning
                           lastRowHeight = rowHeight;
                           int ipd = gu.getColumn().getColumnWidth().getValue();
                           int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; 
  @@ -418,7 +400,7 @@
               }
           }
   
  -        AreaAdditionUtil.addAreas(parentIter, layoutContext);
  +        AreaAdditionUtil.addAreas(this, parentIter, layoutContext);
           
           int contentBPD = getContentHeight(rowHeight, gridUnit);
           curBlockArea.setBPD(contentBPD);
  
  
  
  1.25      +7 -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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TableLayoutManager.java	24 May 2005 09:41:32 -0000	1.24
  +++ TableLayoutManager.java	30 May 2005 09:11:10 -0000	1.25
  @@ -190,6 +190,13 @@
               log.debug("TableContentLM signals pending keep-with-previous");
               context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING);
           }
  +        
  +        //Set index values on elements coming from the content LM
  +        Iterator iter = returnedList.iterator();
  +        while (iter.hasNext()) {
  +            KnuthElement el = (KnuthElement)iter.next();
  +            notifyPos(el.getPosition());
  +        }
           log.debug(returnedList);
           
           if (returnedList.size() == 1
  
  
  
  1.8       +7 -1      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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TableStepper.java	25 May 2005 19:16:00 -0000	1.7
  +++ TableStepper.java	30 May 2005 09:11:10 -0000	1.8
  @@ -198,6 +198,7 @@
           int laststep = 0;
           int step;
           int addedBoxLen = 0;
  +        TableContentPosition lastTCPos = null;
           LinkedList returnList = new LinkedList();
           while ((step = getNextStep(laststep)) >= 0) {
               if (rowBacktrackForLastStep) {
  @@ -262,6 +263,10 @@
               }
               TableContentPosition tcpos = new TableContentPosition(getTableLM(), 
                       gridUnitParts, getActiveRow());
  +            if (returnList.size() == 0) {
  +                tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
  +            }
  +            lastTCPos = tcpos;
               log.debug(" - " + rowBacktrackForLastStep + " - " + activeRow + " - " + tcpos);
               returnList.add(new KnuthBox(boxLen, tcpos, false));
               TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
  @@ -301,6 +306,7 @@
               //we have to signal the still pending last keep-with-next using the LayoutContext.
               context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
           }
  +        lastTCPos.setFlag(TableContentPosition.LAST_IN_ROWGROUP, true);
           return returnList;
       }
       
  
  
  
  1.4       +49 -1     xml-fop/src/java/org/apache/fop/layoutmgr/table/EffRow.java
  
  Index: EffRow.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/EffRow.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EffRow.java	23 May 2005 13:02:41 -0000	1.3
  +++ EffRow.java	30 May 2005 09:11:10 -0000	1.4
  @@ -29,41 +29,68 @@
    */
   public class EffRow {
       
  +    /** Indicates that the row is the first in a table-body */
  +    public static final int FIRST_IN_BODY = GridUnit.FIRST_IN_BODY;
  +    /** Indicates that the row is the last in a table-body */
  +    public static final int LAST_IN_BODY = GridUnit.LAST_IN_BODY;
  +    
       private List gridUnits = new java.util.ArrayList();
       private int index;
       private int bodyType;
       private MinOptMax height;
       private MinOptMax explicitHeight;
       
  +    /**
  +     * Creates a new effective row instance.
  +     * @param index index of the row
  +     * @param bodyType type of body (one of HEADER, FOOTER, BODY as found on TableRowIterator)
  +     */
       public EffRow(int index, int bodyType) {
           this.index = index;
           this.bodyType = bodyType;
       }
       
  +    /** @return the index of the EffRow in the sequence of rows */
       public int getIndex() {
           return this.index;
       }
       
  +    /**
  +     * @return an indicator what type of body this EffRow is in (one of HEADER, FOOTER, BODY 
  +     * as found on TableRowIterator)
  +     */
       public int getBodyType() {
           return this.bodyType;
       }
       
  +    /** @return the calculated height for this EffRow. */
       public MinOptMax getHeight() {
           return this.height;
       }
       
  +    /**
  +     * Sets the calculated height for this EffRow.
  +     * @param mom the calculated height
  +     */
       public void setHeight(MinOptMax mom) {
           this.height = mom;
       }
       
  +    /** @return the explicit height of the EffRow (as specified through properties) */
       public MinOptMax getExplicitHeight() {
           return this.explicitHeight;
       }
       
  +    /**
  +     * Sets the height for this row that resulted from the explicit height properties specified
  +     * by the user.
  +     * @param mom the height
  +     */
       public void setExplicitHeight(MinOptMax mom) {
           this.explicitHeight = mom;
       }
       
  +    /** @return the list of GridUnits for this EffRow */
       public List getGridUnits() {
           return gridUnits;
       }
  @@ -92,6 +119,11 @@
           }
       }
       
  +    /**
  +     * Sets a flag on all grid units of this effective row.
  +     * @param flag which flag to set (on of the GridUnit.* constants)
  +     * @param value new value for the flag
  +     */
       public void setFlagForAllGridUnits(int flag, boolean value) {
           Iterator iter = gridUnits.iterator();
           while (iter.hasNext()) {
  @@ -100,6 +132,22 @@
           }
       }
   
  +    /**
  +     * Returns a flag for this effective row. Only a subset of the flags on GridUnit is supported.
  +     * The flag is determined by inspecting flags on the EffRow's GridUnits.
  +     * @param which the requested flag
  +     * @return true if the flag is set
  +     */
  +    public boolean getFlag(int which) {
  +        if (which == FIRST_IN_BODY) {
  +            return getGridUnit(0).getFlag(GridUnit.FIRST_IN_BODY);
  +        } else if (which == LAST_IN_BODY) {
  +            return getGridUnit(0).getFlag(GridUnit.LAST_IN_BODY);
  +        } else {
  +            throw new IllegalArgumentException("Illegal flag queried: " +  which);
  +        }
  +    }
  +    
       /** @see java.lang.Object#toString() */
       public String toString() {
           StringBuffer sb = new StringBuffer("EffRow {");
  
  
  
  1.11      +141 -53   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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TableContentLayoutManager.java	24 May 2005 09:41:32 -0000	1.10
  +++ TableContentLayoutManager.java	30 May 2005 09:11:10 -0000	1.11
  @@ -29,6 +29,7 @@
   import org.apache.fop.area.Block;
   import org.apache.fop.area.Trait;
   import org.apache.fop.fo.flow.Table;
  +import org.apache.fop.fo.flow.TableBody;
   import org.apache.fop.fo.flow.TableRow;
   import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
   import org.apache.fop.fo.properties.LengthRangeProperty;
  @@ -500,28 +501,22 @@
           RowPainter painter = new RowPainter(layoutContext);
   
           List positions = new java.util.ArrayList();
  +        List headerElements = null;
           List footerElements = null;
  +        Position firstPos = null;
           Position lastPos = null;
           while (parentIter.hasNext()) {
               Position pos = (Position)parentIter.next();
  +            if (firstPos == null) {
  +                firstPos = pos;
  +            }
               lastPos = pos;
               if (pos instanceof TableHeaderFooterPosition) {
                   TableHeaderFooterPosition thfpos = (TableHeaderFooterPosition)pos;
                   //these positions need to be unpacked
                   if (thfpos.header) {
  -                    //header positions for the last part are the second-to-last element and need to
  -                    //be handled first before all other TableContentPositions
  -                    PositionIterator nestedIter = new KnuthPossPosIter(thfpos.nestedElements);
  -                    while (nestedIter.hasNext()) {
  -                        Position containedPos = (Position)nestedIter.next();
  -                        if (containedPos instanceof TableContentPosition) {
  -                            TableContentPosition tcpos = (TableContentPosition)containedPos;
  -                            painter.handleTableContentPosition(tcpos);
  -                        } else {
  -                            log.debug("Ignoring position: " + containedPos);
  -                        }
  -                    }
  -                    painter.addAreasAndFlushRow(true);
  +                    //Positions for header will be added first
  +                    headerElements = thfpos.nestedElements;
                   } else {
                       //Positions for footers are simply added at the end
                       footerElements = thfpos.nestedElements;
  @@ -540,54 +535,102 @@
               if (penaltyPos.headerElements != null) {
                   //Header positions for the penalty position are in the last element and need to
                   //be handled first before all other TableContentPositions
  -                PositionIterator nestedIter = new KnuthPossPosIter(penaltyPos.headerElements);
  -                while (nestedIter.hasNext()) {
  -                    Position containedPos = (Position)nestedIter.next();
  -                    if (containedPos instanceof TableContentPosition) {
  -                        TableContentPosition tcpos = (TableContentPosition)containedPos;
  -                        painter.handleTableContentPosition(tcpos);
  -                    } else {
  -                        log.debug("Ignoring position: " + containedPos);
  -                    }
  -                }
  -                painter.addAreasAndFlushRow(true);
  +                headerElements = penaltyPos.headerElements;
               }
               if (penaltyPos.footerElements != null) {
                   footerElements = penaltyPos.footerElements; 
               }
           }
   
  +        Map markers = getTableLM().getTable().getMarkers();
  +        if (markers != null) {
  +            getTableLM().getCurrentPV().addMarkers(markers, 
  +                    true, getTableLM().isFirst(firstPos), getTableLM().isLast(lastPos));
  +        }
           
  -        Iterator posIter = positions.iterator();
  -        //Iterate over all steps
  -        while (posIter.hasNext()) {
  -            Position pos = (Position)posIter.next();
  -            if (pos instanceof TableContentPosition) {
  -                TableContentPosition tcpos = (TableContentPosition)pos;
  -                painter.handleTableContentPosition(tcpos);
  -            } else {
  -                log.debug("Ignoring position: " + pos);
  -            }
  +        if (headerElements != null) {
  +            //header positions for the last part are the second-to-last element and need to
  +            //be handled first before all other TableContentPositions
  +            PositionIterator nestedIter = new KnuthPossPosIter(headerElements);
  +            iterateAndPaintPositions(nestedIter, painter);
  +            painter.addAreasAndFlushRow(true);
           }
  +        
  +        //Iterate over all steps
  +        Iterator posIter = positions.iterator();
  +        iterateAndPaintPositions(posIter, painter);
           painter.addAreasAndFlushRow(true);
   
           if (footerElements != null) {
               //Positions for footers are simply added at the end
  -            PositionIterator iter = new KnuthPossPosIter(footerElements);
  -            while (iter.hasNext()) {
  -                Position pos = (Position)iter.next();
  -                if (pos instanceof TableContentPosition) {
  -                    TableContentPosition tcpos = (TableContentPosition)pos;
  -                    painter.handleTableContentPosition(tcpos);
  -                } else {
  -                    log.debug("Ignoring position: " + pos);
  -                }
  -            }
  +            PositionIterator nestedIter = new KnuthPossPosIter(footerElements);
  +            iterateAndPaintPositions(nestedIter, painter);
               painter.addAreasAndFlushRow(true);
           }
           
           painter.notifyEndOfSequence();
           this.usedBPD += painter.getAccumulatedBPD();
  +
  +        if (markers != null) {
  +            getTableLM().getCurrentPV().addMarkers(markers, 
  +                    false, getTableLM().isFirst(firstPos), getTableLM().isLast(lastPos));
  +        }
  +    }
  +    
  +    private void iterateAndPaintPositions(Iterator iterator, RowPainter painter) {
  +        List lst = new java.util.ArrayList();
  +        boolean firstPos = false;
  +        boolean lastPos = false;
  +        TableBody body = null;
  +        while (iterator.hasNext()) {
  +            Position pos = (Position)iterator.next();
  +            //System.out.println(pos);
  +            if (pos instanceof TableContentPosition) {
  +                TableContentPosition tcpos = (TableContentPosition)pos;
  +                lst.add(tcpos);
  +                //System.out.println(tcpos.row);
  +                GridUnitPart part = (GridUnitPart)tcpos.gridUnitParts.get(0);
  +                if (body == null) {
  +                    body = part.pgu.getBody();
  +                }
  +                if (tcpos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP) 
  +                        && tcpos.row.getFlag(EffRow.FIRST_IN_BODY)) {
  +                    //System.out.println("pgu is first in body");
  +                    firstPos = true;
  +
  +                }
  +                if (tcpos.getFlag(TableContentPosition.LAST_IN_ROWGROUP) 
  +                        && tcpos.row.getFlag(EffRow.LAST_IN_BODY)) {
  +                    //System.out.println("pgu is last in body");
  +                    lastPos = true;
  +                    getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
  +                            true, firstPos, lastPos);
  +                    int size = lst.size();
  +                    for (int i = 0; i < size; i++) {
  +                        painter.handleTableContentPosition((TableContentPosition)lst.get(i));
  +                    }
  +                    getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
  +                            false, firstPos, lastPos);
  +                    //reset
  +                    firstPos = false;
  +                    lastPos = false;
  +                    body = null;
  +                    lst.clear();
  +                }
  +            } else {
  +                log.debug("Ignoring position: " + pos);
  +            }
  +        }
  +        if (body != null) {
  +            getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
  +                    true, firstPos, lastPos);
  +            int size = lst.size();
  +            for (int i = 0; i < size; i++) {
  +                painter.handleTableContentPosition((TableContentPosition)lst.get(i));
  +            }
  +            getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
  +                    false, firstPos, lastPos);
  +        }
       }
      
       private class RowPainter {
  @@ -828,11 +871,22 @@
               this.end = end;
           }
           
  +        /** @return true if this part is the first part of a cell */
  +        public boolean isFirstPart() {
  +            return (start == 0);
  +        }
  +        
  +        /** @return true if this part is the last part of a cell */
  +        public boolean isLastPart() {
  +            return (end >= 0 && end == pgu.getElements().size() - 1);
  +        }
  +        
           /** @see java.lang.Object#toString() */
           public String toString() {
               StringBuffer sb = new StringBuffer("Part: ");
               sb.append(start).append("-").append(end);
  -            sb.append(" ").append(pgu);
  +            sb.append(" [").append(isFirstPart() ? "F" : "-").append(isLastPart() ? "L" : "-");
  +            sb.append("] ").append(pgu);
               return sb.toString();
           }
           
  @@ -844,10 +898,17 @@
        */
       public static class TableContentPosition extends Position {
   
  +        /** The position is the first of the row group. */ 
  +        public static final int FIRST_IN_ROWGROUP = 1;
  +        /** The position is the last of the row group. */ 
  +        public static final int LAST_IN_ROWGROUP = 2;
  +        
           /** the list of GridUnitParts making up this position */
           protected List gridUnitParts;
           /** effective row this position belongs to */
           protected EffRow row;
  +        /** flags for the position */
  +        protected int flags;
           
           /**
            * Creates a new TableContentPosition.
  @@ -862,11 +923,37 @@
               this.row = row;
           }
           
  +        /**
  +         * Returns a flag for this GridUnit.
  +         * @param which the requested flag
  +         * @return the value of the flag
  +         */
  +        public boolean getFlag(int which) {
  +            return (flags & (1 << which)) != 0;
  +        }
  +        
  +        /**
  +         * Sets a flag on a GridUnit.
  +         * @param which the flag to set
  +         * @param value the new value for the flag
  +         */
  +        public void setFlag(int which, boolean value) {
  +            if (value) {
  +                flags |= (1 << which); //set flag
  +            } else {
  +                flags &= ~(1 << which); //clear flag
  +            }
  +        }
  +        
           /** @see java.lang.Object#toString() */
           public String toString() {
  -            StringBuffer sb = new StringBuffer("TableContentPosition {");
  +            StringBuffer sb = new StringBuffer("TableContentPosition:");
  +            sb.append(getIndex());
  +            sb.append("[").append(getFlag(FIRST_IN_ROWGROUP) ? "F" : "-");
  +            sb.append((getFlag(LAST_IN_ROWGROUP) ? "L" : "-")).append("]");
  +            sb.append("(");
               sb.append(gridUnitParts);
  -            sb.append("}");
  +            sb.append(")");
               return sb.toString();
           }
       }
  @@ -899,9 +986,10 @@
           public String toString() {
               StringBuffer sb = new StringBuffer("Table");
               sb.append(header ? "Header" : "Footer");
  -            sb.append("Position {");
  +            sb.append("Position:");
  +            sb.append(getIndex()).append("(");
               sb.append(nestedElements);
  -            sb.append("}");
  +            sb.append(")");
               return sb.toString();
           }
       }
  @@ -927,13 +1015,13 @@
           
           /** @see java.lang.Object#toString() */
           public String toString() {
  -            StringBuffer sb = new StringBuffer("TableHFPenaltyPosition");
  -            sb.append(" {");
  +            StringBuffer sb = new StringBuffer("TableHFPenaltyPosition:");
  +            sb.append(getIndex()).append("(");
               sb.append("header:");
               sb.append(headerElements);
               sb.append(", footer:");
               sb.append(footerElements);
  -            sb.append("}");
  +            sb.append(")");
               return sb.toString();
           }
       }
  
  
  

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