You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/04/05 17:42:45 UTC
cvs commit: xml-fop/src/java/org/apache/fop/fo FObj.java
jeremias 2005/04/05 08:42:45
Modified: src/java/org/apache/fop/layoutmgr/table Tag:
Temp_KnuthStylePageBreaking Cell.java Body.java
TableLayoutManager.java GridUnit.java
CollapsingBorderModel.java Row.java
CollapsingBorderModelEyeCatching.java
src/java/org/apache/fop/fo/flow Tag:
Temp_KnuthStylePageBreaking TableCell.java
TableBody.java TableColumn.java Table.java
src/java/org/apache/fop/layoutmgr Tag:
Temp_KnuthStylePageBreaking
LayoutManagerMapping.java FlowLayoutManager.java
BlockStackingLayoutManager.java
BlockLayoutManager.java
src/java/org/apache/fop/fo Tag: Temp_KnuthStylePageBreaking
FObj.java
Added: src/java/org/apache/fop/layoutmgr/table Tag:
Temp_KnuthStylePageBreaking OldGridUnit.java
ColumnSetup.java TableContentLayoutManager.java
PrimaryGridUnit.java TableRowIterator.java
Log:
Basic framework for table layout with Knuth elements as documented on the Wiki. The old code is mostly still there for reference.
Revision Changes Path
No revision
No revision
1.26.2.1 +185 -11 xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java
Index: Cell.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Cell.java,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- Cell.java 16 Mar 2005 23:18:43 -0000 1.26
+++ Cell.java 5 Apr 2005 15:42:44 -0000 1.26.2.1
@@ -23,12 +23,18 @@
import org.apache.fop.fo.flow.TableCell;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.layoutmgr.AreaAdditionUtil;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
+import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.MinOptMaxUtil;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
@@ -39,14 +45,17 @@
import org.apache.fop.traits.MinOptMax;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
/**
* LayoutManager for a table-cell FO.
* A cell contains blocks. These blocks fill the cell.
*/
-public class Cell extends BlockStackingLayoutManager {
+public class Cell extends BlockStackingLayoutManager implements BlockLevelLayoutManager {
+
private TableCell fobj;
+ private PrimaryGridUnit gridUnit;
private Block curBlockArea;
@@ -65,16 +74,17 @@
private int borderAndPaddingBPD;
private boolean emptyCell = true;
- /** List of Lists containing GridUnit instances, one List per row. */
+ /** List of Lists containing OldGridUnit instances, one List per row. */
private List rows = new java.util.ArrayList();
/**
* Create a new Cell layout manager.
* @node table-cell FO for which to create the LM
*/
- public Cell(TableCell node) {
+ public Cell(TableCell node, PrimaryGridUnit pgu) {
super(node);
fobj = node;
+ this.gridUnit = pgu;
}
/** @return the table-cell FO */
@@ -126,10 +136,10 @@
for (int i = 0; i < rows.size(); i++) {
List gridUnits = (List)rows.get(i);
startBorderWidth = Math.max(startBorderWidth,
- ((GridUnit)gridUnits.get(0)).
+ ((OldGridUnit)gridUnits.get(0)).
effBorders.getBorderStartWidth(false));
endBorderWidth = Math.max(endBorderWidth,
- ((GridUnit)gridUnits.get(gridUnits.size() - 1)).
+ ((OldGridUnit)gridUnits.get(gridUnits.size() - 1)).
effBorders.getBorderEndWidth(false));
}
//iIndents += fobj.getCommonBorderPaddingBackground().getBorderStartWidth(false);
@@ -145,6 +155,111 @@
}
/**
+ * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
+ */
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+ MinOptMax stackSize = new MinOptMax();
+ MinOptMax stackLimit = new MinOptMax(context.getStackLimit());
+
+ BreakPoss lastPos = null;
+
+ referenceIPD = context.getRefIPD();
+ cellIPD = referenceIPD;
+ cellIPD -= getIPIndents();
+ if (fobj.isSeparateBorderModel()) {
+ int borderSep = fobj.getBorderSeparation().getLengthPair()
+ .getIPD().getLength().getValue();
+ cellIPD -= borderSep;
+ }
+
+ LinkedList returnedList = null;
+ LinkedList contentList = new LinkedList();
+ LinkedList returnList = new LinkedList();
+ Position returnPosition = new NonLeafPosition(this, null);
+
+ BlockLevelLayoutManager curLM; // currently active LM
+ BlockLevelLayoutManager prevLM = null; // previously active LM
+ while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
+ LayoutContext childLC = new LayoutContext(0);
+ // curLM is a ?
+ childLC.setStackLimit(MinOptMax.subtract(context
+ .getStackLimit(), stackLimit));
+ childLC.setRefIPD(cellIPD);
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment);
+ if (returnedList.size() == 1
+ && ((KnuthElement) returnedList.getFirst()).isPenalty()
+ && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-before
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ }
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ if (mustKeepTogether()
+ || prevLM.mustKeepWithNext()
+ || curLM.mustKeepWithPrevious()) {
+ // add an infinite penalty to forbid a break between
+ // blocks
+ contentList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new Position(this), false));
+ } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
+ // add a null penalty to allow a break between blocks
+ contentList.add(new KnuthPenalty(0, 0, false,
+ new Position(this), false));
+ } else {
+ // the last element in contentList is a glue;
+ // it is a feasible breakpoint, there is no need to add
+ // a penalty
+ }
+ }
+ contentList.addAll(returnedList);
+ if (returnedList.size() == 0) {
+ //Avoid NoSuchElementException below (happens with empty blocks)
+ continue;
+ }
+ if (((KnuthElement) returnedList.getLast()).isPenalty()
+ && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-after
+ if (curLM.isFinished()) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+ }
+ prevLM = curLM;
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ setFinished(true);
+ return returnList;
+ }
+
+ /**
* Get the next break possibility for this cell.
* A cell contains blocks so there are breaks around the blocks
* and inside the blocks.
@@ -152,7 +267,7 @@
* @param context the layout context
* @return the next break possibility
*/
- public BreakPoss getNextBreakPoss(LayoutContext context) {
+ public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
LayoutManager curLM; // currently active LM
MinOptMax stackSize = new MinOptMax();
@@ -291,8 +406,8 @@
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
- bBogus = !bp1.generatesAreas();
+ //BreakPoss bp1 = (BreakPoss)parentIter.peekNext();
+ bBogus = false;//!bp1.generatesAreas();
if (!isBogus()) {
addID(fobj.getId());
@@ -310,7 +425,7 @@
if (rows.size() == 1 && ((List)rows.get(0)).size() == 1) {
//Can set the borders directly if there's no span
CommonBorderPaddingBackground effBorders =
- ((GridUnit)((List)rows.get(0)).get(0)).effBorders;
+ ((OldGridUnit)((List)rows.get(0)).get(0)).effBorders;
//TODO Next line is a temporary hack!
TraitSetter.addCollapsingBorders(curBlockArea,
fobj.getCommonBorderPaddingBackground(), outer);
@@ -323,7 +438,7 @@
int dx = xoffset;
int lastRowHeight = 0;
for (int x = 0; x < gridUnits.size(); x++) {
- GridUnit gu = (GridUnit)gridUnits.get(x);
+ OldGridUnit gu = (OldGridUnit)gridUnits.get(x);
if (!gu.effBorders.hasBorder()) {
continue;
}
@@ -364,9 +479,21 @@
}
}
+ AreaAdditionUtil.addAreas(parentIter, layoutContext);
+ /*
LayoutManager childLM;
int iStartPos = 0;
LayoutContext lc = new LayoutContext(0);
+ PositionIterator childPosIter;
+ childPosIter = new StackingIter(positionList.listIterator());
+ while ((childLM = childPosIter.getNextChildLM()) != null) {
+ // set last area flag
+ lc.setFlags(LayoutContext.LAST_AREA,
+ (layoutContext.isLastArea() && childLM == lastLM));
+ lc.setStackLimit(layoutContext.getStackLimit());
+ // Add the line areas to Area
+ childLM.addAreas(childPosIter, lc);
+ }
while (parentIter.hasNext()) {
LeafPosition lfp = (LeafPosition) parentIter.next();
// Add the block areas to Area
@@ -377,7 +504,7 @@
while ((childLM = breakPosIter.getNextChildLM()) != null) {
childLM.addAreas(breakPosIter, lc);
}
- }
+ }*/
int contentBPD = rowHeight;
@@ -461,5 +588,52 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+ */
+ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(org.apache.fop.layoutmgr.KnuthGlue)
+ */
+ public void discardSpace(KnuthGlue spaceGlue) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
+ */
+ public boolean mustKeepTogether() {
+ //TODO Keeps will have to be more sophisticated sooner or later
+ return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()/*
+ || !fobj.getKeepTogether().getWithinPage().isAuto()
+ || !fobj.getKeepTogether().getWithinColumn().isAuto()*/;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
+ */
+ public boolean mustKeepWithPrevious() {
+ return false; //TODO FIX ME
+ /*
+ return !fobj.getKeepWithPrevious().getWithinPage().isAuto()
+ || !fobj.getKeepWithPrevious().getWithinColumn().isAuto();
+ */
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
+ */
+ public boolean mustKeepWithNext() {
+ return false; //TODO FIX ME
+ /*
+ return !fobj.getKeepWithNext().getWithinPage().isAuto()
+ || !fobj.getKeepWithNext().getWithinColumn().isAuto();
+ */
+ }
+
}
1.15.2.1 +137 -2 xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java
Index: Body.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- Body.java 16 Mar 2005 23:18:43 -0000 1.15
+++ Body.java 5 Apr 2005 15:42:44 -0000 1.15.2.1
@@ -18,14 +18,20 @@
package org.apache.fop.layoutmgr.table;
+import java.util.LinkedList;
import java.util.List;
import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
+import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
@@ -39,7 +45,7 @@
* These fo objects have either rows or cells underneath.
* Cells are organised into rows.
*/
-public class Body extends BlockStackingLayoutManager {
+public class Body extends BlockStackingLayoutManager implements BlockLevelLayoutManager {
private TableBody fobj;
private List columns;
@@ -76,13 +82,106 @@
}
/**
+ * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
+ */
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+ LayoutContext childLC = new LayoutContext(0);
+ childLC.setStackLimit(context.getStackLimit());
+ childLC.setRefIPD(context.getRefIPD());
+
+ LinkedList returnedList = null;
+ LinkedList contentList = new LinkedList();
+ LinkedList returnList = new LinkedList();
+ Position returnPosition = new NonLeafPosition(this, null);
+
+ Row curLM; // currently active LM
+ Row prevLM = null; // previously active LM
+ while ((curLM = (Row)getChildLM()) != null) {
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment);
+ /*
+ if (returnedList.size() == 1
+ && ((KnuthElement) returnedList.getFirst()).isPenalty()
+ && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-before
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ bSpaceBeforeServed = false;
+ }
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else*/ {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ if (mustKeepTogether()
+ || prevLM.mustKeepWithNext()
+ || curLM.mustKeepWithPrevious()) {
+ // add an infinite penalty to forbid a break between
+ // blocks
+ contentList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new Position(this), false));
+ } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
+ // add a null penalty to allow a break between blocks
+ contentList.add(new KnuthPenalty(0, 0, false,
+ new Position(this), false));
+ } else {
+ // the last element in contentList is a glue;
+ // it is a feasible breakpoint, there is no need to add
+ // a penalty
+ }
+ }
+ contentList.addAll(returnedList);
+ if (returnedList.size() == 0) {
+ //Avoid NoSuchElementException below (happens with empty blocks)
+ continue;
+ }
+ if (((KnuthElement) returnedList.getLast()).isPenalty()
+ && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-after
+ if (curLM.isFinished()) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+ }
+ prevLM = curLM;
+ }
+
+ setFinished(true);
+ if (returnList.size() > 0) {
+ return returnList;
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Breaks for this layout manager are of the form of before
* or after a row and inside a row.
*
* @param context the layout context for finding the breaks
* @return the next break possibility
*/
- public BreakPoss getNextBreakPoss(LayoutContext context) {
+ public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
Row curLM; // currently active LM
MinOptMax stackSize = new MinOptMax();
@@ -266,5 +365,41 @@
return curBlockArea;
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+ */
+ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(org.apache.fop.layoutmgr.KnuthGlue)
+ */
+ public void discardSpace(KnuthGlue spaceGlue) {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
+ */
+ public boolean mustKeepTogether() {
+ return ((BlockLevelLayoutManager)getParent()).mustKeepTogether();
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
+ */
+ public boolean mustKeepWithPrevious() {
+ return false;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
+ */
+ public boolean mustKeepWithNext() {
+ return false;
+ }
+
}
1.21.2.1 +367 -42 xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
Index: TableLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -r1.21 -r1.21.2.1
--- TableLayoutManager.java 16 Mar 2005 23:18:43 -0000 1.21
+++ TableLayoutManager.java 5 Apr 2005 15:42:44 -0000 1.21.2.1
@@ -21,12 +21,18 @@
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.TableColumn;
import org.apache.fop.fo.properties.TableColLength;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
+import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.BreakPoss;
import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
@@ -37,20 +43,24 @@
import org.apache.fop.traits.SpaceVal;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
/**
* LayoutManager for a table FO.
- * A table consists of columns, table header, table footer and multiple
+ * A table consists of oldColumns, table header, table footer and multiple
* table bodies.
* The header, footer and body add the areas created from the table cells.
- * The table then creates areas for the columns, bodies and rows
+ * The table then creates areas for the oldColumns, bodies and rows
* the render background.
*/
-public class TableLayoutManager extends BlockStackingLayoutManager {
+public class TableLayoutManager extends BlockStackingLayoutManager
+ implements BlockLevelLayoutManager {
private Table fobj;
- private List columns = null;
+ private TableContentLayoutManager contentLM;
+ private List oldColumns = null;
+ private ColumnSetup columns = null;
private Block curBlockArea;
@@ -82,6 +92,7 @@
public TableLayoutManager(Table node) {
super(node);
fobj = node;
+ this.columns = new ColumnSetup(node);
}
/** @return the table FO */
@@ -90,14 +101,18 @@
}
/**
- * Set the columns for this table.
+ * Set the oldColumns for this table.
*
* @param cols the list of column layout managers
*/
public void setColumns(List cols) {
- columns = cols;
+ oldColumns = cols;
}
+ public ColumnSetup getColumns() {
+ return this.columns;
+ }
+
/** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */
protected void initProperties() {
super.initProperties();
@@ -118,14 +133,173 @@
}
/**
+ * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
+ */
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+
+ 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();
+ //Add spacing
+ if (spaceAfter != null) {
+ stackSize.add(spaceAfter);
+ }
+ if (spaceBefore != null) {
+ stackSize.add(spaceBefore);
+ }
+
+ BreakPoss lastPos = null;
+
+ fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
+ fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
+
+ /*
+ if (oldColumns == 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;
+ float factors = 0;
+ for (Iterator i = columns.iterator(); i.hasNext(); ) {
+ TableColumn column = (TableColumn) i.next();
+ Length width = column.getColumnWidth();
+ sumCols += width.getValue();
+ if (width instanceof TableColLength) {
+ factors += ((TableColLength) width).getTableUnits();
+ }
+ }
+ // sets TABLE_UNITS in case where one or more oldColumns is defined using
+ // proportional-column-width
+ if (sumCols < contentIPD) {
+ if (fobj.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue() == 0.0) {
+ fobj.setLayoutDimension(PercentBase.TABLE_UNITS,
+ (contentIPD - sumCols) / factors);
+ }
+ }
+
+ LinkedList headerElements = null;
+ LinkedList footerElements = null;
+ if (getTable().getTableHeader() != null) {
+ Body tableHeader = new Body(getTable().getTableHeader());
+ tableHeader.setParent(this);
+ headerElements = getKnuthElementsForHeaderFooter(
+ tableHeader, context, alignment);
+ }
+ if (getTable().getTableFooter() != null) {
+ Body tableFooter = new Body(getTable().getTableFooter());
+ tableFooter.setParent(this);
+ footerElements = getKnuthElementsForHeaderFooter(
+ tableFooter, context, alignment);
+ }
+
+ LinkedList returnedList = null;
+ LinkedList contentList = new LinkedList();
+ LinkedList returnList = new LinkedList();
+ Position returnPosition = new NonLeafPosition(this, null);
+ Body prevLM = null;
+
+ LayoutContext childLC = new LayoutContext(0);
+ childLC.setStackLimit(
+ MinOptMax.subtract(context.getStackLimit(),
+ stackSize));
+ childLC.setRefIPD(context.getRefIPD());
+
+ contentLM = new TableContentLayoutManager(this);
+ returnedList = contentLM.getNextKnuthElements(childLC, alignment);
+ log.debug(returnedList);
+
+ if (returnedList.size() == 1
+ && ((KnuthElement) returnedList.getFirst()).isPenalty()
+ && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-before
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ //FIX ME
+ //bSpaceBeforeServed = false;
+ }
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ if (mustKeepTogether()
+ /*|| prevLM.mustKeepWithNext()
+ || curLM.mustKeepWithPrevious()*/) {
+ // add an infinite penalty to forbid a break between
+ // blocks
+ contentList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new Position(this), false));
+ } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
+ // add a null penalty to allow a break between blocks
+ contentList.add(new KnuthPenalty(0, 0, false,
+ new Position(this), false));
+ } else {
+ // the last element in contentList is a glue;
+ // it is a feasible breakpoint, there is no need to add
+ // a penalty
+ }
+ }
+ contentList.addAll(returnedList);
+ /*
+ if (returnedList.size() == 0) {
+ //Avoid NoSuchElementException below (happens with empty blocks)
+ continue;
+ }*/
+ if (((KnuthElement) returnedList.getLast()).isPenalty()
+ && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-after
+ if (false /*curLM.isFinished()*/) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+
+ }
+ wrapPositionElements(contentList, returnList);
+ setFinished(true);
+ return returnList;
+ }
+
+ /**
* Get the next break possibility.
* The break possibility depends on the height of the header and footer
* and possible breaks inside the table body.
*
* @param context the layout context for finding breaks
* @return the next break possibility
- */
- public BreakPoss getNextBreakPoss(LayoutContext context) {
+ *//*
+ public BreakPoss getNextBreakPossOLDOLDOLD(LayoutContext context) {
Body curLM; // currently active LM
referenceIPD = context.getRefIPD();
@@ -153,7 +327,7 @@
fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
- if (columns == null) {
+ if (columns.getColumnCount() == 0) {
createColumnsFromFirstRow();
}
@@ -161,8 +335,8 @@
// is used works out total factor, so that value of single unit can be computed.
int sumCols = 0;
float factors = 0;
- if (columns != null) {
- for (Iterator i = columns.iterator(); i.hasNext(); ) {
+ if (oldColumns != null) {
+ for (Iterator i = oldColumns.iterator(); i.hasNext(); ) {
Column column = (Column) i.next();
Length width = column.getWidth();
sumCols += width.getValue();
@@ -171,7 +345,8 @@
}
}
}
- // sets TABLE_UNITS in case where one or more columns is defined using proportional-column-width
+ // sets TABLE_UNITS in case where one or more oldColumns is defined using
+ // proportional-column-width
if (sumCols < contentIPD) {
if (fobj.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue() == 0.0) {
fobj.setLayoutDimension(PercentBase.TABLE_UNITS,
@@ -189,7 +364,7 @@
if (!getTable().omitHeaderAtBreak() || !firstRowHandled) {
Body tableHeader = new Body(getTable().getTableHeader());
tableHeader.setParent(this);
- headerBreak = getHeight(tableHeader, context);
+ headerBreak = getHeightOLDOLDOLD(tableHeader, context);
headerSize = headerBreak.getStackingSize();
stackSize.add(headerSize);
}
@@ -201,7 +376,7 @@
if (getTable().getTableFooter() != null) {
Body tableFooter = new Body(getTable().getTableFooter());
tableFooter.setParent(this);
- footerBreak = getHeight(tableFooter, context);
+ footerBreak = getHeightOLDOLDOLD(tableFooter, context);
footerSize = footerBreak.getStackingSize();
stackSize.add(footerSize);
}
@@ -227,7 +402,7 @@
stackSize));
childLC.setRefIPD(ipd);
- curLM.setColumns(columns);
+ curLM.setColumns(oldColumns);
boolean over = false;
while (!curLM.isFinished()) {
@@ -270,28 +445,29 @@
}
setFinished(true);
return null;
- }
+ }*/
+ /*
private void createColumnsFromFirstRow() {
- this.columns = new java.util.ArrayList();
- //TODO Create columns from first row here
+ this.oldColumns = new java.util.ArrayList();
+ //TODO Create oldColumns 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
+ //Alternative: extend oldColumns on-the-fly, but in this case we need the
//new property evaluation context so proportional-column-width() works
//correctly.
- if (columns.size() == 0) {
+ if (oldColumns.size() == 0) {
Column col = new Column(getTable().getDefaultColumn());
col.setParent(this);
- this.columns.add(col);
+ this.oldColumns.add(col);
}
- }
+ }*/
/**
* @param column the column to check
* @return true if the column is the first column
*/
public boolean isFirst(Column column) {
- return (this.columns.size() == 0 || this.columns.get(0) == column);
+ return (this.oldColumns.size() == 0 || this.oldColumns.get(0) == column);
}
/**
@@ -299,7 +475,7 @@
* @return true if the column is the last column
*/
public boolean isLast(Column column) {
- return (this.columns.size() == 0 || this.columns.get(columns.size() - 1) == column);
+ return (this.oldColumns.size() == 0 || this.oldColumns.get(oldColumns.size() - 1) == column);
}
/**
@@ -309,7 +485,128 @@
* @param context the parent layout context
* @return the break possibility containing the stacking size
*/
- protected BreakPoss getHeight(Body lm, LayoutContext context) {
+ protected LinkedList getKnuthElementsForHeaderFooter(Body lm, LayoutContext context,
+ int alignment) {
+ 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(contentIPD);
+
+ lm.setColumns(oldColumns);
+
+ LinkedList returnedList = null;
+ LinkedList contentList = new LinkedList();
+ LinkedList returnList = new LinkedList();
+ Position returnPosition = new NonLeafPosition(this, null);
+
+ Row curLM; // currently active LM
+ Row prevLM = null; // previously active LM
+ while ((curLM = (Row)getChildLM()) != null) {
+
+ // get elements from curLM
+ returnedList = curLM.getNextKnuthElements(childLC, alignment);
+ /*
+ if (returnedList.size() == 1
+ && ((KnuthElement) returnedList.getFirst()).isPenalty()
+ && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-before
+ if (returnList.size() == 0) {
+ // the first child (or its first child ...) has
+ // break-before;
+ // all this block, including space before, will be put in
+ // the
+ // following page
+ bSpaceBeforeServed = false;
+ }
+ contentList.addAll(returnedList);
+
+ // "wrap" the Position inside each element
+ // moving the elements from contentList to returnList
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ } else*/ {
+ if (prevLM != null) {
+ // there is a block handled by prevLM
+ // before the one handled by curLM
+ if (mustKeepTogether()
+ || prevLM.mustKeepWithNext()
+ || curLM.mustKeepWithPrevious()) {
+ // add an infinite penalty to forbid a break between
+ // blocks
+ contentList.add(new KnuthPenalty(0,
+ KnuthElement.INFINITE, false,
+ new Position(this), false));
+ } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
+ // add a null penalty to allow a break between blocks
+ contentList.add(new KnuthPenalty(0, 0, false,
+ new Position(this), false));
+ } else {
+ // the last element in contentList is a glue;
+ // it is a feasible breakpoint, there is no need to add
+ // a penalty
+ }
+ }
+ contentList.addAll(returnedList);
+ if (returnedList.size() == 0) {
+ //Avoid NoSuchElementException below (happens with empty blocks)
+ continue;
+ }
+ if (((KnuthElement) returnedList.getLast()).isPenalty()
+ && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
+ // a descendant of this block has break-after
+ if (curLM.isFinished()) {
+ // there is no other content in this block;
+ // it's useless to add space after before a page break
+ setFinished(true);
+ }
+
+ returnedList = new LinkedList();
+ wrapPositionElements(contentList, returnList);
+
+ return returnList;
+ }
+ }
+ prevLM = curLM;
+ }
+
+ /*
+ List breaks = new java.util.ArrayList();
+ while (!lm.isFinished()) {
+ if ((bp = lm.getNextBreakPoss(childLC)) != null) {
+ stackSize.add(bp.getStackingSize());
+ breaks.add(bp);
+ childLC.setStackLimit(MinOptMax.subtract(
+ context.getStackLimit(), stackSize));
+ }
+ }
+ BreakPoss breakPoss = new BreakPoss(
+ new SectionPosition(this, breaks.size() - 1, breaks));
+ breakPoss.setStackingSize(stackSize);
+ return breakPoss;*/
+
+ if (returnList.size() > 0) {
+ return returnList;
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * Get the break possibility and height of the table header or footer.
+ *
+ * @param lm the header or footer layout manager
+ * @param context the parent layout context
+ * @return the break possibility containing the stacking size
+ */
+ protected BreakPoss getHeightOLDOLDOLD(Body lm, LayoutContext context) {
int referenceIPD = context.getRefIPD();
int contentIPD = referenceIPD - getIPIndents();
BreakPoss bp;
@@ -320,7 +617,7 @@
childLC.setStackLimit(context.getStackLimit());
childLC.setRefIPD(contentIPD);
- lm.setColumns(columns);
+ lm.setColumns(oldColumns);
List breaks = new java.util.ArrayList();
while (!lm.isFinished()) {
@@ -339,7 +636,7 @@
/**
* The table area is a reference area that contains areas for
- * columns, bodies, rows and the contents are in cells.
+ * oldColumns, bodies, rows and the contents are in cells.
*
* @param parentIter the position iterator
* @param layoutContext the layout context for adding areas
@@ -374,21 +671,7 @@
}
}
- int iStartPos = 0;
- while (parentIter.hasNext()) {
- LeafPosition lfp = (LeafPosition) parentIter.next();
- // Add the block areas to Area
- PositionIterator breakPosIter =
- new BreakPossPosIter(bodyBreaks, iStartPos,
- lfp.getLeafPos() + 1);
- iStartPos = lfp.getLeafPos() + 1;
- while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
- childLM.setXOffset(startXOffset);
- childLM.setYOffset(tableHeight);
- childLM.addAreas(breakPosIter, lc);
- tableHeight += childLM.getBodyHeight();
- }
- }
+ contentLM.addAreas(parentIter, layoutContext);
// add footer areas
if (footerBreak != null) {
@@ -474,5 +757,47 @@
}
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+ */
+ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(org.apache.fop.layoutmgr.KnuthGlue)
+ */
+ public void discardSpace(KnuthGlue spaceGlue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
+ */
+ public boolean mustKeepTogether() {
+ //TODO Keeps will have to be more sophisticated sooner or later
+ return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()
+ || !fobj.getKeepTogether().getWithinPage().isAuto()
+ || !fobj.getKeepTogether().getWithinColumn().isAuto();
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
+ */
+ public boolean mustKeepWithPrevious() {
+ return !fobj.getKeepWithPrevious().getWithinPage().isAuto()
+ || !fobj.getKeepWithPrevious().getWithinColumn().isAuto();
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
+ */
+ public boolean mustKeepWithNext() {
+ return !fobj.getKeepWithNext().getWithinPage().isAuto()
+ || !fobj.getKeepWithNext().getWithinColumn().isAuto();
+ }
+
}
1.1.2.1 +69 -84 xml-fop/src/java/org/apache/fop/layoutmgr/table/GridUnit.java
Index: GridUnit.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/GridUnit.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- GridUnit.java 21 Feb 2005 21:52:14 -0000 1.1
+++ GridUnit.java 5 Apr 2005 15:42:44 -0000 1.1.2.1
@@ -18,114 +18,99 @@
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.Table;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
-
+import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableCell;
+import org.apache.fop.fo.flow.TableColumn;
+import org.apache.fop.fo.flow.TableRow;
+/**
+ * This class represents one grid unit inside a table.
+ */
public class GridUnit {
+
+ /** Table cell which occupies this grid unit */
+ private TableCell cell;
+ /** Table column that this grid unit belongs to */
+ private TableColumn column;
- /** layout manager for the cell occupying this grid unit, may be null */
- public Cell layoutManager;
- /** layout manager for the column that this grid unit belongs to */
- public Column column;
- /** layout manager for the row that this grid unit belongs to */
- public Row row;
+ /** start index of grid unit within row in column direction */
+ private int startCol;
/** index of grid unit within cell in column direction */
- public int colSpanIndex;
+ private int colSpanIndex;
/** index of grid unit within cell in row direction */
- public int rowSpanIndex;
- /** effective borders for a cell slot (used for collapsing border model) */
- public CommonBorderPaddingBackground effBorders;
+ private int rowSpanIndex;
+
- public GridUnit(Cell layoutManager, int colSpanIndex) {
- this.layoutManager = layoutManager;
+ public GridUnit(TableCell cell, TableColumn column, int startCol, int colSpanIndex) {
+ this.cell = cell;
+ this.column = column;
+ this.startCol = startCol;
this.colSpanIndex = colSpanIndex;
- this.rowSpanIndex = 0;
}
- public GridUnit(Cell layoutManager) {
- this(layoutManager, 0);
+ public TableCell getCell() {
+ return this.cell;
}
-
- /** @return true if the grid unit is the primary of a cell */
- public boolean isPrimaryGridUnit() {
- return (colSpanIndex == 0) && (rowSpanIndex == 0);
+
+ public TableColumn getColumn() {
+ return this.column;
}
- /** @return true if the grid unit is the last in column spanning direction */
- public boolean isLastGridUnitColSpan() {
- if (layoutManager != null) {
- return (colSpanIndex == layoutManager.getFObj().getNumberColumnsSpanned() - 1);
+ public TableRow getRow() {
+ if (getCell().getParent() instanceof TableRow) {
+ return (TableRow)getCell().getParent();
} else {
- return true;
+ return null;
}
}
- /** @return true if the grid unit is the last in column spanning direction */
- public boolean isLastGridUnitRowSpan() {
- if (layoutManager != null) {
- return (rowSpanIndex == layoutManager.getFObj().getNumberRowsSpanned() - 1);
- } else {
- return true;
+ public TableBody getBody() {
+ FONode node = getCell();
+ while (!(node instanceof TableBody)) {
+ node = node.getParent();
}
+ return (TableBody)node;
}
- /** @return true if the cell is part of a span in column direction */
- public boolean isColSpan() {
- return (colSpanIndex > 0);
- }
-
- public BorderInfo getOriginalBorderInfoForCell(int side) {
- if (layoutManager != null) {
- return layoutManager.getFObj().getCommonBorderPaddingBackground().getBorderInfo(side);
- } else {
- return null;
+ public Table getTable() {
+ FONode node = getCell();
+ while (!(node instanceof Table)) {
+ node = node.getParent();
}
+ return (Table)node;
}
- /**
- * Assign the borders from the given cell to this cell info. Used in
- * case of separate border model.
- * @param current cell to take the borders from
- */
- public void assignBorder(Cell current) {
- if (current != null) {
- this.effBorders = current.getFObj().getCommonBorderPaddingBackground();
- }
+ public boolean isPrimary() {
+ return false;
}
- /**
- * Assign the borders directly.
- * @param borders the borders to use
- */
- public void assignBorder(CommonBorderPaddingBackground borders) {
- if (borders != null) {
- this.effBorders = borders;
- }
+ public boolean isEmpty() {
+ return this.cell == null;
}
- /**
- * Resolve collapsing borders for the given cell and store the resulting
- * borders in this cell info. Use in case of the collapsing border model.
- * @param current cell to resolve borders for
- * @param before cell before the current cell, if any
- * @param after cell after the current cell, if any
- * @param start cell preceeding the current cell, if any
- * @param end cell succeeding of the current cell, if any
- */
- public static void resolveBorder(Table table,
- CommonBorderPaddingBackground target,
- GridUnit current, GridUnit other, int side) {
- if (current == null) {
- return;
- }
-
- CollapsingBorderModel borderModel = CollapsingBorderModel.getBorderModelFor(
- table.getBorderCollapse());
- target.setBorderInfo(
- borderModel.determineWinner(current, other,
- side, 0), side);
+ public int getStartCol() {
+ return this.startCol;
+ }
+
+ /** @see java.lang.Object#toString() */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if (isEmpty()) {
+ sb.append("EMPTY");
+ } else if (isPrimary()) {
+ sb.append("Primary");
+ }
+ sb.append("GridUnit:");
+ if (colSpanIndex > 0) {
+ sb.append(" colSpan=").append(colSpanIndex);
+ }
+ if (rowSpanIndex > 0) {
+ sb.append(" rowSpan=").append(rowSpanIndex);
+ }
+ sb.append(" startCol=").append(startCol);
+ return sb.toString();
}
-}
\ No newline at end of file
+}
1.1.2.1 +2 -2 xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
Index: CollapsingBorderModel.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- CollapsingBorderModel.java 21 Feb 2005 21:52:14 -0000 1.1
+++ CollapsingBorderModel.java 5 Apr 2005 15:42:44 -0000 1.1.2.1
@@ -116,6 +116,6 @@
* @return the winning BorderInfo
*/
public abstract BorderInfo determineWinner(
- GridUnit current, GridUnit neighbour, int side, int flags);
+ OldGridUnit current, OldGridUnit neighbour, int side, int flags);
}
1.26.2.1 +64 -19 xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java
Index: Row.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -r1.26 -r1.26.2.1
--- Row.java 16 Mar 2005 23:18:43 -0000 1.26
+++ Row.java 5 Apr 2005 15:42:44 -0000 1.26.2.1
@@ -25,7 +25,10 @@
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.BreakPoss;
@@ -52,7 +55,7 @@
* If there are row spanning cells then these cells belong to this row
* but effect the occupied columns of future rows.
*/
-public class Row extends BlockStackingLayoutManager {
+public class Row extends BlockStackingLayoutManager implements BlockLevelLayoutManager {
private TableRow fobj;
@@ -156,7 +159,7 @@
log.error("Overlapping cell at position " + colnum);
}
//Add cell info for primary slot
- GridUnit info = new GridUnit(cellLM);
+ OldGridUnit info = new OldGridUnit(cellLM);
info.row = this;
gridUnits.set(colnum - 1, info);
info.column = getColumn(colnum);
@@ -164,7 +167,7 @@
//Add cell infos on spanned slots if any
for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) {
colnum++;
- GridUnit infoSpan = new GridUnit(cellLM, j);
+ OldGridUnit infoSpan = new OldGridUnit(cellLM, j);
infoSpan.row = this;
infoSpan.column = getColumn(colnum);
if (colnum > gridUnits.size()) {
@@ -186,12 +189,12 @@
private void postProcessGridUnits() {
for (int pos = 1; pos <= gridUnits.size(); pos++) {
- GridUnit gu = (GridUnit)gridUnits.get(pos - 1);
+ OldGridUnit gu = (OldGridUnit)gridUnits.get(pos - 1);
//Empty grid units
if (gu == null) {
//Add grid unit
- gu = new GridUnit(null);
+ gu = new OldGridUnit(null);
gu.row = this;
gu.column = getColumn(pos);
gridUnits.set(pos - 1, gu);
@@ -200,17 +203,17 @@
//Border resolution now that the empty grid units are filled
for (int pos = 1; pos <= gridUnits.size(); pos++) {
- GridUnit starting = (GridUnit)gridUnits.get(pos - 1);
+ OldGridUnit starting = (OldGridUnit)gridUnits.get(pos - 1);
//Border resolution
if (getTable().isSeparateBorderModel()) {
starting.assignBorder(starting.layoutManager);
} else {
//Neighbouring grid unit at start edge
- GridUnit start = null;
+ OldGridUnit start = null;
int find = pos - 1;
while (find >= 1) {
- GridUnit candidate = (GridUnit)gridUnits.get(find - 1);
+ OldGridUnit candidate = (OldGridUnit)gridUnits.get(find - 1);
if (candidate.isLastGridUnitColSpan()) {
start = candidate;
break;
@@ -219,17 +222,17 @@
}
//Ending grid unit for current cell
- GridUnit ending = null;
+ OldGridUnit ending = null;
if (starting.layoutManager != null) {
pos += starting.layoutManager.getFObj().getNumberColumnsSpanned() - 1;
}
- ending = (GridUnit)gridUnits.get(pos - 1);
+ ending = (OldGridUnit)gridUnits.get(pos - 1);
//Neighbouring grid unit at end edge
- GridUnit end = null;
+ OldGridUnit end = null;
find = pos + 1;
while (find <= gridUnits.size()) {
- GridUnit candidate = (GridUnit)gridUnits.get(find - 1);
+ OldGridUnit candidate = (OldGridUnit)gridUnits.get(find - 1);
if (candidate.isPrimaryGridUnit()) {
end = candidate;
break;
@@ -237,14 +240,14 @@
find++;
}
CommonBorderPaddingBackground borders = new CommonBorderPaddingBackground();
- GridUnit.resolveBorder(getTable(), borders, starting,
+ OldGridUnit.resolveBorder(getTable(), borders, starting,
(start != null ? start : null),
CommonBorderPaddingBackground.START);
starting.effBorders = borders;
if (starting != ending) {
borders = new CommonBorderPaddingBackground();
}
- GridUnit.resolveBorder(getTable(), borders, ending,
+ OldGridUnit.resolveBorder(getTable(), borders, ending,
(end != null ? end : null),
CommonBorderPaddingBackground.END);
ending.effBorders = borders;
@@ -260,12 +263,12 @@
* @param pos the position of the cell (must be >= 1)
* @return the cell info object
*/
- protected GridUnit getCellInfo(int pos) {
+ protected OldGridUnit getCellInfo(int pos) {
if (gridUnits == null) {
prepareGridUnits();
}
if (pos <= gridUnits.size()) {
- return (GridUnit)gridUnits.get(pos - 1);
+ return (OldGridUnit)gridUnits.get(pos - 1);
} else {
return null;
}
@@ -281,7 +284,7 @@
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
//LayoutManager curLM; // currently active LM
- GridUnit curGridUnit; //currently active grid unit
+ OldGridUnit curGridUnit; //currently active grid unit
BreakPoss lastPos = null;
List breakList = new java.util.ArrayList();
@@ -322,7 +325,7 @@
getGridUnitsForCell(cellLM, startColumn, spannedGridUnits);
int childRefIPD = 0;
for (int i = 0; i < spannedGridUnits.size(); i++) {
- Column col = ((GridUnit)spannedGridUnits.get(i)).column;
+ Column col = ((OldGridUnit)spannedGridUnits.get(i)).column;
childRefIPD += col.getWidth().getValue();
}
childLC.setRefIPD(childRefIPD);
@@ -455,7 +458,7 @@
*/
protected void reset(Position pos) {
//LayoutManager curLM; // currently active LM
- GridUnit curGridUnit;
+ OldGridUnit curGridUnit;
int cellIndex = 1;
if (pos == null) {
@@ -619,5 +622,47 @@
}
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
+ */
+ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(org.apache.fop.layoutmgr.KnuthGlue)
+ */
+ public void discardSpace(KnuthGlue spaceGlue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether()
+ */
+ public boolean mustKeepTogether() {
+ //TODO Keeps will have to be more sophisticated sooner or later
+ return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()
+ || !fobj.getKeepTogether().getWithinPage().isAuto()
+ || !fobj.getKeepTogether().getWithinColumn().isAuto();
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious()
+ */
+ public boolean mustKeepWithPrevious() {
+ return !fobj.getKeepWithPrevious().getWithinPage().isAuto()
+ || !fobj.getKeepWithPrevious().getWithinColumn().isAuto();
+ }
+
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext()
+ */
+ public boolean mustKeepWithNext() {
+ return !fobj.getKeepWithNext().getWithinPage().isAuto()
+ || !fobj.getKeepWithNext().getWithinColumn().isAuto();
+ }
+
}
1.1.2.1 +3 -3 xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
Index: CollapsingBorderModelEyeCatching.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- CollapsingBorderModelEyeCatching.java 21 Feb 2005 21:52:14 -0000 1.1
+++ CollapsingBorderModelEyeCatching.java 5 Apr 2005 15:42:44 -0000 1.1.2.1
@@ -34,8 +34,8 @@
private static final int START = CommonBorderPaddingBackground.START;
private static final int END = CommonBorderPaddingBackground.END;
- public BorderInfo determineWinner(GridUnit currentGridUnit,
- GridUnit otherGridUnit, int side, int flags) {
+ public BorderInfo determineWinner(OldGridUnit currentGridUnit,
+ OldGridUnit otherGridUnit, int side, int flags) {
final boolean vertical = isVerticalRelation(side);
final int otherSide = getOtherSide(side);
No revision
Index: CollapsingBorderModelEyeCatching.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- CollapsingBorderModelEyeCatching.java 21 Feb 2005 21:52:14 -0000 1.1
+++ CollapsingBorderModelEyeCatching.java 5 Apr 2005 15:42:44 -0000 1.1.2.1
@@ -34,8 +34,8 @@
private static final int START = CommonBorderPaddingBackground.START;
private static final int END = CommonBorderPaddingBackground.END;
- public BorderInfo determineWinner(GridUnit currentGridUnit,
- GridUnit otherGridUnit, int side, int flags) {
+ public BorderInfo determineWinner(OldGridUnit currentGridUnit,
+ OldGridUnit otherGridUnit, int side, int flags) {
final boolean vertical = isVerticalRelation(side);
final int otherSide = getOtherSide(side);
No revision
Index: CollapsingBorderModelEyeCatching.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- CollapsingBorderModelEyeCatching.java 21 Feb 2005 21:52:14 -0000 1.1
+++ CollapsingBorderModelEyeCatching.java 5 Apr 2005 15:42:44 -0000 1.1.2.1
@@ -34,8 +34,8 @@
private static final int START = CommonBorderPaddingBackground.START;
private static final int END = CommonBorderPaddingBackground.END;
- public BorderInfo determineWinner(GridUnit currentGridUnit,
- GridUnit otherGridUnit, int side, int flags) {
+ public BorderInfo determineWinner(OldGridUnit currentGridUnit,
+ OldGridUnit otherGridUnit, int side, int flags) {
final boolean vertical = isVerticalRelation(side);
final int otherSide = getOtherSide(side);
1.1.2.1 +131 -0 xml-fop/src/java/org/apache/fop/layoutmgr/table/Attic/OldGridUnit.java
1.1.2.1 +135 -0 xml-fop/src/java/org/apache/fop/layoutmgr/table/Attic/ColumnSetup.java
1.1.2.1 +469 -0 xml-fop/src/java/org/apache/fop/layoutmgr/table/Attic/TableContentLayoutManager.java
1.1.2.1 +72 -0 xml-fop/src/java/org/apache/fop/layoutmgr/table/Attic/PrimaryGridUnit.java
1.1.2.1 +296 -0 xml-fop/src/java/org/apache/fop/layoutmgr/table/Attic/TableRowIterator.java
No revision
No revision
1.47.2.1 +1 -0 xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java
Index: TableCell.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableCell.java,v
retrieving revision 1.47
retrieving revision 1.47.2.1
diff -u -r1.47 -r1.47.2.1
--- TableCell.java 15 Feb 2005 19:30:51 -0000 1.47
+++ TableCell.java 5 Apr 2005 15:42:45 -0000 1.47.2.1
@@ -156,6 +156,7 @@
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
+ //TODO Complain about startsRow|endsRow=true if parent is a table-row
getFOEventHandler().endCell(this);
}
1.41.2.1 +3 -2 xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java
Index: TableBody.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableBody.java,v
retrieving revision 1.41
retrieving revision 1.41.2.1
diff -u -r1.41 -r1.41.2.1
--- TableBody.java 5 Mar 2005 00:32:25 -0000 1.41
+++ TableBody.java 5 Apr 2005 15:42:45 -0000 1.41.2.1
@@ -102,9 +102,10 @@
getParent().removeChild(this);
}
}
+ /*
if (tableCellsFound) {
convertCellsToRows();
- }
+ }*/
savedPropertyList = null; //Release reference
}
@@ -148,7 +149,7 @@
*/
private void convertCellsToRows() throws FOPException {
//getLogger().debug("Converting cells to rows...");
- List cells = (List)childNodes.clone();
+ List cells = new java.util.ArrayList(childNodes);
childNodes.clear();
Iterator i = cells.iterator();
TableRow row = null;
1.35.2.1 +22 -3 xml-fop/src/java/org/apache/fop/fo/flow/TableColumn.java
Index: TableColumn.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableColumn.java,v
retrieving revision 1.35
retrieving revision 1.35.2.1
diff -u -r1.35 -r1.35.2.1
--- TableColumn.java 4 Feb 2005 10:31:26 -0000 1.35
+++ TableColumn.java 5 Apr 2005 15:42:45 -0000 1.35.2.1
@@ -137,13 +137,16 @@
return columnNumber.getValue();
}
- /**
- * @return value for number of columns repeated
- */
+ /** @return value for number-columns-repeated. */
public int getNumberColumnsRepeated() {
return numberColumnsRepeated.getValue();
}
+ /** @return value for number-columns-spanned. */
+ public int getNumberColumnsSpanned() {
+ return numberColumnsSpanned.getValue();
+ }
+
/** @see org.apache.fop.fo.FONode#getName() */
public String getName() {
return "fo:table-column";
@@ -153,5 +156,21 @@
public int getNameId() {
return FO_TABLE_COLUMN;
}
+
+ /** @see java.lang.Object#toString() */
+ public String toString() {
+ StringBuffer sb = new StringBuffer("fo:table-column");
+ if (hasColumnNumber()) {
+ sb.append(" column-number=").append(getColumnNumber());
+ }
+ if (getNumberColumnsRepeated() > 1) {
+ sb.append(" number-columns-repeated=").append(getNumberColumnsRepeated());
+ }
+ if (getNumberColumnsSpanned() > 1) {
+ sb.append(" number-columns-spanned=").append(getNumberColumnsSpanned());
+ }
+ sb.append(" column-width=").append(getColumnWidth());
+ return sb.toString();
+ }
}
1.51.2.2 +8 -0 xml-fop/src/java/org/apache/fop/fo/flow/Table.java
Index: Table.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Table.java,v
retrieving revision 1.51.2.1
retrieving revision 1.51.2.2
diff -u -r1.51.2.1 -r1.51.2.2
--- Table.java 23 Mar 2005 13:50:16 -0000 1.51.2.1
+++ Table.java 5 Apr 2005 15:42:45 -0000 1.51.2.2
@@ -238,6 +238,14 @@
public List getColumns() {
return columns;
}
+
+ /**
+ * @param index index of the table-body element.
+ * @return the requested table-body element
+ */
+ public TableBody getBody(int index) {
+ return (TableBody)childNodes.get(index);
+ }
public TableBody getTableHeader() {
return tableHeader;
No revision
No revision
1.7.2.1 +14 -11 xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
Index: LayoutManagerMapping.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- LayoutManagerMapping.java 21 Feb 2005 21:52:14 -0000 1.7
+++ LayoutManagerMapping.java 5 Apr 2005 15:42:45 -0000 1.7.2.1
@@ -114,12 +114,12 @@
new PageNumberCitationLayoutManagerMaker());
makers.put(PageSequence.class, new PageSequenceLayoutManagerMaker());
makers.put(Table.class, new TableLayoutManagerMaker());
- makers.put(TableBody.class, new TableBodyLayoutManagerMaker());
- makers.put(TableColumn.class, new TableColumnLayoutManagerMaker());
- makers.put(TableRow.class, new TableRowLayoutManagerMaker());
- makers.put(TableCell.class, new TableCellLayoutManagerMaker());
- makers.put(TableFooter.class, new TableBodyLayoutManagerMaker());
- makers.put(TableHeader.class, new TableBodyLayoutManagerMaker());
+ makers.put(TableBody.class, new /*TableBodyLayoutManager*/Maker());
+ makers.put(TableColumn.class, new /*TableColumnLayoutManager*/Maker());
+ makers.put(TableRow.class, new /*TableRowLayoutManager*/Maker());
+ makers.put(TableCell.class, new /*TableCellLayoutManager*/Maker());
+ makers.put(TableFooter.class, new /*TableBodyLayoutManager*/Maker());
+ makers.put(TableHeader.class, new /*TableBodyLayoutManager*/Maker());
makers.put(Flow.class, new FlowLayoutManagerMaker());
makers.put(StaticContent.class, new StaticContentLayoutManagerMaker());
makers.put(Wrapper.class, new WrapperLayoutManagerMaker());
@@ -313,6 +313,7 @@
public static class TableLayoutManagerMaker extends Maker {
+ /*
private List getColumnLayoutManagerList(Table table, TableLayoutManager tlm) {
List columnLMs = null;
List columns = table.getColumns();
@@ -347,19 +348,21 @@
}
}
return columnLMs;
- }
+ }*/
public void make(FONode node, List lms) {
Table table = (Table) node;
TableLayoutManager tlm = new TableLayoutManager(table);
+ /*
List columnLMs = getColumnLayoutManagerList(table, tlm);
if (columnLMs != null) {
tlm.setColumns(columnLMs);
- }
+ }*/
lms.add(tlm);
}
}
-
+
+ /*
public static class TableBodyLayoutManagerMaker extends Maker {
public void make(FONode node, List lms) {
lms.add(new Body((TableBody) node));
@@ -383,7 +386,7 @@
public void make(FONode node, List lms) {
lms.add(new Cell((TableCell) node));
}
- }
+ }*/
public static class FlowLayoutManagerMaker extends Maker {
public void make(FONode node, List lms) {
1.12.2.2 +34 -24 xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
Index: FlowLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -u -r1.12.2.1 -r1.12.2.2
--- FlowLayoutManager.java 18 Mar 2005 09:02:55 -0000 1.12.2.1
+++ FlowLayoutManager.java 5 Apr 2005 15:42:45 -0000 1.12.2.2
@@ -18,7 +18,6 @@
package org.apache.fop.layoutmgr;
-import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.area.Area;
@@ -152,13 +151,33 @@
}*/
+ /**
+ * "wrap" the Position inside each element moving the elements from
+ * SourceList to targetList
+ * @param sourceList source list
+ * @param targetList target list receiving the wrapped position elements
+ */
+ protected void wrapPositionElements(List sourceList, List targetList) {
+ ListIterator listIter = sourceList.listIterator();
+ while (listIter.hasNext()) {
+ KnuthElement tempElement;
+ tempElement = (KnuthElement) listIter.next();
+ //if (tempElement.getLayoutManager() != this) {
+ tempElement.setPosition(new NonLeafPosition(this,
+ tempElement.getPosition()));
+ //}
+ targetList.add(tempElement);
+ }
+ }
+
+
//TODO Reintroduce emergency counter (generate error to avoid endless loop)
//TODO Reintroduce layout dimensions
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
// currently active LM
BlockLevelLayoutManager curLM;
BlockLevelLayoutManager prevLM = null;
- MinOptMax stackSize = new MinOptMax();
+ //MinOptMax stackSize = new MinOptMax();
LinkedList returnedList;
LinkedList returnList = new LinkedList();
@@ -170,29 +189,20 @@
}
// Set up a LayoutContext
- MinOptMax bpd = context.getStackLimit();
- BreakPoss bp;
- bp = null;
+ //MinOptMax bpd = context.getStackLimit();
LayoutContext childLC = new LayoutContext(0);
- boolean breakPage = false;
- childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
+ childLC.setStackLimit(context.getStackLimit());
childLC.setRefIPD(context.getRefIPD());
// get elements from curLM
returnedList = curLM.getNextKnuthElements(childLC, alignment);
-/*LF*/ //System.out.println("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size());
+ //log.debug("FLM.getNextKnuthElements> returnedList.size() = " + returnedList.size());
// "wrap" the Position inside each element
LinkedList tempList = returnedList;
- KnuthElement tempElement;
returnedList = new LinkedList();
- ListIterator listIter = tempList.listIterator();
- while (listIter.hasNext()) {
- tempElement = (KnuthElement)listIter.next();
- tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition()));
- returnedList.add(tempElement);
- }
+ wrapPositionElements(tempList, returnedList);
if (returnedList.size() == 1
&& ((KnuthElement)returnedList.getFirst()).isPenalty()
@@ -235,31 +245,31 @@
}
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
-/*LF*/ System.out.println(" FLM.negotiateBPDAdjustment> " + adj);
+ log.debug(" FLM.negotiateBPDAdjustment> " + adj);
-/*LF*/ if (lastElement.getPosition() instanceof NonLeafPosition) {
+ if (lastElement.getPosition() instanceof NonLeafPosition) {
// this element was not created by this FlowLM
NonLeafPosition savedPos = (NonLeafPosition)lastElement.getPosition();
lastElement.setPosition(savedPos.getPosition());
int returnValue = ((BlockLevelLayoutManager) lastElement.getLayoutManager()).negotiateBPDAdjustment(adj, lastElement);
lastElement.setPosition(savedPos);
-/*LF*/ System.out.println(" FLM.negotiateBPDAdjustment> gestito " + returnValue);
+ log.debug(" FLM.negotiateBPDAdjustment> result " + returnValue);
return returnValue;
-/*LF*/ } else {
-/*LF*/ return 0;
-/*LF*/ }
+ } else {
+ return 0;
+ }
}
public void discardSpace(KnuthGlue spaceGlue) {
-/*LF*/ System.out.println(" FLM.discardSpace> ");
+ log.debug(" FLM.discardSpace> ");
-/*LF*/ if (spaceGlue.getPosition() instanceof NonLeafPosition) {
+ if (spaceGlue.getPosition() instanceof NonLeafPosition) {
// this element was not created by this FlowLM
NonLeafPosition savedPos = (NonLeafPosition)spaceGlue.getPosition();
spaceGlue.setPosition(savedPos.getPosition());
((BlockLevelLayoutManager) spaceGlue.getLayoutManager()).discardSpace(spaceGlue);
spaceGlue.setPosition(savedPos);
-/*LF*/ }
+ }
}
public boolean mustKeepTogether() {
1.11.2.4 +4 -4 xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
Index: BlockStackingLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java,v
retrieving revision 1.11.2.3
retrieving revision 1.11.2.4
diff -u -r1.11.2.3 -r1.11.2.4
--- BlockStackingLayoutManager.java 21 Mar 2005 15:39:55 -0000 1.11.2.3
+++ BlockStackingLayoutManager.java 5 Apr 2005 15:42:45 -0000 1.11.2.4
@@ -367,10 +367,10 @@
while (listIter.hasNext()) {
KnuthElement tempElement;
tempElement = (KnuthElement) listIter.next();
- //if (tempElement.getLayoutManager() != this) {
- tempElement.setPosition(new NonLeafPosition(this,
- tempElement.getPosition()));
- //}
+ if (tempElement.getLayoutManager() != this) {
+ tempElement.setPosition(new NonLeafPosition(this,
+ tempElement.getPosition()));
+ }
targetList.add(tempElement);
}
}
1.43.2.5 +17 -9 xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
Index: BlockLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
retrieving revision 1.43.2.4
retrieving revision 1.43.2.5
diff -u -r1.43.2.4 -r1.43.2.5
--- BlockLayoutManager.java 21 Mar 2005 15:37:42 -0000 1.43.2.4
+++ BlockLayoutManager.java 5 Apr 2005 15:42:45 -0000 1.43.2.5
@@ -245,7 +245,7 @@
addKnuthElementForBorderPaddingBefore(returnList, returnPosition,
fobj.getCommonBorderPaddingBackground());
-
+
while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
LayoutContext childLC = new LayoutContext(0);
if (curLM instanceof LineLayoutManager) {
@@ -314,11 +314,11 @@
// a penalty
}
}
- contentList.addAll(returnedList);
if (returnedList.size() == 0) {
//Avoid NoSuchElementException below (happens with empty blocks)
continue;
}
+ contentList.addAll(returnedList);
if (((KnuthElement) returnedList.getLast()).isPenalty()
&& ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
// a descendant of this block has break-after
@@ -340,6 +340,11 @@
return returnList;
}
+ /*
+ if (allocatedSpace.min > context.getStackLimit().max) {
+ log.debug("Allocated space exceeds stack limit, returning early.");
+ return returnList;
+ }*/
}
prevLM = curLM;
}
@@ -1169,8 +1174,12 @@
boolean bSpaceAfter = false;
while (parentIter.hasNext()) {
pos = (Position) parentIter.next();
- /* LF *///System.out.println("pos = " + pos.getClass().getName());
- Position innerPosition = ((NonLeafPosition) pos).getPosition();
+ //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
+ Position innerPosition = pos;
+ if (pos instanceof NonLeafPosition) {
+ //Not all elements are wrapped
+ innerPosition = ((NonLeafPosition) pos).getPosition();
+ }
if (innerPosition == null) {
// pos was created by this BlockLM and was inside an element
// representing space before or after
@@ -1178,24 +1187,23 @@
if (positionList.size() == 0) {
// pos was in the element representing space-before
bSpaceBefore = true;
- /* LF *///System.out.println(" spazio prima");
+ //log.trace(" space before");
} else {
// pos was in the element representing space-after
bSpaceAfter = true;
- /* LF *///System.out.println(" spazio dopo");
+ //log.trace(" space-after");
}
} else if (innerPosition.getLM() == this
&& !(innerPosition instanceof MappingPosition)) {
// pos was created by this BlockLM and was inside a penalty
// allowing or forbidding a page break
// nothing to do
- /* LF *///System.out.println(" penalty");
+ //log.trace(" penalty");
} else {
// innerPosition was created by another LM
positionList.add(innerPosition);
lastLM = innerPosition.getLM();
- /* LF *///System.out.println(" " +
- // innerPosition.getClass().getName());
+ //log.trace(" " + innerPosition.getClass().getName());
}
}
No revision
No revision
1.92.2.1 +6 -7 xml-fop/src/java/org/apache/fop/fo/FObj.java
Index: FObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v
retrieving revision 1.92
retrieving revision 1.92.2.1
diff -u -r1.92 -r1.92.2.1
--- FObj.java 23 Feb 2005 22:04:01 -0000 1.92
+++ FObj.java 5 Apr 2005 15:42:45 -0000 1.92.2.1
@@ -18,9 +18,8 @@
package org.apache.fop.fo;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,7 @@
public static PropertyMaker[] propertyListTable = null;
/** The immediate child nodes of this node. */
- public ArrayList childNodes = null;
+ public List childNodes = null;
/** Used to indicate if this FO is either an Out Of Line FO (see rec)
or a descendant of one. Used during validateChildNode() FO
@@ -164,7 +163,7 @@
addMarker((Marker) child);
} else {
if (childNodes == null) {
- childNodes = new ArrayList();
+ childNodes = new java.util.ArrayList();
}
childNodes.add(child);
}
@@ -198,7 +197,7 @@
*/
public void setLayoutDimension(PercentBase.LayoutDimension key, int dimension) {
if (layoutDimension == null) {
- layoutDimension = new HashMap();
+ layoutDimension = new java.util.HashMap();
}
layoutDimension.put(key, new Integer(dimension));
}
@@ -210,7 +209,7 @@
*/
public void setLayoutDimension(PercentBase.LayoutDimension key, float dimension) {
if (layoutDimension == null) {
- layoutDimension = new HashMap();
+ layoutDimension = new java.util.HashMap();
}
layoutDimension.put(key, new Float(dimension));
}
@@ -307,7 +306,7 @@
}
}
if (markers == null) {
- markers = new HashMap();
+ markers = new java.util.HashMap();
}
if (!markers.containsKey(mcname)) {
markers.put(mcname, marker);
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
Re: cvs commit: xml-fop/src/java/org/apache/fop/fo FObj.java
Posted by Jeremias Maerki <de...@greenmail.ch>.
The basic framework stands and so far seems to do its work. Now I can
get on to adding features again (display-align, borders, keeps, breaks
etc.).
At first sight, the whole thing probably looks like a big mess. I didn't
want to remove the old code just yet, because there may be several
passages that I can look at for hints. I'll remove it as soon as
possible. For those interested, the most interesting places to look at
will be:
- TableLayoutManager
- TableContentLayoutManager
- TableRowIterator
- Cell
- ColumnSetup
- (Primary)GridUnit
On 05.04.2005 17:42:45 jeremias wrote:
> jeremias 2005/04/05 08:42:45
>
> Log:
> Basic framework for table layout with Knuth elements as documented
> on the Wiki. The old code is mostly still there for reference.
Jeremias Maerki