You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2007/10/26 13:21:00 UTC
svn commit: r588604 - in
/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow: Table.java
TableBody.java TableCellContainer.java
Author: vhennebert
Date: Fri Oct 26 04:20:59 2007
New Revision: 588604
URL: http://svn.apache.org/viewvc?rev=588604&view=rev
Log:
Made the columns field in Table private, and created suitable accessors to it
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableBody.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCellContainer.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java?rev=588604&r1=588603&r2=588604&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Table.java Fri Oct 26 04:20:59 2007
@@ -71,7 +71,7 @@
private Length orphanContentLimit;
/** collection of columns in this table */
- protected List columns = new ArrayList();
+ private List columns = new ArrayList();
/** helper variables for implicit column-numbering */
private int columnIndex = 1;
@@ -341,6 +341,24 @@
return columns;
}
+ /**
+ * Returns the column at the given index, if any.
+ *
+ * @param index index of the column to be retrieved, 0-based
+ * @return the corresponding column, or null if their is no column at the given index
+ */
+ TableColumn getColumn(int index) {
+ if (index >= columns.size()) {
+ return null;
+ } else {
+ return (TableColumn) columns.get(index);
+ }
+ }
+
+ int getNumberOfColumns() {
+ return columns.size();
+ }
+
/** @return the body for the table-header. */
public TableBody getTableHeader() {
return tableHeader;
@@ -509,7 +527,7 @@
FObj fobj = (FObj) super.clone(parent, removeChildren);
if (removeChildren) {
Table t = (Table) fobj;
- t.columns = null;
+ t.columns = new ArrayList();
t.tableHeader = null;
t.tableFooter = null;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableBody.java?rev=588604&r1=588603&r2=588604&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableBody.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableBody.java Fri Oct 26 04:20:59 2007
@@ -82,14 +82,12 @@
Attributes attlist, PropertyList pList)
throws FOPException {
if (!inMarker()) {
- if (getTable().columns != null) {
- int cap = getTable().columns.size();
- pendingSpans = new java.util.ArrayList(cap);
- usedColumnIndices = new java.util.BitSet(cap);
- } else {
- pendingSpans = new java.util.ArrayList();
- usedColumnIndices = new java.util.BitSet();
+ int cap = getTable().getNumberOfColumns();
+ if (cap == 0) {
+ cap = 10; // Default value for ArrayList
}
+ pendingSpans = new java.util.ArrayList(cap);
+ usedColumnIndices = new java.util.BitSet(cap);
setNextColumnIndex();
}
super.processNode(elementName, locator, attlist, pList);
@@ -223,14 +221,14 @@
if (child.getNameId() == FO_TABLE_ROW) {
pendingSpans = ((TableRow) child).pendingSpans;
} else if (pendingSpans == null) {
- if (getTable().columns != null) {
- List tableCols = getTable().columns;
- pendingSpans = new java.util.ArrayList(tableCols.size());
- for (int i = tableCols.size(); --i >= 0;) {
+ int colNumber = getTable().getNumberOfColumns();
+ if (colNumber == 0) {
+ pendingSpans = new java.util.ArrayList();
+ } else {
+ pendingSpans = new java.util.ArrayList(colNumber);
+ for (int i = colNumber; --i >= 0;) {
pendingSpans.add(null);
}
- } else {
- pendingSpans = new java.util.ArrayList();
}
}
}
@@ -295,11 +293,9 @@
//the index is not assigned to any
//column, increment further until the next
//index occupied by a column...
- if (getTable().columns != null) {
- while (columnIndex <= getTable().columns.size()
- && !getTable().isColumnNumberUsed(columnIndex) ) {
- columnIndex++;
- }
+ while (columnIndex <= getTable().getNumberOfColumns()
+ && !getTable().isColumnNumberUsed(columnIndex) ) {
+ columnIndex++;
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCellContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCellContainer.java?rev=588604&r1=588603&r2=588604&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCellContainer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/TableCellContainer.java Fri Oct 26 04:20:59 2007
@@ -46,15 +46,13 @@
}
for (int i = colNr; i < colNr + colSpan; ++i) {
- if (t.columns.size() < i
- || t.columns.get(i - 1) == null) {
+ TableColumn col = t.getColumn(i - 1);
+ if (col == null) {
t.addDefaultColumn(colWidth,
i == colNr
? cell.getColumnNumber()
: 0);
} else {
- TableColumn col =
- (TableColumn) t.columns.get(i - 1);
if (!col.isDefaultColumn()
&& colWidth != null) {
col.setColumnWidth(colWidth);
@@ -142,13 +140,11 @@
*/
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if (getTable().columns != null) {
- List cols = getTable().columns;
- int tmpIndex = endIndex;
- for (i = startIndex; i <= tmpIndex; ++i) {
- if (i < cols.size() && cols.get(i) == null) {
- endIndex++;
- }
+ List cols = getTable().getColumns();
+ int tmpIndex = endIndex;
+ for (i = startIndex; i <= tmpIndex; ++i) {
+ if (i < cols.size() && cols.get(i) == null) {
+ endIndex++;
}
}
flagColumnIndices(startIndex, endIndex);
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org