]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for handling of horizontal border-separation. My first interpretation was wrong.
authorJeremias Maerki <jeremias@apache.org>
Wed, 9 Feb 2005 11:51:30 +0000 (11:51 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 9 Feb 2005 11:51:30 +0000 (11:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198403 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/table/Cell.java
src/java/org/apache/fop/layoutmgr/table/Row.java

index 859a8d917c4fd64638083525bb8fd3f9eb646f87..4287676af358de1c4d877200a224c2f071784acd 100644 (file)
@@ -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();
index a76d8db3c41cbebf137524d5371daee3ceb2c87b..f29402c12e8c1629233ad3b8bb9b4035174e52f5 100644 (file)
@@ -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