aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/fo/flow/table/EffRow.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java7
-rw-r--r--src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java7
-rw-r--r--src/java/org/apache/fop/fo/flow/table/GridUnit.java42
-rw-r--r--src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java50
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowPainter.java12
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java6
9 files changed, 64 insertions, 72 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 03012aa3c..fb2162e55 100644
--- a/src/java/org/apache/fop/fo/flow/table/EffRow.java
+++ b/src/java/org/apache/fop/fo/flow/table/EffRow.java
@@ -57,7 +57,7 @@ public class EffRow {
for (Iterator guIter = gridUnits.iterator(); guIter.hasNext();) {
Object gu = guIter.next();
if (gu instanceof PrimaryGridUnit) {
- ((PrimaryGridUnit) gu).setStartRow(index);
+ ((PrimaryGridUnit) gu).setRowIndex(index);
}
}
}
diff --git a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
index 7a8b0be62..1f0f7be04 100644
--- a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
@@ -30,11 +30,10 @@ public class EmptyGridUnit extends GridUnit {
/**
* @param table the containing table
* @param row the table-row element this grid unit belongs to (if any)
- * @param startRow index of the row this grid unit belongs to, 0-based
- * @param startCol column index, 0-based
+ * @param colIndex column index, 0-based
*/
- EmptyGridUnit(Table table, TableRow row, int startRow, int startCol) {
- super(table, row, table.getColumn(startCol), startCol, 0, 0);
+ EmptyGridUnit(Table table, TableRow row, int colIndex) {
+ super(table, row, table.getColumn(colIndex), 0, 0);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
index 2f8b0bbb8..51279c399 100644
--- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
@@ -87,8 +87,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
GridUnit[] cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
cellRow[0] = pgu;
for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) {
- GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex + j),
- columnIndex + j, j, 0);
+ GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex + j), j, 0);
row.set(columnIndex + j, gu);
cellRow[j] = gu;
}
@@ -98,7 +97,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
for (int j = 0; j < cell.getNumberColumnsSpanned(); j++) {
GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex + j),
- columnIndex + j, j, i);
+ j, i);
row.set(columnIndex + j, gu);
cellRow[j] = gu;
}
@@ -124,7 +123,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
// Fill gaps with empty grid units
for (int i = 0; i < numberOfColumns; i++) {
if (currentRow.get(i) == null) {
- currentRow.set(i, new EmptyGridUnit(table, currentTableRow, currentRowIndex, i));
+ currentRow.set(i, new EmptyGridUnit(table, currentTableRow, i));
}
}
borderResolver.endRow(currentRow, container);
diff --git a/src/java/org/apache/fop/fo/flow/table/GridUnit.java b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
index a583697f6..75d0c5516 100644
--- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
@@ -59,9 +59,6 @@ public class GridUnit {
/** Table column that this grid unit belongs to */
private TableColumn column;
- /** start index of grid unit within row in column direction */
- private int startCol;
-
/** index of grid unit within cell in column direction */
private int colSpanIndex;
@@ -84,13 +81,12 @@ public class GridUnit {
* @param table the containing table
* @param row the table-row element this grid unit belongs to (if any)
* @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
* @param colSpanIndex index of this grid unit in the span, in column direction
* @param rowSpanIndex index of this grid unit in the span, in row direction
*/
- protected GridUnit(Table table, TableRow row, TableColumn column, int startCol,
- int colSpanIndex, int rowSpanIndex) {
- this(row, column, startCol, colSpanIndex, rowSpanIndex);
+ protected GridUnit(Table table, TableRow row, TableColumn column, int colSpanIndex,
+ int rowSpanIndex) {
+ this(row, column, colSpanIndex, rowSpanIndex);
setBorders(table);
}
@@ -100,13 +96,12 @@ public class GridUnit {
* @param cell table cell which occupies this grid unit
* @param row the table-row element this grid unit belongs to (if any)
* @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
* @param colSpanIndex index of this grid unit in the span, in column direction
* @param rowSpanIndex index of this grid unit in the span, in row direction
*/
- protected GridUnit(TableCell cell, TableRow row, TableColumn column, int startCol,
- int colSpanIndex, int rowSpanIndex) {
- this(row, column, startCol, colSpanIndex, rowSpanIndex);
+ protected GridUnit(TableCell cell, TableRow row, TableColumn column, int colSpanIndex,
+ int rowSpanIndex) {
+ this(row, column, colSpanIndex, rowSpanIndex);
this.cell = cell;
setBorders(cell.getTable());
}
@@ -117,21 +112,18 @@ public class GridUnit {
* @param primary the before-start grid unit of the cell containing this grid unit
* @param row the table-row element this grid unit belongs to (if any)
* @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
* @param colSpanIndex index of this grid unit in the span, in column direction
* @param rowSpanIndex index of this grid unit in the span, in row direction
*/
- GridUnit(PrimaryGridUnit primary, TableRow row, TableColumn column, int startCol,
- int colSpanIndex, int rowSpanIndex) {
- this(primary.getCell(), row, column, startCol, colSpanIndex, rowSpanIndex);
+ GridUnit(PrimaryGridUnit primary, TableRow row, TableColumn column, int colSpanIndex,
+ int rowSpanIndex) {
+ this(primary.getCell(), row, column, colSpanIndex, rowSpanIndex);
this.primary = primary;
}
- private GridUnit(TableRow row, TableColumn column, int startCol, int colSpanIndex,
- int rowSpanIndex) {
+ private GridUnit(TableRow row, TableColumn column, int colSpanIndex, int rowSpanIndex) {
this.row = row;
this.column = column;
- this.startCol = startCol;
this.colSpanIndex = colSpanIndex;
this.rowSpanIndex = rowSpanIndex;
}
@@ -222,15 +214,6 @@ public class GridUnit {
return cell == null;
}
- /**
- * Returns the index of the column this grid unit belongs to.
- *
- * @return the column index, 0-based
- */
- public int getStartCol() {
- return startCol;
- }
-
/** @return true if the grid unit is the last in column spanning direction */
public boolean isLastGridUnitColSpan() {
return (colSpanIndex == cell.getNumberColumnsSpanned() - 1);
@@ -474,10 +457,9 @@ public class GridUnit {
buffer.append("(last)");
}
}
- buffer.append(" startCol=").append(startCol);
if (!isPrimary() && getPrimary() != null) {
- buffer.append(" primary=").append(getPrimary().getStartRow());
- buffer.append("/").append(getPrimary().getStartCol());
+ buffer.append(" primary=").append(getPrimary().getRowIndex());
+ buffer.append("/").append(getPrimary().getColIndex());
if (getPrimary().getCell() != null) {
buffer.append(" id=" + getPrimary().getCell().getId());
}
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 684fa58d1..b73cd62d7 100644
--- a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
@@ -22,8 +22,6 @@ package org.apache.fop.fo.flow.table;
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
@@ -34,14 +32,17 @@ import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
*/
public class PrimaryGridUnit extends GridUnit {
- private static Log log = LogFactory.getLog(PrimaryGridUnit.class);
-
/** Cell layout manager. */
private TableCellLayoutManager cellLM;
/** List of Knuth elements representing the contents of the cell. */
private LinkedList elements;
- /** Index of row where this cell starts */
- private int startRow;
+
+ /** Index of the row where this cell starts. */
+ private int rowIndex;
+
+ /** Index of the column where this cell starts. */
+ private int colIndex;
+
/** Links to the spanned grid units. (List of GridUnit arrays, one array represents a row) */
private List rows;
/** The calculated size of the cell's content. (cached value) */
@@ -56,15 +57,14 @@ public class PrimaryGridUnit extends GridUnit {
* @param cell table cell which occupies this grid unit
* @param row the table-row element this grid unit belongs to (if any)
* @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to, zero-based
- * @param startRow index of the row this grid unit belongs to, zero-based
+ * @param colIndex index of the column this grid unit belongs to, zero-based
*/
- PrimaryGridUnit(TableCell cell, TableRow row, TableColumn column, int startCol) {
- super(cell, row, column, startCol, 0, 0);
+ PrimaryGridUnit(TableCell cell, TableRow row, TableColumn column, int colIndex) {
+ super(cell, row, column, 0, 0);
+ this.colIndex = colIndex;
this.isSeparateBorderModel = column.getTable().isSeparateBorderModel(); // TODO
this.halfBorderSeparationBPD = column.getTable().getBorderSeparation().getBPD().getLength()
.getValue() / 2; // TODO
- log.trace("PrimaryGridUnit created, row " + startRow + " col " + startCol);
}
public TableCellLayoutManager getCellLM() {
@@ -248,17 +248,29 @@ public class PrimaryGridUnit extends GridUnit {
rows.add(row);
}
- void setStartRow(int startRow) {
- this.startRow = startRow;
+ void setRowIndex(int rowIndex) {
+ this.rowIndex = rowIndex;
}
/**
- * Returns the index of the row this grid unit belongs to.
- *
- * @return the index of the row this grid unit belongs to.
+ * Returns the index of the row this grid unit belongs to. This is the index, in the
+ * enclosing table part, of the first row spanned by the cell. Note that if the table
+ * has several table-body children, then the index grows continuously across them;
+ * they are considered to form one single part, the "body of the table".
+ *
+ * @return the index of the row this grid unit belongs to, 0-based.
+ */
+ public int getRowIndex() {
+ return rowIndex;
+ }
+
+ /**
+ * Returns the index of the column this grid unit belongs to.
+ *
+ * @return the column index, 0-based
*/
- public int getStartRow() {
- return this.startRow;
+ public int getColIndex() {
+ return colIndex;
}
/**
@@ -290,7 +302,7 @@ public class PrimaryGridUnit extends GridUnit {
/** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" startRow=").append(startRow);
+ sb.append(" rowIndex=").append(rowIndex);
return sb.toString();
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
index 9364d2fba..6d66da097 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
@@ -175,8 +175,8 @@ class RowGroupLayoutManager {
//Calculate width of cell
int spanWidth = 0;
- for (int i = primary.getStartCol();
- i < primary.getStartCol()
+ for (int i = primary.getColIndex();
+ i < primary.getColIndex()
+ primary.getCell().getNumberColumnsSpanned();
i++) {
if (tableLM.getColumns().getColumn(i + 1) != null) {
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index f46b503bb..e5b90aa5f 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -117,7 +117,7 @@ class RowPainter {
if (log.isDebugEnabled()) {
log.debug(">" + cellPart);
}
- int colIndex = cellPart.pgu.getStartCol();
+ int colIndex = cellPart.pgu.getColIndex();
if (firstCellParts[colIndex] == null) {
firstCellParts[colIndex] = cellPart;
cellHeights[colIndex] = cellPart.getBorderPaddingBefore(firstCellOnPage[colIndex]);
@@ -159,7 +159,7 @@ class RowPainter {
int cellHeight = cellHeights[i];
cellHeight += lastCellParts[i].getConditionalAfterContentLength();
cellHeight += lastCellParts[i].getBorderPaddingAfter(lastInPart);
- int cellOffset = getRowOffset(Math.max(firstCellParts[i].pgu.getStartRow(),
+ int cellOffset = getRowOffset(Math.max(firstCellParts[i].pgu.getRowIndex(),
firstRowIndex));
actualRowHeight = Math.max(actualRowHeight, cellOffset + cellHeight
- currentRowOffset);
@@ -256,7 +256,7 @@ class RowPainter {
* Determine the index of the first row of this cell that will be displayed on the
* current page.
*/
- int startRowIndex = Math.max(pgu.getStartRow(), firstRowIndex);
+ int startRowIndex = Math.max(pgu.getRowIndex(), firstRowIndex);
int currentRowIndex = currentRow.getIndex();
/*
@@ -280,7 +280,7 @@ class RowPainter {
int cellTotalHeight = rowHeight + currentRowOffset - cellOffset;
if (log.isDebugEnabled()) {
log.debug("Creating area for cell:");
- log.debug(" start row: " + pgu.getStartRow() + " " + currentRowOffset + " "
+ log.debug(" start row: " + pgu.getRowIndex() + " " + currentRowOffset + " "
+ cellOffset);
log.debug(" rowHeight=" + rowHeight + " cellTotalHeight=" + cellTotalHeight);
}
@@ -295,8 +295,8 @@ class RowPainter {
startPos, endPos, prevBreak);
}
cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1),
- layoutContext, spannedGridRowHeights, startRowIndex - pgu.getStartRow(),
- currentRowIndex - pgu.getStartRow(), borderBeforeWhich, borderAfterWhich,
+ layoutContext, spannedGridRowHeights, startRowIndex - pgu.getRowIndex(),
+ currentRowIndex - pgu.getRowIndex(), borderBeforeWhich, borderAfterWhich,
startRowIndex == firstRowOnPageIndex, lastOnPage);
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index 421d3d580..9469a1121 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -346,8 +346,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
false, false, this);
}
} else {
- boolean inFirstColumn = (primaryGridUnit.getStartCol() == 0);
- boolean inLastColumn = (primaryGridUnit.getStartCol()
+ boolean inFirstColumn = (primaryGridUnit.getColIndex() == 0);
+ boolean inLastColumn = (primaryGridUnit.getColIndex()
+ getTableCell().getNumberColumnsSpanned() == getTable()
.getNumberOfColumns());
if (!primaryGridUnit.hasSpanning()) {
@@ -407,7 +407,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
int bpd = spannedGridRowHeights[y - startRow];
int dx = xoffset;
for (int x = 0; x < gridUnits.length; x++) {
- int ipd = getTable().getColumn(primaryGridUnit.getStartCol() + x)
+ int ipd = getTable().getColumn(primaryGridUnit.getColIndex() + x)
.getColumnWidth().getValue((PercentBaseContext) getParent());
if (blocks[y][x] != null) {
Block block = blocks[y][x];
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index 3455e8a32..1c748a5cf 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -33,7 +33,7 @@ import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.table.EffRow;
-import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
import org.apache.fop.fo.flow.table.TableRow;
@@ -273,8 +273,8 @@ public class TableContentLayoutManager implements PercentBaseContext {
* @param gu the grid unit
* @return the requested X offset
*/
- protected int getXOffsetOfGridUnit(GridUnit gu) {
- int col = gu.getStartCol();
+ protected int getXOffsetOfGridUnit(PrimaryGridUnit gu) {
+ int col = gu.getColIndex();
return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM());
}