]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Individual grid unit block areas for painting the resolved borders.
authorJeremias Maerki <jeremias@apache.org>
Tue, 22 Feb 2005 09:52:03 +0000 (09:52 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 22 Feb 2005 09:52:03 +0000 (09:52 +0000)
Bugfix in Row for searching the adjacent cell at end edge.
Setting the borders that are already resolved on the right grid units.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198453 13f79535-47bb-0310-9956-ffa450edef68

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

index f664f8b60adce75fabf4fe0f4266ed0d13d62761..cd2c9a7ba286f94ab095fb77ea79e18c4af72d28 100644 (file)
@@ -311,9 +311,38 @@ public class Cell extends BlockStackingLayoutManager {
                 //Can set the borders directly if there's no span
                 CommonBorderPaddingBackground effBorders =
                     ((GridUnit)((List)rows.get(0)).get(0)).effBorders;
+                //TODO Next line is a temporary hack!
+                TraitSetter.addCollapsingBorders(curBlockArea, 
+                        fobj.getCommonBorderPaddingBackground(), outer);
                 TraitSetter.addCollapsingBorders(curBlockArea, 
                         effBorders, outer);
             } else {
+                int dy = yoffset;
+                for (int y = 0; y < rows.size(); y++) {
+                    List gridUnits = (List)rows.get(y);
+                    int dx = xoffset;
+                    int lastRowHeight = 0;
+                    for (int x = 0; x < gridUnits.size(); x++) {
+                        GridUnit gu = (GridUnit)gridUnits.get(x);
+                        //Blocks for painting grid unit borders
+                        Block block = new Block();
+                        block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
+                        block.setPositioning(Block.ABSOLUTE);
+                        block.setBPD(gu.row.getRowHeight());
+                        lastRowHeight = gu.row.getRowHeight();
+                        int ipd = gu.column.getWidth().getValue();
+                        int borderStartWidth = gu.effBorders.getBorderStartWidth(false) / 2; 
+                        ipd -= borderStartWidth;
+                        ipd -= gu.effBorders.getBorderEndWidth(false) / 2;
+                        block.setIPD(ipd);
+                        block.setXOffset(dx + borderStartWidth);
+                        block.setYOffset(dy);
+                        TraitSetter.addCollapsingBorders(block, gu.effBorders, outer);
+                        parentLM.addChild(block);
+                        dx += gu.column.getWidth().getValue();
+                    }
+                    dy += lastRowHeight;
+                }
                 log.warn("TODO Add collapsed border painting for spanned cells");
             }
         }
index 87ac870a2afdd58f64dee8e5c5626492ac4bfdf9..29d1ce281732b3b4c05a31fad2649d2e7457e7b0 100644 (file)
@@ -200,12 +200,13 @@ public class Row extends BlockStackingLayoutManager {
             
         //Border resolution now that the empty grid units are filled
         for (int pos = 1; pos <= gridUnits.size(); pos++) {
-            GridUnit gu = (GridUnit)gridUnits.get(pos - 1);
+            GridUnit starting = (GridUnit)gridUnits.get(pos - 1);
          
             //Border resolution
             if (getTable().isSeparateBorderModel()) {
-                gu.assignBorder(gu.layoutManager);
+                starting.assignBorder(starting.layoutManager);
             } else {
+                //Neighbouring grid unit at start edge 
                 GridUnit start = null;
                 int find = pos - 1;
                 while (find >= 1) {
@@ -216,6 +217,13 @@ public class Row extends BlockStackingLayoutManager {
                     }
                     find--;
                 }
+                
+                //Ending grid unit for current cell
+                GridUnit ending = null;
+                pos += starting.layoutManager.getFObj().getNumberColumnsSpanned() - 1;
+                ending = (GridUnit)gridUnits.get(pos - 1);
+                
+                //Neighbouring grid unit at end edge 
                 GridUnit end = null;
                 find = pos + 1;
                 while (find <= gridUnits.size()) {
@@ -224,15 +232,20 @@ public class Row extends BlockStackingLayoutManager {
                         end = candidate;
                         break;
                     }
+                    find++;
                 }
                 CommonBorderPaddingBackground borders = new CommonBorderPaddingBackground();
-                GridUnit.resolveBorder(getTable(), borders, gu
+                GridUnit.resolveBorder(getTable(), borders, starting
                         (start != null ? start : null), 
                         CommonBorderPaddingBackground.START);
-                GridUnit.resolveBorder(getTable(), borders, gu, 
+                starting.effBorders = borders;
+                if (starting != ending) {
+                    borders = new CommonBorderPaddingBackground();
+                }
+                GridUnit.resolveBorder(getTable(), borders, ending, 
                         (end != null ? end : null), 
                         CommonBorderPaddingBackground.END);
-                gu.effBorders = borders;
+                ending.effBorders = borders;
                 //Only start and end borders here, before and after during layout
                 //TODO resolve before and after borders during layout
             }
@@ -412,21 +425,21 @@ public class Row extends BlockStackingLayoutManager {
     }
 
     /**
-     * Determines the columns that are spanned by the given cell.
+     * Determines the grid units that are spanned by the given cell.
      * @param cellLM table-cell LM
      * @param startCell starting cell index (must be >= 1)
-     * @param spannedColumns List to receive the applicable columns
+     * @param spannedGridUnits List to receive the applicable grid units
      */
-    private void getGridUnitsForCell(Cell cellLM, int startCell, List spannedColumns) {
+    private void getGridUnitsForCell(Cell cellLM, int startCell, List spannedGridUnits) {
         int count;
         if (cellLM != null) {
             count = cellLM.getFObj().getNumberColumnsSpanned();
         } else {
             count = 1;
         }
-        spannedColumns.clear();
+        spannedGridUnits.clear();
         for (int i = 0; i < count; i++) {
-            spannedColumns.add(this.gridUnits.get(startCell + i - 1));
+            spannedGridUnits.add(this.gridUnits.get(startCell + i - 1));
         }
     }