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/14 22:14:18 UTC

svn commit: r604297 [1/2] - in /xmlgraphics/fop/branches/Temp_ImagePackageRedesign: ./ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/flow/table/ src/java/org/apache/fop/fo/properties/ src/java/org/apache/fop/la...

Author: jeremias
Date: Fri Dec 14 13:14:12 2007
New Revision: 604297

URL: http://svn.apache.org/viewvc?rev=604297&view=rev
Log:
Merged revisions 603643-604293 via svnmerge from 
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r603890 | vhennebert | 2007-12-13 12:35:17 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Fixed @throws statements in javadoc
........
  r603926 | adelmelle | 2007-12-13 15:43:08 +0100 (Do, 13 Dez 2007) | 4 lines
  
  Minor tweaks:
  * only add text to a fo:wrapper if it is not a direct flow-descendant
  * error if an fo:wrapper that is a direct flow-descendant contains inline-level children
........
  r603943 | vhennebert | 2007-12-13 16:55:29 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Removed calls to removeLegalBreaks since they aren't necessary (the whole content is put in a single box anyway) and the method is buggy.
........
  r603945 | vhennebert | 2007-12-13 17:10:32 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Implemented the resolution of collapsing borders in the FO tree, for every situation (normal, cell at the top of a page, cell broken), taking conditionality, headers and footers into account.
........
  r603959 | vhennebert | 2007-12-13 18:21:24 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Reverted change accidentally introduced in the previous commit. A proper fix needs to be found for this one.
........
  r603961 | vhennebert | 2007-12-13 18:31:26 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Ok, now /really/ revert the previous commit :-\
........
  r603962 | vhennebert | 2007-12-13 18:32:43 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Style only: removed trailing white spaces
........
  r603968 | vhennebert | 2007-12-13 19:28:56 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Fixed the handling of columns in the border resolution, especially in case of column-spanning cells
........
  r603975 | vhennebert | 2007-12-13 19:52:48 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Removed parameter from the endPart method, since the part is already passed as a parameter of the previously called startPart method
........
  r603979 | vhennebert | 2007-12-13 19:57:25 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Removed parameter from the endTablePart method, as the part is already passed as as a parameter of the previously called startTablePart method
........
  r603990 | vhennebert | 2007-12-13 20:17:12 +0100 (Do, 13 Dez 2007) | 2 lines
  
  Throw a ValidationException if table-footer is put after table-body and the table uses the collapsing border model. The footer must be known to properly resolve borders.
........
  r604171 | vhennebert | 2007-12-14 12:32:51 +0100 (Fr, 14 Dez 2007) | 2 lines
  
  Clean up: removed all reset and resetPosition methods, which pre-date the Knuth era and are no longer needed
........
  r604180 | vhennebert | 2007-12-14 13:23:10 +0100 (Fr, 14 Dez 2007) | 2 lines
  
  Reduced visibility of methods from public to package-private
........
  r604185 | acumiskey | 2007-12-14 14:16:06 +0100 (Fr, 14 Dez 2007) | 2 lines
  
  Fixed copy constructor
........
  r604293 | jeremias | 2007-12-14 21:58:53 +0100 (Fr, 14 Dez 2007) | 2 lines
  
  Bugfix: DecodeParms -> DecodeParams (introduced when I changed to generic PDF structures)
  (fixes CCITT encoded images)
........

Added:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
      - copied unchanged from r604293, xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
Modified:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/   (props changed)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/FOPropertyMapping.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/Wrapper.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/GridUnit.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/Table.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableBody.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableCell.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableFObj.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableHeader.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/LayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/pdf/PDFFilterList.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution.xml
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/test/layoutengine/standard-testcases/table_border-collapse_collapse_resolution_no-col.xml

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Dec 14 13:14:12 2007
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-603642
+/xmlgraphics/fop/trunk:1-604293

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/FOPropertyMapping.java Fri Dec 14 13:14:12 2007
@@ -1141,7 +1141,7 @@
         m.useGeneric(genericSpace);
         corr = new SpacePropertyMaker(m);
         corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT);
-        corr.setUseParent(true);
+        corr.setUseParent(false);
         corr.setRelative(true);
         addPropertyMaker("space-before", m);
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/Wrapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/Wrapper.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/Wrapper.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/Wrapper.java Fri Dec 14 13:14:12 2007
@@ -19,9 +19,12 @@
 
 package org.apache.fop.fo.flow;
 
