From 8c9f964e3c158d790305e04e2688522e92503b9c Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 17 Jul 2007 17:53:50 +0000 Subject: [PATCH] - Compute the height of already handled rows progressively in TableStepper - 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 --- .../fop/layoutmgr/table/ActiveCell.java | 19 ++++++------------- .../fop/layoutmgr/table/TableStepper.java | 4 +++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java index aa5f14b59..b19426f46 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java +++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java @@ -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; } } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 358f22535..2ed175fca 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -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); -- 2.39.5