aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2008-01-10 15:53:20 +0000
committerVincent Hennebert <vhennebert@apache.org>2008-01-10 15:53:20 +0000
commit8fb6ba565df16744165598c9a74d3dcc5ac85795 (patch)
tree92851aad555a7bdbfc232458351a7b9dd1e813e1
parente8fd5b3999e6bfbda9453017012266951db71c83 (diff)
downloadxmlgraphics-fop-8fb6ba565df16744165598c9a74d3dcc5ac85795.tar.gz
xmlgraphics-fop-8fb6ba565df16744165598c9a74d3dcc5ac85795.zip
- renamed variables for clarity
- moved the computation of a cell's content length in PrimaryGridUnit - better javadoc for getHeight method in EffRow git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@610821 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/flow/table/EffRow.java11
-rw-r--r--src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java59
3 files changed, 39 insertions, 40 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/EffRow.java b/src/java/org/apache/fop/fo/flow/table/EffRow.java
index 17ab67f98..03012aa3c 100644
--- a/src/java/org/apache/fop/fo/flow/table/EffRow.java
+++ b/src/java/org/apache/fop/fo/flow/table/EffRow.java
@@ -80,13 +80,20 @@ public class EffRow {
return getGridUnit(0).getRow();
}
- /** @return the calculated height for this EffRow. */
+ /**
+ * Returns the calculated height for this EffRow, including the cells'
+ * bpds/paddings/borders, and the table's border-separation.
+ *
+ * @return the row's height
+ */
public MinOptMax getHeight() {
return this.height;
}
/**
- * Sets the calculated height for this EffRow.
+ * Sets the calculated height for this EffRow, including everything (cells' bpds,
+ * paddings, borders, and border-separation).
+ *
* @param mom the calculated height
*/
public void setHeight(MinOptMax mom) {
diff --git a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
index 2f2cd940e..ae8db7ba7 100644
--- a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
/**
@@ -142,13 +143,11 @@ public class PrimaryGridUnit extends GridUnit {
return getHalfMaxBeforeBorderWidth() + getHalfMaxAfterBorderWidth();
}
- /** @param value The length of the cell content to remember. */
- public void setContentLength(int value) {
- this.contentLength = value;
- }
-
/** @return the length of the cell content. */
public int getContentLength() {
+ if (contentLength < 0) {
+ contentLength = ElementListUtils.calcContentLength(elements);
+ }
return contentLength;
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
index 028d60bf3..3fa40a8fd 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
@@ -148,9 +148,9 @@ class RowGroupLayoutManager {
TableRow tableRow = null;
// The row's minimum content height; 0 if the row's height is auto, otherwise
// the .minimum component of the explicitly specified value
- int minContentHeight = 0;
- int maxCellHeight = 0;
- int effRowContentHeight = 0;
+ int minRowBPD = 0;
+ // The BPD of the biggest cell in the row
+ int maxCellBPD = 0;
for (int j = 0; j < row.getGridUnits().size(); j++) {
assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size();
maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
@@ -168,14 +168,12 @@ class RowGroupLayoutManager {
tableRow = primary.getRow();
//Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
- LengthRangeProperty bpd = tableRow.getBlockProgressionDimension();
- if (!bpd.getMinimum(tableLM).isAuto()) {
- minContentHeight = Math.max(
- minContentHeight,
- bpd.getMinimum(
- tableLM).getLength().getValue(tableLM));
+ LengthRangeProperty rowBPD = tableRow.getBlockProgressionDimension();
+ if (!rowBPD.getMinimum(tableLM).isAuto()) {
+ minRowBPD = Math.max(minRowBPD,
+ rowBPD.getMinimum(tableLM).getLength().getValue(tableLM));
}
- MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+ MinOptMaxUtil.restrict(explicitRowHeights[rgi], rowBPD, tableLM);
}
@@ -218,31 +216,27 @@ class RowGroupLayoutManager {
}
}
-
- //Calculate height of cell contents
- primary.setContentLength(ElementListUtils.calcContentLength(
- primary.getElements()));
- maxCellHeight = Math.max(maxCellHeight, primary.getContentLength());
-
//Calculate height of row, see CSS21, 17.5.3 Table height algorithms
if (gu.isLastGridUnitRowSpan()) {
- int effCellContentHeight = minContentHeight;
- LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension();
- if (!bpd.getMinimum(tableLM).isAuto()) {
- effCellContentHeight = Math.max(
- effCellContentHeight,
- bpd.getMinimum(tableLM).getLength().getValue(tableLM));
+ // The effective cell's bpd, after taking into account bpd
+ // (possibly explicitly) set on the row or on the cell, and the
+ // cell's content length
+ int effectiveCellBPD = minRowBPD;
+ LengthRangeProperty cellBPD = primary.getCell()
+ .getBlockProgressionDimension();
+ if (!cellBPD.getMinimum(tableLM).isAuto()) {
+ effectiveCellBPD = Math.max(effectiveCellBPD,
+ cellBPD.getMinimum(tableLM).getLength().getValue(tableLM));
}
- if (!bpd.getOptimum(tableLM).isAuto()) {
- effCellContentHeight = Math.max(
- effCellContentHeight,
- bpd.getOptimum(tableLM).getLength().getValue(tableLM));
+ if (!cellBPD.getOptimum(tableLM).isAuto()) {
+ effectiveCellBPD = Math.max(effectiveCellBPD,
+ cellBPD.getOptimum(tableLM).getLength().getValue(tableLM));
}
if (gu.getRowSpanIndex() == 0) {
//TODO ATM only non-row-spanned cells are taken for this
- MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM);
+ MinOptMaxUtil.restrict(explicitRowHeights[rgi], cellBPD, tableLM);
}
- effCellContentHeight = Math.max(effCellContentHeight,
+ effectiveCellBPD = Math.max(effectiveCellBPD,
primary.getContentLength());
int borderWidths;
@@ -253,13 +247,12 @@ class RowGroupLayoutManager {
borderWidths = primary.getHalfMaxBorderWidth();
}
int padding = 0;
- effRowContentHeight = Math.max(effRowContentHeight,
- effCellContentHeight);
+ maxCellBPD = Math.max(maxCellBPD, effectiveCellBPD);
CommonBorderPaddingBackground cbpb
= primary.getCell().getCommonBorderPaddingBackground();
padding += cbpb.getPaddingBefore(false, primary.getCellLM());
padding += cbpb.getPaddingAfter(false, primary.getCellLM());
- int effRowHeight = effCellContentHeight
+ int effRowHeight = effectiveCellBPD
+ padding + borderWidths
+ 2 * tableLM.getHalfBorderSeparationBPD();
for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) {
@@ -279,13 +272,13 @@ class RowGroupLayoutManager {
row.setHeight(rowHeights[rgi]);
row.setExplicitHeight(explicitRowHeights[rgi]);
- if (effRowContentHeight > row.getExplicitHeight().max) {
+ if (maxCellBPD > row.getExplicitHeight().max) {
log.warn(FONode.decorateWithContextInfo(
"The contents of row " + (row.getIndex() + 1)
+ " are taller than they should be (there is a"
+ " block-progression-dimension or height constraint on the indicated row)."
+ " Due to its contents the row grows"
- + " to " + effRowContentHeight + " millipoints, but the row shouldn't get"
+ + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
+ " any taller than " + row.getExplicitHeight() + " millipoints.",
row.getTableRow()));
}