]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
- Compute the height of already handled rows progressively in TableStepper
authorVincent Hennebert <vhennebert@apache.org>
Tue, 17 Jul 2007 17:53:50 +0000 (17:53 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Tue, 17 Jul 2007 17:53:50 +0000 (17:53 +0000)
- Give this information to the ActiveCell constructor. This allows to:
  - avoid passing the row-group to the constructor
  - avoid re-computing it for each cell starting on the current row

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

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

index aa5f14b59fec149c29318dcb16e70af57ec7b03e..b19426f460e75221de52f743e39c0a56cb2a585d 100644 (file)
@@ -43,7 +43,7 @@ class ActiveCell {
          */
         private int width;
         private int remainingLength;
-        private int baseWidth;
+        private int previousRowsLength;
         private int totalLength;
         private int includedLength;
         private int borderBefore;
@@ -53,7 +53,7 @@ class ActiveCell {
         private boolean keepWithNextSignal;
         private int lastPenaltyLength;
 
-        ActiveCell(PrimaryGridUnit pgu, EffRow row, int rowIndex, EffRow[] rowGroup, TableLayoutManager tableLM) {
+        ActiveCell(PrimaryGridUnit pgu, EffRow row, int rowIndex, int previousRowsLength, TableLayoutManager tableLM) {
             this.pgu = pgu;
             boolean makeBoxForWholeRow = false;
             if (row.getExplicitHeight().min > 0) {
@@ -80,6 +80,9 @@ class ActiveCell {
 //                    log.trace("column " + (column+1) + ": recording " + elementLists.size() + " element(s)");
 //                }
             }
+            includedLength = -1;  // Avoid troubles with cells having content of zero length
+            this.previousRowsLength = previousRowsLength;
+            width = previousRowsLength;
             totalLength = ElementListUtils.calcContentLength(elementList);
             if (pgu.getTable().isSeparateBorderModel()) {
                 borderBefore = pgu.getBorders().getBorderBeforeWidth(false)
@@ -96,20 +99,10 @@ class ActiveCell {
             end = -1;
             startRow = rowIndex;
             keepWithNextSignal = false;
-            computeBaseWidth(rowGroup);
             remainingLength = totalLength;
             goToNextLegalBreak();
         }
 
-        private void computeBaseWidth(EffRow[] rowGroup) {
-            width = 0;
-            includedLength = -1;  // Avoid troubles with cells having content of zero length
-            for (int prevRow = 0; prevRow < startRow; prevRow++) {
-                width += rowGroup[prevRow].getHeight().opt;
-            }
-            baseWidth = width;
-        }
-
         boolean endsOnRow(int rowIndex) {
             return rowIndex == startRow + pgu.getCell().getNumberRowsSpanned() - 1;
         }
@@ -177,7 +170,7 @@ class ActiveCell {
                 computeRemainingLength();
                 return false;
             } else {
-                return baseWidth + borderBefore + borderAfter + paddingBefore + paddingAfter > minStep;
+                return previousRowsLength + borderBefore + borderAfter + paddingBefore + paddingAfter > minStep;
             }
         }
 
index 358f22535b3770cf9e741d54fe72273c68be90ae..2ed175fca17ac69f1a5b939eb088a7d070bbc614 100644 (file)
@@ -49,6 +49,7 @@ public class TableStepper {
     /** Number of columns in the row group. */
     private int columnCount;
     private int totalHeight;
+    private int previousRowsLength = 0;
     private int activeRowIndex;
     private boolean rowBacktrackForLastStep;
     private boolean skippedStep;
@@ -128,7 +129,7 @@ public class TableStepper {
         for (int i = 0; i < columnCount; i++) {
             GridUnit gu = getActiveGridUnit(i);
             if (gu != null && !gu.isEmpty() && gu.isPrimary()) {
-                activeCells.add(new ActiveCell((PrimaryGridUnit) gu, row, activeRowIndex, rowGroup, getTableLM()));
+                activeCells.add(new ActiveCell((PrimaryGridUnit) gu, row, activeRowIndex, previousRowsLength, getTableLM()));
             }
         }
     }
@@ -347,6 +348,7 @@ public class TableStepper {
                             "break-after ignored on table-row because of row spanning "
                             + "in progress (See XSL 1.0, 7.19.1)", rowFO));
                 }
+                previousRowsLength += rowGroup[activeRowIndex].getHeight().opt;
                 activeRowIndex++;
                 if (log.isDebugEnabled()) {
                     log.debug("===> new row: " + activeRowIndex);