+import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.pagination.Flow;
 import org.xml.sax.Locator;
 
 /**
@@ -35,12 +38,24 @@
     
     // used for FO validation
     private boolean blockOrInlineItemFound = false;
+    private boolean isFlowChild = false;
 
     /**
      * @param parent FONode that is the parent of this object
      */
     public Wrapper(FONode parent) {
         super(parent);
+        /* Check if the fo:wrapper is a child of an fo:flow or fo:static-content
+         * (or a descendant in nested fo:wrapper sequence, the first of which
+         *  is a child of an fo:flow or fo:static-content */
+        FONode ancestor = this.parent;
+        while (!(ancestor instanceof Flow)
+                && ancestor instanceof Wrapper) {
+            ancestor = ancestor.getParent();
+        }
+        if (ancestor instanceof Flow) {
+            this.isFlowChild = true;
+        }
     }
 
     /**
@@ -49,6 +64,7 @@
      * Additionally (unimplemented): "An fo:wrapper that is a child of an 
      * fo:multi-properties is only permitted to have children that would 
      * be permitted in place of the fo:multi-properties."
+     * 
      */
     protected void validateChildNode(Locator loc, String nsURI, String localName) 
         throws ValidationException {
@@ -58,9 +74,30 @@
                     "(#PCDATA|%inline;|%block;)");
             }
         } else if (isBlockOrInlineItem(nsURI, localName)) {
+            if (isFlowChild
+                    && isInlineItem(nsURI, localName)
+                    && !isNeutralItem(nsURI, localName)) {
+                invalidChildError(loc, nsURI, localName,
+                        "fo:" + localName + " not allowed as child of an fo:wrapper "
+                        + "that is a child of an fo:flow or fo:static-content");
+            }
             blockOrInlineItemFound = true;
         } else {
             invalidChildError(loc, nsURI, localName);
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected void addCharacters(
+                char[] data, 
+                int start, 
+                int end, 
+                PropertyList pList, 
+                Locator locator) throws FOPException {
+        /* Only add text if the fo:wrapper is not a child of an fo:flow 
+         * or fo:static-content */
+        if (!this.isFlowChild) {
+            super.addCharacters(data, start, end, pList, locator);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderResolver.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderResolver.java Fri Dec 14 13:14:12 2007
@@ -44,10 +44,8 @@
 
     /**
      * Receives notification of the end of a table-header/footer/body.
-     * 
-     * @param part the part that has ended
      */
-    void endPart(TableBody part);
+    void endPart();
 
     /**
      * Receives notification of the end of the table.

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/BorderSpecification.java Fri Dec 14 13:14:12 2007
@@ -20,6 +20,7 @@
 package org.apache.fop.fo.flow.table;
 
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 
 /**
@@ -28,6 +29,8 @@
  */
 public/*TODO*/ class BorderSpecification {
 
+    private static BorderSpecification defaultBorder;
+
     private BorderInfo borderInfo;
 
     private int holder;
@@ -43,6 +46,14 @@
         this.holder = holder;
     }
 
+    static synchronized BorderSpecification getDefaultBorder() {
+        if (defaultBorder == null) {
+            defaultBorder = new BorderSpecification(CommonBorderPaddingBackground
+                    .getDefaultBorderInfo(), Constants.FO_TABLE_CELL);
+        }
+        return defaultBorder;
+    }
+
     /**
      * Returns this border's informations.
      * 
@@ -66,6 +77,17 @@
 
     /** {@inheritDoc} */
     public String toString() {
-        return "{" + borderInfo + ", " + holder + "}";
+        String holderName = "";
+        switch (holder) {
+        case Constants.FO_TABLE: holderName = "table"; break;
+        case Constants.FO_TABLE_COLUMN: holderName = "table-column"; break;
+        case Constants.FO_TABLE_HEADER: holderName = "table-header"; break;
+        case Constants.FO_TABLE_FOOTER: holderName = "table-footer"; break;
+        case Constants.FO_TABLE_BODY: holderName = "table-body"; break;
+        case Constants.FO_TABLE_ROW: holderName = "table-row"; break;
+        case Constants.FO_TABLE_CELL: holderName = "table-cell"; break;
+        default: assert false;
+        }
+        return "{" + borderInfo + ", " + holderName + "}";
     }
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java Fri Dec 14 13:14:12 2007
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fo.flow.table;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
@@ -31,138 +32,374 @@
 
     private Table table;
 
-    private List previousRow;
-
     /**
-     * The flow of rows is interrupted by the table-footer. Save the header's last row (if
-     * any) for resolution between it and the body's first row.
+     * The previously registered row, either in the header or the body(-ies), but not in
+     * the footer (handled separately).
      */
-    private List previousRowSave;
-
-    private TableBody currentTablePart;
+    private List/*<GridUnit>*/ previousRow;
 
     private boolean firstInTable;
 
-    private boolean firstInPart;
+    private List/*<GridUnit>*/ footerFirstRow;
 
-    private List footerFirstRow;
+    /** The last currently registered footer row. */
+    private List/*<GridUnit>*/ footerLastRow;
 
-    private List footerLastRow;
+    private Resolver delegate;
 
-    private boolean inFooter;
+    private Resolver resolverInFooter;
 
-    CollapsingBorderResolver(Table table) {
-        this.table = table;
-        firstInTable = true;
-    }
+    private List/*<ConditionalBorder>*/ leadingBorders;
 
-    /** {@inheritDoc} */
-    public void endRow(List row, TableCellContainer container) {
-        // Resolve before- and after-borders for the table-row
-        if (container instanceof TableRow) {
-            TableRow tableRow = (TableRow) container;
-            for (Iterator iter = row.iterator(); iter.hasNext();) {
-                GridUnit gu = (GridUnit) iter.next();
+    private List/*<ConditionalBorder>*/ trailingBorders;
+
+    /**
+     * Base class for delegate resolvers. Implementation of the State design pattern: the
+     * treatment differs slightly whether we are in the table's header, footer or body. To
+     * avoid complicated if statements, specialised delegate resolvers will be used
+     * instead.
+     */
+    private abstract class Resolver {
+
+        protected TableBody tablePart;
+
+        protected boolean firstInPart;
+
+        /**
+         * Integrates border-before specified on the table and its column.
+         * 
+         * @param row the first row of the table (in the header, or in the body if the
+         * table has no header)
+         * @param withLeadingTrailing
+         * @param withNonLeadingTrailing
+         * @param withRest
+         */
+        void resolveBordersFirstRowInTable(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
+                boolean withNonLeadingTrailing, boolean withRest) {
+            assert firstInTable;
+            for (int i = 0; i < row.size(); i++) {
+                TableColumn column = table.getColumn(i);
+                ((GridUnit) row.get(i)).integrateBorderSegment(
+                        CommonBorderPaddingBackground.BEFORE, column, withLeadingTrailing,
+                        withNonLeadingTrailing, withRest);
+            }
+            firstInTable = false;
+        }
+
+        /**
+         * Resolves border-after for the first row, border-before for the second one.
+         * 
+         * @param rowBefore
+         * @param rowAfter
+         */
+        void resolveBordersBetweenRows(List/*<GridUnit>*/ rowBefore, List/*<GridUnit>*/ rowAfter) {
+            assert rowBefore != null && rowAfter != null;
+            for (int i = 0; i < rowAfter.size(); i++) {
+                GridUnit gu = (GridUnit) rowAfter.get(i);
                 if (gu.getRowSpanIndex() == 0) {
-                    gu.resolveBorder(CommonBorderPaddingBackground.BEFORE, tableRow);
-                }
-                if (gu.isLastGridUnitRowSpan()) {
-                    gu.resolveBorder(CommonBorderPaddingBackground.AFTER, tableRow);
+                    GridUnit beforeGU = (GridUnit) rowBefore.get(i);
+                    gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
                 }
             }
         }
-        if (inFooter) {
-            if (footerFirstRow == null) {
-                footerFirstRow = row;
+
+        /** Integrates the border-after of the part. */
+        void resolveBordersLastRowInPart(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
+                boolean withNonLeadingTrailing, boolean withRest) {
+            for (int i = 0; i < row.size(); i++) {
+                ((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
+                        tablePart, withLeadingTrailing, withNonLeadingTrailing, withRest);
             }
-            footerLastRow = row;
-        } else if (firstInTable) {
-            // Resolve border-before for the first row in the table
+        }
+
+        /**
+         * Integrates border-after specified on the table and its columns.
+         * 
+         * @param row the last row of the footer, or of the last body if the table has no
+         * footer
+         * @param withLeadingTrailing
+         * @param withNonLeadingTrailing
+         * @param withRest
+         */
+        void resolveBordersLastRowInTable(List/*<GridUnit>*/ row, boolean withLeadingTrailing,
+                boolean withNonLeadingTrailing, boolean withRest) {
             for (int i = 0; i < row.size(); i++) {
                 TableColumn column = table.getColumn(i);
-                ((GridUnit) row.get(i)).resolveBorder(CommonBorderPaddingBackground.BEFORE, column);
+                ((GridUnit) row.get(i)).integrateBorderSegment(CommonBorderPaddingBackground.AFTER,
+                        column, withLeadingTrailing, withNonLeadingTrailing, withRest);
             }
-            firstInTable = false;
         }
-        if (firstInPart) {
-            // Resolve border-before for the first row in the part
-            for (int i = 0; i < row.size(); i++) {
-                ((GridUnit) row.get(i)).resolveBorder(CommonBorderPaddingBackground.BEFORE,
-                        currentTablePart);
+
+        /**
+         * Integrates either border-before specified on the table and its columns if the
+         * table has no header, or border-after specified on the cells of the header's
+         * last row. For the case the grid unit are at the top of a page.
+         * 
+         * @param row
+         */
+        void integrateLeadingBorders(List/*<GridUnit>*/ row) {
+            for (int i = 0; i < table.getNumberOfColumns(); i++) {
+                GridUnit gu = (GridUnit) row.get(i);
+                ConditionalBorder border = (ConditionalBorder) leadingBorders.get(i);
+                gu.integrateCompetingBorder(CommonBorderPaddingBackground.BEFORE, border,
+                        true, false, true);
             }
-            firstInPart = false;
         }
-        if (previousRow != null) {
-            // Resolve after/before borders between rows
-            for (int i = 0; i < row.size(); i++) {
+
+        /**
+         * Integrates either border-after specified on the table and its columns if the
+         * table has no footer, or border-before specified on the cells of the footer's
+         * first row. For the case the grid unit are at the bottom of a page.
+         * 
+         * @param row
+         */
+        void integrateTrailingBorders(List/*<GridUnit>*/ row) {
+            for (int i = 0; i < table.getNumberOfColumns(); i++) {
                 GridUnit gu = (GridUnit) row.get(i);
-                if (gu.getRowSpanIndex() == 0) {
-                    GridUnit beforeGU = (GridUnit) previousRow.get(i);
-                    gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
-                }
+                ConditionalBorder border = (ConditionalBorder) trailingBorders.get(i);
+                gu.integrateCompetingBorder(CommonBorderPaddingBackground.AFTER, border,
+                        true, false, true);
             }
         }
-        // Resolve start/end borders in the row
-        Iterator guIter = row.iterator();
-        GridUnit gu = (GridUnit) guIter.next();
-        gu.resolveBorder(CommonBorderPaddingBackground.START, container);
-        while (guIter.hasNext()) {
-            GridUnit guEnd = (GridUnit) guIter.next();
-            if (gu.isLastGridUnitColSpan()) {
-                gu.resolveBorder(guEnd, CommonBorderPaddingBackground.END);
+
+        void startPart(TableBody part) {
+            tablePart = part;
+            firstInPart = true;
+        }
+
+        /**
+         * Resolves the applicable borders for the given row.
+         * <ul>
+         * <li>Integrates the border-before/after of the containing table-row if any;</li>
+         * <li>Integrates the border-before of the containing part, if first row;</li>
+         * <li>Resolves border-start/end between grid units.</li>
+         * </ul>
+         * 
+         * @param row the row being finished
+         * @param container the containing element
+         */
+        void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+            // Resolve before- and after-borders for the table-row
+            if (container instanceof TableRow) {
+                TableRow tableRow = (TableRow) container;
+                for (Iterator iter = row.iterator(); iter.hasNext();) {
+                    GridUnit gu = (GridUnit) iter.next();
+                    if (gu.getRowSpanIndex() == 0) {
+                        gu.integrateBorderSegment(CommonBorderPaddingBackground.BEFORE, tableRow,
+                                true, true, true);
+                    }
+                    if (gu.isLastGridUnitRowSpan()) {
+                        gu.integrateBorderSegment(CommonBorderPaddingBackground.AFTER, tableRow,
+                                true, true, true);
+                    }
+                }
+            }
+            if (firstInPart) {
+                // Integrate the border-before of the part
+                for (int i = 0; i < row.size(); i++) {
+                    ((GridUnit) row.get(i)).integrateBorderSegment(
+                            CommonBorderPaddingBackground.BEFORE, tablePart, true, true, true);
+                }
+                firstInPart = false;
             }
-            gu = guEnd;
+            // Resolve start/end borders in the row
+            Iterator guIter = row.iterator();
+            GridUnit gu = (GridUnit) guIter.next();
+            Iterator colIter = table.getColumns().iterator();
+            TableColumn col = (TableColumn) colIter.next();
+            gu.integrateBorderSegment(CommonBorderPaddingBackground.START, col);
+            gu.integrateBorderSegment(CommonBorderPaddingBackground.START, container);
+            while (guIter.hasNext()) {
+                GridUnit nextGU = (GridUnit) guIter.next();
+                TableColumn nextCol = (TableColumn) colIter.next();
+                if (gu.isLastGridUnitColSpan()) {
+                    gu.integrateBorderSegment(CommonBorderPaddingBackground.END, col);
+                    nextGU.integrateBorderSegment(CommonBorderPaddingBackground.START, nextCol);
+                    gu.resolveBorder(nextGU, CommonBorderPaddingBackground.END);
+                }
+                gu = nextGU;
+                col = nextCol;
+            }
+            gu.integrateBorderSegment(CommonBorderPaddingBackground.END, col);
+            gu.integrateBorderSegment(CommonBorderPaddingBackground.END, container);
+        }
+
+        void endPart() {
+            resolveBordersLastRowInPart(previousRow, true, true, true);
         }
-        gu.resolveBorder(CommonBorderPaddingBackground.END, container);
 
-        previousRow = row;
+        abstract void endTable();
     }
 
-    /** {@inheritDoc} */
-    public void startPart(TableBody part) {
-        firstInPart = true;
-        currentTablePart = part;
-        if (part.isTableFooter()) {
-            inFooter = true;
-            previousRowSave = previousRow;
-            previousRow = null;
+    private class ResolverInHeader extends Resolver {
+
+        void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+            super.endRow(row, container);
+            if (previousRow != null) {
+                resolveBordersBetweenRows(previousRow, row);
+            } else {
+                /*
+                 * This is a bit hacky...
+                 * The two only sensible values for border-before on the header's first row are:
+                 * - at the beginning of the table (normal case)
+                 * - if the header is repeated after each page break
+                 * To represent those values we (ab)use the nonLeadingTrailing and the rest
+                 * fields of ConditionalBorder. But strictly speaking this is not their
+                 * purposes.
+                 */
+                for (Iterator guIter = row.iterator(); guIter.hasNext();) {
+                    ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
+                    borderBefore.leadingTrailing = null;
+                    borderBefore.rest = borderBefore.nonLeadingTrailing;
+                }
+                resolveBordersFirstRowInTable(row, false, true, true);
+            }
+            previousRow = row;
         }
-    }
 
-    /** {@inheritDoc} */
-    public void endPart(TableBody part) {
-        // Resolve border-after for the last row in the part
-        for (int i = 0; i < previousRow.size(); i++) {
-            ((GridUnit) previousRow.get(i))
-                    .resolveBorder(CommonBorderPaddingBackground.AFTER, part);
-        }
-        if (inFooter) {
-            inFooter = false;
-            previousRow = previousRowSave;
+        void endPart() {
+            super.endPart();
+            leadingBorders = new ArrayList(table.getNumberOfColumns());
+            /*
+             * Another hack...
+             * The border-after of a header is always the same. Leading and rest don't
+             * apply to cells in the header since they are never broken. To ease
+             * resolution we override the (normally unused) leadingTrailing and rest
+             * fields of ConditionalBorder with the only sensible nonLeadingTrailing
+             * field. That way grid units from the body will always resolve against the
+             * same, normal header border.
+             */
+            for (Iterator guIter = previousRow.iterator(); guIter.hasNext();) {
+                ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
+                borderAfter.leadingTrailing = borderAfter.nonLeadingTrailing;
+                borderAfter.rest = borderAfter.nonLeadingTrailing;
+                leadingBorders.add(borderAfter);
+            }
+        }
+
+        void endTable() {
+            throw new IllegalStateException();
         }
     }
 
-    /** {@inheritDoc} */
-    public void endTable() {
-        if (footerFirstRow != null) {
+    private class ResolverInFooter extends Resolver {
+
+        void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+            super.endRow(row, container);
+            if (footerFirstRow == null) {
+                footerFirstRow = row;
+            } else {
+                // There is a previous row
+                resolveBordersBetweenRows(footerLastRow, row);
+            }
+            footerLastRow = row;
+        }
+
+        void endPart() {
+            resolveBordersLastRowInPart(footerLastRow, true, true, true);
+            trailingBorders = new ArrayList(table.getNumberOfColumns());
+            // See same method in ResolverInHeader for an explanation of the hack
+            for (Iterator guIter = footerFirstRow.iterator(); guIter.hasNext();) {
+                ConditionalBorder borderBefore = ((GridUnit) guIter.next()).borderBefore;
+                borderBefore.leadingTrailing = borderBefore.nonLeadingTrailing;
+                borderBefore.rest = borderBefore.nonLeadingTrailing;
+                trailingBorders.add(borderBefore);
+            }
+        }
+
+        void endTable() {
             // Resolve after/before border between the last row of table-body and the
             // first row of table-footer
-            for (int i = 0; i < footerFirstRow.size(); i++) {
-                GridUnit gu = (GridUnit) footerFirstRow.get(i);
-                GridUnit beforeGU = (GridUnit) previousRow.get(i);
-                gu.resolveBorder(beforeGU, CommonBorderPaddingBackground.BEFORE);
+            resolveBordersBetweenRows(previousRow, footerFirstRow);
+            // See endRow method in ResolverInHeader for an explanation of the hack
+            for (Iterator guIter = footerLastRow.iterator(); guIter.hasNext();) {
+                ConditionalBorder borderAfter = ((GridUnit) guIter.next()).borderAfter;
+                borderAfter.leadingTrailing = null;
+                borderAfter.rest = borderAfter.nonLeadingTrailing;
             }
+            resolveBordersLastRowInTable(footerLastRow, false, true, true);
         }
-        List lastRow;
-        if (footerLastRow != null) {
-            lastRow = footerLastRow;
-        } else {
-            lastRow = previousRow;
+    }
+
+    private class ResolverInBody extends Resolver {
+
+        void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+            super.endRow(row, container);
+            if (firstInTable) {
+                resolveBordersFirstRowInTable(row, true, true, true);
+            } else {
+                // Either there is a header, and then previousRow is set to the header's last row,
+                // or this is not the first row in the body, and previousRow is not null
+                resolveBordersBetweenRows(previousRow, row);
+                integrateLeadingBorders(row);
+            }
+            integrateTrailingBorders(row);
+            previousRow = row;
         }
-        // Resolve border-after for the last row of the table
-        for (int i = 0; i < lastRow.size(); i++) {
-            TableColumn column = table.getColumn(i);
-            ((GridUnit) lastRow.get(i)).resolveBorder(CommonBorderPaddingBackground.AFTER, column);
+
+        void endTable() {
+            if (resolverInFooter != null) {
+                resolverInFooter.endTable();
+            } else {
+                // Trailing and rest borders already resolved with integrateTrailingBorders
+                resolveBordersLastRowInTable(previousRow, false, true, false);
+            }
         }
+    }
+
+    CollapsingBorderResolver(Table table) {
+        this.table = table;
+        firstInTable = true;
+    }
+
+    /** {@inheritDoc} */
+    public void endRow(List/*<GridUnit>*/ row, TableCellContainer container) {
+        delegate.endRow(row, container);
+    }
+
+    /** {@inheritDoc} */
+    public void startPart(TableBody part) {
+        if (part.isTableHeader()) {
+            delegate = new ResolverInHeader();
+        } else {
+            if (leadingBorders == null) {
+                // No header, leading borders determined by the table
+                leadingBorders = new ArrayList(table.getNumberOfColumns());
+                for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
+                    // See endRow method in ResolverInHeader for an explanation of the hack
+                    ConditionalBorder border = ((TableColumn) colIter.next()).borderBefore;
+                    border.leadingTrailing = border.rest;
+                    leadingBorders.add(border);
+                }
+            }
+            if (part.isTableFooter()) {
+                resolverInFooter = new ResolverInFooter();
+                delegate = resolverInFooter;
+            } else {
+                if (trailingBorders == null) {
+                    // No footer, trailing borders determined by the table
+                    trailingBorders = new ArrayList(table.getNumberOfColumns());
+                    for (Iterator colIter = table.getColumns().iterator(); colIter.hasNext();) {
+                        // See endRow method in ResolverInHeader for an explanation of the hack
+                        ConditionalBorder border = ((TableColumn) colIter.next()).borderAfter;
+                        border.leadingTrailing = border.rest;
+                        trailingBorders.add(border);
+                    }
+                }
+                delegate = new ResolverInBody();
+            }
+        }
+        delegate.startPart(part);
+    }
+
+    /** {@inheritDoc} */
+    public void endPart() {
+        delegate.endPart();
+    }
+
+    /** {@inheritDoc} */
+    public void endTable() {
+        delegate.endTable();
+        delegate = null;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java Fri Dec 14 13:14:12 2007
@@ -19,8 +19,6 @@
 
 package org.apache.fop.fo.flow.table;
 
-import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 
 /**
  * GridUnit subclass for empty grid units.
@@ -40,10 +38,11 @@
     }
 
     /** {@inheritDoc} */
-    protected void setBorder(int side) {
-        resolvedBorders[side] = new BorderSpecification(
-                CommonBorderPaddingBackground.getDefaultBorderInfo(),
-                Constants.FO_TABLE_CELL);
+    protected void setBordersFromCell() {
+        borderBefore = ConditionalBorder.getDefaultBorder(collapsingBorderModel);
+        borderAfter = ConditionalBorder.getDefaultBorder(collapsingBorderModel);
+        borderStart = BorderSpecification.getDefaultBorder();
+        borderEnd = BorderSpecification.getDefaultBorder();
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java Fri Dec 14 13:14:12 2007
@@ -164,13 +164,13 @@
     }
 
     /** {@inheritDoc} */
-    void endTablePart(TableBody tableBody) throws ValidationException {
+    void endTablePart() throws ValidationException {
         if (rows.size() > 0) {
             throw new ValidationException(
                     "A table-cell is spanning more rows than available in its parent element.");
         }
         setFlagForCols(GridUnit.LAST_IN_PART, lastRow);
-        borderResolver.endPart(tableBody);
+        borderResolver.endPart();
         inFooter = false;
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/GridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/GridUnit.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/GridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/GridUnit.java Fri Dec 14 13:14:12 2007
@@ -90,9 +90,12 @@
     /** flags for the grid unit */
     private byte flags = 0;
 
-    protected BorderSpecification[] resolvedBorders;
+    ConditionalBorder borderBefore;
+    ConditionalBorder borderAfter;
+    BorderSpecification borderStart;
+    BorderSpecification borderEnd;
 
-    private CollapsingBorderModel collapsingBorderModel;
+    protected CollapsingBorderModel collapsingBorderModel;
 
     /**
      * Creates a new grid unit.
@@ -156,26 +159,27 @@
         if (table.isSeparateBorderModel()) {
             assignBorderForSeparateBorderModel();
         } else {
-            resolvedBorders = new BorderSpecification[4];
             collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
                     .getBorderCollapse());
-            if (rowSpanIndex == 0) {
-                setBorder(CommonBorderPaddingBackground.BEFORE);
-            }
-            if (isLastGridUnitRowSpan()) {
-                setBorder(CommonBorderPaddingBackground.AFTER);
-            }
-            if (colSpanIndex == 0) {
-                setBorder(CommonBorderPaddingBackground.START);
-            }
-            if (isLastGridUnitColSpan()) {
-                setBorder(CommonBorderPaddingBackground.END);
-            }
+            setBordersFromCell();
         }
     }
 
-    protected void setBorder(int side) {
-        resolvedBorders[side] = cell.resolvedBorders[side];
+    protected void setBordersFromCell() {
+        borderBefore = cell.borderBefore.copy();
+        if (rowSpanIndex > 0) {
+            borderBefore.nonLeadingTrailing = null;
+        }
+        borderAfter = cell.borderAfter.copy();
+        if (!isLastGridUnitRowSpan()) {
+            borderAfter.nonLeadingTrailing = null;
+        }
+        if (colSpanIndex == 0) {
+            borderStart = cell.borderStart;
+        }
+        if (isLastGridUnitColSpan()) {
+            borderEnd = cell.borderEnd;
+        }
     }
 
     public TableCell getCell() {
@@ -301,8 +305,30 @@
     }
 
     private void setBorderInfo(int side) {
-        if (resolvedBorders[side] != null) {
-            effectiveBorders.setBorderInfo(resolvedBorders[side].getBorderInfo(), side);
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            if (borderBefore.nonLeadingTrailing/*TODO*/ != null) {
+                effectiveBorders.setBorderInfo(borderBefore.nonLeadingTrailing.getBorderInfo(),
+                        side);
+            }
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            if (borderAfter.nonLeadingTrailing/*TODO*/ != null) {
+                effectiveBorders.setBorderInfo(borderAfter.nonLeadingTrailing.getBorderInfo(),
+                        side);
+            }
+            break;
+        case CommonBorderPaddingBackground.START:
+            if (borderStart != null) {
+                effectiveBorders.setBorderInfo(borderStart.getBorderInfo(), side);
+            }
+            break;
+        case CommonBorderPaddingBackground.END:
+            if (borderEnd != null) {
+                effectiveBorders.setBorderInfo(borderEnd.getBorderInfo(), side);
+            }
+            break;
+        default: assert false;
         }
     }
 
@@ -332,26 +358,96 @@
      * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
      */
     void resolveBorder(GridUnit other, int side) {
-        BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
-                resolvedBorders[side], other.resolvedBorders[CollapsingBorderModel
-                        .getOtherSide(side)]);
-        if (resolvedBorder != null) {
-            this.resolvedBorders[side] = resolvedBorder;
-            other.resolvedBorders[CollapsingBorderModel.getOtherSide(side)] = resolvedBorder;
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            borderBefore.resolve(other.borderAfter, false, true, false);
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            borderAfter.resolve(other.borderBefore, false, true, false);
+            break;
+        case CommonBorderPaddingBackground.START:
+            BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+                    borderStart, other.borderEnd);
+            if (resolvedBorder != null) {
+                this.borderStart = resolvedBorder;
+                other.borderEnd = resolvedBorder;
+            }
+            break;
+        case CommonBorderPaddingBackground.END:
+            resolvedBorder = collapsingBorderModel.determineWinner(
+                    borderEnd, other.borderStart);
+            if (resolvedBorder != null) {
+                this.borderEnd = resolvedBorder;
+                other.borderStart = resolvedBorder;
+            }
+            break;
+        default: assert false;
         }
     }
 
     /**
-     * Resolves the border on the given side of this grid unit, comparing it against the
-     * same border of the given parent element.
+     * For the given side, integrates in the conflict resolution the border segment of the
+     * given parent element.
      * 
-     * @param side the side to resolve (one of
+     * @param side the side to consider (either CommonBorderPaddingBackground.BEFORE or
+     * AFTER)
+     * @param parent a table element whose corresponding border coincides on the given
+     * side
+     */
+    void integrateBorderSegment(int side, TableFObj parent, boolean withLeadingTrailing,
+            boolean withNonLeadingTrailing, boolean withRest) {
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            borderBefore.integrateSegment(parent.borderBefore, withLeadingTrailing,
+                    withNonLeadingTrailing, withRest);
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            borderAfter.integrateSegment(parent.borderAfter, withLeadingTrailing,
+                    withNonLeadingTrailing, withRest);
+            break;
+        default: assert false;
+        }
+    }
+
+    /**
+     * For the given side, integrates in the conflict resolution the border segment of the
+     * given parent element.
+     * 
+     * @param side the side to consider (one of
      * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
-     * @param parent the parent element holding a competing border
+     * @param parent a table element whose corresponding border coincides on the given side
      */
-    void resolveBorder(int side, TableFObj parent) {
-        resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
-                parent.resolvedBorders[side]);
+    void integrateBorderSegment(int side, TableFObj parent) {
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+        case CommonBorderPaddingBackground.AFTER:
+            integrateBorderSegment(side, parent, true, true, true);
+            break;
+        case CommonBorderPaddingBackground.START:
+            borderStart = collapsingBorderModel.determineWinner(borderStart,
+                    parent.borderStart);
+            break;
+        case CommonBorderPaddingBackground.END:
+            borderEnd = collapsingBorderModel.determineWinner(borderEnd,
+                    parent.borderEnd);
+            break;
+        default: assert false;
+        }
+    }
+
+    void integrateCompetingBorder(int side, ConditionalBorder competitor,
+            boolean withLeadingTrailing, boolean withNonLeadingTrailing, boolean withRest) {
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            borderBefore.integrateCompetingSegment(competitor, withLeadingTrailing,
+                    withNonLeadingTrailing, withRest);
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            borderAfter.integrateCompetingSegment(competitor, withLeadingTrailing,
+                    withNonLeadingTrailing, withRest);
+            break;
+        default: assert false;
+        }
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java Fri Dec 14 13:14:12 2007
@@ -77,10 +77,9 @@
      * row-group is checked for emptiness. This row group builder is reset for handling
      * further possible table parts.
      * 
-     * @param tableBody the table part being ended
      * @throws ValidationException if a row-spanning cell overflows the given table part
      */
-    abstract void endTablePart(TableBody tableBody) throws ValidationException;
+    abstract void endTablePart() throws ValidationException;
 
     /**
      * Receives notification of the end of the table.

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java Fri Dec 14 13:14:12 2007
@@ -35,7 +35,7 @@
     }
 
     /** {@inheritDoc} */
-    public void endPart(TableBody part) {
+    public void endPart() {
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/Table.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/Table.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/Table.java Fri Dec 14 13:14:12 2007
@@ -192,9 +192,17 @@
                     tooManyNodesError(loc, "table-footer");
                 } else {
                     tableFooterFound = true;
-                    if (tableBodyFound && getUserAgent().validateStrictly()) {
-                        nodesOutOfOrderError(loc, "fo:table-footer",
-                            "(table-body+)");
+                    if (tableBodyFound) {
+                        if (getUserAgent().validateStrictly()) {
+                            nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)");
+                        } else if (!isSeparateBorderModel()) {
+                            nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)."
+                                    + " This table uses the collapsing border"
+                                    + " model. In order to resolve borders in an efficient way"
+                                    + " the table-footer must be known before any table-body"
+                                    + " is parsed. Either put the footer at the correct place"
+                                    + " or switch to the separate border model");
+                        }
                     }
                 }
             } else if ("table-body".equals(localName)) {

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableBody.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableBody.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableBody.java Fri Dec 14 13:14:12 2007
@@ -138,14 +138,14 @@
 
     protected void finishLastRowGroup() throws ValidationException {
         if (!inMarker()) {
-            RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder(); 
+            RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
             if (tableRowsFound) {
                 rowGroupBuilder.endRow(lastRow);
             } else if (!lastCellEndsRow) {
                 rowGroupBuilder.endRow(this);
             }
             try {
-                rowGroupBuilder.endTablePart(this);
+                rowGroupBuilder.endTablePart();
             } catch (ValidationException e) {
                 e.setLocator(locator);
                 throw e;
@@ -211,7 +211,7 @@
                 rowsStarted = true;
                 TableCell cell = (TableCell) child;
                 addTableCellChild(cell, firstRow);
-                lastCellEndsRow = cell.endsRow(); 
+                lastCellEndsRow = cell.endsRow();
                 if (lastCellEndsRow) {
                     firstRow = false;
                     columnNumberManager.prepareForNextRow(pendingSpans);
@@ -259,6 +259,10 @@
      */
     public int getNameId() {
         return FO_TABLE_BODY;
+    }
+
+    protected boolean isTableHeader() {
+        return false;
     }
 
     protected boolean isTableFooter() {

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableCell.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableCell.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableCell.java Fri Dec 14 13:14:12 2007
@@ -138,15 +138,8 @@
     protected void setCollapsedBorders() {
         createBorder(CommonBorderPaddingBackground.BEFORE);
         createBorder(CommonBorderPaddingBackground.AFTER);
-        Table table = getTable();
-        if (table.hasExplicitColumns()) {
-            TableColumn col = table.getColumn(getColumnNumber() - 1);
-            createBorder(CommonBorderPaddingBackground.START, col);
-            createBorder(CommonBorderPaddingBackground.END, col);
-        } else {
-            createBorder(CommonBorderPaddingBackground.START);
-            createBorder(CommonBorderPaddingBackground.END);
-        }
+        createBorder(CommonBorderPaddingBackground.START);
+        createBorder(CommonBorderPaddingBackground.END);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableFObj.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableFObj.java Fri Dec 14 13:14:12 2007
@@ -42,10 +42,13 @@
     private Numeric borderEndPrecedence;
     private Numeric borderStartPrecedence;
 
-    BorderSpecification[] resolvedBorders = new BorderSpecification[4]; // TODO
+    ConditionalBorder borderBefore;
+    ConditionalBorder borderAfter;
+    BorderSpecification borderStart;
+    BorderSpecification borderEnd;
 
     CollapsingBorderModel collapsingBorderModel;
-    
+
     /**
      * Main constructor
      * 
@@ -200,13 +203,12 @@
         if (!inMarker() && !table.isSeparateBorderModel()) {
             collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
                     .getBorderCollapse());
-            resolvedBorders = new BorderSpecification[4];
             setCollapsedBorders();
         }
     }
 
     /*
-     * TODO made public so that RetrieveMarker can access it.  
+     * TODO made public so that RetrieveMarker can access it.
      */
     /** {@inheritDoc} */
     public void endOfNode() throws FOPException {
@@ -226,8 +228,23 @@
      * @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END
      */
     protected void createBorder(int side) {
-        resolvedBorders[side] = new BorderSpecification(getCommonBorderPaddingBackground()
-                .getBorderInfo(side), getNameId()); 
+        BorderSpecification borderSpec = new BorderSpecification(
+                getCommonBorderPaddingBackground().getBorderInfo(side), getNameId());
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel);
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel);
+            break;
+        case CommonBorderPaddingBackground.START:
+            borderStart = borderSpec;
+            break;
+        case CommonBorderPaddingBackground.END:
+            borderEnd = borderSpec;
+            break;
+        default: assert false;
+        }
     }
 
     /**
@@ -240,7 +257,22 @@
      */
     protected void createBorder(int side, TableFObj competitor) {
         createBorder(side);
-        resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
-                competitor.resolvedBorders[side]);
+        switch (side) {
+        case CommonBorderPaddingBackground.BEFORE:
+            borderBefore.integrateSegment(competitor.borderBefore, true, true, true);
+            break;
+        case CommonBorderPaddingBackground.AFTER:
+            borderAfter.integrateSegment(competitor.borderAfter, true, true, true);
+            break;
+        case CommonBorderPaddingBackground.START:
+            borderStart = collapsingBorderModel.determineWinner(borderStart,
+                    competitor.borderStart);
+            break;
+        case CommonBorderPaddingBackground.END:
+            borderEnd = collapsingBorderModel.determineWinner(borderEnd,
+                    competitor.borderEnd);
+            break;
+        default: assert false;
+        }
     }
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableHeader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableHeader.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableHeader.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/TableHeader.java Fri Dec 14 13:14:12 2007
@@ -66,4 +66,9 @@
     public int getNameId() {
         return FO_TABLE_HEADER;
     }
+
+    /** {@inheritDoc} */
+    protected boolean isTableHeader() {
+        return true;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java Fri Dec 14 13:14:12 2007
@@ -91,11 +91,11 @@
     }
 
     /** {@inheritDoc} */
-    void endTablePart(final TableBody tableBody) throws ValidationException {
+    void endTablePart() throws ValidationException {
         // TODO catch the ValidationException sooner?
         events.add(new Event() {
             public void play(RowGroupBuilder rowGroupBuilder) throws ValidationException {
-                rowGroupBuilder.endTablePart(tableBody);
+                rowGroupBuilder.endTablePart();
             }
         });
     }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java Fri Dec 14 13:14:12 2007
@@ -66,20 +66,20 @@
      * The "background-position-vertical" property.
      */
     public Length backgroundPositionVertical;
-    
-    
+
+
     private ImageInfo backgroundImageInfo;
-    
-    
-    /** the "before" edge */ 
+
+
+    /** the "before" edge */
     public static final int BEFORE = 0;
-    /** the "after" edge */ 
+    /** the "after" edge */
     public static final int AFTER = 1;
-    /** the "start" edge */ 
+    /** the "start" edge */
     public static final int START = 2;
-    /** the "end" edge */ 
+    /** the "end" edge */
     public static final int END = 3;
-    
+
     public static class BorderInfo {
         private int mStyle; // Enum for border style
         private Color mColor; // Border color
@@ -90,15 +90,15 @@
             mWidth = width;
             mColor = color;
         }
-        
+
         public int getStyle() {
             return this.mStyle;
         }
-        
+
         public Color getColor() {
             return this.mColor;
         }
-        
+
         public CondLengthProperty getWidth() {
             return this.mWidth;
         }
@@ -111,7 +111,7 @@
                 return mWidth.getLengthValue();
             }
         }
-        
+
         /** {@inheritDoc} */
         public String toString() {
             StringBuffer sb = new StringBuffer("BorderInfo");
@@ -133,14 +133,68 @@
     private static BorderInfo defaultBorderInfo;
 
     /**
+     * A conditional length of value 0. Returned by the
+     * {@link CommonBorderPaddingBackground#getBorderInfo(int)} method when the
+     * corresponding border isn't specified, to avoid to callers painful checks for null.
+     */
+    private static class ConditionalNullLength extends CondLengthProperty {
+
+        /** {@inheritDoc} */
+        public Property getComponent(int cmpId) {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        public Property getConditionality() {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        public Length getLength() {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        public Property getLengthComponent() {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        public int getLengthValue() {
+            return 0;
+        }
+
+        /** {@inheritDoc} */
+        public int getLengthValue(PercentBaseContext context) {
+            return 0;
+        }
+
+        /** {@inheritDoc} */
+        public boolean isDiscard() {
+            return true;
+        }
+
+        /** {@inheritDoc} */
+        public void setComponent(int cmpId, Property cmpnValue, boolean isDefault) {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return "CondLength[0mpt, discard]";
+        }
+    }
+
+    /**
      * Returns a default BorderInfo of style none.
      * 
      * @return a BorderInfo instance with style set to {@link Constants#EN_NONE}
      */
     public static synchronized BorderInfo getDefaultBorderInfo() {
         if (defaultBorderInfo == null) {
-            /* It is enough to set color and width to null, as they should never be consulted */
-            defaultBorderInfo = new BorderInfo(Constants.EN_NONE, null, null);
+            /* It is enough to set color to null, as it should never be consulted */
+            defaultBorderInfo = new BorderInfo(Constants.EN_NONE,
+                    new ConditionalNullLength(), null);
         }
         return defaultBorderInfo;
     }
@@ -152,9 +206,8 @@
      * Construct a CommonBorderPaddingBackground object.
      */
     public CommonBorderPaddingBackground() {
-        
     }
-    
+
     /**
      * Construct a CommonBorderPaddingBackground object.
      * 
@@ -162,7 +215,7 @@
      * @throws PropertyException if there's an error while binding the properties
      */
     public CommonBorderPaddingBackground(PropertyList pList) throws PropertyException {
-        
+
         backgroundAttachment = pList.get(Constants.PR_BACKGROUND_ATTACHMENT).getEnum();
         backgroundColor = pList.get(Constants.PR_BACKGROUND_COLOR).getColor(
                                         pList.getFObj().getUserAgent());
@@ -179,7 +232,7 @@
                     Constants.PR_BACKGROUND_POSITION_HORIZONTAL).getLength();
             backgroundPositionVertical = pList.get(
                     Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();
-            
+
             //Additional processing: preload image
             String uri = ImageFactory.getURL(backgroundImage);
             FOUserAgent userAgent = pList.getFObj().getUserAgent();
@@ -195,30 +248,30 @@
             //TODO Report to caller so he can decide to throw an exception
         }
 
-        initBorderInfo(pList, BEFORE, 
-                Constants.PR_BORDER_BEFORE_COLOR, 
-                Constants.PR_BORDER_BEFORE_STYLE, 
-                Constants.PR_BORDER_BEFORE_WIDTH, 
+        initBorderInfo(pList, BEFORE,
+                Constants.PR_BORDER_BEFORE_COLOR,
+                Constants.PR_BORDER_BEFORE_STYLE,
+                Constants.PR_BORDER_BEFORE_WIDTH,
                 Constants.PR_PADDING_BEFORE);
-        initBorderInfo(pList, AFTER, 
-                Constants.PR_BORDER_AFTER_COLOR, 
-                Constants.PR_BORDER_AFTER_STYLE, 
-                Constants.PR_BORDER_AFTER_WIDTH, 
+        initBorderInfo(pList, AFTER,
+                Constants.PR_BORDER_AFTER_COLOR,
+                Constants.PR_BORDER_AFTER_STYLE,
+                Constants.PR_BORDER_AFTER_WIDTH,
                 Constants.PR_PADDING_AFTER);
-        initBorderInfo(pList, START, 
-                Constants.PR_BORDER_START_COLOR, 
-                Constants.PR_BORDER_START_STYLE, 
-                Constants.PR_BORDER_START_WIDTH, 
+        initBorderInfo(pList, START,
+                Constants.PR_BORDER_START_COLOR,
+                Constants.PR_BORDER_START_STYLE,
+                Constants.PR_BORDER_START_WIDTH,
                 Constants.PR_PADDING_START);
-        initBorderInfo(pList, END, 
-                Constants.PR_BORDER_END_COLOR, 
-                Constants.PR_BORDER_END_STYLE, 
-                Constants.PR_BORDER_END_WIDTH, 
+        initBorderInfo(pList, END,
+                Constants.PR_BORDER_END_COLOR,
+                Constants.PR_BORDER_END_STYLE,
+                Constants.PR_BORDER_END_WIDTH,
                 Constants.PR_PADDING_END);
 
     }
 
-    private void initBorderInfo(PropertyList pList, int side, 
+    private void initBorderInfo(PropertyList pList, int side,
                     int colorProp, int styleProp, int widthProp, int paddingProp)
                 throws PropertyException {
         padding[side] = pList.get(paddingProp).getCondLength();
@@ -231,7 +284,7 @@
                 pList.get(colorProp).getColor(ua)), side);
         }
     }
-    
+
     /**
      * Sets a border.
      * @param info the border information
@@ -240,7 +293,7 @@
     public void setBorderInfo(BorderInfo info, int side) {
         this.borderInfo[side] = info;
     }
-    
+
     /**
      * @param side the side to retrieve
      * @return the border info for a side
@@ -252,7 +305,7 @@
             return this.borderInfo[side];
         }
     }
-    
+
     /**
      * Set padding.
      * @param source the padding info to copy from
@@ -260,7 +313,7 @@
     public void setPadding(CommonBorderPaddingBackground source) {
         this.padding = source.padding;
     }
-    
+
     /**
      * @return the background image info object, null if there is
      *     no background image.
@@ -268,7 +321,7 @@
     public ImageInfo getImageInfo() {
         return this.backgroundImageInfo;
     }
-    
+
     /**
      * @param bDiscard indicates whether the .conditionality component should be
      * considered (start of a reference-area)
@@ -351,7 +404,7 @@
             return padding[side].getLengthValue(context);
         }
     }
-    
+
     /**
      * Returns the CondLengthProperty for the padding on one side.
      * @param side the side
@@ -362,21 +415,21 @@
     }
 
     /**
-     * Return all the border and padding width in the inline progression 
+     * Return all the border and padding width in the inline progression
      * dimension.
      * @param bDiscard the discard flag.
      * @param context for percentage evaluation.
      * @return all the padding and border width.
      */
     public int getIPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
-        return getPaddingStart(bDiscard, context) 
-            + getPaddingEnd(bDiscard, context) 
-            + getBorderStartWidth(bDiscard) 
-            + getBorderEndWidth(bDiscard);        
+        return getPaddingStart(bDiscard, context)
+            + getPaddingEnd(bDiscard, context)
+            + getBorderStartWidth(bDiscard)
+            + getBorderEndWidth(bDiscard);
     }
-    
+
     /**
-     * Return all the border and padding height in the block progression 
+     * Return all the border and padding height in the block progression
      * dimension.
      * @param bDiscard the discard flag.
      * @param context for percentage evaluation
@@ -384,7 +437,7 @@
      */
     public int getBPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
         return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context)
-               + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);        
+               + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);
     }
 
     /** {@inheritDoc} */
@@ -394,7 +447,7 @@
             + getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n"
             + "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", "
             + getBorderColor(START) + ", " + getBorderColor(END) + ")\n"
-            + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null) 
+            + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null)
             + ", " + getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n";
     }
 
@@ -407,19 +460,19 @@
 
     /** @return true if border is non-zero. */
     public boolean hasBorder() {
-        return ((getBorderBeforeWidth(false) + getBorderAfterWidth(false) 
+        return ((getBorderBeforeWidth(false) + getBorderAfterWidth(false)
                 + getBorderStartWidth(false) + getBorderEndWidth(false)) > 0);
     }
 
     /** 
      * @param context for percentage based evaluation.
-     * @return true if padding is non-zero. 
+     * @return true if padding is non-zero.
      */
     public boolean hasPadding(PercentBaseContext context) {
-        return ((getPaddingBefore(false, context) + getPaddingAfter(false, context) 
+        return ((getPaddingBefore(false, context) + getPaddingAfter(false, context)
                 + getPaddingStart(false, context) + getPaddingEnd(false, context)) > 0);
     }
-    
+
     /** @return true if there are any borders defined. */
     public boolean hasBorderInfo() {
         return (borderInfo[BEFORE] != null || borderInfo[AFTER] != null

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -130,45 +130,6 @@
     }
 
     /**
-     * Reset the layoutmanager "iterator" so that it will start
-     * with the passed Position's generating LM
-     * on the next call to getChildLM.
-     * @param pos a Position returned by a child layout manager
-     * representing a potential break decision.
-     * If pos is null, then back up to the first child LM.
-     */
-    protected void reset(org.apache.fop.layoutmgr.Position pos) {
-        //if (lm == null) return;
-        LayoutManager lm = (pos != null) ? pos.getLM() : null;
-        if (curChildLM != lm) {
-            // ASSERT curChildLM == (LayoutManager)childLMiter.previous()
-            if (childLMiter.hasPrevious() && curChildLM
-                    != (LayoutManager) childLMiter.previous()) {
-                //log.error("LMiter problem!");
-            }
-            while (curChildLM != lm && childLMiter.hasPrevious()) {
-                curChildLM.resetPosition(null);
-                curChildLM = (LayoutManager) childLMiter.previous();
-            }
-            // Otherwise next returns same object
-            childLMiter.next();
-        }
-        if (curChildLM != null) {
-            curChildLM.resetPosition(pos);
-        }
-        if (isFinished()) {
-            setFinished(false);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void resetPosition(Position resetPos) {
-        //  if (resetPos == null) {
-        //      reset(null);
-        //  }
-    }
-
-    /**
      * Tell whether this LayoutManager has handled all of its content.
      * @return True if there are no more break possibilities,
      * ie. the last one returned represents the end of the content.

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -938,15 +938,6 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
-
     /** 
      * Force current area to be added to parent area.
      * {@inheritDoc}

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -477,19 +477,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-            childBreaks.clear();
-        } else {
-            //reset(resetPos);
-            LayoutManager lm = resetPos.getLM();
-        }
-    }
-
-    /**
      * convenience method that returns the Block node
      * @return the block node
      */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Fri Dec 14 13:14:12 2007
@@ -31,31 +31,6 @@
 public class ElementListUtils {
 
     /**
-     * Removes all legal breaks in an element list.
-     * @param elements the element list
-     */
-    public static void removeLegalBreaks(LinkedList elements) {
-        ListIterator i = elements.listIterator();
-        while (i.hasNext()) {
-            ListElement el = (ListElement)i.next();
-            if (el.isPenalty()) {
-                BreakElement breakPoss = (BreakElement)el;
-                //Convert all penalties no break inhibitors
-                if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) {
-                    breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
-                }
-            } else if (el.isGlue()) {
-                i.previous();
-                if (el.isBox()) {
-                    i.next();
-                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
-                            null, false));
-                }
-            }
-        }
-    }
-    
-    /**
      * Removes legal breaks in an element list. A constraint can be specified to limit the
      * range in which the breaks are removed. Legal breaks occuring before at least 
      * constraint.opt space is filled will be removed.
@@ -66,7 +41,7 @@
     public static boolean removeLegalBreaks(LinkedList elements, MinOptMax constraint) {
         return removeLegalBreaks(elements, constraint.opt);
     }
-    
+
     /**
      * Removes legal breaks in an element list. A constraint can be specified to limit the
      * range in which the breaks are removed. Legal breaks occuring before at least 
@@ -84,7 +59,7 @@
                 KnuthPenalty penalty = (KnuthPenalty)el;
                 //Convert all penalties to break inhibitors
                 if (penalty.getP() < KnuthPenalty.INFINITE) {
-                    iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, 
+                    iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
                             penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
                 }
             } else if (el.isGlue()) {
@@ -94,7 +69,7 @@
                 el = (ListElement)iter.previous();
                 iter.next();
                 if (el.isBox()) {
-                    iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
+                    iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
                             null, false));
                 }
                 iter.next();
@@ -131,7 +106,7 @@
                 KnuthPenalty penalty = (KnuthPenalty)el;
                 //Convert all penalties to break inhibitors
                 if (penalty.getP() < KnuthPenalty.INFINITE) {
-                    i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, 
+                    i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE,
                             penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary()));
                 }
             } else if (el.isGlue()) {
@@ -140,7 +115,7 @@
                 el = (ListElement)i.previous();
                 i.next();
                 if (el.isBox()) {
-                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, 
+                    i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
                             null, false));
                 }
             } else if (el.isUnresolvedElement()) {
@@ -163,7 +138,7 @@
         }
         return true;
     }
-    
+
     /**
      * Calculates the content length of the given element list. Warning: It doesn't take any
      * stretch and shrink possibilities into account.
@@ -193,7 +168,7 @@
         }
         return len;
     }
-    
+
     /**
      * Calculates the content length of the given element list. Warning: It doesn't take any
      * stretch and shrink possibilities into account.
@@ -203,7 +178,7 @@
     public static int calcContentLength(List elems) {
         return calcContentLength(elems, 0, elems.size() - 1);
     }
-    
+
     /**
      * Indicates whether the given element list ends with a forced break.
      * @param elems the element list
@@ -213,7 +188,7 @@
         ListElement last = (ListElement)elems.getLast();
         return last.isForcedBreak();
     }
-    
+
     /**
      * Determines the position of the previous break before the start index on an
      * element list.
@@ -232,5 +207,5 @@
         }
         return prevBreak;
     }
-    
+
 }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -343,14 +343,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public void resetPosition(Position resetPos) {
-        if (resetPos == null) {
-            reset(null);
-        }
-    }
-    /**
      * Returns the IPD of the content area
      * @return the IPD of the content area
      */

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/LayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/LayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/LayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/LayoutManager.java Fri Dec 14 13:14:12 2007
@@ -59,13 +59,6 @@
     PageSequenceLayoutManager getPSLM();
 
     /**
-     * Reset to the position.
-     *
-     * @param position the Position to reset to
-     */
-    void resetPosition(Position position);
-
-    /**
      * Return a value indicating whether this LayoutManager has laid out
      * all its content (or generated BreakPossibilities for all content.)
      *

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -215,13 +215,6 @@
     /**
      * {@inheritDoc}
      */
-    public void resetPosition(Position position) {
-        //to be done
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean createNextChildLMs(int pos) {
         return false;
     }

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=604297&r1=604296&r2=604297&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Fri Dec 14 13:14:12 2007
@@ -155,41 +155,6 @@
     }
 
     /**
-     * Reset position for returning next BreakPossibility.
-     * @param prevPos a Position returned by this layout manager
-     * representing a potential break decision.
-     */
-    public void resetPosition(Position prevPos) {
-        if (prevPos != null) {
-            // ASSERT (prevPos.getLM() == this)
-            if (prevPos.getLM() != this) {
-                //getLogger().error(
-                //  "InlineStackingLayoutManager.resetPosition: " +
-                //  "LM mismatch!!!");
-            }
-            // Back up the child LM Position
-            Position childPos = prevPos.getPosition();
-            reset(childPos);
-            /*
-            if (prevBP != null
-                    && prevBP.getLayoutManager() != childPos.getLM()) {
-                childLC = null;
-            }
-            prevBP = new BreakPoss(childPos);
-            */
-        } else {
-            // Backup to start of first child layout manager
-            //prevBP = null;
-            // super.resetPosition(prevPos);
-            reset(prevPos);
-            // If any areas created, we are restarting!
-            bAreaCreated = false;
-        }
-        // Do we need to reset some context like pending or prevContent?
-        // What about prevBP?
-    }
-
-    /**
      * TODO: Explain this method
      * @param lm ???
      * @return ???



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