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 sp...@apache.org on 2008/01/10 20:58:31 UTC

svn commit: r610906 [2/4] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/e...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EffRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EffRow.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EffRow.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EffRow.java Thu Jan 10 11:58:23 2008
@@ -80,13 +80,20 @@
         return getGridUnit(0).getRow();
     }
     
-    /** @return the calculated height for this EffRow. */
+    /**
+     * Returns the calculated height for this EffRow, including the cells'
+     * bpds/paddings/borders, and the table's border-separation.
+     * 
+     * @return the row's height
+     */
     public MinOptMax getHeight() {
         return this.height;
     }
     
     /**
-     * Sets the calculated height for this EffRow.
+     * Sets the calculated height for this EffRow, including everything (cells' bpds,
+     * paddings, borders, and border-separation).
+     * 
      * @param mom the calculated height
      */
     public void setHeight(MinOptMax mom) {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/GridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/GridUnit.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/GridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/GridUnit.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java Thu Jan 10 11:58:23 2008
@@ -24,6 +24,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
 
 /**
@@ -142,13 +143,11 @@
         return getHalfMaxBeforeBorderWidth() + getHalfMaxAfterBorderWidth();
     }
 
-    /** @param value The length of the cell content to remember. */
-    public void setContentLength(int value) {
-        this.contentLength = value;
-    }
-
     /** @return the length of the cell content. */
     public int getContentLength() {
+        if (contentLength < 0) {
+            contentLength = ElementListUtils.calcContentLength(elements);
+        }
         return contentLength;
     }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java Thu Jan 10 11:58:23 2008
@@ -35,7 +35,7 @@
     }
 
     /** {@inheritDoc} */
