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.List;
private Block curBlockArea;
+ private int referenceIPD = 0;
+
private List bodyBreaks = new ArrayList();
+ //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) {
super(lm, pos);
list = l;
}
- }
+ }*/
/**
* Create a new table layout manager.
- *
+ * @param node list-block to create the layout manager for
*/
public ListBlockLayoutManager(ListBlock node) {
super(node);
fobj = node;
}
+ /** @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
// currently active LM
LayoutManager curLM;
+ referenceIPD = context.getRefIPD();
+
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;
while ((curLM = (LayoutManager)getChildLM()) != null) {
// Make break positions
// Set up a LayoutContext
- int ipd = context.getRefIPD();
+ //int ipd = context.getRefIPD();
BreakPoss bp;
LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimit(
MinOptMax.subtract(context.getStackLimit(),
stackSize));
- childLC.setRefIPD(ipd);
+ childLC.setRefIPD(referenceIPD);
boolean over = false;
while (!curLM.isFinished()) {
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
+
+ // if adjusted space before
+ double adjust = layoutContext.getSpaceAdjust();
+ addBlockSpacing(adjust, spaceBefore);
+ spaceBefore = null;
+
addID(fobj.getId());
// the list block contains areas stacked from each list item
- int listHeight = 0;
+ //int listHeight = 0;
LayoutManager childLM;
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);
+ PositionIterator breakPosIter = new BreakPossPosIter(
+ bodyBreaks, iStartPos, lfp.getLeafPos() + 1);
iStartPos = lfp.getLeafPos() + 1;
while ((childLM = (LayoutManager)breakPosIter.getNextChildLM()) != null) {
childLM.addAreas(breakPosIter, lc);
}
}
- TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
- TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
flush();
+ // if adjusted space after
+ addBlockSpacing(adjust, spaceAfter);
+
bodyBreaks.clear();
curBlockArea = null;
}
public Area getParentArea(Area childArea) {
if (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);
+
+ // set traits
+ TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addMargins(curBlockArea,
+ fobj.getCommonBorderPaddingBackground(),
+ fobj.getCommonMarginBlock());
+ TraitSetter.addBreaks(curBlockArea,
+ fobj.getBreakBefore(), fobj.getBreakAfter());
+
+ int contentIPD = referenceIPD - getIPIndents();
+ curBlockArea.setIPD(contentIPD);
+
+ setCurrentArea(curBlockArea);
}
return curBlockArea;
}
bodyBreaks.clear();
reset(null);
} else {
-
+ //TODO Something to put here?
}
}
}
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.BreakPossPosIter;
import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.TraitSetter;
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.Iterator;
import java.util.ArrayList;
private Item label;
private Item body;
+ private int referenceIPD = 0;
+
private Block curBlockArea = null;
- private List cellList = null;
+ //private List cellList = null;
private int listItemHeight;
+ //TODO space-before|after: handle space-resolution rules
+ private MinOptMax spaceBefore;
+ private MinOptMax spaceAfter;
+
private class ItemPosition extends LeafPosition {
protected List cellBreaks;
protected ItemPosition(LayoutManager lm, int pos, List l) {
/**
* Create a new list item layout manager.
- *
+ * @param node list-item to create the layout manager for
*/
public ListItemLayoutManager(ListItem node) {
super(node);
body.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.
*
// currently active LM
Item curLM;
+ //int allocBPD = context.
+ referenceIPD = context.getRefIPD();
+
BreakPoss lastPos = null;
List breakList = new ArrayList();
// Set up a LayoutContext
// the ipd is from the current column
- int ipd = context.getRefIPD();
+ //int ipd = context.getRefIPD();
BreakPoss bp;
LayoutContext childLC = new LayoutContext(0);
childLC.setStackLimit(
MinOptMax.subtract(context.getStackLimit(),
stackSize));
- childLC.setRefIPD(context.getRefIPD());
+ childLC.setRefIPD(referenceIPD);
stage++;
while (!curLM.isFinished()) {
}
listItemHeight = opt;
- MinOptMax itemSize = new MinOptMax(min, opt, max);
-
if (label.isFinished() && body.isFinished()) {
setFinished(true);
}
+ MinOptMax itemSize = new MinOptMax(min, opt, max);
+
+ //Add spacing
+ if (spaceAfter != null) {
+ itemSize.add(spaceAfter);
+ }
+ if (spaceBefore != null) {
+ itemSize.add(spaceBefore);
+ }
+
ItemPosition rp = new ItemPosition(this, breakList.size() - 1, breakList);
BreakPoss breakPoss = new BreakPoss(rp);
if (over) {
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
+
+ // if adjusted space before
+ double adjust = layoutContext.getSpaceAdjust();
+ addBlockSpacing(adjust, spaceBefore);
+ spaceBefore = null;
+
addID(fobj.getId());
Item childLM;
flush();
+ // if adjusted space after
+ addBlockSpacing(adjust, spaceAfter);
+
curBlockArea = null;
}
curBlockArea = new Block();
// Set up dimensions
- 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);
+
+ // set traits
+ TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addMargins(curBlockArea,
+ fobj.getCommonBorderPaddingBackground(),
+ fobj.getCommonMarginBlock());
+ TraitSetter.addBreaks(curBlockArea,
+ fobj.getBreakBefore(), fobj.getBreakAfter());
+
+ int contentIPD = referenceIPD - getIPIndents();
+ curBlockArea.setIPD(contentIPD);
+
+ setCurrentArea(curBlockArea);
}
return curBlockArea;
}