You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/12/12 17:13:16 UTC

svn commit: r603656 [3/7] - in /xmlgraphics/fop/branches/Temp_ImagePackageRedesign: ./ examples/fo/basic/ lib/ src/documentation/ src/documentation/content/xdocs/ src/documentation/content/xdocs/trunk/ src/documentation/intermediate-format-ng/ src/java...

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java Wed Dec 12 08:13:06 2007
@@ -20,11 +20,7 @@
 package org.apache.fop.layoutmgr.table;
 
 import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableCell;
-import org.apache.fop.fo.flow.table.TableColumn;
-import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.flow.table.BorderSpecification;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 
 /**
@@ -34,268 +30,45 @@
  */
 public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel {
 
-    public BorderInfo determineWinner(GridUnit currentGridUnit, 
-            GridUnit otherGridUnit, int side, int flags) {
-        final boolean vertical = isVerticalRelation(side);
-        final int otherSide = getOtherSide(side);
-        
-        //Get cells
-        TableCell currentCell = currentGridUnit.getCell();
-        TableCell otherCell = null;
-        if (otherGridUnit != null) {
-            otherCell = otherGridUnit.getCell();
-        }
-        
-        //Get rows
-        TableRow currentRow = currentGridUnit.getRow();
-        TableRow otherRow = null;
-        if (vertical && otherCell != null) {
-            otherRow = otherGridUnit.getRow();
-        }
-        
-        //get bodies
-        TableBody currentBody = currentGridUnit.getBody();
-        TableBody otherBody = null;
-        if (otherRow != null) {
-            otherBody = otherGridUnit.getBody();
-        }
-
-        //get columns
-        TableColumn currentColumn = currentGridUnit.getColumn();
-        TableColumn otherColumn = null;
-        if (otherGridUnit != null) {
-            otherColumn = otherGridUnit.getColumn();
-        }
-        
-        //TODO get column groups
-        
-        //Get table
-        Table table = currentGridUnit.getTable();
-        
-        //----------------------------------------------------------------------
-        //We're creating two arrays containing the applicable BorderInfos for
-        //each cell in question.
-        //0 = cell, 1 = row, 2 = row group (body), 3 = column, 
-        //4 = col group (spanned column, see 6.7.3), 5 = table
-
-        BorderInfo[] current = new BorderInfo[6];
-        BorderInfo[] other = new BorderInfo[6];
-        //cell
-        current[0] = currentGridUnit.getOriginalBorderInfoForCell(side);
-        if (otherGridUnit != null) {
-            other[0] = otherGridUnit.getOriginalBorderInfoForCell(otherSide);
-        }
-        if ((currentRow != null) 
-                && (side == BEFORE 
-                    || side == AFTER
-                    || (currentGridUnit.getFlag(GridUnit.IN_FIRST_COLUMN) && side == START)
-                    || (currentGridUnit.getFlag(GridUnit.IN_LAST_COLUMN) && side == END))) {
-            //row
-            current[1] = currentRow.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherRow != null) {
-            //row
-            other[1] = otherRow.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        if (currentBody != null
-                && ((side == BEFORE && currentGridUnit.getFlag(GridUnit.FIRST_IN_PART))
-                || (side == AFTER && currentGridUnit.getFlag(GridUnit.LAST_IN_PART))
-                || (currentGridUnit.getFlag(GridUnit.IN_FIRST_COLUMN) && side == START)
-                || (currentGridUnit.getFlag(GridUnit.IN_LAST_COLUMN) && side == END))) {
-            //row group (=body, table-header or table-footer)
-            current[2] = currentBody.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherGridUnit != null
-                && otherBody != null
-                && ((otherSide == BEFORE && otherGridUnit.getFlag(GridUnit.FIRST_IN_PART))
-                    || (otherSide == AFTER && otherGridUnit.getFlag(GridUnit.LAST_IN_PART)))) {
-            //row group (=body, table-header or table-footer)
-            other[2] = otherBody.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        if ((side == BEFORE && otherGridUnit == null)
-                || (side == AFTER && otherGridUnit == null)
-                || (side == START)
-                || (side == END)) {
-            //column
-            current[3] = currentColumn.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherColumn != null) {
-            //column
-            other[3] = otherColumn.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        //TODO current[4] and other[4] for column groups
-        if (otherGridUnit == null
-            && ((side == BEFORE && (flags & VERTICAL_START_END_OF_TABLE) > 0)
-                    || (side == AFTER && (flags & VERTICAL_START_END_OF_TABLE) > 0)
-                    || (side == START)
-                    || (side == END))) {
-            //table
-            current[5] = table.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        //other[6] is always null, since it's always the same table
-        
-        BorderInfo resolved = null;
-        
-        // *** Rule 1 ***
-        resolved = doRule1(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 2 ***
-        if (!doRule2(current, other)) {
-        }
-        
-        // *** Rule 3 ***
-        resolved = doRule3(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 4 ***
-        resolved = doRule4(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 5 ***
-        resolved = doRule5(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        return null; //no winner, no border
-    }
-
-    private BorderInfo doRule1(BorderInfo[] current, BorderInfo[] other) {
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getStyle() == Constants.EN_HIDDEN)) {
-                return current[i];
-            }
-            if ((other[i] != null) && (other[i].getStyle() == Constants.EN_HIDDEN)) {
-                return other[i];
-            }
-        }
-        return null;
-    }
-    
-    private boolean doRule2(BorderInfo[] current, BorderInfo[] other) {
-        boolean found = false;
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getStyle() != Constants.EN_NONE)) {
-                found = true;
-                break;
+    /** {@inheritDoc} */
+    public BorderSpecification determineWinner(BorderSpecification border1,
+            BorderSpecification border2) {
+        BorderInfo bi1 = border1.getBorderInfo();
+        BorderInfo bi2 = border2.getBorderInfo();
+        // Rule 1
+        if (bi1.getStyle() == Constants.EN_HIDDEN) {
+            return border1;
+        } else if (bi2.getStyle() == Constants.EN_HIDDEN) {
+            return border2;
+        }
+        // Rule 2
+        if (bi2.getStyle() == Constants.EN_NONE) {
+            return border1;
+        } else if (bi1.getStyle() == Constants.EN_NONE) {
+            return border2;
+        }
+        // Rule 3
+        int width1 = bi1.getRetainedWidth();
+        int width2 = bi2.getRetainedWidth();
+        if (width1 > width2) {
+            return border1;
+        } else if (width1 == width2) {
+            int cmp = compareStyles(bi1.getStyle(), bi2.getStyle());
+            if (cmp > 0) {
+                return border1;
+            } else if (cmp < 0) {
+                return border2;
             }
-            if ((other[i] != null) && (other[i].getStyle() != Constants.EN_NONE)) {
-                found = true;
-                break;
-            }
-        }
-        return found;
-    }
-
-    private BorderInfo doRule3(BorderInfo[] current, BorderInfo[] other) {
-        int width = 0;
-        //Find max border width
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getRetainedWidth() > width)) {
-                width = current[i].getRetainedWidth();
-            }
-            if ((other[i] != null) && (other[i].getRetainedWidth() > width)) {
-                width = other[i].getRetainedWidth();
-            }
-        }
-        BorderInfo widest = null;
-        int count = 0;
-        //See if there's only one with the widest border
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getRetainedWidth() == width)) {
-                count++;
-                if (widest == null) {
-                    widest = current[i];
-                }
-            } else {
-                current[i] = null; //Discard the narrower ones
-            }
-            if ((other[i] != null) && (other[i].getRetainedWidth() == width)) {
-                count++;
-                if (widest == null) {
-                    widest = other[i];
-                }
-            } else {
-                other[i] = null; //Discard the narrower ones
-            }
-        }
-        if (count == 1) {
-            return widest;
         } else {
-            return null;
+            return border2;
         }
-    }
-
-    private BorderInfo doRule4(BorderInfo[] current, BorderInfo[] other) {
-        int pref = getPreferenceValue(Constants.EN_INSET); //Lowest preference
-        //Find highest preference value
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                int currPref = getPreferenceValue(current[i].getStyle());
-                if (currPref > pref) {
-                    pref = currPref;
-                }
-            }
-            if (other[i] != null) {
-                int currPref = getPreferenceValue(other[i].getStyle());
-                if (currPref > pref) {
-                    pref = currPref;
-                }
-            }
-        }
-        BorderInfo preferred = null;
-        int count = 0;
-        //See if there's only one with the preferred border style
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                int currPref = getPreferenceValue(current[i].getStyle());
-                if (currPref == pref) {
-                    count++;
-                    if (preferred == null) {
-                        preferred = current[i];
-                    }
-                    break;
-                }
-            } else {
-                current[i] = null; //Discard the ones that are not preferred
-            }
-            if (other[i] != null) {
-                int currPref = getPreferenceValue(other[i].getStyle());
-                if (currPref == pref) {
-                    count++;
-                    if (preferred == null) {
-                        preferred = other[i];
-                    }
-                    break;
-                }
-            } else {
-                other[i] = null; //Discard the ones that are not preferred
-            }
-        }
-        if (count == 1) {
-            return preferred;
-        } else {
-            return null;
-        }
-    }
-
-    private BorderInfo doRule5(BorderInfo[] current, BorderInfo[] other) {
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                return current[i];
-            }
-            if (other[i] != null) {
-                return other[i];
-            }
+        // Rule 4
+        int cmp = compareFOs(border1.getHolder(), border2.getHolder());
+        if (cmp > 0) {
+            return border1;
+        } else if (cmp < 0) {
+            return border2;
         }
         return null;
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java Wed Dec 12 08:13:06 2007
@@ -19,6 +19,9 @@
 
 package org.apache.fop.layoutmgr.table;
 
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+
 /**
  * Represents a non-dividable part of a grid unit. Used by the table stepper.
  */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Wed Dec 12 08:13:06 2007
