Browse Source

Restored the setting of the parent table-row element on grid units


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@594836 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Vincent Hennebert 16 years ago
parent
commit
107b19a5b6

+ 3
- 8
src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java View File

@@ -27,16 +27,16 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
*/
public class EmptyGridUnit extends GridUnit {

private TableRow row;
private TableBody body;

/**
* @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
*/
EmptyGridUnit(Table table, int startRow, int startCol) {
super(table, table.getColumn(startCol), startCol, 0, 0);
EmptyGridUnit(Table table, TableRow row, int startRow, int startCol) {
super(table, row, table.getColumn(startCol), startCol, 0, 0);
}

/** {@inheritDoc} */
@@ -62,11 +62,6 @@ public class EmptyGridUnit extends GridUnit {
return this.body;
}

/** {@inheritDoc} */
public TableRow getRow() {
return this.row;
}

/** {@inheritDoc} */
public boolean isLastGridUnitColSpan() {
return true;

+ 13
- 5
src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java View File

@@ -35,6 +35,8 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
/** Number of columns in the corresponding table. */
private int numberOfColumns;

private TableRow currentTableRow = null;

/** 0-based, index in the row group. */
private int currentRowIndex;

@@ -83,15 +85,15 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
rows.add(effRow);
}
int columnIndex = cell.getColumnNumber() - 1;
PrimaryGridUnit pgu = new PrimaryGridUnit(cell, table.getColumn(columnIndex), columnIndex,
currentRowIndex);
PrimaryGridUnit pgu = new PrimaryGridUnit(cell, currentTableRow,
table.getColumn(columnIndex), columnIndex, currentRowIndex);
List row = (List) rows.get(currentRowIndex);
row.set(columnIndex, pgu);
// TODO
GridUnit[] cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
cellRow[0] = pgu;
for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) {
GridUnit gu = new GridUnit(pgu, table.getColumn(columnIndex + j),
GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex + j),
columnIndex + j, j, 0);
row.set(columnIndex + j, gu);
cellRow[j] = gu;
@@ -101,7 +103,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
row = (List) rows.get(currentRowIndex + i);
cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
for (int j = 0; j < cell.getNumberColumnsSpanned(); j++) {
GridUnit gu = new GridUnit(pgu, table.getColumn(columnIndex + j),
GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex + j),
columnIndex + j, j, i);
row.set(columnIndex + j, gu);
cellRow[j] = gu;
@@ -116,6 +118,11 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
}
}

/** {@inheritDoc} */
void startRow(TableRow tableRow) {
currentTableRow = tableRow;
}

/** {@inheritDoc} */
void endRow(TableCellContainer container) {
List currentRow = (List) rows.get(currentRowIndex);
@@ -123,7 +130,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, currentRowIndex, i));
currentRow.set(i, new EmptyGridUnit(table, currentTableRow, currentRowIndex, i));
}
}
borderResolver.endRow(currentRow, container);
@@ -146,6 +153,7 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
} else {
currentRowIndex++;
}
currentTableRow = null;
}

/** {@inheritDoc} */

+ 21
- 25
src/java/org/apache/fop/fo/flow/table/GridUnit.java View File

