aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/flow
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2007-11-14 11:14:03 +0000
committerVincent Hennebert <vhennebert@apache.org>2007-11-14 11:14:03 +0000
commit107b19a5b689d19264d49acb4524796cbf940958 (patch)
tree948b6d2e166a2d639e9d3966c81105d62f9dd3ee /src/java/org/apache/fop/fo/flow
parentec3c28e72612ba7bb6ecc95c5c5b2552c652570d (diff)
downloadxmlgraphics-fop-107b19a5b689d19264d49acb4524796cbf940958.tar.gz
xmlgraphics-fop-107b19a5b689d19264d49acb4524796cbf940958.zip
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
Diffstat (limited to 'src/java/org/apache/fop/fo/flow')
-rw-r--r--src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java11
-rw-r--r--src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java18
-rw-r--r--src/java/org/apache/fop/fo/flow/table/GridUnit.java46
-rw-r--r--src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java5
-rw-r--r--src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java7
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableBody.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java9
7 files changed, 57 insertions, 40 deletions
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 96fd54ef4..be487931b 100644
--- a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
@@ -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} */
@@ -63,11 +63,6 @@ public class EmptyGridUnit extends GridUnit {
}
/** {@inheritDoc} */
- public TableRow getRow() {
- return this.row;
- }
-
- /** {@inheritDoc} */
public boolean isLastGridUnitColSpan() {
return true;
}
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 0b10ebe18..3fef2795d 100644
--- a/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
@@ -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;
@@ -117,13 +119,18 @@ class FixedColRowGroupBuilder extends RowGroupBuilder {
}
/** {@inheritDoc} */
+ void startRow(TableRow tableRow) {
+ currentTableRow = tableRow;
+ }
+
+ /** {@inheritDoc} */
void endRow(TableCellContainer container) {
List currentRow = (List) rows.get(currentRowIndex);
lastRow = currentRow;
// 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} */
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 d1958605c..f7c7672e3 100644
--- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
@@ -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() {
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 cbc7f1166..fa50b525f 100644
--- a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
@@ -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);
}
diff --git a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
index 1e1f9b894..220eff85b 100644
--- a/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
@@ -49,6 +49,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
* part (i.e., the given container itself or its parent if this is a table-row) will
diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java
index ece1f0049..6b12271fc 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -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) {
diff --git a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
index e35ad5c27..66322b1b7 100644
--- a/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
+++ b/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
@@ -64,6 +64,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() {
public void play(RowGroupBuilder rowGroupBuilder) {