]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix for ArrayIndexOutOfBoundsException when empty grid units are involved.
authorJeremias Maerki <jeremias@apache.org>
Thu, 12 May 2005 14:13:45 +0000 (14:13 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 12 May 2005 14:13:45 +0000 (14:13 +0000)
Convenience accessor for GridUnits on EffRow.

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

src/java/org/apache/fop/layoutmgr/table/EffRow.java
src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableStepper.java

index 6580cba28be42a0a8a12fb226caf7916eb1d5d38..5438352a6085f23845f4ce8403a9769fcedbe182 100644 (file)
@@ -60,6 +60,14 @@ public class EffRow {
         return gridUnits;
     }
     
+    public GridUnit getGridUnit(int index) {
+        if (index >= 0 && index < gridUnits.size()) {
+            return (GridUnit)gridUnits.get(index);
+        } else {
+            return null;
+        }
+    }
+    
     public void setFlagForAllGridUnits(int flag, boolean value) {
         Iterator iter = gridUnits.iterator();
         while (iter.hasNext()) {
index 1a750407024b7a510d87c4b1fa3d770199327bad..3881cfd6493670f628c8e6b18695e5da5ffd68da 100644 (file)
@@ -269,7 +269,7 @@ public class TableContentLayoutManager {
             if (next != null) {
                 guCount = Math.max(guCount, next.getGridUnits().size());
             }
-            GridUnit gu = (GridUnit)row.getGridUnits().get(0);
+            GridUnit gu = row.getGridUnit(0);
             //Create empty grid units to hold resolved borders of neighbouring cells
             //TODO maybe this needs to be done differently (and sooner)
             for (int i = 0; i < guCount - row.getGridUnits().size(); i++) {
@@ -285,11 +285,11 @@ public class TableContentLayoutManager {
                 //nop, borders are already assigned at this point
             } else {
                 for (int i = 0; i < row.getGridUnits().size(); i++) {
-                    gu = (GridUnit)row.getGridUnits().get(i);
+                    gu = row.getGridUnit(i);
                     GridUnit other;
                     int flags = 0;
                     if (prev != null && i < prev.getGridUnits().size()) {
-                        other = (GridUnit)prev.getGridUnits().get(i);
+                        other = prev.getGridUnit(i);
                     } else {
                         other = null;
                     }
@@ -312,7 +312,7 @@ public class TableContentLayoutManager {
                     
                     flags = 0;
                     if (next != null && i < next.getGridUnits().size()) {
-                        other = (GridUnit)next.getGridUnits().get(i);
+                        other = next.getGridUnit(i);
                     } else {
                         other = null;
                     }
@@ -364,7 +364,7 @@ public class TableContentLayoutManager {
             int maxCellHeight = 0;
             for (int j = 0; j < row.getGridUnits().size(); j++) {
                 maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
-                GridUnit gu = (GridUnit)row.getGridUnits().get(j);
+                GridUnit gu = row.getGridUnit(j);
                 if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan())) 
                         && !gu.isEmpty()) {
                     PrimaryGridUnit primary = gu.getPrimary();
@@ -706,10 +706,10 @@ public class TableContentLayoutManager {
             //Add areas for row
             //addRowBackgroundArea(rowFO, lastRowHeight, layoutContext.getRefIPD(), yoffset);
             for (int i = 0; i < gridUnits.length; i++) {
-                GridUnit currentGU = (GridUnit)lastRow.getGridUnits().get(i);
+                GridUnit currentGU = lastRow.getGridUnit(i);
                 if ((gridUnits[i] != null) 
                         && (forcedFlush || (end[i] == gridUnits[i].getElements().size() - 1))
-                        && (currentGU.isLastGridUnitRowSpan())) {
+                        && (currentGU == null || currentGU.isLastGridUnitRowSpan())) {
                     if (log.isDebugEnabled()) {
                         log.debug((forcedFlush ? "FORCED " : "") + "flushing..." + i + " " 
                                 + start[i] + "-" + end[i]);
index c41f0a201d888a3e56e5b21281b5e547a723cf00..b43b67c04c3af8f2d48d537dd5d0afb0eebfc4ba 100644 (file)
@@ -81,7 +81,7 @@ public class TableStepper {
     }
     
     private GridUnit getActiveGridUnit(int column) {
-        return (GridUnit)getActiveRow().getGridUnits().get(column);
+        return getActiveRow().getGridUnit(column);
     }
     
     private PrimaryGridUnit getActivePrimaryGridUnit(int column) {