diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-02-08 10:10:00 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-02-08 10:10:00 +0000 |
commit | 6ef1677fb7c30c00df49807c3cd0fb3b7cf1d511 (patch) | |
tree | 38b7b8258ce8a9c82af2cd62542e898fd4ac62cf /src/java/org/apache/fop/layoutmgr/table | |
parent | c03c698bbdbe36dd810ef702c973b5e0e74c7e37 (diff) | |
download | xmlgraphics-fop-6ef1677fb7c30c00df49807c3cd0fb3b7cf1d511.tar.gz xmlgraphics-fop-6ef1677fb7c30c00df49807c3cd0fb3b7cf1d511.zip |
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.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198393 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/table')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/table/Cell.java | 33 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/table/Row.java | 19 |
2 files changed, 44 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java index dce9da005..7962a727d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Cell.java +++ b/src/java/org/apache/fop/layoutmgr/table/Cell.java @@ -53,8 +53,9 @@ public class Cell extends BlockStackingLayoutManager { 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 @@ public class Cell extends BlockStackingLayoutManager { 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 class Cell extends BlockStackingLayoutManager { 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 @@ public class Cell extends BlockStackingLayoutManager { } 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 @@ public class Cell extends BlockStackingLayoutManager { } /** - * 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 @@ public class Cell extends BlockStackingLayoutManager { } //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 @@ public class Cell extends BlockStackingLayoutManager { 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 @@ public class Cell extends BlockStackingLayoutManager { 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(); diff --git a/src/java/org/apache/fop/layoutmgr/table/Row.java b/src/java/org/apache/fop/layoutmgr/table/Row.java index 7233adf27..3b81c6fe7 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Row.java +++ b/src/java/org/apache/fop/layoutmgr/table/Row.java @@ -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 @@ public class Row extends BlockStackingLayoutManager { } /** + * @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 @@ public class Row extends BlockStackingLayoutManager { 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(); + } } } |