]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: getMaxRemainingHeight() was not very accurate and resulted in wrong element...
authorJeremias Maerki <jeremias@apache.org>
Tue, 31 May 2005 12:46:14 +0000 (12:46 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 31 May 2005 12:46:14 +0000 (12:46 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198706 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java

index d19c9d74f6e4d6f83f41606e3755dba0eac106ed..e6d6ff3307a9238c66df67eefa2e80a04cd2b4db 100644 (file)
@@ -68,6 +68,7 @@ public class TableRowIterator {
     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 @@ public class TableRowIterator {
         }
         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 @@ public class TableRowIterator {
                     break;
                 }
             }
+            lastIndex = lastRowInGroup.getIndex();
             if (!allFinished) {
-                lastIndex = lastRowInGroup.getIndex();
                 lastRowInGroup = getNextRow();
                 if (lastRowInGroup == null) {
                     allFinished = true;
@@ -221,6 +223,14 @@ public class TableRowIterator {
         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 @@ public class TableRowIterator {
         
         //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 @@ public class TableRowIterator {
             safelySetListItem(gridUnits, colnum - 1, gu);
             boolean hasRowSpanningLeft = !gu.isLastGridUnitRowSpan();
             if (hasRowSpanningLeft) {
+                pendingRowSpans++;
                 safelySetListItem(lastRowsSpanningCells, colnum - 1, gu);
             }
             
index 55a3c1b1b0a18bae4b81ee9a3c2f85d0f44e24ad..4b09fce356ddf72c9100d15657eb71722f5473bb 100644 (file)
@@ -107,19 +107,27 @@ public class TableStepper {
                 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 @@ public class TableStepper {
     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) {