aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/flow/table/TableBody.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/fo/flow/table/TableBody.java')
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableBody.java219
1 files changed, 6 insertions, 213 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java
index b4e48d2e6..b4071e255 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java
@@ -15,53 +15,18 @@
* limitations under the License.
*/
-/* $Id$ */
+/* $Id: $ */
package org.apache.fop.fo.flow.table;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-
-import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.apps.FOPException;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-body">
* <code>fo:table-body</code></a> object.
*/
-public class TableBody extends TableCellContainer {
- // The value of properties relevant for fo:table-body.
- private CommonBorderPaddingBackground commonBorderPaddingBackground;
- // Unused but valid items, commented out for performance:
- // private CommonAccessibility commonAccessibility;
- // private CommonAural commonAural;
- // private CommonRelativePosition commonRelativePosition;
- // private int visibility;
- // End of property values
-
- /**
- * used for validation
- */
- protected boolean tableRowsFound = false;
- protected boolean tableCellsFound = false;
-
- private boolean firstRow = true;
-
- private boolean rowsStarted = false;
-
- private boolean lastCellEndsRow = true;
-
- /** The last encountered table-row. */
- private TableRow lastRow;
-
- private List rowGroups = new LinkedList();
+public class TableBody extends TablePart {
/**
* Create a TableBody instance with the given {@link FONode}
@@ -73,159 +38,15 @@ public class TableBody extends TableCellContainer {
}
/** {@inheritDoc} */
- public void bind(PropertyList pList) throws FOPException {
- commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
- super.bind(pList);
- }
-
- /** {@inheritDoc} */
- public void processNode(String elementName, Locator locator,
- Attributes attlist, PropertyList pList)
- throws FOPException {
- if (!inMarker()) {
- Table t = getTable();
- if (t.hasExplicitColumns()) {
- int size = t.getNumberOfColumns();
- pendingSpans = new ArrayList(size);
- for (int i = 0; i < size; i++) {
- pendingSpans.add(null);
- }
- } else {
- pendingSpans = new ArrayList();
- }
- columnNumberManager = new ColumnNumberManager();
- }
- super.processNode(elementName, locator, attlist, pList);
- }
-
- /** {@inheritDoc} */
- public void startOfNode() throws FOPException {
+ protected void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startBody(this);
}
/** {@inheritDoc} */
- public void endOfNode() throws FOPException {
-
- if (!inMarker()) {
- pendingSpans = null;
- columnNumberManager = null;
- }
-
+ protected void endOfNode() throws FOPException {
+ super.endOfNode();
getFOEventHandler().endBody(this);
-
- if (!(tableRowsFound || tableCellsFound)) {
- missingChildElementError("marker* (table-row+|table-cell+)", true);
- getParent().removeChild(this);
- } else {
- finishLastRowGroup();
- }
- }
-
- /** {@inheritDoc} */
- TableBody getTablePart() {
- return this;
- }
-
- protected void finishLastRowGroup() throws ValidationException {
- if (!inMarker()) {
- RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
- if (tableRowsFound) {
- rowGroupBuilder.endTableRow();
- } else if (!lastCellEndsRow) {
- rowGroupBuilder.endRow(this);
- }
- try {
- rowGroupBuilder.endTablePart();
- } catch (ValidationException e) {
- e.setLocator(locator);
- throw e;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- * <br>XSL Content Model: marker* (table-row+|table-cell+)
- */
- protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI)) {
- if (localName.equals("marker")) {
- if (tableRowsFound || tableCellsFound) {
- nodesOutOfOrderError(loc, "fo:marker", "(table-row+|table-cell+)");
- }
- } else if (localName.equals("table-row")) {
- tableRowsFound = true;
- if (tableCellsFound) {
- TableEventProducer eventProducer = TableEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.noMixRowsAndCells(this, getName(), getLocator());
- }
- } else if (localName.equals("table-cell")) {
- tableCellsFound = true;
- if (tableRowsFound) {
- TableEventProducer eventProducer = TableEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.noMixRowsAndCells(this, getName(), getLocator());
- }
- } else {
- invalidChildError(loc, nsURI, localName);
- }
- }
- }
-
- /** {@inheritDoc} */
- protected void addChildNode(FONode child) throws FOPException {
- if (!inMarker()) {
- switch (child.getNameId()) {
- case FO_TABLE_ROW:
- if (!rowsStarted) {
- getTable().getRowGroupBuilder().startTablePart(this);
- } else {
- columnNumberManager.prepareForNextRow(pendingSpans);
- getTable().getRowGroupBuilder().endTableRow();
- }
- rowsStarted = true;
- lastRow = (TableRow) child;
- getTable().getRowGroupBuilder().startTableRow(lastRow);
- break;
- case FO_TABLE_CELL:
- if (!rowsStarted) {
- getTable().getRowGroupBuilder().startTablePart(this);
- }
- rowsStarted = true;
- TableCell cell = (TableCell) child;
- addTableCellChild(cell, firstRow);
- lastCellEndsRow = cell.endsRow();
- if (lastCellEndsRow) {
- firstRow = false;
- columnNumberManager.prepareForNextRow(pendingSpans);
- getTable().getRowGroupBuilder().endRow(this);
- }
- break;
- default:
- //nop
- }
- }
- super.addChildNode(child);
- }
-
- void addRowGroup(List rowGroup) {
- rowGroups.add(rowGroup);
- }
-
- public List getRowGroups() {
- return rowGroups;
- }
-
- /**
- * Get the {@link CommonBorderPaddingBackground} instance attached
- * to this TableBody.
- * @return the {@link CommonBorderPaddingBackground} instance.
- */
- public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
- return commonBorderPaddingBackground;
}
/** {@inheritDoc} */
@@ -240,32 +61,4 @@ public class TableBody extends TableCellContainer {
public int getNameId() {
return FO_TABLE_BODY;
}
-
- protected boolean isTableHeader() {
- return false;
- }
-
- protected boolean isTableFooter() {
- return false;
- }
-
- /**
- * @param obj table row in question
- * @return true if the given table row is the first row of this body.
- */
- public boolean isFirst(TableRow obj) {
- return (firstChild == null
- || firstChild == obj);
- }
-
- void signalNewRow() {
- if (rowsStarted) {
- firstRow = false;
- if (!lastCellEndsRow) {
- columnNumberManager.prepareForNextRow(pendingSpans);
- getTable().getRowGroupBuilder().endRow(this);
- }
- }
- }
-
}