From 8d532b99b6bedabcca84b8241da6b1a90f192bdc Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 9 Feb 2005 11:51:30 +0000 Subject: [PATCH] Fix for handling of horizontal border-separation. My first interpretation was wrong. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198403 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/layoutmgr/table/Cell.java | 25 ++++++++++++++++++- .../org/apache/fop/layoutmgr/table/Row.java | 14 ++--------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/table/Cell.java b/src/java/org/apache/fop/layoutmgr/table/Cell.java index 859a8d917..4287676af 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Cell.java +++ b/src/java/org/apache/fop/layoutmgr/table/Cell.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.TableCell; import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; @@ -74,6 +76,17 @@ public class Cell extends BlockStackingLayoutManager { return this.fobj; } + /** + * @return the table owning this cell + */ + public Table getTable() { + FONode node = fobj.getParent(); + while (!(node instanceof Table)) { + node = node.getParent(); + } + return (Table)node; + } + private int getIPIndents() { int iIndents = 0; iIndents += fobj.getCommonBorderPaddingBackground().getIPPaddingAndBorder(false); @@ -102,6 +115,11 @@ public class Cell extends BlockStackingLayoutManager { referenceIPD = context.getRefIPD(); cellIPD = referenceIPD; cellIPD -= getIPIndents(); + if (getTable().getBorderCollapse() == EN_SEPARATE) { + int borderSep = getTable().getBorderSeparation().getLengthPair() + .getIPD().getLength().getValue(); + cellIPD -= borderSep; + } while ((curLM = getChildLM()) != null) { if (curLM.generatesInlineAreas()) { @@ -294,7 +312,12 @@ public class Cell extends BlockStackingLayoutManager { indent += fobj.getCommonBorderPaddingBackground().getBorderStartWidth(false); indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); // set position - curBlockArea.setXOffset(xoffset + inRowIPDOffset + indent); + int halfBorderSep = 0; + if (getTable().getBorderCollapse() == EN_SEPARATE) { + halfBorderSep = getTable().getBorderSeparation().getLengthPair() + .getIPD().getLength().getValue() / 2; + } + curBlockArea.setXOffset(xoffset + inRowIPDOffset + halfBorderSep + indent); 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 a76d8db3c..f29402c12 100644 --- a/src/java/org/apache/fop/layoutmgr/table/Row.java +++ b/src/java/org/apache/fop/layoutmgr/table/Row.java @@ -229,16 +229,10 @@ public class Row extends BlockStackingLayoutManager { //Determine which columns this cell will occupy getColumnsForCell(cellLM, startColumn, spannedColumns); int childRefIPD = 0; - Iterator i = spannedColumns.iterator(); - while (i.hasNext()) { - Column col = (Column)i.next(); + for (int i = 0; i < spannedColumns.size(); i++) { + Column col = (Column)spannedColumns.get(i); childRefIPD += col.getWidth().getValue(); } - //Handle border-separation when border-collapse="separate" - if (getTable().getBorderCollapse() == EN_SEPARATE) { - childRefIPD += (spannedColumns.size() - 1) - * getTable().getBorderSeparation().getIPD().getLength().getValue(); - } childLC.setRefIPD(childRefIPD); if (cellLM != null) { @@ -280,11 +274,7 @@ public class Row extends BlockStackingLayoutManager { } //Adjust in-row x offset for individual cells - //TODO Probably needs more work to support writing modes ipdOffset += childRefIPD; - if (getTable().getBorderCollapse() == EN_SEPARATE) { - ipdOffset += getTable().getBorderSeparation().getIPD().getLength().getValue(); - } // the min is the maximum min of all cells -- 2.39.5