aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2005-09-20 19:29:31 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2005-09-20 19:29:31 +0000
commit6eff247a8277cb748598778c71d6b49ca898b162 (patch)
tree82d2a629c6f3ab3a8232993df0bd9552268ebc93 /src/java
parent9ba44a77f51fba6564e1fd23c4dc72cf8b39e989 (diff)
downloadxmlgraphics-fop-6eff247a8277cb748598778c71d6b49ca898b162.tar.gz
xmlgraphics-fop-6eff247a8277cb748598778c71d6b49ca898b162.zip
Update for initial-values of column-number + some pending style-violation corrections
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@290540 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/fo/flow/Table.java1
-rw-r--r--src/java/org/apache/fop/fo/flow/TableBody.java26
-rw-r--r--src/java/org/apache/fop/fo/flow/TableCell.java28
-rw-r--r--src/java/org/apache/fop/fo/flow/TableColumn.java6
-rw-r--r--src/java/org/apache/fop/fo/flow/TableFObj.java35
-rw-r--r--src/java/org/apache/fop/fo/flow/TableRow.java30
6 files changed, 91 insertions, 35 deletions
diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java
index 474efc6b7..f65a68f58 100644
--- a/src/java/org/apache/fop/fo/flow/Table.java
+++ b/src/java/org/apache/fop/fo/flow/Table.java
@@ -427,6 +427,7 @@ public class Table extends TableFObj {
* (used by TableColumn.bind() in case the column-number
* was explicitly specified)
*
+ * @param newIndex the new value for column index
*/
protected void setCurrentColumnIndex(int newIndex) {
columnIndex = newIndex;
diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java
index 460e7b803..8d8cd53a2 100644
--- a/src/java/org/apache/fop/fo/flow/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/TableBody.java
@@ -50,11 +50,15 @@ public class TableBody extends TableFObj {
private PropertyList savedPropertyList;
- //used for validation
+ /**
+ * used for validation
+ */
protected boolean tableRowsFound = false;
protected boolean tableCellsFound = false;
- //used for initial values of column-number property
+ /**
+ * used for initial values of column-number property
+ */
protected List pendingSpans;
protected BitSet usedColumnIndices = new BitSet();
private int columnIndex = 1;
@@ -175,7 +179,7 @@ public class TableBody extends TableFObj {
int colSpan = cell.getNumberColumnsSpanned();
//if there were no explicit columns, pendingSpans
//will not be properly initialized for the first row
- if (firstRow && ((Table) parent).columns == null) {
+ if (firstRow && getTable().columns == null) {
if (pendingSpans == null) {
pendingSpans = new java.util.ArrayList();
}
@@ -198,8 +202,8 @@ public class TableBody extends TableFObj {
//take up more than three columnIndices...
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if (((Table) parent).columns != null) {
- List cols = ((Table) parent).columns;
+ if (getTable().columns != null) {
+ List cols = getTable().columns;
int tmpIndex = endIndex;
for (int i = startIndex; i <= tmpIndex; ++i) {
if (i < cols.size() && cols.get(i) == null) {
@@ -298,8 +302,8 @@ public class TableBody extends TableFObj {
*
*/
protected void initPendingSpans() {
- if (((Table) parent).columns != null) {
- List tableCols = ((Table) parent).columns;
+ if (getTable().columns != null) {
+ List tableCols = getTable().columns;
pendingSpans = new java.util.ArrayList(tableCols.size());
for (int i = tableCols.size(); --i >= 0;) {
pendingSpans.add(null);
@@ -362,9 +366,9 @@ public class TableBody extends TableFObj {
//the updated index is not assigned to any
//column, increment further until the next
//index occupied by a column...
- if (((Table) parent).columns != null) {
- while (columnIndex <= ((Table) parent).columns.size()
- && !((Table) parent).isColumnNumberUsed(columnIndex) ) {
+ if (getTable().columns != null) {
+ while (columnIndex <= getTable().columns.size()
+ && !getTable().isColumnNumberUsed(columnIndex) ) {
columnIndex++;
}
}
@@ -396,6 +400,6 @@ public class TableBody extends TableFObj {
*/
protected boolean isColumnNumberUsed(int colNr) {
return usedColumnIndices.get(colNr - 1);
- }
+ }
}
diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java
index 7fb8f8b28..fa03a0f88 100644
--- a/src/java/org/apache/fop/fo/flow/TableCell.java
+++ b/src/java/org/apache/fop/fo/flow/TableCell.java
@@ -133,17 +133,29 @@ public class TableCell extends TableFObj {
//check if any of the column-numbers occupied by this cell
//are already in use in the current row...
- for( int i = getColumnNumber();
- ++i <= getColumnNumber() + getNumberColumnsSpanned(); ) {
- if( ((TableFObj) parent).isColumnNumberUsed(i - 1) ) {
- throw new FOPException("cell overlaps in column " + (i - 1),
- locator);
+ int i = -1;
+ int columnIndex = columnNumber.getValue();
+ while (++i < getNumberColumnsSpanned()) {
+ //if table has explicit columns and the column-number isn't
+ //assigned to any column, increment further until the next
+ //column is encountered
+ if (getTable().columns != null) {
+ while (columnIndex <= getTable().columns.size()
+ && !getTable().isColumnNumberUsed(columnIndex)) {
+ columnIndex++;
+ }
+ }
+ //if column-number is already in use by another cell
+ //in the current row => error!
+ if (((TableFObj) parent).isColumnNumberUsed(columnIndex)) {
+ throw new FOPException("fo:table-cell overlaps in column "
+ + i, locator);
}
}
//if column-number was explicitly specified, force the parent's current
//column index to the specified value, so that the updated index will
//be the correct initial value for the next cell (see Rec 7.26.8)
- if( pList.getExplicit(PR_COLUMN_NUMBER) != null ) {
+ if (pList.getExplicit(PR_COLUMN_NUMBER) != null) {
((TableFObj) parent).setCurrentColumnIndex(columnNumber.getValue());
}
}
@@ -165,7 +177,7 @@ public class TableCell extends TableFObj {
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
- if( (startsRow() || endsRow())
+ if ((startsRow() || endsRow())
&& getParent().getNameId() == FO_TABLE_ROW ) {
getLogger().warn("starts-row/ends-row for fo:table-cells "
+ "non-applicable for children of an fo:table-row.");
@@ -192,6 +204,8 @@ public class TableCell extends TableFObj {
/**
* Set position relative to table (set by body?)
+ *
+ * @param offset new offset
*/
public void setStartOffset(int offset) {
startOffset = offset;
diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java
index 107c1df7f..c7b7eab6f 100644
--- a/src/java/org/apache/fop/fo/flow/TableColumn.java
+++ b/src/java/org/apache/fop/fo/flow/TableColumn.java
@@ -75,7 +75,7 @@ public class TableColumn extends TableFObj {
visibility = pList.get(PR_VISIBILITY).getEnum();
super.bind(pList);
- if( pList.getExplicit(PR_COLUMN_NUMBER) != null ) {
+ if (pList.getExplicit(PR_COLUMN_NUMBER) != null) {
if (columnNumber.getValue() <= 0) {
//TODO: This is actually a non-fatal error. See Rec 7.26.8:
//"A positive integer. If a negative or non-integer value
@@ -83,7 +83,7 @@ public class TableColumn extends TableFObj {
// nearest integer value greater than or equal to 1."
throw new PropertyException("column-number must be 1 or bigger, "
+ "but got " + columnNumber);
- } else if( ((Table) parent).isColumnNumberUsed(columnNumber.getValue()) ) {
+ } else if (getTable().isColumnNumberUsed(columnNumber.getValue())) {
throw new PropertyException("specified column-number \""
+ columnNumber
+ "\" has already been assigned to a previous column");
@@ -92,7 +92,7 @@ public class TableColumn extends TableFObj {
//to the specified value, so that the updated index
//will be the correct initial value for the next column
//(see Rec 7.26.8)
- ((Table) parent).setCurrentColumnIndex(columnNumber.getValue());
+ getTable().setCurrentColumnIndex(columnNumber.getValue());
}
}
if (numberColumnsRepeated.getValue() <= 0) {
diff --git a/src/java/org/apache/fop/fo/flow/TableFObj.java b/src/java/org/apache/fop/fo/flow/TableFObj.java
index f042e0f96..8bd88d386 100644
--- a/src/java/org/apache/fop/fo/flow/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/TableFObj.java
@@ -45,6 +45,9 @@ public abstract class TableFObj extends FObj {
*/
protected static class PendingSpan {
+ /**
+ * member variable holding the number of rows left
+ */
protected int rowsLeft;
/**
@@ -130,6 +133,38 @@ public abstract class TableFObj extends FObj {
}
/**
+ * Checks whether a given column-number is assigned to
+ * an explicit column in the parent table
+ * (overridden for TableBody, TableRow)
+ *
+ * @param colNr the column-number to check
+ * @return true if the table has explicit columns, and
+ * the column-number is in use
+ */
+ protected boolean isColumnNumberUsedInTable(int colNr) {
+ return false;
+ }
+
+ /**
+ * Convenience method to returns a reference
+ * to the base Table instance
+ *
+ * @return the base table instance
+ *
+ */
+ protected Table getTable() {
+ if (this.getNameId() == FO_TABLE) {
+ //node is a Table
+ //=> return itself
+ return (Table) this;
+ } else {
+ //any other Table-node
+ //=> recursive call to parent.getTable()
+ return ((TableFObj) parent).getTable();
+ }
+ }
+
+ /**
* @return the Common Border, Padding, and Background Properties.
*/
public abstract CommonBorderPaddingBackground getCommonBorderPaddingBackground();
diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java
index 18baabf2c..3081e1632 100644
--- a/src/java/org/apache/fop/fo/flow/TableRow.java
+++ b/src/java/org/apache/fop/fo/flow/TableRow.java
@@ -109,7 +109,7 @@ public class TableRow extends TableFObj {
protected void startOfNode() throws FOPException {
pendingSpans = ((TableBody) parent).pendingSpans;
usedColumnIndices = ((TableBody) parent).usedColumnIndices;
- while( usedColumnIndices.get(columnIndex - 1) ) {
+ while (usedColumnIndices.get(columnIndex - 1)) {
columnIndex++;
}
@@ -124,8 +124,8 @@ public class TableRow extends TableFObj {
if (childNodes == null) {
missingChildElementError("(table-cell+)");
}
- if( ((TableBody) parent).isFirst(this)
- && ((Table) parent.getParent()).columns == null ) {
+ if (((TableBody) parent).isFirst(this)
+ && getTable().columns == null ) {
//force parent body's pendingSpans
//to the one accumulated after processing this row
((TableBody) parent).pendingSpans = pendingSpans;
@@ -155,20 +155,20 @@ public class TableRow extends TableFObj {
TableCell cell = (TableCell) child;
int rowSpan = cell.getNumberRowsSpanned();
int colSpan = cell.getNumberColumnsSpanned();
- if( ((TableBody) parent).isFirst(this)
- && ((Table) parent.getParent()).columns == null ) {
- if( pendingSpans == null ) {
+ if (((TableBody) parent).isFirst(this)
+ && getTable().columns == null ) {
+ if (pendingSpans == null) {
pendingSpans = new java.util.ArrayList();
}
pendingSpans.add(null);
- if( usedColumnIndices == null ) {
+ if (usedColumnIndices == null) {
usedColumnIndices = new BitSet();
}
}
//if the current cell spans more than one row,
//update pending span list for the next row
- if( rowSpan > 1 ) {
- for( int i = colSpan; --i >= 0; ) {
+ if (rowSpan > 1) {
+ for (int i = colSpan; --i >= 0;) {
pendingSpans.set(columnIndex - 1 + i,
new PendingSpan(rowSpan));
}
@@ -180,18 +180,18 @@ public class TableRow extends TableFObj {
//take up more than three columnIndices...
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if( ((Table) parent.getParent()).columns != null ) {
- List cols = ((Table) parent.getParent()).columns;
+ if (getTable().columns != null) {
+ List cols = getTable().columns;
int tmpIndex = endIndex;
- for( int i = startIndex; i <= tmpIndex; ++i ) {
- if( i < cols.size() && cols.get(i) == null ) {
+ for (int i = startIndex; i <= tmpIndex; ++i) {
+ if (i < cols.size() && cols.get(i) == null) {
endIndex++;
}
}
}
usedColumnIndices.set(startIndex, endIndex);
//update columnIndex for the next cell
- while( usedColumnIndices.get(columnIndex - 1) ) {
+ while (usedColumnIndices.get(columnIndex - 1)) {
columnIndex++;
}
super.addChildNode(cell);
@@ -301,6 +301,7 @@ public class TableRow extends TableFObj {
* in case a column-number was explicitly specified
* (used by TableCell.bind())
*
+ * @param newIndex new value for column index
*/
protected void setCurrentColumnIndex(int newIndex) {
columnIndex = newIndex;
@@ -310,6 +311,7 @@ public class TableRow extends TableFObj {
* Checks whether a given column-number is already in use
* for the current row (used by TableCell.bind());
*
+ * @param colNr the column-number to check
* @return true if column-number is already occupied
*/
protected boolean isColumnNumberUsed(int colNr) {