Browse Source

Support for table-cells as direct children of table-body|header|footer.

The table-cells are grouped into table-rows using starts-row and ends-row properties during FO tree building so the layout managers don't have to handle both cases. This will hopefully keep the code simpler.
Additional accessors on some FO objects.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198391 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Jeremias Maerki 19 years ago
parent
commit
a5e511a608

+ 1
- 1
src/java/org/apache/fop/fo/PropertyList.java View File

@@ -203,7 +203,7 @@ abstract public class PropertyList {
* Use that from the nearest ancestor, including self, which generates
* reference areas, or from root FO if no ancestor found.
*/
protected void setWritingMode() throws PropertyException {
public void setWritingMode() throws PropertyException {
FObj p = fobj.findNearestAncestorFObj();
// If this is a RA or the root, use the property value.
if (fobj.generatesReferenceAreas() || p == null) {

+ 5
- 0
src/java/org/apache/fop/fo/flow/Table.java View File

@@ -200,6 +200,11 @@ public class Table extends FObj {
return breakBefore;
}
/** @return the "border-collapse" property. */
public int getBorderCollapse() {
return borderCollapse;
}

/** @return the "border-separation" property. */
public LengthPairProperty getBorderSeparation() {
return borderSeparation;

+ 51
- 3
src/java/org/apache/fop/fo/flow/TableBody.java View File

@@ -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;

+ 10
- 0
src/java/org/apache/fop/fo/flow/TableCell.java View File

@@ -324,6 +324,16 @@ public class TableCell extends FObj {
return displayAlign;
}
/** @return true if the cell starts a row. */
public boolean startsRow() {
return (startsRow == EN_TRUE);
}
/** @return true if the cell ends a row. */
public boolean endsRow() {
return (endsRow == EN_TRUE);
}
/**
* @see org.apache.fop.fo.FObj#getName()
*/

+ 15
- 1
src/java/org/apache/fop/fo/flow/TableRow.java View File

@@ -25,6 +25,7 @@ import org.apache.fop.datatypes.Length;
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;
@@ -56,7 +57,7 @@ public class TableRow extends FObj {
private KeepProperty keepWithPrevious;
private int visibility;
// End of property values
private boolean setup = false;

/**
@@ -89,6 +90,19 @@ public class TableRow extends FObj {
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
*/

Loading…
Cancel
Save