/*
- * 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.ArrayList;
import java.util.List;
-import java.util.ListIterator;
import org.apache.fop.apps.FOPException;
-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.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthPairProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
-import org.apache.fop.layoutmgr.table.Body;
-import org.apache.fop.layoutmgr.table.Column;
-import org.apache.fop.layoutmgr.table.TableLayoutManager;
/**
* Class modelling the fo:table object.
private String id;
private LengthRangeProperty inlineProgressionDimension;
private int intrusionDisplace;
- private Length height;
+ //private Length height;
private KeepProperty keepTogether;
private KeepProperty keepWithNext;
private KeepProperty keepWithPrevious;
private int tableLayout;
private int tableOmitFooterAtBreak;
private int tableOmitHeaderAtBreak;
- private Length width;
+ //private Length width;
private int writingMode;
// End of property values
private static final int MINCOLWIDTH = 10000; // 10pt
/** collection of columns in this table */
- protected ArrayList columns = null;
+ protected List columns = null;
private TableBody tableHeader = null;
private TableBody tableFooter = null;
id = pList.get(PR_ID).getString();
inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
intrusionDisplace = pList.get(PR_INTRUSION_DISPLACE).getEnum();
- height = pList.get(PR_HEIGHT).getLength();
+ //height = pList.get(PR_HEIGHT).getLength();
keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
tableLayout = pList.get(PR_TABLE_LAYOUT).getEnum();
tableOmitFooterAtBreak = pList.get(PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum();
tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
- width = pList.get(PR_WIDTH).getLength();
+ //width = pList.get(PR_WIDTH).getLength();
writingMode = pList.get(PR_WRITING_MODE).getEnum();
}
protected void addChildNode(FONode child) throws FOPException {
if (child.getName().equals("fo:table-column")) {
if (columns == null) {
- columns = new ArrayList();
+ columns = new java.util.ArrayList();
}
columns.add(((TableColumn)child));
} else if (child.getName().equals("fo:table-footer")) {
}
}
- public ArrayList getColumns() {
+ public List getColumns() {
return columns;
}
}
/**
- * Return the Common Margin Properties-Block.
+ * @return the "inline-progression-dimension" property.
+ */
+ public LengthRangeProperty getInlineProgressionDimension() {
+ return inlineProgressionDimension;
+ }
+
+ /**
+ * @return the "block-progression-dimension" property.
+ */
+ public LengthRangeProperty getBlockProgressionDimension() {
+ return blockProgressionDimension;
+ }
+
+ /**
+ * @return the Common Margin Properties-Block.
*/
public CommonMarginBlock getCommonMarginBlock() {
return commonMarginBlock;
}
/**
- * Return the Common Border, Padding, and Background Properties.
+ * @return the Common Border, Padding, and Background Properties.
*/
public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
return commonBorderPaddingBackground;
}
/**
- * Return the "id" property.
+ * @return the "break-after" property.
+ */
+ public int getBreakAfter() {
+ return breakAfter;
+ }
+
+ /**
+ * @return the "break-before" property.
+ */
+ public int getBreakBefore() {
+ return breakBefore;
+ }
+
+ /**
+ * @return the "id" property.
*/
public String getId() {
return id;
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-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.
public void make(FONode node, List lms) {
Table table = (Table) node;
TableLayoutManager tlm = new TableLayoutManager(table);
- ArrayList columns = table.getColumns();
+ List columns = table.getColumns();
if (columns != null) {
ArrayList columnLMs = new ArrayList();
ListIterator iter = columns.listIterator();
/*
- * 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.
private boolean rows = true;
private List columns;
+ private int xoffset;
private int yoffset;
private int bodyHeight;
return null;
}
+ /**
+ * Set the x offset of this body within the table.
+ * This is used to set the row offsets.
+ * @param value
+ */
+ public void setXOffset(int off) {
+ xoffset = off;
+ }
+
/**
* Set the y offset of this body within the table.
* This is used to set the row offsets.
iStartPos = lfp.getLeafPos() + 1;
int lastheight = 0;
while ((childLM = (Row)breakPosIter.getNextChildLM()) != null) {
+ childLM.setXOffset(xoffset);
childLM.setYOffset(yoffset + rowoffset);
childLM.addAreas(breakPosIter, lc);
lastheight = childLM.getRowHeight();
TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
return curBlockArea;
}
+
}
/*
- * 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.
private List cellList = null;
private List columns = null;
private int rowHeight;
+ private int xoffset;
private int yoffset;
private class RowPosition extends LeafPosition {
setFinished(false);
}
+ /**
+ * Set the x position offset of this row.
+ * This is used to set the position of the areas returned by this row.
+ *
+ * @param off the x offset
+ */
+ public void setXOffset(int off) {
+ xoffset = off;
+ }
+
/**
* Set the y position offset of this row.
* This is used to set the position of the areas returned by this row.
// Add the block areas to Area
int cellcount = 0;
- int xoffset = 0;
+ int x = this.xoffset;
+ //int x = (TableLayoutManager)getParent()).;
for (Iterator iter = lfp.cellBreaks.iterator(); iter.hasNext();) {
List cellsbr = (List)iter.next();
PositionIterator breakPosIter;
}
while ((childLM = (Cell)breakPosIter.getNextChildLM()) != null) {
- childLM.setXOffset(xoffset);
+ childLM.setXOffset(x);
childLM.setYOffset(yoffset);
childLM.setRowHeight(rowHeight);
childLM.addAreas(breakPosIter, lc);
}
- xoffset += col.getWidth().getValue();
+ x += col.getWidth().getValue();
}
}
TraitSetter.addBackground(block, fobj.getCommonBorderPaddingBackground());
return block;
}
+
}
/*
- * 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.
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
+import org.apache.fop.traits.SpaceVal;
import java.util.ArrayList;
import java.util.Iterator;
private List bodyBreaks = new ArrayList();
private BreakPoss headerBreak;
private BreakPoss footerBreak;
+
+ private int referenceIPD;
+ //TODO space-before|after: handle space-resolution rules
+ private MinOptMax spaceBefore;
+ private MinOptMax spaceAfter;
+
+
private class SectionPosition extends LeafPosition {
protected List list;
protected SectionPosition(LayoutManager lm, int pos, List l) {
tableFooter.setParent(this);
}
+ /** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */
+ protected void initProperties() {
+ super.initProperties();
+ spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
+ spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
+ }
+
+ private int getIPIndents() {
+ int iIndents = 0;
+ iIndents += fobj.getCommonMarginBlock().startIndent.getValue();
+ iIndents += fobj.getCommonMarginBlock().endIndent.getValue();
+ return iIndents;
+ }
+
/**
* Get the next break possibility.
* The break possibility depends on the height of the header and footer
public BreakPoss getNextBreakPoss(LayoutContext context) {
Body curLM; // currently active LM
+ referenceIPD = context.getRefIPD();
+ if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
+ referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue();
+ }
+ if (referenceIPD > context.getRefIPD()) {
+ log.warn("Allocated IPD exceeds available reference IPD");
+ }
+ int contentIPD = referenceIPD - getIPIndents();
+
MinOptMax stackSize = new MinOptMax();
- // if starting add space before
- // stackSize.add(spaceBefore);
+ //Add spacing
+ if (spaceAfter != null) {
+ stackSize.add(spaceAfter);
+ }
+ if (spaceBefore != null) {
+ stackSize.add(spaceBefore);
+ }
+
BreakPoss lastPos = null;
- fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD());
+ fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
- fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, context.getRefIPD());
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
// either works out table of column widths or if proportional-column-width function
}
}
// sets TABLE_UNITS in case where one or more columns is defined using proportional-column-width
- if (sumCols < context.getRefIPD()) {
+ if (sumCols < contentIPD) {
if (fobj.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue() == 0.0) {
fobj.setLayoutDimension(PercentBase.TABLE_UNITS,
- (context.getRefIPD() - sumCols) / factors);
+ (contentIPD - sumCols) / factors);
}
}
MinOptMax headerSize = null;
* @return the break possibility containing the stacking size
*/
protected BreakPoss getHeight(Body lm, LayoutContext context) {
- int ipd = context.getRefIPD();
+ int referenceIPD = context.getRefIPD();
+ int contentIPD = referenceIPD - getIPIndents();
BreakPoss bp;
MinOptMax stackSize = new MinOptMax();
LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimit(context.getStackLimit());
- childLC.setRefIPD(ipd);
+ childLC.setRefIPD(contentIPD);
lm.setColumns(columns);
getParentArea(null);
addID(fobj.getId());
+ // if adjusted space before
+ double adjust = layoutContext.getSpaceAdjust();
+ addBlockSpacing(adjust, spaceBefore);
+ spaceBefore = null;
+
// add column, body then row areas
int tableHeight = 0;
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.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.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.setYOffset(tableHeight);
childLM.addAreas(breakPosIter, lc);
tableHeight += childLM.getBodyHeight();
TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addMargins(curBlockArea,
+ fobj.getCommonBorderPaddingBackground(),
+ fobj.getCommonMarginBlock());
+ TraitSetter.addBreaks(curBlockArea,
+ fobj.getBreakBefore(), fobj.getBreakAfter());
flush();
+ // if adjusted space after
+ addBlockSpacing(adjust, spaceAfter);
+
bodyBreaks.clear();
curBlockArea = null;
}
curBlockArea = new Block();
// Set up dimensions
// Must get dimensions from parent area
- Area parentArea = parentLM.getParentArea(curBlockArea);
- int referenceIPD = parentArea.getIPD();
- curBlockArea.setIPD(referenceIPD);
- // Get reference IPD from parentArea
- setCurrentArea(curBlockArea); // ??? for generic operations
+ /*Area parentArea =*/ parentLM.getParentArea(curBlockArea);
+
+ int contentIPD = referenceIPD - getIPIndents();
+ curBlockArea.setIPD(contentIPD);
+
+ setCurrentArea(curBlockArea);
}
return curBlockArea;
}
reset(null);
}
}
+
}