Table table = (Table) foNode;
//recurse all table-columns
- for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
- recurseFONode( (FONode) it.next() );
+ if (table.getColumns() != null) {
+ for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
+ recurseFONode( (FONode) it.next() );
+ }
+ } else {
+ //TODO Implement implicit column setup handling!
+ log.warn("No table-columns found on table. RTF output requires that all"
+ + " table-columns for a table are defined. Output will be incorrect.");
}
//recurse table-header
public interface ITableColumnsInfo {
/** value for invalid column width */
- float INVALID_COLUM_WIDTH = 200f;
+ float INVALID_COLUMN_WIDTH = 200f;
/** reset the column iteration index, meant to be called when creating a new row */
void selectFirstColumn();
}
/**
- *
+ * Adds a column and sets its width.
* @param width Width of next column
- * @throws Exception
*/
- public void setNextColumnWidth(Float width)
- throws Exception {
+ public void setNextColumnWidth(Float width) {
colWidths.add(width);
}
boolean bFirstSpanningCol) {
if (colIndex < colRowSpanningNumber.size()) {
+ while (colIndex >= colFirstSpanningCol.size()) {
+ setNextFirstSpanningCol(false);
+ }
colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
} else {
colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
* 'number-columns-spanned' processing
*/
public float getColumnWidth() {
- try {
- return ((Float)colWidths.get(colIndex)).floatValue();
- } catch (IndexOutOfBoundsException ex) {
- // this code contributed by Trembicki-Guy, Ed <GuyE@DNB.com>
- log.warn("fo:table-column width not defined, using " + INVALID_COLUM_WIDTH);
- return INVALID_COLUM_WIDTH;
+ if (colIndex < 0) {
+ throw new IllegalStateException("colIndex must not be negative!");
+ } else if (colIndex >= getNumberOfColumns()) {
+ log.warn("Column width for column " + (colIndex + 1) + " is not defined, using "
+ + INVALID_COLUMN_WIDTH);
+ while (colIndex >= getNumberOfColumns()) {
+ setNextColumnWidth(new Float(INVALID_COLUMN_WIDTH));
+ }
}
+ return ((Float)colWidths.get(colIndex)).floatValue();
}
/**