jeremias2005/01/28 08:59:28
Modified:src/java/org/apache/fop/layoutmgr/list
ListItemLayoutManager.java
ListBlockLayoutManager.java
Log:
Added border, padding and spacing for list-blocks and list-items.
Revision ChangesPath
1.18 +63 -11
xml-fop/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
Index: ListItemLayoutManager.java
===
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ListItemLayoutManager.java28 Jan 2005 11:05:35 - 1.17
+++ ListItemLayoutManager.java28 Jan 2005 16:59:28 - 1.18
@@ -29,9 +29,11 @@
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;
@@ -47,11 +49,17 @@
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) {
@@ -62,7 +70,7 @@
/**
* Create a new list item layout manager.
- *
+ * @param node list-item to create the layout manager for
*/
public ListItemLayoutManager(ListItem node) {
super(node);
@@ -89,6 +97,20 @@
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.
*
@@ -99,6 +121,9 @@
// currently active LM
Item curLM;
+//int allocBPD = context.
+referenceIPD = context.getRefIPD();
+
BreakPoss lastPos = null;
List breakList = new ArrayList();
@@ -121,14 +146,14 @@
// 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()) {
@@ -178,12 +203,20 @@
}
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) {
@@ -203,6 +236,12 @@
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;
@@ -226,6 +265,9 @@
flush();
+// if adjusted space after
+