+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
package org.apache.fop.fo.flow;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+/**
+ * Superclass for table-related FOs
+ *
+ */
public abstract class TableFObj extends FObj {
private Numeric borderBeforePrecedence;
private Numeric borderEndPrecedence;
private Numeric borderStartPrecedence;
-
+
+ /**
+ * Used for determining initial values for column-numbers
+ * in case of row-spanning cells
+ * (for clarity)
+ *
+ */
protected static class PendingSpan {
+
protected int rowsLeft;
- public PendingSpan( int rows ) {
+ /**
+ * Constructor
+ *
+ * @param rows number of rows spanned
+ */
+ public PendingSpan(int rows) {
rowsLeft = rows;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("pending span: rowsLeft=").append(rowsLeft);
- return sb.toString();
- }
+ }
}
+ /**
+ * Main constructor
+ *
+ * @param parent the parent node
+ */
public TableFObj(FONode parent) {
super(parent);
}
-
+
+ /**
+ * @see FObj#bind(PropertyList)
+ */
public void bind(PropertyList pList) throws FOPException {
borderAfterPrecedence = pList.get(PR_BORDER_AFTER_PRECEDENCE).getNumeric();
borderBeforePrecedence = pList.get(PR_BORDER_BEFORE_PRECEDENCE).getNumeric();
return null;
}
}
-
- protected void setBorderPrecedence(int side, Numeric newPrecedence) {
- switch( side ) {
- case CommonBorderPaddingBackground.BEFORE:
- borderBeforePrecedence = newPrecedence;
- case CommonBorderPaddingBackground.AFTER:
- borderAfterPrecedence = newPrecedence;
- case CommonBorderPaddingBackground.START:
- borderStartPrecedence = newPrecedence;
- case CommonBorderPaddingBackground.END:
- borderEndPrecedence = newPrecedence;
- }
- }
-
+
/**
* Returns the current column index of the given TableFObj
* (overridden for Table, TableBody, TableRow)
/**
* Sets the current column index of the given TableFObj
+ * used when a value for column-number is explicitly
+ * specified on the child FO (TableCell or TableColumn)
* (overridden for Table, TableBody, TableRow)
+ *
+ * @param newIndex new value for column index
*/
protected void setCurrentColumnIndex(int newIndex) {
//do nothing by default
public ColumnNumberPropertyMaker(int propId) {
super(propId);
}
-
+
/**
- * Set default column-number from parent's currentColumnIndex
- *
+ * Set default column-number from parent's currentColumnIndex.
+ *
+ * @param propertyList
* @return the default value for column-number
+ * @throws PropertyException
*/
public Property make(PropertyList propertyList) throws PropertyException {
FObj fo = propertyList.getFObj();
-
- if( fo.getNameId() == Constants.FO_TABLE_CELL
- || fo.getNameId() == Constants.FO_TABLE_COLUMN ) {
+
+ if (fo.getNameId() == Constants.FO_TABLE_CELL
+ || fo.getNameId() == Constants.FO_TABLE_COLUMN) {
TableFObj parent = (TableFObj) propertyList.getParentFObj();
int columnIndex = parent.getCurrentColumnIndex();
- if( fo.getNameId() == Constants.FO_TABLE_CELL
- && parent.getNameId() == Constants.FO_TABLE_BODY ) {
+ if (fo.getNameId() == Constants.FO_TABLE_CELL
+ && parent.getNameId() == Constants.FO_TABLE_BODY) {
boolean startsRow = propertyList.get(Constants.PR_STARTS_ROW)
.getEnum() == Constants.EN_TRUE;
-
- //cell w/ starts-row="true", but previous cell
+
+ //cell w/ starts-row="true", but previous cell
//didn't have ends-row="true", so index has still has
//to be reset (for other cases this already happened in
//body.addChildNode())
- if( startsRow && !((TableBody) parent).lastCellEndedRow() ) {
+ if (startsRow && !((TableBody) parent).lastCellEndedRow()) {
//reset column index, and reassign...
((TableBody) parent).resetColumnIndex();
columnIndex = parent.getCurrentColumnIndex();
}
return new NumberProperty(columnIndex);
} else {
- throw new PropertyException("column-number property is only allowed on "
- + "fo:table-cell or fo:table-column, not on " + fo.getName());
+ throw new PropertyException("column-number property is only allowed"
+ + " on fo:table-cell or fo:table-column, not on "
+ + fo.getName());
}
}
}