-    public void endPart(TableBody part) {
+    public void endPart() {
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/Table.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/Table.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/Table.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableBody.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableBody.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableBody.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableCell.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableCell.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableCell.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableFObj.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableFObj.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableHeader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableHeader.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableHeader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/TableHeader.java Thu Jan 10 11:58:23 2008
@@ -66,4 +66,9 @@
     public int getNameId() {
         return FO_TABLE_HEADER;
     }
+
+    /** {@inheritDoc} */
+    protected boolean isTableHeader() {
+        return true;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java Thu Jan 10 11:58:23 2008
@@ -93,14 +93,20 @@
      * @param isFirstPage True if page is first page
      * @param isLastPage True if page is last page
      * @param isBlankPage True if page is blank
+     * @param isOnlyPage True if page is the only page
      * @return True if the conditions for this reference are met
      */
     protected boolean isValid(boolean isOddPage,
                               boolean isFirstPage,
                               boolean isLastPage,
+                              boolean isOnlyPage,
                               boolean isBlankPage) {
         // page-position
-        if (isFirstPage) {
+        if (isOnlyPage) {
+            if (pagePosition != EN_ONLY) {
+                return false;
+            }
+        } else if (isFirstPage) {
             if (pagePosition == EN_REST) {
                 return false;
             } else if (pagePosition == EN_LAST) {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java Thu Jan 10 11:58:23 2008
@@ -25,32 +25,22 @@
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 
 /**
- * Implementation of the fo:page-sequence formatting object.
+ * Abstract base implementation for page sequences.
  */
-public class PageSequence extends FObj {
+public class PageSequence extends AbstractPageSequence {
     
     // The value of properties relevant for fo:page-sequence.
     private String country;
-    private String format;
     private String language;
-    private int letterValue;
-    private char groupingSeparator;
-    private int groupingSize;
-    private Numeric initialPageNumber;
-    private int forcePageCount;
     private String masterReference;
+    //private int writingMode; //XSL 1.1
     // End of property values
 
-    /** The parent root object */
-    private Root root;
-
     // There doesn't seem to be anything in the spec requiring flows
     // to be in the order given, only that they map to the regions
     // defined in the page sequence, so all we need is this one hashmap
@@ -59,9 +49,6 @@
     /** Map of flows to their flow name (flow-name, Flow) */
     private Map flowMap;
 
-    private int startingPageNumber = 0;
-    private PageNumberGenerator pageNumberGenerator;
-
     /**
      * The currentSimplePageMaster is either the page master for the
      * whole page sequence if master-reference refers to a simple-page-master,
@@ -97,14 +84,9 @@
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
         country = pList.get(PR_COUNTRY).getString();
-        format = pList.get(PR_FORMAT).getString();
         language = pList.get(PR_LANGUAGE).getString();
-        letterValue = pList.get(PR_LETTER_VALUE).getEnum();
-        groupingSeparator = pList.get(PR_GROUPING_SEPARATOR).getCharacter();
-        groupingSize = pList.get(PR_GROUPING_SIZE).getNumber().intValue();
-        initialPageNumber = pList.get(PR_INITIAL_PAGE_NUMBER).getNumeric();
-        forcePageCount = pList.get(PR_FORCE_PAGE_COUNT).getEnum();
         masterReference = pList.get(PR_MASTER_REFERENCE).getString();
+        //writingMode = pList.getWritingMode();
         
         if (masterReference == null || masterReference.equals("")) {
             missingPropertyError("master-reference");
@@ -116,13 +98,12 @@
      */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        this.root = (Root) parent;
         flowMap = new java.util.HashMap();
 
-        this.simplePageMaster = root.getLayoutMasterSet().getSimplePageMaster(masterReference);
+        this.simplePageMaster = getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference);
         if (this.simplePageMaster == null) {
             this.pageSequenceMaster
-                    = root.getLayoutMasterSet().getPageSequenceMaster(masterReference);
+                    = getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
             if (this.pageSequenceMaster == null) {
                 throw new ValidationException("master-reference '" + masterReference
                    + "' for fo:page-sequence matches no"
@@ -130,9 +111,6 @@
             }
         }
 
-        this.pageNumberGenerator = new PageNumberGenerator(
-                format, groupingSeparator, groupingSize, letterValue);
-
         getFOEventHandler().startPageSequence(this);
     }
 
@@ -211,7 +189,7 @@
                 + "\" found within fo:page-sequence", flow.getLocator());
         }
 
-        if (!root.getLayoutMasterSet().regionNameExists(flowName) 
+        if (!getRoot().getLayoutMasterSet().regionNameExists(flowName) 
             && !flowName.equals("xsl-before-float-separator") 
             && !flowName.equals("xsl-footnote-separator")) {
                 throw new ValidationException("flow-name \""
@@ -221,31 +199,6 @@
         }
     }
 
-    /**
-     * Initialize the current page number for the start of the page sequence.
-     */
-    public void initPageNumber() {
-        int pageNumberType = 0;
-        
-        if (initialPageNumber.getEnum() != 0) {
-            // auto | auto-odd | auto-even.
-            startingPageNumber = root.getEndingPageNumberOfPreviousSequence() + 1;
-            pageNumberType = initialPageNumber.getEnum();
-            if (pageNumberType == EN_AUTO_ODD) {
-                if (startingPageNumber % 2 == 0) {
-                    startingPageNumber++;
-                }
-            } else if (pageNumberType == EN_AUTO_EVEN) {
-                if (startingPageNumber % 2 == 1) {
-                    startingPageNumber++;
-                }
-            }
-        } else { // <integer> for explicit page number
-            int pageStart = initialPageNumber.getValue();
-            startingPageNumber = (pageStart > 0) ? pageStart : 1; // spec rule
-        }
-    }
-
 //     /**
 //      * Returns true when there is more flow elements left to lay out.
 //      */
@@ -306,15 +259,6 @@
 //          return false;
 //      }
 
-    /**
-     * Get the starting page number for this page sequence.
-     *
-     * @return the starting page number
-     */
-    public int getStartingPageNumber() {
-        return startingPageNumber;
-    }
-
 //     private void forcePage(AreaTree areaTree, int firstAvailPageNumber) {
 //         boolean makePage = false;
 //         if (this.forcePageCount == ForcePageCount.AUTO) {
@@ -433,6 +377,8 @@
      *      page sequence
      * @param isLastPage indicator whether this page is the last page of the
      *      page sequence
+     * @param isOnlyPage indicator whether this page is the only page of the
+     *      page sequence
      * @param isBlank indicator whether the page will be blank
      * @return the SimplePageMaster to use for this page
      * @throws FOPException if there's a problem determining the page master
@@ -440,6 +386,7 @@
     public SimplePageMaster getNextSimplePageMaster(int page, 
             boolean isFirstPage,  
             boolean isLastPage,  
+            boolean isOnlyPage,
             boolean isBlank) throws FOPException {
 
         if (pageSequenceMaster == null) {
@@ -450,11 +397,12 @@
             log.debug("getNextSimplePageMaster(page=" + page
                     + " isOdd=" + isOddPage 
                     + " isFirst=" + isFirstPage 
-                    + " isLast=" + isLastPage 
+                    + " isLast=" + isLastPage
+                    + " isOnly=" + isOnlyPage
                     + " isBlank=" + isBlank + ")");
         }
         return pageSequenceMaster.getNextSimplePageMaster(isOddPage, 
-            isFirstPage, isLastPage, isBlank);
+            isFirstPage, isLastPage, isOnlyPage, isBlank);
     }
 
     /**
@@ -478,24 +426,15 @@
         }
     }
     
-    /**
-     * Retrieves the string representation of a page number applicable
-     * for this page sequence
-     * @param pageNumber the page number
-     * @return string representation of the page number
-     */
-    public String makeFormattedPageNumber(int pageNumber) {
-        return pageNumberGenerator.makeFormattedPageNumber(pageNumber);
-    }
-
-    /**
-     * Public accessor for the ancestor Root.
-     * @return the ancestor Root
-     */
-    public Root getRoot() {
-        return root;
+    /** @return true if the page-sequence has a page-master with page-position="only" */
+    public boolean hasPagePositionOnly() {
+        if (pageSequenceMaster == null) {
+            return false;
+        } else {
+            return pageSequenceMaster.hasPagePositionOnly();
+        }
     }
-
+    
     /** @return the "master-reference" property. */
     public String getMasterReference() {
         return masterReference;
@@ -509,16 +448,6 @@
     /** {@inheritDoc} */
     public int getNameId() {
         return FO_PAGE_SEQUENCE;
-    }
-    
-    /** @return the force-page-count value */
-    public int getForcePageCount() {
-        return forcePageCount;
-    }
-
-    /** @return the initial-page-number property value */
-    public Numeric getInitialPageNumber() {
-        return initialPageNumber;
     }
     
     /** @return the country property value */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java Thu Jan 10 11:58:23 2008
@@ -171,11 +171,21 @@
         }
     }
     
+    /** @return true if the page-sequence-master has a page-master with page-position="only" */
+    public boolean hasPagePositionOnly() {
+        if (currentSubSequence != null) {
+            return currentSubSequence.hasPagePositionOnly();
+        } else {
+            return false;
+        }
+    }
+    
     /**
      * Returns the next simple-page-master.
      * @param isOddPage True if the next page number is odd
      * @param isFirstPage True if the next page is the first
      * @param isLastPage True if the next page is the last
+     * @param isOnlyPage True if the next page is the only page
      * @param isBlankPage True if the next page is blank
      * @return the requested page master
      * @throws FOPException if there's a problem determining the next page master
@@ -183,6 +193,7 @@
     public SimplePageMaster getNextSimplePageMaster(boolean isOddPage,
                                                     boolean isFirstPage,
                                                     boolean isLastPage,
+                                                    boolean isOnlyPage,
                                                     boolean isBlankPage)
                                                       throws FOPException {
         if (currentSubSequence == null) {
@@ -193,7 +204,7 @@
             }
         }
         String pageMasterName = currentSubSequence
-            .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isBlankPage);
+            .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage);
         boolean canRecover = true;
         while (pageMasterName == null) {
             SubSequenceSpecifier nextSubSequence = getNextSubSequence();
@@ -212,7 +223,7 @@
                 currentSubSequence = nextSubSequence;
             }
             pageMasterName = currentSubSequence
-                .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isBlankPage);
+                .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage);
         }
         SimplePageMaster pageMaster = this.layoutMasterSet
             .getSimplePageMaster(pageMasterName);

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java Thu Jan 10 11:58:23 2008
@@ -49,6 +49,7 @@
 
     private List conditionalPageMasterRefs;
     private boolean hasPagePositionLast = false;
+    private boolean hasPagePositionOnly = false;
 
     /**
      * @see org.apache.fop.fo.FONode#FONode(FONode)
@@ -124,6 +125,7 @@
     public String getNextPageMasterName(boolean isOddPage,
                                         boolean isFirstPage,
                                         boolean isLastPage,
+                                        boolean isOnlyPage,
                                         boolean isBlankPage) {
         if (getMaximumRepeats() != INFINITE) {
             if (numberConsumed < getMaximumRepeats()) {
@@ -138,7 +140,7 @@
         for (int i = 0; i < conditionalPageMasterRefs.size(); i++) {
             ConditionalPageMasterReference cpmr
                 = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i);
-            if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
+            if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage)) {
                 return cpmr.getMasterReference();
             }
         }
@@ -155,6 +157,9 @@
         if (cpmr.getPagePosition() == EN_LAST) {
             this.hasPagePositionLast = true;
         }
+        if (cpmr.getPagePosition() == EN_ONLY) {
+            this.hasPagePositionOnly = true;
+        }
     }
 
     /** {@inheritDoc} */
@@ -178,6 +183,12 @@
     }
     
     /** {@inheritDoc} */
+    /** @see org.apache.fop.fo.pagination.SubSequenceSpecifier#hasPagePositionOnly() */
+    public boolean hasPagePositionOnly() {
+        return this.hasPagePositionOnly;
+    }
+    
+    /** @see org.apache.fop.fo.FONode#getLocalName() */
     public String getLocalName() {
         return "repeatable-page-master-alternatives";
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java Thu Jan 10 11:58:23 2008
@@ -93,6 +93,7 @@
     public String getNextPageMasterName(boolean isOddPage,
                                         boolean isFirstPage,
                                         boolean isLastPage,
+                                        boolean isOnlyPage,
                                         boolean isEmptyPage) {
         if (getMaximumRepeats() != INFINITE) {
             if (numberConsumed < getMaximumRepeats()) {
@@ -141,6 +142,11 @@
     }
 
     /** {@inheritDoc} */
+    public boolean hasPagePositionOnly() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     public String getLocalName() {
         return "repeatable-page-master-reference";
     }
@@ -149,5 +155,6 @@
     public int getNameId() {
         return FO_REPEATABLE_PAGE_MASTER_REFERENCE;
     }
+
 
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/Root.java Thu Jan 10 11:58:23 2008
@@ -25,6 +25,7 @@
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
@@ -85,7 +86,7 @@
     protected void endOfNode() throws FOPException {
         if (!pageSequenceFound || layoutMasterSet == null) {
             missingChildElementError("(layout-master-set, declarations?, " + 
-                "bookmark-tree?, page-sequence+)");
+                "bookmark-tree?, (page-sequence+|fox:external-document))");
         }
     }
 
@@ -129,7 +130,21 @@
                 invalidChildError(loc, nsURI, localName);
             }
         } else {
-            invalidChildError(loc, nsURI, localName);
+            if (FOX_URI.equals(nsURI)) {
+                if ("external-document".equals(localName)) {
+                    pageSequenceFound = true;
+                }
+            }
+            //invalidChildError(loc, nsURI, localName);
+            //Ignore non-FO elements under root
+        }
+    }
+    
+
+    /** @inheritDoc */
+    protected void validateChildNode(Locator loc, FONode child) throws ValidationException {
+        if (child instanceof AbstractPageSequence) {
+            pageSequenceFound = true;
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java Thu Jan 10 11:58:23 2008
@@ -85,6 +85,7 @@
     public String getNextPageMasterName(boolean isOddPage,
                                         boolean isFirstPage,
                                         boolean isLastPage,
+                                        boolean isOnlyPage,
                                         boolean isEmptyPage) {
         if (this.state == FIRST) {
             this.state = DONE;
@@ -117,6 +118,11 @@
     }
 
     /** {@inheritDoc} */
+    public boolean hasPagePositionOnly() {
+        return false;
+    }
+    
+    /** {@inheritDoc} */
     public String getLocalName() {
         return "single-page-master-reference";
     }
@@ -125,5 +131,6 @@
     public int getNameId() {
         return FO_SINGLE_PAGE_MASTER_REFERENCE;
     }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java Thu Jan 10 11:58:23 2008
@@ -32,6 +32,7 @@
      * @param isOddPage True if the next page number is odd
      * @param isFirstPage True if the next page is the first
      * @param isLastPage True if the next page is the last
+     * @param isOnlyPage True if the next page is the only page
      * @param isBlankPage True if the next page is blank
      * @return the page master name
      * @throws FOPException if there's a problem determining the next page master
@@ -39,6 +40,7 @@
     String getNextPageMasterName(boolean isOddPage,
                                  boolean isFirstPage,
                                  boolean isLastPage,
+                                 boolean isOnlyPage,
                                  boolean isBlankPage)
                                     throws FOPException;
 
@@ -56,6 +58,9 @@
 
     /** @return true if the subsequence has a page master for page-position "last" */
     boolean hasPagePositionLast();
+    
+    /** @return true if the subsequence has a page master for page-position "only" */
+    boolean hasPagePositionOnly();
     
 }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java Thu Jan 10 11:58:23 2008
@@ -64,20 +64,20 @@
      * The "background-position-vertical" property.
      */
     public Length backgroundPositionVertical;
-    
-    
+
+
     private FopImage fopimage;
-    
-    
-    /** 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
@@ -88,15 +88,15 @@
             mWidth = width;
             mColor = color;
         }
-        
+
         public int getStyle() {
             return this.mStyle;
         }
-        
+
         public Color getColor() {
             return this.mColor;
         }
-        
+
         public CondLengthProperty getWidth() {
             return this.mWidth;
         }
@@ -109,7 +109,7 @@
                 return mWidth.getLengthValue();
             }
         }
-        
+
         /** {@inheritDoc} */
         public String toString() {
             StringBuffer sb = new StringBuffer("BorderInfo");
@@ -131,14 +131,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;
     }
@@ -150,9 +204,8 @@
      * Construct a CommonBorderPaddingBackground object.
      */
     public CommonBorderPaddingBackground() {
-        
     }
-    
+
     /**
      * Construct a CommonBorderPaddingBackground object.
      * 
@@ -160,7 +213,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());
@@ -177,7 +230,7 @@
                     Constants.PR_BACKGROUND_POSITION_HORIZONTAL).getLength();
             backgroundPositionVertical = pList.get(
                     Constants.PR_BACKGROUND_POSITION_VERTICAL).getLength();
-            
+
             //Additional processing: preload image
             String url = ImageFactory.getURL(backgroundImage);
             FOUserAgent userAgent = pList.getFObj().getUserAgent();
@@ -188,37 +241,37 @@
             } else {
                 // load dimensions
                 if (!fopimage.load(FopImage.DIMENSIONS)) {
-                    Property.log.error("Cannot read background image dimensions: " 
+                    Property.log.error("Cannot read background image dimensions: "
                             + backgroundImage);
                 }
             }
             //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 as a preloaded FopImage, null if there is
      *     no background image.
@@ -268,7 +321,7 @@
     public FopImage getFopImage() {
         return this.fopimage;
     }
-    
+
     /**
      * @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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -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.
@@ -263,9 +224,7 @@
         return newLMs;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public PageSequenceLayoutManager getPSLM() {
         return parentLM.getPSLM();
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -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_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=610906&r1=610905&r2=610906&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Thu Jan 10 11:58:23 2008
@@ -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
      */



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