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;
private TableBody tableHeader = null;
private TableBody tableFooter = null;
+ /**
+ * Default table-column used when no columns are specified. It is used
+ * to handle inheritance (especially visibility) and defaults properly. */
+ private TableColumn defaultColumn;
+
/**
* @param parent FONode that is the parent of this object
*/
tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
//width = pList.get(PR_WIDTH).getLength();
writingMode = pList.get(PR_WRITING_MODE).getEnum();
+
+ //Create default column in case no table-columns will be defined.
+ defaultColumn = new TableColumn(this);
+ PropertyList colPList = new StaticPropertyList(defaultColumn, pList);
+ colPList.setWritingMode();
+ defaultColumn.bind(colPList);
}
/**
return (tableLayout != EN_FIXED);
}
+ /** @return the default table column */
+ public TableColumn getDefaultColumn() {
+ return this.defaultColumn;
+ }
+
public List getColumns() {
return columns;
}
package org.apache.fop.layoutmgr.table;
+import java.util.List;
+
import org.apache.fop.fo.flow.TableBody;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* LayoutManager for a table-header, table-footer and table body FO.
* These fo objects have either rows or cells underneath.
public class Body extends BlockStackingLayoutManager {
private TableBody fobj;
- private boolean rows = true;
private List columns;
private int xoffset;
private int yoffset;
private int bodyHeight;
- private Block curBlockArea;
+ //private Block curBlockArea;
- private List childBreaks = new ArrayList();
+ private List childBreaks = new java.util.ArrayList();
/**
* Create a new body layout manager.
+ * @param node the table-body FO
*/
public Body(TableBody node) {
super(node);
MinOptMax stackSize = new MinOptMax();
BreakPoss lastPos = null;
- if (columns == null) {
- setFinished(true);
- log.warn("ignoring fo:table-body with undefined fo:table-columns");
- return null;
- }
-
while ((curLM = (Row)getChildLM()) != null) {
// Make break positions
// Set up a LayoutContext
/**
* Set the x offset of this body within the table.
* This is used to set the row offsets.
- * @param value
+ * @param off the x offset
*/
public void setXOffset(int off) {
xoffset = off;
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
// Add the block areas to Area
- PositionIterator breakPosIter =
- new BreakPossPosIter(childBreaks, iStartPos,
+ PositionIterator breakPosIter
+ = new BreakPossPosIter(childBreaks, iStartPos,
lfp.getLeafPos() + 1);
iStartPos = lfp.getLeafPos() + 1;
int lastheight = 0;
flush();
childBreaks.clear();
- curBlockArea = null;
+ //curBlockArea = null;
}
/**
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.flow.Table;
+import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.properties.TableColLength;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutManager;
private BreakPoss footerBreak;
private int referenceIPD;
+ private boolean autoLayout = true;
//TODO space-before|after: handle space-resolution rules
private MinOptMax spaceBefore;
/**
* Create a new table layout manager.
- *
+ * @param node the table FO
*/
public TableLayoutManager(Table node) {
super(node);
fobj = node;
}
+ /** @return the table FO */
+ public Table getTable() {
+ return this.fobj;
+ }
+
/**
* Set the columns for this table.
*
super.initProperties();
spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
+
+ if (!fobj.isAutoLayout()
+ && fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
+ autoLayout = false;
+ }
}
private int getIPIndents() {
fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
+ if (columns == null) {
+ createColumnsFromFirstRow();
+ }
+
// either works out table of column widths or if proportional-column-width function
// is used works out total factor, so that value of single unit can be computed.
int sumCols = 0;
return null;
}
+ private void createColumnsFromFirstRow() {
+ this.columns = new java.util.ArrayList();
+ //TODO Create columns from first row here
+ //--> rule 2 in "fixed table layout", see CSS2, 17.5.2
+ //Alternative: extend columns on-the-fly, but in this case we need the
+ //new property evaluation context so proportional-column-width() works
+ //correctly.
+ if (columns.size() == 0) {
+ this.columns.add(new Column(getTable().getDefaultColumn()));
+ }
+ }
+
/**
* Get the break possibility and height of the table header or footer.
*
double adjust = layoutContext.getSpaceAdjust();
addBlockSpacing(adjust, spaceBefore);
spaceBefore = null;
+
+ int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue();
// add column, body then row areas
List list = pos.list;
PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
- childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
+ childLM.setXOffset(startXOffset);
childLM.addAreas(breakPosIter, lc);
tableHeight += childLM.getBodyHeight();
}
lfp.getLeafPos() + 1);
iStartPos = lfp.getLeafPos() + 1;
while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
- childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
+ childLM.setXOffset(startXOffset);
childLM.setYOffset(tableHeight);
childLM.addAreas(breakPosIter, lc);
tableHeight += childLM.getBodyHeight();
List list = pos.list;
PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
- childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
+ childLM.setXOffset(startXOffset);
childLM.setYOffset(tableHeight);
childLM.addAreas(breakPosIter, lc);
tableHeight += childLM.getBodyHeight();