for (Iterator guIter = gridUnits.iterator(); guIter.hasNext();) {
Object gu = guIter.next();
if (gu instanceof PrimaryGridUnit) {
- ((PrimaryGridUnit) gu).setStartRow(index);
+ ((PrimaryGridUnit) gu).setRowIndex(index);
}
}
}
/**
* @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} */
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;
}
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;
}
// 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);
/** 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;
* @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);
}
* @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());
}
* @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;
}
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);
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());
}
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;
*/
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) */
* @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() {
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;
}
/**
/** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" startRow=").append(startRow);
+ sb.append(" rowIndex=").append(rowIndex);
return sb.toString();
}
//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) {
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]);
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);
* 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();
/*
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);
}
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);
}
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()) {
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];
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;
* @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());
}