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/31 14:46:14 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/table TableStepper.java TableRowIterator.java

jeremias    2005/05/31 05:46:14

  Modified:    src/java/org/apache/fop/layoutmgr/table TableStepper.java
                        TableRowIterator.java
  Log:
  Bugfix: getMaxRemainingHeight() was not very accurate and resulted in wrong element lists. Mostly problems with calculations when row spans are involved.
  Bugfix: rows that are dynamically created by a row span are now correctly handled.
  Bugfix: Proper reset of variables for empty grid units during the stepping process.
  
  Revision  Changes    Path
  1.9       +20 -5     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TableStepper.java	30 May 2005 09:11:10 -0000	1.8
  +++ TableStepper.java	31 May 2005 12:46:14 -0000	1.9
  @@ -107,19 +107,27 @@
                   if (elementLists[i] == null) {
                       continue;
                   }
  -                if (getActivePrimaryGridUnit(i).getCell().getNumberRowsSpanned() > 1) {
  +                if (end[i] == elementLists[i].size() - 1) {
  +                    continue;
  +                }
  +                GridUnit gu = getActiveGridUnit(i); 
  +                if (!gu.isLastGridUnitRowSpan()) {
                       continue;
                   }
                   int len = widths[i]; 
                   if (len > 0) {
                       len += borderBefore[i] + borderAfter[i]; 
                   }
  -                if (len == rowGroup[activeRow].getHeight().opt) {
  +                int nominalHeight = rowGroup[activeRow].getHeight().opt;
  +                for (int r = 0; r < gu.getRowSpanIndex(); r++) {
  +                    nominalHeight += rowGroup[activeRow - r - 1].getHeight().opt;
  +                }
  +                if (len == nominalHeight) {
                       //row is filled
                       maxW = 0;
                       break;
                   }
  -                maxW = Math.max(maxW, rowGroup[activeRow].getHeight().opt - len);
  +                maxW = Math.max(maxW, nominalHeight - len);
               }
           }
           for (int i = activeRow + 1; i < rowGroup.length; i++) {
  @@ -132,7 +140,14 @@
       private void setupElementList(int column) {
           GridUnit gu = getActiveGridUnit(column);
           EffRow row = getActiveRow();
  -        if (gu.isPrimary() && !gu.isEmpty()) {
  +        if (gu.isEmpty()){
  +            elementLists[column] = null;
  +            start[column] = 0;
  +            end[column] = -1;
  +            widths[column] = 0;
  +            startRow[column] = activeRow;
  +            keepWithNextSignals[column] = false;
  +        } else if (gu.isPrimary()) {
               PrimaryGridUnit pgu = (PrimaryGridUnit)gu;
               boolean makeBoxForWholeRow = false;
               if (row.getExplicitHeight().min > 0) {
  
  
  
  1.6       +38 -24    xml-fop/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
  
  Index: TableRowIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableRowIterator.java	30 May 2005 08:38:50 -0000	1.5
  +++ TableRowIterator.java	31 May 2005 12:46:14 -0000	1.6
  @@ -68,6 +68,7 @@
       private List rows = new java.util.ArrayList();
       //private int indexOfFirstRowInList;
       private int currentIndex = -1;
  +    private int pendingRowSpans;
       
       //prefetch state
       private ListIterator bodyIterator = null;
  @@ -126,8 +127,9 @@
           }
           EffRow lastRowInGroup = firstRowInGroup;
           int lastIndex = lastRowInGroup.getIndex();
  -        boolean allFinished = true;
  +        boolean allFinished;
           do {
  +            allFinished = true;
               Iterator iter = lastRowInGroup.getGridUnits().iterator();
               while (iter.hasNext()) {
                   GridUnit gu = (GridUnit)iter.next();
  @@ -136,8 +138,8 @@
                       break;
                   }
               }
  +            lastIndex = lastRowInGroup.getIndex();
               if (!allFinished) {
  -                lastIndex = lastRowInGroup.getIndex();
                   lastRowInGroup = getNextRow();
                   if (lastRowInGroup == null) {
                       allFinished = true;
  @@ -221,6 +223,14 @@
           if (childInBodyIterator != null) {
               if (!childInBodyIterator.hasNext()) {
                   //force skip on to next body
  +                if (pendingRowSpans > 0) {
  +                    this.currentRow.clear();
  +                    this.currentRowIndex++;
  +                    EffRow gridUnits = buildGridRow(this.currentRow, null);
  +                    log.debug(gridUnits);
  +                    rows.add(gridUnits);
  +                    return true;
  +                }
                   childInBodyIterator = null;
                   if (rows.size() > 0) {
                       getCachedRow(rows.size() - 1).setFlagForAllGridUnits(
  @@ -317,30 +327,33 @@
           
           //Create all row-spanned grid units based on information from the last row
           int colnum = 1;
  -        ListIterator spanIter = lastRowsSpanningCells.listIterator();
           GridUnit[] horzSpan = null;
  -        while (spanIter.hasNext()) {
  -            GridUnit gu = (GridUnit)spanIter.next();
  -            if (gu != null) {
  -                if (gu.getColSpanIndex() == 0) {
  -                    horzSpan = new GridUnit[gu.getCell().getNumberColumnsSpanned()];
  -                }
  -                GridUnit newGU = gu.createNextRowSpanningGridUnit();
  -                newGU.setRow(rowFO);
  -                safelySetListItem(gridUnits, colnum - 1, newGU);
  -                horzSpan[newGU.getColSpanIndex()] = newGU;
  -                if (newGU.isLastGridUnitColSpan()) {
  -                    //Add the array of row-spanned grid units to the primary grid unit
  -                    newGU.getPrimary().addRow(horzSpan);
  -                    horzSpan = null;
  -                }
  -                if (newGU.isLastGridUnitRowSpan()) {
  -                    spanIter.set(null);
  -                } else {
  -                    spanIter.set(newGU);
  +        if (pendingRowSpans > 0) {
  +            ListIterator spanIter = lastRowsSpanningCells.listIterator();
  +            while (spanIter.hasNext()) {
  +                GridUnit gu = (GridUnit)spanIter.next();
  +                if (gu != null) {
  +                    if (gu.getColSpanIndex() == 0) {
  +                        horzSpan = new GridUnit[gu.getCell().getNumberColumnsSpanned()];
  +                    }
  +                    GridUnit newGU = gu.createNextRowSpanningGridUnit();
  +                    newGU.setRow(rowFO);
  +                    safelySetListItem(gridUnits, colnum - 1, newGU);
  +                    horzSpan[newGU.getColSpanIndex()] = newGU;
  +                    if (newGU.isLastGridUnitColSpan()) {
  +                        //Add the array of row-spanned grid units to the primary grid unit
  +                        newGU.getPrimary().addRow(horzSpan);
  +                        horzSpan = null;
  +                    }
  +                    if (newGU.isLastGridUnitRowSpan()) {
  +                        spanIter.set(null);
  +                        pendingRowSpans--;
  +                    } else {
  +                        spanIter.set(newGU);
  +                    }
                   }
  +                colnum++;
               }
  -            colnum++;
           }
           
           //Transfer available cells to their slots
  @@ -369,6 +382,7 @@
               safelySetListItem(gridUnits, colnum - 1, gu);
               boolean hasRowSpanningLeft = !gu.isLastGridUnitRowSpan();
               if (hasRowSpanningLeft) {
  +                pendingRowSpans++;
                   safelySetListItem(lastRowsSpanningCells, colnum - 1, gu);
               }
               
  
  
  

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