Browse Source

Made the columns field in Table private, and created suitable accessors to it


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

+ 20
- 2
src/java/org/apache/fop/fo/flow/Table.java View File

@@ -71,7 +71,7 @@ public class Table extends TableFObj {
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 @@ public class Table extends TableFObj {
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 @@ public class Table extends TableFObj {
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;
}

+ 14
- 18
src/java/org/apache/fop/fo/flow/TableBody.java View File

@@ -82,14 +82,12 @@ public class TableBody extends TableCellContainer {
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 @@ public class TableBody extends TableCellContainer {
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 @@ public class TableBody extends TableCellContainer {
//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++;
}
}


+ 7
- 11
src/java/org/apache/fop/fo/flow/TableCellContainer.java View File

@@ -46,15 +46,13 @@ public abstract class TableCellContainer extends TableFObj {
}
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 @@ public abstract class TableCellContainer extends TableFObj {
*/
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);

Loading…
Cancel
Save