From: Jeremias Maerki Date: Tue, 8 Feb 2005 10:10:00 +0000 (+0000) Subject: Correct cell-borders when border-collapse="separate" and initial support for horizont... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~114 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6ef1677fb7c30c00df49807c3cd0fb3b7cf1d511;p=xmlgraphics-fop.git 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 --- 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; @@ -73,6 +75,17 @@ public class Row extends BlockStackingLayoutManager { fobj = node; } + /** + * @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. * @@ -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(); + } } }