private int width;
private boolean isEmpty = true;
+ /**
+ * Constructor
+ */
+ public MainReference() {
+ addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
+ }
+
/**
* Add a span area to this area.
*
*/
protected void tooManyNodesError(Locator loc, String nsURI, String lName)
throws ValidationException {
- throw new ValidationException(errorText(loc) + getName() + ", only one "
- + getNodeString(nsURI, lName) + " may be declared.", loc);
+ throw new ValidationException(errorText(loc) + "For " + getName() +
+ ", only one " + getNodeString(nsURI, lName) + " may be declared.",
+ loc);
}
/**
*/
protected void tooManyNodesError(Locator loc, String offendingNode)
throws ValidationException {
- throw new ValidationException(errorText(loc) + getName() + ", only one "
- + offendingNode + " may be declared.", loc);
+ throw new ValidationException(errorText(loc) + "For " + getName() +
+ ", only one " + offendingNode + " may be declared.", loc);
}
/**
package org.apache.fop.fo.flow;
+import org.xml.sax.Locator;
+
import java.util.List;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.StaticPropertyList;
+import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonAccessibility;
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
protected List columns = null;
private TableBody tableHeader = null;
private TableBody tableFooter = null;
-
+
+ /** used for validation */
+ private boolean tableColumnFound = false;
+ private boolean tableHeaderFound = false;
+ private boolean tableFooterFound = false;
+ private boolean tableBodyFound = false;
+
/**
* Default table-column used when no columns are specified. It is used
* to handle inheritance (especially visibility) and defaults properly. */
checkId(id);
getFOEventHandler().startTable(this);
}
+
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: (marker*,table-column*,table-header?,table-footer?,table-body+)
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws ValidationException {
+ if (nsURI == FO_URI) {
+ if (localName.equals("marker")) {
+ if (tableColumnFound || tableHeaderFound || tableFooterFound
+ || tableBodyFound) {
+ nodesOutOfOrderError(loc, "fo:marker",
+ "(table-column*,table-header?,table-footer?,table-body+)");
+ }
+ } else if (localName.equals("table-column")) {
+ tableColumnFound = true;
+ if (tableHeaderFound || tableFooterFound || tableBodyFound) {
+ nodesOutOfOrderError(loc, "fo:table-column",
+ "(table-header?,table-footer?,table-body+)");
+ }
+ } else if (localName.equals("table-header")) {
+ if (tableHeaderFound) {
+ tooManyNodesError(loc, "table-header");
+ } else {
+ tableHeaderFound = true;
+ if (tableFooterFound || tableBodyFound) {
+ nodesOutOfOrderError(loc, "fo:table-header",
+ "(table-footer?,table-body+)");
+ }
+ }
+ } else if (localName.equals("table-footer")) {
+ if (tableFooterFound) {
+ tooManyNodesError(loc, "table-footer");
+ } else {
+ tableFooterFound = true;
+ if (tableBodyFound) {
+ nodesOutOfOrderError(loc, "fo:table-footer",
+ "(table-body+)");
+ }
+ }
+ } else if (localName.equals("table-body")) {
+ tableBodyFound = true;
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
/**
* @see org.apache.fop.fo.FONode#endOfNode
getParent().removeChild(this);
}
}
- convertCellsToRows();
+ if (tableCellsFound) {
+ convertCellsToRows();
+ }
+ savedPropertyList = null; //Release reference
}
/**
/**
* If table-cells are used as direct children of a table-body|header|footer
- * they are replace in this method by proper table-rows.
+ * they are replaced in this method by proper table-rows.
* @throws FOPException if there's a problem binding the TableRows properties.
*/
private void convertCellsToRows() throws FOPException {
- try {
- if (childNodes == null
- || childNodes.size() == 0
- || childNodes.get(0) instanceof TableRow) {
- return;
+ //getLogger().debug("Converting cells to rows...");
+ List cells = (List)childNodes.clone();
+ childNodes.clear();
+ Iterator i = cells.iterator();
+ TableRow row = null;
+ while (i.hasNext()) {
+ TableCell cell = (TableCell)i.next();
+ if (cell.startsRow() && (row != null)) {
+ childNodes.add(row);
+ row = null;
}
- //getLogger().debug("Converting cells to rows...");
- List cells = (List)childNodes.clone();
- childNodes.clear();
- Iterator i = cells.iterator();
- TableRow row = null;
- while (i.hasNext()) {
- TableCell cell = (TableCell)i.next();
- if (cell.startsRow() && (row != null)) {
- childNodes.add(row);
- row = null;
- }
- if (row == null) {
- row = new TableRow(this);
- PropertyList pList = new StaticPropertyList(row, savedPropertyList);
- pList.setWritingMode();
- row.bind(pList);
- }
- row.addReplacedCell(cell);
- if (cell.endsRow()) {
- childNodes.add(row);
- row = null;
- }
+ if (row == null) {
+ row = new TableRow(this);
+ PropertyList pList = new StaticPropertyList(row, savedPropertyList);
+ pList.setWritingMode();
+ row.bind(pList);
}
- if (row != null) {
+ row.addReplacedCell(cell);
+ if (cell.endsRow()) {
childNodes.add(row);
+ row = null;
}
- } finally {
- savedPropertyList = null; //Release reference
+ }
+ if (row != null) {
+ childNodes.add(row);
}
}
package org.apache.fop.fo.flow;
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
-import org.xml.sax.Locator;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.ValidationException;
/**
* Class modelling the fo:table-footer object.
package org.apache.fop.fo.flow;
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
+
/**
* Class modelling the fo:table-header object.
* @todo implement validateChildNode()
super(parent);
}
+ /**
+ * @see org.apache.fop.fo.FONode#startOfNode
+ */
+ protected void startOfNode() throws FOPException {
+// getFOEventHandler().startHeader(this);
+ }
+
+ /**
+ * @see org.apache.fop.fo.FONode#endOfNode
+ */
+ protected void endOfNode() throws FOPException {
+// getFOEventHandler().endHeader(this);
+ if (!(tableRowsFound || tableCellsFound)) {
+ missingChildElementError("marker* (table-row+|table-cell+)");
+ }
+// convertCellsToRows();
+ }
+
/**
* @see org.apache.fop.fo.FObj#getName()
*/
}
private void createBodyMainReferenceArea() {
- MainReference mainRef = new MainReference();
- mainRef.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
- curBody.setMainReference(mainRef);
+ curBody.setMainReference(new MainReference());
}
private Flow createFlow() {