|
|
@@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
* 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. |
|
|
@@ -19,17 +19,18 @@ |
|
|
|
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. |
|
|
@@ -48,6 +49,8 @@ public class TableBody extends FObj { |
|
|
|
private int visibility; |
|
|
|
// End of property values |
|
|
|
|
|
|
|
private PropertyList savedPropertyList; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param parent FONode that is the parent of the object |
|
|
|
*/ |
|
|
@@ -68,6 +71,9 @@ public class TableBody extends FObj { |
|
|
|
// 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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -82,10 +88,52 @@ public class TableBody extends FObj { |
|
|
|
*/ |
|
|
|
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; |