import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.LinkedList;
/**
* LayoutManager for a table-cell FO.
private int xoffset;
private int itemIPD;
+ private static class StackingIter extends PositionIterator {
+ StackingIter(Iterator parentIter) {
+ super(parentIter);
+ }
+
+ protected LayoutManager getLM(Object nextObj) {
+ return ((Position) nextObj).getLM();
+ }
+
+ protected Position getPos(Object nextObj) {
+ return ((Position) nextObj);
+ }
+ }
+
/**
* Create a new Cell layout manager.
*/
xoffset = off;
}
+ public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+ //log.debug(" Item.getChanged>");
+ return super.getChangedKnuthElements(oldList, alignment);
+ }
+
/**
* Add the areas for the break points.
* The list item contains block stacking layout managers
addID(((ListItemBody) fobj).getId());
}
- LayoutManager childLM;
- int iStartPos = 0;
+ LayoutManager childLM = null;
LayoutContext lc = new LayoutContext(0);
+ LayoutManager firstLM = null;
+ LayoutManager lastLM = null;
+
+ // "unwrap" the NonLeafPositions stored in parentIter
+ // and put them in a new list;
+ LinkedList positionList = new LinkedList();
+ Position pos;
while (parentIter.hasNext()) {
- LeafPosition lfp = (LeafPosition) parentIter.next();
- // Add the block areas to Area
- PositionIterator breakPosIter =
- new BreakPossPosIter(childBreaks, iStartPos,
- lfp.getLeafPos() + 1);
- iStartPos = lfp.getLeafPos() + 1;
- while ((childLM = breakPosIter.getNextChildLM()) != null) {
- childLM.addAreas(breakPosIter, lc);
+ pos = (Position)parentIter.next();
+ if (pos instanceof NonLeafPosition) {
+ // pos was created by a child of this ListBlockLM
+ positionList.add(((NonLeafPosition) pos).getPosition());
+ lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ if (firstLM == null) {
+ firstLM = lastLM;
+ }
+ } else {
+ // pos was created by this ListBlockLM, so it must be ignored
}
}
+ StackingIter childPosIter = new StackingIter(positionList.listIterator());
+ while ((childLM = childPosIter.getNextChildLM()) != null) {
+ // Add the block areas to Area
+ lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
+ lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
+ lc.setStackLimit(layoutContext.getStackLimit());
+ childLM.addAreas(childPosIter, lc);
+ }
+
/*
if (borderProps != null) {
TraitSetter.addBorders(curBlockArea, borderProps);
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.traits.SpaceVal;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
/**
private MinOptMax spaceBefore;
private MinOptMax spaceAfter;
+ private static class StackingIter extends PositionIterator {
+ StackingIter(Iterator parentIter) {
+ super(parentIter);
+ }
+
+ protected LayoutManager getLM(Object nextObj) {
+ return ((Position) nextObj).getLM();
+ }
+
+ protected Position getPos(Object nextObj) {
+ return ((Position) nextObj);
+ }
+ }
+
/*
private class SectionPosition extends LeafPosition {
protected List list;
}*/
/**
- * Create a new table layout manager.
+ * Create a new list block layout manager.
* @param node list-block to create the layout manager for
*/
public ListBlockLayoutManager(ListBlock node) {
return null;
}
+ public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+ //log.debug("LBLM.getChangedKnuthElements>");
+ return super.getChangedKnuthElements(oldList, alignment);
+ }
+
/**
* The table area is a reference area that contains areas for
* columns, bodies, rows and the contents are in cells.
// the list block contains areas stacked from each list item
- //int listHeight = 0;
-
- LayoutManager childLM;
- int iStartPos = 0;
+ LayoutManager childLM = null;
LayoutContext lc = new LayoutContext(0);
+ LayoutManager firstLM = null;
+ LayoutManager lastLM = null;
+
+ // "unwrap" the NonLeafPositions stored in parentIter
+ // and put them in a new list;
+ LinkedList positionList = new LinkedList();
+ Position pos;
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 = (LayoutManager)breakPosIter.getNextChildLM()) != null) {
- childLM.addAreas(breakPosIter, lc);
+ pos = (Position)parentIter.next();
+ if (pos instanceof NonLeafPosition
+ && ((NonLeafPosition) pos).getPosition().getLM() != this) {
+ // pos was created by a child of this ListBlockLM
+ positionList.add(((NonLeafPosition) pos).getPosition());
+ lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ if (firstLM == null) {
+ firstLM = lastLM;
+ }
}
}
+ StackingIter childPosIter = new StackingIter(positionList.listIterator());
+ while ((childLM = childPosIter.getNextChildLM()) != null) {
+ // Add the block areas to Area
+ lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
+ lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
+ lc.setStackLimit(layoutContext.getStackLimit());
+ childLM.addAreas(childPosIter, lc);
+ }
flush();
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.TraitSetter;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthPossPosIter;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
+import java.util.LinkedList;
+import java.util.ListIterator;
/**
* LayoutManager for a list-item FO.
private Block curBlockArea = null;
+ private LinkedList labelList = null;
+ private boolean labelAreasAdded = false;
+
+ private static class StackingIter extends PositionIterator {
+ StackingIter(Iterator parentIter) {
+ super(parentIter);
+ }
+
+ protected LayoutManager getLM(Object nextObj) {
+ return ((Position) nextObj).getLM();
+ }
+
+ protected Position getPos(Object nextObj) {
+ return ((Position) nextObj);
+ }
+ }
+
//private List cellList = null;
private int listItemHeight;
return breakPoss;
}
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+ // label
+ labelList = label.getNextKnuthElements(context, alignment);
+
+ // body
+ LinkedList returnedList = body.getNextKnuthElements(context, alignment);
+
+ // "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);
+ }
+
+ setFinished(true);
+ return returnedList;
+ }
+
+ public LinkedList getChangedKnuthElements(List oldList, int alignment) {
+/*LF*/ //log.debug(" LILM.getChanged> label");
+ // label
+ labelList = label.getChangedKnuthElements(labelList, alignment);
+
+/*LF*/ //log.debug(" LILM.getChanged> body");
+ // body
+ // "unwrap" the Positions stored in the elements
+ ListIterator oldListIterator = oldList.listIterator();
+ KnuthElement oldElement = null;
+ while (oldListIterator.hasNext()) {
+ oldElement = (KnuthElement)oldListIterator.next();
+ Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
+/*LF*/ //System.out.println(" BLM> unwrapping: " + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) + " creato da " + oldElement.getLayoutManager().getClass().getName());
+/*LF*/ //System.out.println(" BLM> unwrapping: " + oldElement.getPosition().getClass().getName());
+ if (innerPosition != null) {
+ // oldElement was created by a descendant of this BlockLM
+ oldElement.setPosition(innerPosition);
+ } else {
+ // thisElement was created by this BlockLM
+ // modify its position in order to recognize it was not created
+ // by a child
+ oldElement.setPosition(new Position(this));
+ }
+ }
+
+ LinkedList returnedList = body.getChangedKnuthElements(oldList, alignment);
+ // "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);
+ }
+
+ return returnedList;
+ }
+
/**
* Add the areas for the break points.
* This sets the offset of each cell as it is added.
addID(fobj.getId());
- Item childLM;
+ LayoutManager childLM = null;
LayoutContext lc = new LayoutContext(0);
+ LayoutManager firstLM = null;
+ LayoutManager lastLM = null;
+
+ // create a new list;
+ // add the label areas, if this is the first time addAreas() is called
+ LinkedList positionList = new LinkedList();
+ if (!labelAreasAdded) {
+ KnuthPossPosIter labelPosIter = new KnuthPossPosIter(labelList, 0, labelList.size());
+ while (labelPosIter.hasNext()) {
+ positionList.add((Position) labelPosIter.next());
+ }
+ }
+ // "unwrap" the NonLeafPositions stored in parentIter
+ Position pos;
while (parentIter.hasNext()) {
- ItemPosition lfp = (ItemPosition) parentIter.next();
- // Add the block areas to Area
-
- for (Iterator iter = lfp.cellBreaks.iterator(); iter.hasNext();) {
- List cellsbr = (List)iter.next();
- PositionIterator breakPosIter;
- breakPosIter = new BreakPossPosIter(cellsbr, 0, cellsbr.size());
-
- while ((childLM = (Item)breakPosIter.getNextChildLM()) != null) {
- childLM.addAreas(breakPosIter, lc);
+ pos = (Position) parentIter.next();
+ if (pos instanceof NonLeafPosition
+ && ((NonLeafPosition) pos).getPosition().getLM() != this) {
+ // pos was created by a child of this ListBlockLM
+ positionList.add(((NonLeafPosition) pos).getPosition());
+ lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ if (firstLM == null) {
+ firstLM = lastLM;
}
}
}
- curBlockArea.setBPD(listItemHeight);
+ StackingIter childPosIter = new StackingIter(positionList.listIterator());
+ while ((childLM = childPosIter.getNextChildLM()) != null) {
+ // Add the block areas to Area
+ lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
+ lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
+ // reset the area height after adding the label areas
+ if (!labelAreasAdded && childLM == firstLM) {
+ curBlockArea.setBPD(0);
+ labelAreasAdded = true;
+ }
+ /* questo non e' correttissimo, bisogna avere due diversi valori per la label e il body */
+ lc.setStackLimit(layoutContext.getStackLimit());
+ childLM.addAreas(childPosIter, lc);
+ }
flush();