]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Correct cell-borders when border-collapse="separate" and initial support for horizont...
authorJeremias Maerki <jeremias@apache.org>
Tue, 8 Feb 2005 10:10:00 +0000 (10:10 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 8 Feb 2005 10:10:00 +0000 (10:10 +0000)
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

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

index dce9da0054e406febff59c378809d70c006c66e3..7962a727dac768ac7a8fdcb57501357f2ea9e3b0 100644 (file)
@@ -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();
index 7233adf27eb37212b1a5fb71111e95b5f2dff46a..3b81c6fe751bdc0079e501352e8f033b7e39a561 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.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();
+                }
             }
         }