@@ -69,7 +69,7 @@ public class GridUnit {
/** Table cell which occupies this grid unit */
protected TableCell cell;

/** Table row which occupies this grid unit (may be null) */
/** Table row occupied by this grid unit (may be null). */
private TableRow row;

/** Table column that this grid unit belongs to */
@@ -98,14 +98,15 @@ public class GridUnit {
* Creates a new grid unit.
*
* @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, TableColumn column, int startCol, int colSpanIndex,
int rowSpanIndex) {
this(column, startCol, colSpanIndex, rowSpanIndex);
protected GridUnit(Table table, TableRow row, TableColumn column, int startCol,
int colSpanIndex, int rowSpanIndex) {
this(row, column, startCol, colSpanIndex, rowSpanIndex);
setBorders(table);
}

@@ -113,14 +114,15 @@ public class GridUnit {
* Creates a new grid unit.
*
* @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, TableColumn column, int startCol, int colSpanIndex,
int rowSpanIndex) {
this(column, startCol, colSpanIndex, rowSpanIndex);
protected GridUnit(TableCell cell, TableRow row, TableColumn column, int startCol,
int colSpanIndex, int rowSpanIndex) {
this(row, column, startCol, colSpanIndex, rowSpanIndex);
this.cell = cell;
setBorders(cell.getTable());
}
@@ -129,18 +131,21 @@ public class GridUnit {
* Creates a new grid unit.
*
* @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, TableColumn column, int startCol, int colSpanIndex,
int rowSpanIndex) {
this(primary.getCell(), column, startCol, colSpanIndex, rowSpanIndex);
GridUnit(PrimaryGridUnit primary, TableRow row, TableColumn column, int startCol,
int colSpanIndex, int rowSpanIndex) {
this(primary.getCell(), row, column, startCol, colSpanIndex, rowSpanIndex);
this.primary = primary;
}

private GridUnit(TableColumn column, int startCol, int colSpanIndex, int rowSpanIndex) {
private GridUnit(TableRow row, TableColumn column, int startCol, int colSpanIndex,
int rowSpanIndex) {
this.row = row;
this.column = column;
this.startCol = startCol;
this.colSpanIndex = colSpanIndex;
@@ -181,23 +186,14 @@ public class GridUnit {
return column;
}

public TableRow getRow() {
if (row != null) {
return row;
} else if (getCell().getParent() instanceof TableRow) {
return (TableRow) getCell().getParent();
} else {
return null;
}
}

/**
* Sets the table-row FO, if applicable.
* Returns the fo:table-row element (if any) this grid unit belongs to.
*
* @param row the table-row FO
* @return the row containing this grid unit, or null if there is no fo:table-row
* element in the corresponding table-part
*/
public void setRow(TableRow row) {
this.row = row;
public TableRow getRow() {
return row;
}

public TableBody getBody() {

+ 3
- 2
src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java View File

@@ -49,12 +49,13 @@ public class PrimaryGridUnit extends GridUnit {
* Creates a new primary grid unit.
*
* @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
*/
PrimaryGridUnit(TableCell cell, TableColumn column, int startCol, int startRow) {
super(cell, column, startCol, 0, 0);
PrimaryGridUnit(TableCell cell, TableRow row, TableColumn column, int startCol, int startRow) {
super(cell, row, column, startCol, 0, 0);
this.startRow = startRow;
log.trace("PrimaryGridUnit created, row " + startRow + " col " + startCol);
}

+ 7
- 0
src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java View File

@@ -48,6 +48,13 @@ abstract class RowGroupBuilder {
*/
abstract void addTableCell(TableCell cell);

/**
* Receives notification of the start of an fo:table-row element.
*
* @param tableRow the row being started
*/
abstract void startRow(TableRow tableRow);

/**
* Receives notification of the end of the current row. If the current row finishes
* the row group, the {@link TableBody#addRowGroup(List)} method of the parent table

+ 1
- 0
src/java/org/apache/fop/fo/flow/table/TableBody.java View File

@@ -202,6 +202,7 @@ public class TableBody extends TableCellContainer {
}
rowsStarted = true;
lastRow = (TableRow) child;
getTable().getRowGroupBuilder().startRow(lastRow);
break;
case FO_TABLE_CELL:
if (!rowsStarted) {

+ 9
- 0
src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java View File

@@ -63,6 +63,15 @@ class VariableColRowGroupBuilder extends RowGroupBuilder {
});
}

/** {@inheritDoc} */
void startRow(final TableRow tableRow) {
events.add(new Event() {
public void play(RowGroupBuilder rowGroupBuilder) {
rowGroupBuilder.startRow(tableRow);
}
});
}

/** {@inheritDoc} */
void endRow(final TableCellContainer container) {
events.add(new Event() {

Loading…
Cancel
Save