@@ -26,6 +26,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.LengthRangeProperty;
@@ -47,21 +50,12 @@
 
     private TableLayoutManager tableLM;
 
-    private TableRowIterator bodyIter;
-    private TableRowIterator headerIter;
-    private TableRowIterator footerIter;
-    private TableRowIterator thisIter;
     private TableStepper tableStepper;
 
-    RowGroupLayoutManager(TableLayoutManager tableLM, EffRow[] rowGroup, TableRowIterator bodyIter,
-            TableRowIterator headerIter, TableRowIterator footerIter, TableRowIterator thisIter,
+    RowGroupLayoutManager(TableLayoutManager tableLM, EffRow[] rowGroup,
             TableStepper tableStepper) {
         this.tableLM = tableLM;
         this.rowGroup = rowGroup;
-        this.bodyIter = bodyIter;
-        this.headerIter = headerIter;
-        this.footerIter = footerIter;
-        this.thisIter = thisIter;
         this.tableStepper = tableStepper;
     }
 
@@ -97,10 +91,6 @@
 
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
         LinkedList returnList = new LinkedList();
-        //Border resolution
-        if (!tableLM.getTable().isSeparateBorderModel()) {
-            resolveNormalBeforeAfterBordersForRowGroup();
-        }
 
         //Reset keep-with-next when remaining inside the table.
         //The context flag is only used to propagate keep-with-next to the outside.
@@ -134,107 +124,6 @@
     }
 
     /**
-     * Resolves normal borders for a row group.
-     * @param iter Table row iterator to operate on
-     */
-    private void resolveNormalBeforeAfterBordersForRowGroup() {
-        for (int rgi = 0; rgi < rowGroup.length; rgi++) {
-            EffRow row = rowGroup[rgi];
-            EffRow prevRow = thisIter.getPrecedingRow(row);
-            EffRow nextRow = thisIter.getFollowingRow(row);
-            if ((prevRow == null) && (thisIter == bodyIter) && (headerIter != null)) {
-                prevRow = headerIter.getLastRow();
-            }
-            if ((nextRow == null) && (thisIter == headerIter)) {
-                nextRow = bodyIter.getFirstRow();
-            }
-            if ((nextRow == null) && (thisIter == bodyIter) && (footerIter != null)) {
-                nextRow = footerIter.getFirstRow();
-            }
-            if ((prevRow == null) && (thisIter == footerIter)) {
-                //TODO This could be bad for memory consumption because it already causes the
-                //whole body iterator to be prefetched!
-                prevRow = bodyIter.getLastRow();
-            }
-            log.debug("prevRow-row-nextRow: " + prevRow + " - " + row + " - " + nextRow);
-            
-            //Determine the grid units necessary for getting all the borders right
-            int guCount = row.getGridUnits().size();
-            if (prevRow != null) {
-                guCount = Math.max(guCount, prevRow.getGridUnits().size());
-            }
-            if (nextRow != null) {
-                guCount = Math.max(guCount, nextRow.getGridUnits().size());
-            }
-            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++) {
-                //TODO This block is untested!
-                int pos = row.getGridUnits().size() + i;
-                row.getGridUnits().add(new EmptyGridUnit(gu.getRow(), 
-                        tableLM.getColumns().getColumn(pos + 1), gu.getBody(), 
-                        pos));
-            }
-            
-            //Now resolve normal borders
-            if (tableLM.getTable().isSeparateBorderModel()) {
-                //nop, borders are already assigned at this point
-            } else {
-                for (int i = 0; i < row.getGridUnits().size(); i++) {
-                    gu = row.getGridUnit(i);
-                    GridUnit other;
-                    int flags = 0;
-                    if (prevRow != null && i < prevRow.getGridUnits().size()) {
-                        other = prevRow.getGridUnit(i);
-                    } else {
-                        other = null;
-                    }
-                    if (other == null 
-                            || other.isEmpty() 
-                            || gu.isEmpty() 
-                            || gu.getPrimary() != other.getPrimary()) {
-                        if ((thisIter == bodyIter)
-                                && gu.getFlag(GridUnit.FIRST_IN_TABLE)
-                                && (headerIter == null)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        if ((thisIter == headerIter)
-                                && gu.getFlag(GridUnit.FIRST_IN_TABLE)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        gu.resolveBorder(other, 
-                                CommonBorderPaddingBackground.BEFORE, flags);
-                    }
-                    
-                    flags = 0;
-                    if (nextRow != null && i < nextRow.getGridUnits().size()) {
-                        other = nextRow.getGridUnit(i);
-                    } else {
-                        other = null;
-                    }
-                    if (other == null 
-                            || other.isEmpty() 
-                            || gu.isEmpty() 
-                            || gu.getPrimary() != other.getPrimary()) {
-                        if ((thisIter == bodyIter)
-                                && gu.getFlag(GridUnit.LAST_IN_TABLE)
-                                && (footerIter == null)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        if ((thisIter == footerIter)
-                                && gu.getFlag(GridUnit.LAST_IN_TABLE)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        gu.resolveBorder(other, 
-                                CommonBorderPaddingBackground.AFTER, flags);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
      * Creates Knuth elements for a row group (see TableRowIterator.getNextRowGroup()).
      * @param context Active LayoutContext
      * @param alignment alignment indicator
@@ -263,7 +152,7 @@
             int maxCellHeight = 0;
             int effRowContentHeight = 0;
             for (int j = 0; j < row.getGridUnits().size(); j++) {
-//                assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size(); // TODO vh
+                assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size();
                 maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
                 GridUnit gu = row.getGridUnit(j);
                 if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan())) 
@@ -271,6 +160,7 @@
                     PrimaryGridUnit primary = gu.getPrimary();
                     
                     if (gu.isPrimary()) {
+                        primary.createCellLM(); // TODO a new LM must be created for every new static-content
                         primary.getCellLM().setParent(tableLM);
                      
                         //Determine the table-row if any

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Wed Dec 12 08:13:06 2007
@@ -25,6 +25,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 import org.apache.fop.layoutmgr.ElementListUtils;

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Wed Dec 12 08:13:06 2007
@@ -23,8 +23,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.Trait;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableCell;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
@@ -32,18 +37,16 @@
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.ListElement;
-import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.SpaceResolver;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-import org.apache.fop.area.Trait;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -230,8 +233,15 @@
         }
 
         returnedList = new LinkedList();
-        wrapPositionElements(contentList, returnList);
-
+        if (contentList.size() > 0) {
+            wrapPositionElements(contentList, returnList);
+        } else {
+            // In relaxed validation mode, table-cells having no children are authorised.
+            // Add a zero-width block here to not have to take this special case into
+            // account later
+            // Copied from BlockStackingLM
+            returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
+        }
         //Space resolution
         SpaceResolver.resolveElementList(returnList);
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Wed Dec 12 08:13:06 2007
@@ -31,6 +31,8 @@
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
 import org.apache.fop.fo.flow.table.TableRow;
@@ -75,15 +77,12 @@
     public TableContentLayoutManager(TableLayoutManager parent) {
         this.tableLM = parent;
         Table table = getTableLM().getTable();
-        this.bodyIter = new TableRowIterator(table, getTableLM().getColumns(),
-                TableRowIterator.BODY);
+        this.bodyIter = new TableRowIterator(table, TableRowIterator.BODY);
         if (table.getTableHeader() != null) {
-            headerIter = new TableRowIterator(table, 
-                    getTableLM().getColumns(), TableRowIterator.HEADER);
+            headerIter = new TableRowIterator(table, TableRowIterator.HEADER);
         }
         if (table.getTableFooter() != null) {
-            footerIter = new TableRowIterator(table, 
-                    getTableLM().getColumns(), TableRowIterator.FOOTER);
+            footerIter = new TableRowIterator(table, TableRowIterator.FOOTER);
         }
     }
     
@@ -212,7 +211,7 @@
         int breakBetween = Constants.EN_AUTO;
         while ((rowGroup = iter.getNextRowGroup()) != null) {
             RowGroupLayoutManager rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup,
-                    bodyIter, headerIter, footerIter, iter, stepper);
+                    stepper);
             if (breakBetween == Constants.EN_AUTO) {
                 // TODO improve
                 breakBetween = rowGroupLM.getBreakBefore();
@@ -233,7 +232,8 @@
         // Break after the table's last row
         // TODO should eventually be handled at the table level
         if (breakBetween != Constants.EN_AUTO) {
-            if (returnList.size() > 0) {
+            if (returnList.size() > 0 && ((ListElement) returnList.getLast()).isPenalty()) {
+                // May be a glue if the unbroken height is greater than the broken heights
                 BreakElement breakPoss = (BreakElement) returnList.getLast();
                 breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
                 breakPoss.setBreakClass(breakBetween);

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java Wed Dec 12 08:13:06 2007
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.Position;
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java Wed Dec 12 08:13:06 2007
@@ -20,18 +20,14 @@
 package org.apache.fop.layoutmgr.table;
 
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fo.flow.Marker;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FONode.FONodeIterator;
+import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableCell;
-import org.apache.fop.fo.flow.table.TableColumn;
-import org.apache.fop.fo.flow.table.TableRow;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 
 
 /**
@@ -48,82 +44,41 @@
     /** Selects the table-footer elements for iteration. */
     public static final int FOOTER = 2;
 
-    /** Logger **/
-    private static Log log = LogFactory.getLog(TableRowIterator.class);
-
     /** The table on which this instance operates. */
     protected Table table;
-    /** Column setup of the operated table. */
-    private ColumnSetup columns;
 
     /** Part of the table over which to iterate. One of BODY, HEADER or FOOTER. */
     private int tablePart;
 
-    /** Holds the currently fetched row (TableCell instances). */
-    private List currentRow = new java.util.ArrayList();
-
-    /**
-     * Holds the grid units of cells from the previous row which will span over the
-     * current row. Should be read "previous row's spanning cells". List of GridUnit
-     * instances.
-     */
-    private List previousRowsSpanningCells = new java.util.ArrayList();
-
-    /** Index of the row currently being fetched. */
-    private int fetchIndex = -1;
-
-    /**
-     * Number of spans found on the current row which will also span over the next row.
-     */
-    private int pendingRowSpans;
+    private Iterator rowGroupsIter;
 
-    //TODO rows should later be a Jakarta Commons LinkedList so concurrent modifications while
-    //using a ListIterator are possible
-    /** List of cached rows. This is a list of EffRow elements. */
-    private List fetchedRows = new java.util.ArrayList();
-
-    /**
-     * Index of the row that will be returned at the next iteration step. Note that there
-     * is no direct relation between this field and {@link
-     * TableRowIterator#fetchIndex}. The fetching of rows and the iterating over them are
-     * two different processes. Hence the two indices. */
-    private int iteratorIndex = 0;
-
-    //prefetch state
-    /**
-     * Iterator over the requested table's part(s) (header, footer, body). Note that
-     * a table may have several table-body children, hence the iterator.
-     */
-    private ListIterator tablePartIterator = null;
-    /** Iterator over a part's child elements (either table-rows or table-cells). */
-    private ListIterator tablePartChildIterator = null;
+    private int rowIndex = 0;
 
     /**
      * Creates a new TableRowIterator.
      * @param table the table to iterate over
-     * @param columns the column setup for the table
      * @param tablePart indicates what part of the table to iterate over (HEADER, FOOTER, BODY)
      */
-    public TableRowIterator(Table table, ColumnSetup columns, int tablePart) {
+    public TableRowIterator(Table table, int tablePart) {
         this.table = table;
-        this.columns = columns;
         this.tablePart = tablePart;
         switch(tablePart) {
-            case HEADER: {
-                List bodyList = new java.util.ArrayList();
-                bodyList.add(table.getTableHeader());
-                this.tablePartIterator = bodyList.listIterator();
+            case HEADER:
+                rowGroupsIter = table.getTableHeader().getRowGroups().iterator();
                 break;
-            }
-            case FOOTER: {
-                List bodyList = new java.util.ArrayList();
-                bodyList.add(table.getTableFooter());
-                this.tablePartIterator = bodyList.listIterator();
+            case FOOTER:
+                rowGroupsIter = table.getTableFooter().getRowGroups().iterator();
                 break;
-            }
-            default: {
-                this.tablePartIterator = table.getChildNodes();
-            }
+            default:
+                List rowGroupsList = new LinkedList();
+                // TODO this is ugly
+                for (FONodeIterator iter = table.getChildNodes(); iter.hasNext();) {
+                    FONode node = iter.nextNode();
+                    if (node instanceof TableBody) {
+                        rowGroupsList.addAll(((TableBody) node).getRowGroups());
+                    }
+                }
+                rowGroupsIter = rowGroupsList.iterator();
         }
     }
 
@@ -132,429 +87,18 @@
      * consecutive rows which contains all spanned grid units of its cells.
      * @return the next row group, or null
      */
-    public EffRow[] getNextRowGroup() {
-        EffRow firstRowInGroup = getNextRow();
-        if (firstRowInGroup == null) {
-            return null;
-        }
-        EffRow lastRowInGroup = firstRowInGroup;
-        int lastIndex = lastRowInGroup.getIndex();
-        boolean allFinished;
-        do {
-            allFinished = true;
-            Iterator iter = lastRowInGroup.getGridUnits().iterator();
-            while (iter.hasNext()) {
-                GridUnit gu = (GridUnit)iter.next();
-                if (!gu.isLastGridUnitRowSpan()) {
-                    allFinished = false;
-                    break;
-                }
-            }
-            lastIndex = lastRowInGroup.getIndex();
-            if (!allFinished) {
-                lastRowInGroup = getNextRow();
-                if (lastRowInGroup == null) {
-                    allFinished = true;
-                }
-            }
-        } while (!allFinished);
-        int rowCount = lastIndex - firstRowInGroup.getIndex() + 1;
-        EffRow[] rowGroup = new EffRow[rowCount];
-        for (int i = 0; i < rowCount; i++) {
-            rowGroup[i] = getCachedRow(i + firstRowInGroup.getIndex());
-        }
-        return rowGroup;
-    }
-
-    /**
-     * Returns the row at the given index, fetching rows up to the requested one if
-     * necessary.
-     *
-     * @return the requested row, or null if there is no row at the given index (index
-     * &lt; 0 or end of table-part reached)
-     */
-    private EffRow getRow(int index) {
-        boolean moreRows = true;
-        while (moreRows && fetchedRows.size() <= index) {
-            moreRows = prefetchNext();
-        }
-        // Whatever the value of index, getCachedRow will handle it nicely
-        return getCachedRow(index);
-    }
-
-    /**
-     * Returns the next effective row.
-     * @return the requested effective row or null if there is no more row.
-     */
-    private EffRow getNextRow() {
-        return getRow(iteratorIndex++);
-    }
-
-    /**
-     * Returns the row preceding the given row, without moving the iterator.
-     *
-     * @param row a row in the iterated table part
-     * @return the preceding row, or null if there is no such row (the given row is the
-     * first one in the table part)
-     */
-    public EffRow getPrecedingRow(EffRow row) {
-        return getRow(row.getIndex() - 1);
-    }
-
-    /**
-     * Returns the row following the given row, without moving the iterator.
-     *
-     * @param row a row in the iterated table part
-     * @return the following row, or null if there is no more row
-     */
-    public EffRow getFollowingRow(EffRow row) {
-        return getRow(row.getIndex() + 1);
-    }
-
-    /**
-     * Returns the first effective row.
-     * @return the requested effective row.
-     */
-    public EffRow getFirstRow() {
-        if (fetchedRows.size() == 0) {
-            prefetchNext();
-        }
-        return getCachedRow(0);
-    }
-
-    /**
-     * Returns the last effective row.
-     * <p>Note:This is inefficient for large tables because the whole table
-     * if preloaded.</p>
-     * @return the requested effective row.
-     */
-    public EffRow getLastRow() {
-        while (prefetchNext()) {
-            //nop
-        }
-        return getCachedRow(fetchedRows.size() - 1);
-    }
-
-    /**
-     * Returns a cached effective row. If the given index points outside the range of rows
-     * (negative or greater than the number of already fetched rows), this methods
-     * terminates nicely by returning null.
-     * 
-     * @param index index of the row (zero-based)
-     * @return the requested effective row or null if (index &lt; 0 || index &gt;= the
-     * number of already fetched rows)
-     */
-    private EffRow getCachedRow(int index) {
-        if (index < 0 || index >= fetchedRows.size()) {
-            return null;
-        } else {
-            return (EffRow)fetchedRows.get(index);
-        }
-    }
-
-    /**
-     * Fetches the next row.
-     * 
-     * @return true if there was a row to fetch; otherwise, false (the end of the
-     * table-part has been reached)
-     */
-    private boolean prefetchNext() {
-        boolean firstInTable = false;
-        boolean firstInTablePart = false;
-        // If we are at the end of the current table part
-        if (tablePartChildIterator != null && !tablePartChildIterator.hasNext()) {
-            //force skip on to next component
-            if (pendingRowSpans > 0) {
-                this.currentRow.clear();
-                this.fetchIndex++;
-                EffRow gridUnits = buildGridRow(this.currentRow, null);
-                log.debug(gridUnits);
-                fetchedRows.add(gridUnits);
-                return true;
-            }
-            tablePartChildIterator = null;
-            if (fetchedRows.size() > 0) {
-                getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits(
-                        GridUnit.LAST_IN_PART, true);
-            }
-        }
-        // If the iterating over the current table-part has not started yet
-        if (tablePartChildIterator == null) {
-            if (tablePartIterator.hasNext()) {
-                tablePartChildIterator = ((TableBody)tablePartIterator.next()).getChildNodes();
-                if (fetchedRows.size() == 0) {
-                    firstInTable = true;
-                }
-                firstInTablePart = true;
-            } else {
-                //no more rows in that part of the table
-                if (fetchedRows.size() > 0) {
-                    getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits(
-                            GridUnit.LAST_IN_PART, true);
-                    // If the last row is the last of the table
-                    if (tablePart == FOOTER
-                            || (tablePart == BODY && table.getTableFooter() == null)) {
-                        getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits(
-                                GridUnit.LAST_IN_TABLE, true);
-                    }
-                }
-                return false;
-            }
-        }
-        Object node = tablePartChildIterator.next();
-        while (node instanceof Marker) {
-            node = tablePartChildIterator.next();
-        }
-        this.currentRow.clear();
-        this.fetchIndex++;
-        TableRow rowFO = null;
-        if (node instanceof TableRow) {
-            rowFO = (TableRow)node;
-            ListIterator cellIterator = rowFO.getChildNodes();
-            while (cellIterator.hasNext()) {
-                this.currentRow.add(cellIterator.next());
-            }
-        } else if (node instanceof TableCell) {
-            this.currentRow.add(node);
-            if (!((TableCell)node).endsRow()) {
-                while (tablePartChildIterator.hasNext()) {
-                    TableCell cell = (TableCell)tablePartChildIterator.next();
-                    if (cell.startsRow()) {
-                        //next row already starts here, one step back
-                        tablePartChildIterator.previous();
-                        break;
-                    }
-                    this.currentRow.add(cell);
-                    if (cell.endsRow()) {
-                        break;
-                    }
-                }
-            }
-        } else {
-            throw new IllegalStateException("Illegal class found: " + node.getClass().getName());
-        }
-        EffRow gridUnits = buildGridRow(this.currentRow, rowFO);
-        if (firstInTablePart) {
-            gridUnits.setFlagForAllGridUnits(GridUnit.FIRST_IN_PART, true);
-        }
-        if (firstInTable && (tablePart == HEADER || table.getTableHeader() == null)
-                && tablePart != FOOTER) {
-            gridUnits.setFlagForAllGridUnits(GridUnit.FIRST_IN_TABLE, true);
-        }
-        log.debug(gridUnits);
-        fetchedRows.add(gridUnits);
-        return true;
-    }
-
-    /**
-     * Places the given object at the given position in the list, first extending it if
-     * necessary with null objects to reach the position.
-     *
-     * @param list the list in which to place the object
-     * @param position index at which the object must be placed (0-based)
-     * @param obj the object to place
-     */
-    private void safelySetListItem(List list, int position, Object obj) {
-        while (position >= list.size()) {
-            list.add(null);
-        }
-        list.set(position, obj);
-    }
-
-    private Object safelyGetListItem(List list, int position) {
-        if (position >= list.size()) {
+    EffRow[] getNextRowGroup() {
+        if (!rowGroupsIter.hasNext()) {
             return null;
-        } else {
-            return list.get(position);
-        }
-    }
-
-    /**
-     * Builds the list of grid units corresponding to the given table row.
-     *
-     * @param cells list of cells starting at the current row
-     * @param rowFO the fo:table-row object containing the row, possibly null
-     * @return the list of grid units
-     */
-    private EffRow buildGridRow(List cells, TableRow rowFO) {
-        EffRow row = new EffRow(this.fetchIndex, tablePart);
-        List gridUnits = row.getGridUnits();
-
-        TableBody bodyFO = null;
-
-        //Create all row-spanned grid units based on information from the previous row
-        int colnum = 1;
-        GridUnit[] horzSpan = null;  // Grid units horizontally spanned by a single cell
-        if (pendingRowSpans > 0) {
-            ListIterator spanIter = previousRowsSpanningCells.listIterator();
-            while (spanIter.hasNext()) {
-                GridUnit gu = (GridUnit)spanIter.next();
-                if (gu != null) {
-                    if (gu.getColSpanIndex() == 0) {
-                        horzSpan = new GridUnit[gu.getCell().getNumberColumnsSpanned()];
-                    }
-                    GridUnit newGU = gu.createNextRowSpanningGridUnit();
-                    newGU.setRow(rowFO);
-                    safelySetListItem(gridUnits, colnum - 1, newGU);
-                    horzSpan[newGU.getColSpanIndex()] = newGU;
-                    if (newGU.isLastGridUnitColSpan()) {
-                        //Add the array of row-spanned grid units to the primary grid unit
-                        newGU.getPrimary().addRow(horzSpan);
-                        horzSpan = null;
-                    }
-                    if (newGU.isLastGridUnitRowSpan()) {
-                        spanIter.set(null);
-                        pendingRowSpans--;
-                    } else {
-                        spanIter.set(newGU);
-                    }
-                }
-                colnum++;
-            }
         }
-        if (pendingRowSpans < 0) {
-            throw new IllegalStateException("pendingRowSpans must not become negative!");
-        }
-
-        //Transfer available cells to their slots
-        colnum = 1;
-        ListIterator iter = cells.listIterator();
-        while (iter.hasNext()) {
-            TableCell cell = (TableCell)iter.next();
-
-            colnum = cell.getColumnNumber();
-
-            //TODO: remove the check below???
-            //shouldn't happen here, since
-            //overlapping cells already caught in
-            //fo.flow.TableCell.bind()...
-            GridUnit other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1);
-            if (other != null) {
-                String err = "A table-cell ("
-                        + cell.getContextInfo()
-                        + ") is overlapping with another ("
-                        + other.getCell().getContextInfo()
-                        + ") in column " + colnum;
-                throw new IllegalStateException(err
-                        + " (this should have been catched by FO tree validation)");
-            }
-            TableColumn col = columns.getColumn(colnum);
-
-            //Add grid unit for primary grid unit
-            PrimaryGridUnit gu = new PrimaryGridUnit(cell, col, colnum - 1, this.fetchIndex);
-            safelySetListItem(gridUnits, colnum - 1, gu);
-            boolean hasRowSpanningLeft = !gu.isLastGridUnitRowSpan();
-            if (hasRowSpanningLeft) {
-                pendingRowSpans++;
-                safelySetListItem(previousRowsSpanningCells, colnum - 1, gu);
-            }
-
-            if (gu.hasSpanning()) {
-                //Add grid units on spanned slots if any
-                horzSpan = new GridUnit[cell.getNumberColumnsSpanned()];
-                horzSpan[0] = gu;
-                for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) {
-                    colnum++;
-                    GridUnit guSpan = new GridUnit(gu, columns.getColumn(colnum), colnum - 1, j);
-                    //TODO: remove the check below???
-                    other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1);
-                    if (other != null) {
-                        String err = "A table-cell ("
-                            + cell.getContextInfo()
-                            + ") is overlapping with another ("
-                            + other.getCell().getContextInfo()
-                            + ") in column " + colnum;
-                        throw new IllegalStateException(err
-                            + " (this should have been catched by FO tree validation)");
-                    }
-                    safelySetListItem(gridUnits, colnum - 1, guSpan);
-                    if (hasRowSpanningLeft) {
-                        pendingRowSpans++;
-                        safelySetListItem(previousRowsSpanningCells, colnum - 1, guSpan);
-                    }
-                    horzSpan[j] = guSpan;
-                }
-                gu.addRow(horzSpan);
-            }
-
-            //Gather info for empty grid units (used later)
-            if (bodyFO == null) {
-                bodyFO = gu.getBody();
-            }
-
-            colnum++;
-        }
-
-        //Post-processing the list (looking for gaps and resolve start and end borders)
-        fillEmptyGridUnits(gridUnits, rowFO, bodyFO);
-        resolveStartEndBorders(gridUnits);
-
-        return row;
-    }
-
-    private void fillEmptyGridUnits(List gridUnits, TableRow row, TableBody body) {
-        for (int pos = 1; pos <= gridUnits.size(); pos++) {
-            GridUnit gu = (GridUnit)gridUnits.get(pos - 1);
-
-            //Empty grid units
-            if (gu == null) {
-                //Add grid unit
-                gu = new EmptyGridUnit(row, columns.getColumn(pos), body,
-                        pos - 1);
-                gridUnits.set(pos - 1, gu);
-            }
-
-            //Set flags
-            gu.setFlag(GridUnit.IN_FIRST_COLUMN, (pos == 1));
-            gu.setFlag(GridUnit.IN_LAST_COLUMN, (pos == gridUnits.size()));
-        }
-    }
-
-    private void resolveStartEndBorders(List gridUnits) {
-        for (int pos = 1; pos <= gridUnits.size(); pos++) {
-            GridUnit starting = (GridUnit)gridUnits.get(pos - 1);
-
-            //Border resolution
-            if (table.isSeparateBorderModel()) {
-                starting.assignBorderForSeparateBorderModel();
-            } else {
-                //Neighbouring grid unit at start edge
-                GridUnit start = null;
-                int find = pos - 1;
-                while (find >= 1) {
-                    GridUnit candidate = (GridUnit)gridUnits.get(find - 1);
-                    if (candidate.isLastGridUnitColSpan()) {
-                        start = candidate;
-                        break;
-                    }
-                    find--;
-                }
-
-                //Ending grid unit for current cell
-                GridUnit ending = null;
-                if (starting.getCell() != null) {
-                    pos += starting.getCell().getNumberColumnsSpanned() - 1;
-                }
-                ending = (GridUnit)gridUnits.get(pos - 1);
-
-                //Neighbouring grid unit at end edge
-                GridUnit end = null;
-                find = pos + 1;
-                while (find <= gridUnits.size()) {
-                    GridUnit candidate = (GridUnit)gridUnits.get(find - 1);
-                    if (candidate.isPrimary()) {
-                        end = candidate;
-                        break;
-                    }
-                    find++;
-                }
-                starting.resolveBorder(start,
-                        CommonBorderPaddingBackground.START);
-                ending.resolveBorder(end,
-                        CommonBorderPaddingBackground.END);
-                //Only start and end borders here, before and after during layout
-            }
+        List rowGroup = (List) rowGroupsIter.next();
+        EffRow[] effRowGroup = new EffRow[rowGroup.size()];
+        int i = 0;
+        for (Iterator rowIter = rowGroup.iterator(); rowIter.hasNext();) {
+            List gridUnits = (List) rowIter.next();
+            effRowGroup[i++] = new EffRow(rowIndex++, tablePart, gridUnits);
         }
+        return effRowGroup;
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Wed Dec 12 08:13:06 2007
@@ -27,6 +27,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.KnuthBox;
@@ -153,15 +156,15 @@
         boolean signalKeepWithNext = false;
         int laststep = 0;
         int step;
-        int addedBoxLen = 0;
+        int cumulateLength = 0; // Length of the content accumulated before the break
         TableContentPosition lastTCPos = null;
         LinkedList returnList = new LinkedList();
         while ((step = getNextStep()) >= 0) {
             int normalRow = activeRowIndex;
             int increase = step - laststep;
             int penaltyOrGlueLen = step + getMaxRemainingHeight() - totalHeight;
-            int boxLen = step - addedBoxLen - Math.max(0, penaltyOrGlueLen);
-            addedBoxLen += boxLen;
+            int boxLen = step - cumulateLength - Math.max(0, penaltyOrGlueLen)/* the penalty, if any */;
+            cumulateLength += boxLen + Math.max(0, -penaltyOrGlueLen)/* the glue, if any */;
 
             boolean forcedBreak = false;
             int breakClass = -1;

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java Wed Dec 12 08:13:06 2007
@@ -27,12 +27,15 @@
 import java.util.List;
 
 import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FopFactory;
@@ -47,6 +50,7 @@
 import org.apache.fop.fonts.autodetect.FontFileFinder;
 import org.apache.fop.fonts.autodetect.FontInfoFinder;
 import org.apache.fop.util.LogUtil;
+import org.apache.xmlgraphics.util.ClasspathResource;
 
 /**
  * Base Print renderer configurator (mostly handles font configuration)
@@ -156,6 +160,16 @@
                 } catch (IOException e) {
                     LogUtil.handleException(log, e, strict);
                 }
+
+                // load fonts from classpath
+                addFontInfoListFromFileList(ClasspathResource.getInstance()
+                        .listResourcesOfMimeType("application/x-font"),
+                        fontInfoList, fontResolver, fontCache);
+                addFontInfoListFromFileList(
+                        ClasspathResource.getInstance()
+                                .listResourcesOfMimeType(
+                                        "application/x-font-truetype"),
+                        fontInfoList, fontResolver, fontCache);
             }
 
             // directory (multiple font) configuration
@@ -222,7 +236,15 @@
             }
         }
     }
-        
+
+    private static void closeSource(Source src) {
+        if (src instanceof StreamSource) {
+            StreamSource streamSource = (StreamSource)src;
+            IOUtils.closeQuietly(streamSource.getInputStream());
+            IOUtils.closeQuietly(streamSource.getReader());
+        }
+    }
+
     /**
      * Returns a font info from a font node Configuration definition
      * 
@@ -243,23 +265,27 @@
             LogUtil.handleError(log, "Font configuration without metric-url or embed-url", strict);
             return null;
         }
-        if (embedUrl != null) {
-            Source source = fontResolver.resolve(embedUrl);
-            if (source == null) {
-                LogUtil.handleError(log,
-                        "Failed to resolve font with embed-url '" + embedUrl + "'", strict);
-                return null;
-            }
-            embedUrl = source.getSystemId(); // absolute path/url
-        }
-        if (metricsUrl != null) {
-            Source source = fontResolver.resolve(metricsUrl);
-            if (source == null) {
-                LogUtil.handleError(log,
-                        "Failed to resolve font with metric-url '" + metricsUrl + "'", strict);
-                return null;
+        if (strict) {
+            //This section just checks early whether the URIs can be resolved
+            //Stream are immediately closed again since they will never be used anyway
+            if (embedUrl != null) {
+                Source source = fontResolver.resolve(embedUrl);
+                closeSource(source);
+                if (source == null) {
+                    LogUtil.handleError(log,
+                            "Failed to resolve font with embed-url '" + embedUrl + "'", strict);
+                    return null;
+                }
+            }
+            if (metricsUrl != null) {
+                Source source = fontResolver.resolve(metricsUrl);
+                closeSource(source);
+                if (source == null) {
+                    LogUtil.handleError(log,
+                            "Failed to resolve font with metric-url '" + metricsUrl + "'", strict);
+                    return null;
+                }
             }
-            metricsUrl = source.getSystemId(); // absolute path/url
         }
         boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
                         

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/AFPFontAttributes.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/AFPFontAttributes.java?rev=603656&r1=603655&r2=603656&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/AFPFontAttributes.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/AFPFontAttributes.java Wed Dec 12 08:13:06 2007
@@ -20,10 +20,9 @@
 package org.apache.fop.render.afp;
 
 import org.apache.fop.render.afp.fonts.AFPFont;
-import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
- * This class encapsulates the font atributes that need to be included
+ * This class encapsulates the font attributes that need to be included
  * in the AFP data stream. This class does not assist in converting the
  * font attributes to AFP code pages and character set values.
  *
@@ -31,24 +30,24 @@
 public class AFPFontAttributes {
 
     /**
-     * The font reference byte
+     * The font reference
      */
-    private byte _fontReference;
+    private int fontReference;
 
     /**
      * The font key
      */
-    private String _fontKey;
+    private String fontKey;
 
     /**
      * The font
      */
-    private AFPFont _font;
+    private AFPFont font;
 
     /**
      * The point size
      */
-    private int _pointSize;
+    private int pointSize;
 
     /**
      * Constructor for the AFPFontAttributes
@@ -56,45 +55,38 @@
      * @param font the font
      * @param pointSize the point size
      */
-    public AFPFontAttributes(
-
-        String fontKey,
-        AFPFont font,
-        int pointSize) {
-
-        _fontKey = fontKey;
-        _font = font;
-        _pointSize = pointSize;
-
+    public AFPFontAttributes(String fontKey, AFPFont font, int pointSize) {
+        this.fontKey = fontKey;
+        this.font = font;
+        this.pointSize = pointSize;
     }
+
     /**
      * @return the font
      */
     public AFPFont getFont() {
-        return _font;
+        return font;
     }
 
     /**
      * @return the FontKey attribute
      */
     public String getFontKey() {
-
-        return _fontKey + _pointSize;
-
+        return fontKey + pointSize;
     }
 
     /**
      * @return the point size attribute
      */
     public int getPointSize() {
-        return _pointSize;
+        return pointSize;
     }
 
     /**
      * @return the FontReference attribute
      */
-    public byte getFontReference() {
-        return _fontReference;
+    public int getFontReference() {
+        return fontReference;
     }
 
     /**
@@ -102,10 +94,7 @@
      * @param fontReference the FontReference to set
      */
     public void setFontReference(int fontReference) {
-
-        String id = String.valueOf(fontReference);
-        _fontReference = BinaryUtils.convert(id)[0];
-
+        this.fontReference = fontReference;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org