/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-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.
package org.apache.fop.fo.flow;
// Java
+import java.util.Iterator;
import java.util.List;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.StaticPropertyList;
import org.apache.fop.fo.properties.CommonAccessibility;
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonRelativePosition;
-import org.apache.fop.layoutmgr.table.Body;
/**
* Class modelling the fo:table-body object.
private int visibility;
// End of property values
+ private PropertyList savedPropertyList;
+
/**
* @param parent FONode that is the parent of the object
*/
// borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE);
// borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE);
visibility = pList.get(PR_VISIBILITY).getEnum();
+
+ //Used by convertCellsToRows()
+ savedPropertyList = pList;
}
/**
*/
protected void endOfNode() throws FOPException {
getFOEventHandler().endBody(this);
+ convertCellsToRows();
}
/**
- * Return the Common Border, Padding, and Background Properties.
+ * If table-cells are used as direct children of a table-body|header|footer
+ * they are replace 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.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;
+ }
+ 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) {
+ childNodes.add(row);
+ }
+ } finally {
+ savedPropertyList = null; //Release reference
+ }
+ }
+
+ /**
+ * @return the Common Border, Padding, and Background Properties.
*/
public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
return commonBorderPaddingBackground;
import org.apache.fop.fo.FONode;
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;
private KeepProperty keepWithPrevious;
private int visibility;
// End of property values
-
+
private boolean setup = false;
/**
visibility = pList.get(PR_VISIBILITY).getEnum();
}
+ /**
+ * Adds a cell to this row (skips marker handling done by FObj.addChildNode().
+ * Used by TableBody during the row building process when only cells are
+ * used as direct children of a table-body/header/footer.
+ * @param cell cell to add.
+ */
+ protected void addReplacedCell(TableCell cell) {
+ if (childNodes == null) {
+ childNodes = new java.util.ArrayList();
+ }
+ childNodes.add(cell);
+ }
+
/**
* @see org.apache.fop.fo.FONode#startOfNode
*/