diff options
Diffstat (limited to 'src/java/org/apache/fop/fo/flow/table/TableFObj.java')
-rw-r--r-- | src/java/org/apache/fop/fo/flow/table/TableFObj.java | 114 |
1 files changed, 65 insertions, 49 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/TableFObj.java b/src/java/org/apache/fop/fo/flow/table/TableFObj.java index 370bb9de4..faf1f7aba 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java @@ -55,9 +55,10 @@ public abstract class TableFObj extends FObj { CollapsingBorderModel collapsingBorderModel; /** - * Main constructor + * Create a TableFObj instance that is a child + * of the given {@link FONode} * - * @param parent the parent node + * @param parent the parent {@link FONode} */ public TableFObj(FONode parent) { super(parent); @@ -81,6 +82,8 @@ public abstract class TableFObj extends FObj { } /** + * Return the value for the "border-precedence" property + * for the given side. * * @param side the side for which to return the border precedence * @return the "border-precedence" value for the given side @@ -102,13 +105,13 @@ public abstract class TableFObj extends FObj { /** * Convenience method to returns a reference - * to the base Table instance + * to the base {@link Table} instance. * * @return the base table instance * */ public Table getTable() { - // Will be overridden in Table; for any other Table-node, recursive call to + // Overridden in Table; for any other Table-node, recursive call to // parent.getTable() return ((TableFObj) parent).getTable(); } @@ -119,13 +122,13 @@ public abstract class TableFObj extends FObj { public abstract CommonBorderPaddingBackground getCommonBorderPaddingBackground(); /** - * PropertyMaker subclass for the column-number property - * + * {@link PropertyMaker} subclass for the column-number property */ public static class ColumnNumberPropertyMaker extends PropertyMaker { /** * Constructor + * * @param propId the id of the property for which the maker should * be created */ @@ -144,46 +147,50 @@ public abstract class TableFObj extends FObj { /** + * {@inheritDoc} * Check the value of the column-number property. - * Return the parent's column index (initial value) in case - * of a negative or zero value - * - * @see org.apache.fop.fo.properties.PropertyMaker#make(PropertyList, String, FObj) */ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { + Property p = super.make(propertyList, value, fo); - ColumnNumberManagerHolder parent - = (ColumnNumberManagerHolder) propertyList.getParentFObj(); - ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); int columnIndex = p.getNumeric().getValue(); int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED) .getNumeric().getValue(); - - int lastIndex = columnIndex - 1 + colSpan; - for (int i = columnIndex; i <= lastIndex; ++i) { - if (columnIndexManager.isColumnNumberUsed(i)) { - /* if column-number is already in use by another - * cell/column => error! - */ - TableEventProducer eventProducer = TableEventProducer.Provider.get( - fo.getUserAgent().getEventBroadcaster()); - eventProducer.cellOverlap(this, propertyList.getFObj().getName(), - i, fo.getLocator()); + + // only check whether the column-number is occupied in case it was + // specified on a fo:table-cell or fo:table-column + int foId = propertyList.getFObj().getNameId(); + if (foId == FO_TABLE_COLUMN || foId == FO_TABLE_CELL) { + ColumnNumberManagerHolder parent + = (ColumnNumberManagerHolder) propertyList.getParentFObj(); + ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); + int lastIndex = columnIndex - 1 + colSpan; + for (int i = columnIndex; i <= lastIndex; ++i) { + if (columnIndexManager.isColumnNumberUsed(i)) { + /* if column-number is already in use by another + * cell/column => error! + */ + TableEventProducer eventProducer + = TableEventProducer.Provider.get( + fo.getUserAgent().getEventBroadcaster()); + eventProducer.cellOverlap( + this, propertyList.getFObj().getName(), + i, propertyList.getFObj().getLocator()); + } } } - return p; } - + /** - * If the value is not positive, return a property whose value is the next column number - * * {@inheritDoc} + * If the value is not positive, return a property whose value + * is the next column number. */ - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof EnumProperty) { return EnumNumber.getInstance(p); @@ -191,15 +198,24 @@ public abstract class TableFObj extends FObj { Number val = p.getNumber(); if (val != null) { int i = Math.round(val.floatValue()); + int foId = propertyList.getFObj().getNameId(); if (i <= 0) { - ColumnNumberManagerHolder parent = - (ColumnNumberManagerHolder) propertyList.getParentFObj(); - ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); - i = columnIndexManager.getCurrentColumnNumber(); + if (foId == FO_TABLE_CELL || foId == FO_TABLE_COLUMN) { + ColumnNumberManagerHolder parent = + (ColumnNumberManagerHolder) propertyList.getParentFObj(); + ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); + i = columnIndexManager.getCurrentColumnNumber(); + } else { + /* very exceptional case: + * negative column-number specified on + * a FO that is not a fo:table-cell or fo:table-column + */ + i = 1; + } TableEventProducer eventProducer = TableEventProducer.Provider.get(fo.getUserAgent().getEventBroadcaster()); eventProducer.forceNextColumnNumber(this, propertyList.getFObj().getName(), - val, i, fo.getLocator()); + val, i, propertyList.getFObj().getLocator()); } return NumberProperty.getInstance(i); } @@ -233,26 +249,26 @@ public abstract class TableFObj extends FObj { /** * Creates a BorderSpecification from the border set on the given side. If no border * is set, a BorderSpecification with border-style none is created. - * + * * @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END */ private void createBorder(int side) { BorderSpecification borderSpec = new BorderSpecification( getCommonBorderPaddingBackground().getBorderInfo(side), getNameId()); switch (side) { - case CommonBorderPaddingBackground.BEFORE: - borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel); - break; - case CommonBorderPaddingBackground.AFTER: - borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel); - break; - case CommonBorderPaddingBackground.START: - borderStart = borderSpec; - break; - case CommonBorderPaddingBackground.END: - borderEnd = borderSpec; - break; - default: assert false; + case CommonBorderPaddingBackground.BEFORE: + borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel); + break; + case CommonBorderPaddingBackground.AFTER: + borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel); + break; + case CommonBorderPaddingBackground.START: + borderStart = borderSpec; + break; + case CommonBorderPaddingBackground.END: + borderEnd = borderSpec; + break; + default: assert false; } } } |