jeremias 2005/02/08 02:10:00
Modified: src/java/org/apache/fop/layoutmgr/table Row.java Cell.java
Log:
Correct cell-borders when border-collapse="separate" and initial support for
horizontal border-separation.
This is WIP, just a save-point while I'm investigating other issues
surrounding tables.
Revision Changes Path
1.18 +19 -0 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Row.java 7 Feb 2005 11:01:37 -0000 1.17
+++ Row.java 8 Feb 2005 10:10:00 -0000 1.18
@@ -18,6 +18,8 @@
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
@@ -74,6 +76,17 @@
}
/**
+ * @return the table owning this row
+ */
+ public Table getTable() {
+ FONode node = fobj.getParent();
+ while (!(node instanceof Table)) {
+ node = node.getParent();
+ }
+ return (Table)node;
+ }
+
+ /**
* Set the columns from the table.
*
* @param cols the list of columns for this table
@@ -337,6 +350,12 @@
childLM.addAreas(breakPosIter, lc);
}
x += col.getWidth().getValue();
+
+ //Handle border-separation
+ Table table = getTable();
+ if (table.getBorderCollapse() == EN_SEPARATE) {
+ x +=
table.getBorderSeparation().getIPD().getLength().getValue();
+ }
}
}
1.15 +25 -8 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Cell.java 7 Feb 2005 11:01:37 -0000 1.14
+++ Cell.java 8 Feb 2005 10:10:00 -0000 1.15
@@ -53,8 +53,9 @@
private int xoffset;
private int yoffset;
private int cellIPD;
- private int allocBPD;
+ private int rowHeight;
private int usedBPD;
+ private int borderAndPaddingBPD;
/**
* Create a new Cell layout manager.
@@ -64,6 +65,12 @@
fobj = node;
}
+ private int getIPIndents() {
+ int iIndents = 0;
+ iIndents +=
fobj.getCommonBorderPaddingBackground().getIPPaddingAndBorder(false);
+ return iIndents;
+ }
+
/**
* Get the next break possibility for this cell.
* A cell contains blocks so there are breaks around the blocks
@@ -75,12 +82,16 @@
public BreakPoss getNextBreakPoss(LayoutContext context) {
LayoutManager curLM; // currently active LM
+ borderAndPaddingBPD = fobj.getCommonBorderPaddingBackground()
+ .getBPPaddingAndBorder(false);
+
MinOptMax stackSize = new MinOptMax();
// if starting add space before
// stackSize.add(spaceBefore);
BreakPoss lastPos = null;
cellIPD = context.getRefIPD();
+ cellIPD -= getIPIndents();
while ((curLM = getChildLM()) != null) {
if (curLM.generatesInlineAreas()) {
@@ -139,6 +150,7 @@
}
MinOptMaxUtil.restrict(stackSize, specifiedBPD);
}
+ stackSize = MinOptMax.add(stackSize, new
MinOptMax(borderAndPaddingBPD));
BreakPoss breakPoss = new BreakPoss(
new LeafPosition(this,
childBreaks.size() - 1));
@@ -173,12 +185,13 @@
}
/**
- * Set the row height that contains this cell.
+ * Set the row height that contains this cell. This method is used during
+ * addAreas() stage.
*
* @param h the height of the row
*/
public void setRowHeight(int h) {
- allocBPD = h;
+ rowHeight = h;
}
/**
@@ -200,14 +213,14 @@
}
//Handle display-align
- if (usedBPD < allocBPD) {
+ if (usedBPD < rowHeight) {
if (fobj.getDisplayAlign() == EN_CENTER) {
Block space = new Block();
- space.setBPD((allocBPD - usedBPD) / 2);
+ space.setBPD((rowHeight - usedBPD) / 2);
curBlockArea.addBlock(space);
} else if (fobj.getDisplayAlign() == EN_AFTER) {
Block space = new Block();
- space.setBPD((allocBPD - usedBPD));
+ space.setBPD((rowHeight - usedBPD));
curBlockArea.addBlock(space);
}
}
@@ -230,7 +243,9 @@
TraitSetter.addBorders(curBlockArea,
fobj.getCommonBorderPaddingBackground());
TraitSetter.addBackground(curBlockArea,
fobj.getCommonBorderPaddingBackground());
- curBlockArea.setBPD(allocBPD);
+ int contentBPD = rowHeight;
+ contentBPD -= borderAndPaddingBPD;
+ curBlockArea.setBPD(contentBPD);
flush();
@@ -257,7 +272,9 @@
curBlockArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
curBlockArea.setPositioning(Block.ABSOLUTE);
// set position
- curBlockArea.setXOffset(xoffset);
+ int x = xoffset; //mimic start-indent
+ x +=
fobj.getCommonBorderPaddingBackground().getBorderStartWidth(false);
+ curBlockArea.setXOffset(x);
curBlockArea.setYOffset(yoffset);
curBlockArea.setIPD(cellIPD);
//curBlockArea.setHeight();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]