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 vh...@apache.org on 2006/11/13 10:39:22 UTC

svn commit: r474218 [2/5] - in /xmlgraphics/fop/branches/Temp_Floats: ./ src/documentation/content/xdocs/trunk/ src/foschema/ src/java-1.4/org/apache/fop/image/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/expr/ src/java/org/apache/fop/fo/flo...

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/RetrieveMarker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/RetrieveMarker.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/RetrieveMarker.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/RetrieveMarker.java Mon Nov 13 01:39:19 2006
@@ -19,24 +19,24 @@
 
 package org.apache.fop.fo.flow;
 
-import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.ArrayList;
-
-import org.xml.sax.Locator;
-
-import org.apache.commons.logging.Log;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FOText;
+import org.apache.fop.fo.FOPropertyMapping;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.properties.Property;
+import org.apache.fop.fo.properties.PropertyMaker;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
 
 
 /**
@@ -44,7 +44,7 @@
  * This will create a layout manager that will retrieve
  * a marker based on the information.
  */
-public class RetrieveMarker extends FObj {
+public class RetrieveMarker extends FObjMixed {
     // The value of properties relevant for fo:retrieve-marker.
     private String retrieveClassName;
     private int retrievePosition;
@@ -78,7 +78,9 @@
         
         if (retrieveClassName == null || retrieveClassName.equals("")) {
             missingPropertyError("retrieve-class-name");
-        }        
+        }
+        
+        propertyList = pList.getParentPropertyList();
     }
     
     /**
@@ -90,40 +92,70 @@
             invalidChildError(loc, nsURI, localName);
     }
 
-    protected PropertyList createPropertyList(PropertyList parent, 
-            FOEventHandler foEventHandler) throws FOPException {
-        // TODO: A special RetrieveMarkerPropertyList would be more memory
-        // efficient. Storing a StaticPropertyList like this will keep all
-        // the parent PropertyLists alive.
-        propertyList = new StaticPropertyList(this, parent);
-        return propertyList;
-    }
-
-    public PropertyList getPropertyList() {
-        return propertyList;
-    }
-
     /**
-     * Return the "retrieve-class-name" property.
+     * @return the "retrieve-class-name" property.
      */
     public String getRetrieveClassName() {
         return retrieveClassName;
     }
 
     /**
-     * Return the "retrieve-position" property.
+     * @return the "retrieve-position" property (enum value).
      */
     public int getRetrievePosition() {
         return retrievePosition;
     }
 
     /**
-     * Return the "retrieve-boundry" property.
+     * @return the "retrieve-boundary" property (enum value).
      */
     public int getRetrieveBoundary() {
         return retrieveBoundary;
     }
+    
+    private PropertyList createPropertyListFor(FObj fo, PropertyList parent) {
+        return getFOEventHandler().getPropertyListMaker().make(fo, parent);
+    }
+
+    private void cloneSingleNode(FONode child, FONode newParent,
+                            Marker marker, PropertyList parentPropertyList)
+        throws FOPException {
 
+        if (child != null) {
+            FONode newChild = child.clone(newParent, true);
+            if (child instanceof FObj) {
+                Marker.MarkerPropertyList pList;
+                PropertyList newPropertyList = createPropertyListFor(
+                            (FObj) newChild, parentPropertyList);
+                
+                pList = marker.getPropertyListFor(child);
+                newChild.processNode(
+                        child.getLocalName(),
+                        getLocator(),
+                        pList,
+                        newPropertyList);
+                if (newChild.getNameId() == FO_TABLE) {
+                    Table t = (Table) child;
+                    cloneSubtree(t.getColumns().listIterator(),
+                            newChild, marker, newPropertyList);
+                    cloneSingleNode(t.getTableHeader(),
+                            newChild, marker, newPropertyList);
+                    cloneSingleNode(t.getTableFooter(),
+                            newChild, marker, newPropertyList);
+                }
+                cloneSubtree(child.getChildNodes(), newChild,
+                        marker, newPropertyList);
+                if (newChild instanceof FObjMixed) {
+                    handleWhiteSpaceFor((FObjMixed) newChild);
+                }
+            } else if (child instanceof FOText) {
+                FOText ft = (FOText) newChild;
+                ft.bind(parentPropertyList);
+            }
+            addChildTo(newChild, (FObj) newParent);
+        }
+    }
+    
     /**
      * Clone the FO nodes in the parent iterator,
      * attach the new nodes to the new parent,
@@ -136,94 +168,48 @@
      * @param descPLists the map of the new nodes to property lists
      */
     private void cloneSubtree(Iterator parentIter, FONode newParent,
-                              Marker marker, Map descPLists)
-        throws FOPException {
-        if (parentIter == null) return;
-        while (parentIter.hasNext()) {
-            FONode child = (FONode) parentIter.next();
-            FONode newChild = child.clone(newParent, true);
-            descPLists.put(newChild, marker.getPList(child));
-            cloneSubtree(child.getChildNodes(), newChild, marker, descPLists);
-        }
-    }
-
-    /**
-     * Clone the subtree of marker,
-     * and attach the new subtree to this node.
-     * The property lists are not cloned;
-     * the existing property lists of the direct children
-     * are reparented to the property list of this node.
-     * @param marker the marker that is to be cloned
-     * @param descPLists the map of the new nodes to property lists
-     */
-    private void cloneFromMarker(Marker marker, Map descPLists)
+                              Marker marker, PropertyList parentPropertyList)
         throws FOPException {
-        // release child nodes from a possible earlier layout
-        childNodes = new ArrayList();
-        Iterator markerIter = marker.getChildNodes();
-        cloneSubtree(markerIter, this, marker, descPLists);
-        // reparent the property lists of the direct children
-        for (Iterator iter = getChildNodes(); iter.hasNext(); ) {
-            FONode child = (FONode) iter.next();
-            Marker.MarkerPropertyList pList
-                = (Marker.MarkerPropertyList) descPLists.get(child);
-            if (pList != null) {
-                pList.setParentPropertyList(propertyList);
+        if (parentIter != null) {
+            FONode child;
+            while (parentIter.hasNext()) {
+                child = (FONode) parentIter.next();
+                cloneSingleNode(child, newParent, 
+                        marker, parentPropertyList);
             }
         }
     }
 
-    /**
-     * Bind the new nodes to the property values in this context
-     * @param descPLists the map of the new nodes to property lists
-     */
-    private void bindChildren(Map descPLists) throws FOPException {
-        for (Iterator i = descPLists.keySet().iterator(); i.hasNext(); ) {
-            FONode desc = (FONode) i.next();
-            PropertyList descPList;
-            if (desc instanceof FObj) {
-                descPList = (PropertyList) descPLists.get(desc);
-                ((FObj) desc).bind(descPList);
-            } else if (desc instanceof FOText) {
-                descPList = (PropertyList) descPLists.get(desc.getParent());
-                if (descPList == null) {
-                    descPList = propertyList;
-                }
-                ((FOText) desc).bind(descPList);
-            }
+    private void cloneFromMarker(Marker marker)
+        throws FOPException {
+        // clean up remnants from a possible earlier layout
+        if (childNodes != null) {
+            currentTextNode = null;
+            childNodes.removeAll(childNodes);
         }
+        cloneSubtree(marker.getChildNodes(), this, 
+                        marker, propertyList);
     }
 
     /**
-     * Clone the subtree of marker
-     * and bind the nodes to the property values in this context.
-     * The property lists are not cloned,
-     * but the subtree is attached to the property list of this node.
-     * This is only needed for the binding of the FO nodes.
-     * After that a subsequent retrieve-marker
-     * may reparent the property lists.
+     * Clone the subtree of the given marker
+     * 
      * @param marker the marker that is to be cloned
      */
     public void bindMarker(Marker marker) {
-        // assert(marker != null);
-        // catch empty marker
-        if (marker.getChildNodes() == null) {
-            return;
-        }
-        HashMap descPLists = new HashMap();
-        try {
-            cloneFromMarker(marker, descPLists);
-        } catch (FOPException exc) {
-            Log log = getLogger();
-            log.error("fo:retrieve-marker unable to clone subtree of fo:marker", exc);
-            return;
-        }
-        try {
-            bindChildren(descPLists);
-        } catch (FOPException exc) {
-            Log log = getLogger();
-            log.error("fo:retrieve-marker unable to rebind property values", exc);
+        if (marker.getChildNodes() != null) {
+            try {
+                cloneFromMarker(marker);
+            } catch (FOPException exc) {
+                log.error("fo:retrieve-marker unable to clone "
+                        + "subtree of fo:marker (marker-class-name="
+                        + marker.getMarkerClassName() + ")", exc);
+                return;
+            }
+        } else if (log.isInfoEnabled()) {
+            log.info("Empty marker retrieved...");
         }
+        return;
     }
 
     /** @see org.apache.fop.fo.FONode#getLocalName() */
@@ -236,5 +222,5 @@
      */
     public int getNameId() {
         return FO_RETRIEVE_MARKER;
-    }
-}
+    }    
+}
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/Table.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/Table.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/Table.java Mon Nov 13 01:39:19 2006
@@ -27,6 +27,7 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.ValidationPercentBaseContext;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
@@ -209,15 +210,19 @@
      * @see org.apache.fop.fo.FONode#endOfNode
      */
     protected void endOfNode() throws FOPException {
+        
         if (!tableBodyFound) {
            missingChildElementError(
                    "(marker*,table-column*,table-header?,table-footer?"
                        + ",table-body+)");
         }
-        if (columns != null && !columns.isEmpty()) {
-            for (int i = columns.size(); --i >= 0;) {
-                if (isColumnNumberUsed(i + 1)) {
-                    ((TableColumn) columns.get(i)).releasePropertyList();
+        if (!inMarker()) {
+            if (columns != null && !columns.isEmpty()) {
+                for (int i = columns.size(); --i >= 0;) {
+                    TableColumn col = (TableColumn) columns.get(i);
+                    if (col != null) {
+                        col.releasePropertyList();
+                    }
                 }
             }
         }
@@ -229,7 +234,14 @@
      */
     protected void addChildNode(FONode child) throws FOPException {
         if ("fo:table-column".equals(child.getName())) {
-            addColumnNode((TableColumn) child);
+            if (columns == null) {
+                columns = new java.util.ArrayList();
+            }
+            if (!inMarker()) {
+                addColumnNode((TableColumn) child);
+            } else {
+                columns.add((TableColumn) child);
+            }
         } else {
             if ("fo:table-footer".equals(child.getName())) {
                 tableFooter = (TableBody) child;
@@ -252,9 +264,6 @@
     private void addColumnNode(TableColumn col) {
         int colNumber = col.getColumnNumber();
         int colRepeat = col.getNumberColumnsRepeated();
-        if (columns == null) {
-            columns = new java.util.ArrayList();
-        }
         if (columns.size() < colNumber) {
             //add nulls for non-occupied indices between
             //the last column up to and including the current one
@@ -273,6 +282,10 @@
                 columns.add(col);
             }
         }
+        //flag column indices used by this column
+        int startIndex = columnIndex - 1;
+        int endIndex = startIndex + colRepeat;
+        flagColumnIndices(startIndex, endIndex);
     }
 
     /** @return true of table-layout="auto" */
@@ -458,9 +471,17 @@
     }
     
     /**
-     * @see org.apache.fop.fo.flow.TableFObj#existsUsedColumnIndices()
+     * @see org.apache.fop.fo.FONode#clone(FONode, boolean)
      */
-    protected boolean existsUsedColumnIndices() {
-        return (usedColumnIndices != null);
+    public FONode clone(FONode parent, boolean removeChildren)
+        throws FOPException {
+        FObj fobj = (FObj) super.clone(parent, removeChildren);
+        if (removeChildren) {
+            Table t = (Table) fobj;
+            t.columns = null;
+            t.tableHeader = null;
+            t.tableFooter = null;
+        }
+        return fobj;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableBody.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableBody.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableBody.java Mon Nov 13 01:39:19 2006
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.ListIterator;
 
+import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
@@ -33,6 +34,7 @@
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.flow.TableFObj.PendingSpan;
 import org.apache.fop.fo.properties.CommonAccessibility;
 import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
@@ -62,7 +64,7 @@
      * used for initial values of column-number property
      */
     protected List pendingSpans;
-    protected BitSet usedColumnIndices = new BitSet();
+    protected BitSet usedColumnIndices;
     private int columnIndex = 1;
     protected boolean firstRow = true;
     
@@ -88,10 +90,29 @@
     }
     
     /**
+     * @see org.apache.fop.fo.FONode#processNode()
+     */
+    public void processNode(String elementName, Locator locator, 
+                            Attributes attlist, PropertyList pList) 
+                    throws FOPException {
+        if (!inMarker()) {
+            if (getTable().columns != null) {
+                int cap = getTable().columns.size();
+                pendingSpans = new java.util.ArrayList(cap);
+                usedColumnIndices = new java.util.BitSet(cap);
+            } else {
+                pendingSpans = new java.util.ArrayList();
+                usedColumnIndices = new java.util.BitSet();
+            }
+            setNextColumnIndex();
+        }
+        super.processNode(elementName, locator, attlist, pList);
+    }
+
+    /**
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        initPendingSpans();
         getFOEventHandler().startBody(this);
     }
 
@@ -99,7 +120,16 @@
      * @see org.apache.fop.fo.FONode#endOfNode
      */
     protected void endOfNode() throws FOPException {
+        
+        if (!inMarker()) {
+            // clean up
+            savedPropertyList = null;
+            pendingSpans = null;
+            usedColumnIndices = null;
+        }
+        
         getFOEventHandler().endBody(this);
+        
         if (!(tableRowsFound || tableCellsFound)) {
             if (getUserAgent().validateStrictly()) {
                 missingChildElementError("marker* (table-row+|table-cell+)");
@@ -110,18 +140,11 @@
             }
         }
         
+        /*
         if (tableCellsFound) {
             convertCellsToRows();
         }
-        
-        //reset column index (so that it would be
-        //correct if the table is cloned during
-        //marker retrieval)
-        resetColumnIndex();
-        //release references
-        savedPropertyList = null;
-        pendingSpans = null;
-        usedColumnIndices = null;
+        */
     }
 
     /**
@@ -159,6 +182,18 @@
     }
     
     /**
+     * @see org.apache.fop.fo.FONode#addChildNode(FONode)
+     */
+    protected void addChildNode(FONode child) throws FOPException {
+        if (!inMarker()) {
+            if (firstRow && child.getNameId() == FO_TABLE_ROW) {
+                firstRow = false;
+            }
+        }
+        super.addChildNode(child);
+    }
+    
+    /**
      * If table-cells are used as direct children of a table-body|header|footer
      * they are replaced in this method by proper table-rows.
      * @throws FOPException if there's a problem binding the TableRow's 
@@ -243,15 +278,17 @@
      *  column-number of 2, since the first column is already 
      *  occupied...)
      */
-    protected void initPendingSpans() {
-        if (getTable().columns != null) {
-            List tableCols = getTable().columns;
-            pendingSpans = new java.util.ArrayList(tableCols.size());
-            for (int i = tableCols.size(); --i >= 0;) {
-                pendingSpans.add(null);
-            }
-        } else {
-            if (firstRow && pendingSpans == null) {
+    protected void initPendingSpans(FONode child) {
+        if (child.getNameId() == FO_TABLE_ROW) {
+            pendingSpans = ((TableRow) child).pendingSpans;
+        } else if (pendingSpans == null) {
+            if (getTable().columns != null) {
+                List tableCols = getTable().columns;
+                pendingSpans = new java.util.ArrayList(tableCols.size());
+                for (int i = tableCols.size(); --i >= 0;) {
+                    pendingSpans.add(null);
+                }
+            } else {
                 pendingSpans = new java.util.ArrayList();
             }
         }
@@ -262,7 +299,7 @@
      * 
      * @return the next column number to use
      */
-    public int getCurrentColumnIndex() {
+    protected int getCurrentColumnIndex() {
         return columnIndex;
     }
 
@@ -273,7 +310,7 @@
      * 
      * @param newIndex  the new column index
      */
-    public void setCurrentColumnIndex(int newIndex) {
+    protected void setCurrentColumnIndex(int newIndex) {
         columnIndex = newIndex;
     }
 
@@ -281,11 +318,12 @@
      * Resets the current column index for the TableBody
      *
      */
-    public void resetColumnIndex() {
+    protected void resetColumnIndex() {
         columnIndex = 1;
-        for (int i = 0; i < usedColumnIndices.size(); i++) {
+        for (int i = usedColumnIndices.length(); --i >= 0;) {
             usedColumnIndices.clear(i);
         }
+        
         PendingSpan pSpan;
         for (int i = pendingSpans.size(); --i >= 0;) {
             pSpan = (PendingSpan) pendingSpans.get(i);
@@ -293,13 +331,10 @@
                 pSpan.rowsLeft--;
                 if (pSpan.rowsLeft == 0) {
                     pendingSpans.set(i, null);
+                } else {
+                    usedColumnIndices.set(i);
                 }
             }
-            if (pendingSpans.get(i) != null) {
-                usedColumnIndices.set(i);
-            } else {
-                usedColumnIndices.clear(i);
-            }
         }
         if (!firstRow) {
             setNextColumnIndex();
@@ -310,19 +345,19 @@
      * Increases columnIndex to the next available value
      *
      */
-    private void setNextColumnIndex() {
+    protected void setNextColumnIndex() {
         while (usedColumnIndices.get(columnIndex - 1)) {
             //increment columnIndex
             columnIndex++;
-            //if the table has explicit columns, and
-            //the updated index is not assigned to any
-            //column, increment further until the next
-            //index occupied by a column...
-            if (getTable().columns != null) {
-                while (columnIndex <= getTable().columns.size()
-                        && !getTable().isColumnNumberUsed(columnIndex) ) {
-                    columnIndex++;
-                }
+        }
+        //if the table has explicit columns, and
+        //the index is not assigned to any
+        //column, increment further until the next
+        //index occupied by a column...
+        if (getTable().columns != null) {
+            while (columnIndex <= getTable().columns.size()
+                    && !getTable().isColumnNumberUsed(columnIndex) ) {
+                columnIndex++;
             }
         }
     }
@@ -337,11 +372,10 @@
      *          b) there is no previous cell (implicit 
      *             start of row)
      */
-    protected boolean lastCellEndedRow(TableCell currentCell) {
-        if (childNodes != null && childNodes.indexOf(currentCell) > 0) {
-            FONode prevNode = (FONode) childNodes.get(
-                    childNodes.indexOf(currentCell) - 1);
-            if (prevNode != null && prevNode.getNameId() == FO_TABLE_CELL) {
+    protected boolean previousCellEndedRow() {
+        if (childNodes != null) {
+            FONode prevNode = (FONode) childNodes.get(childNodes.size() - 1);
+            if (prevNode.getNameId() == FO_TABLE_CELL) {
                 return ((TableCell) prevNode).endsRow();
             }
         }
@@ -367,12 +401,5 @@
             usedColumnIndices.set(i);
         }
         setNextColumnIndex();
-    }
-    
-    /**
-     * @see org.apache.fop.fo.flow.TableFObj#existsUsedColumnIndices()
-     */
-    protected boolean existsUsedColumnIndices() {
-        return (usedColumnIndices != null);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableCell.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableCell.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableCell.java Mon Nov 13 01:39:19 2006
@@ -22,6 +22,7 @@
 import java.util.BitSet;
 import java.util.List;
 
+import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
@@ -30,10 +31,12 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.fo.properties.CommonAccessibility;
 import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonRelativePosition;
+import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 
 /**
@@ -59,6 +62,9 @@
     private Numeric numberRowsSpanned;
     private int startsRow;
     private Length width;
+    private KeepProperty keepTogether;
+    private KeepProperty keepWithNext;
+    private KeepProperty keepWithPrevious;
     // End of property values
 
     /** used for FO validation */
@@ -95,11 +101,6 @@
     protected int top;
 
     /**
-     * Set to true if all content completely laid out.
-     */
-    private boolean bDone = false;
-    
-    /**
      * @param parent FONode that is the parent of this object
      */
     public TableCell(FONode parent) {
@@ -122,16 +123,14 @@
         height = pList.get(PR_HEIGHT).getLength();
         id = pList.get(PR_ID).getString();
         inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
+        columnNumber = pList.get(PR_COLUMN_NUMBER).getNumeric();
         numberColumnsSpanned = pList.get(PR_NUMBER_COLUMNS_SPANNED).getNumeric();
         numberRowsSpanned = pList.get(PR_NUMBER_ROWS_SPANNED).getNumeric();
         startsRow = pList.get(PR_STARTS_ROW).getEnum();
         width = pList.get(PR_WIDTH).getLength();
-        
-        //Check to make sure we're not in retrieve-marker context
-        //TODO: Can this be generalized/extended to other FOs/Properties?
-        if (((TableFObj) parent).existsUsedColumnIndices()) {
-            columnNumber = pList.get(PR_COLUMN_NUMBER).getNumeric();
-        }
+        keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
+        keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
+        keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
         
         super.bind(pList);
     }
@@ -163,112 +162,9 @@
             getLogger().warn("starts-row/ends-row for fo:table-cells "
                     + "non-applicable for children of an fo:table-row.");
         }
-        updateParentColumnIndex();
         getFOEventHandler().endCell(this);
     }
 
-    private void updateParentColumnIndex() {
-        
-        int rowSpan = getNumberRowsSpanned();
-        int colSpan = getNumberColumnsSpanned();
-        int columnIndex = ((TableFObj) parent).getCurrentColumnIndex();
-        
-        int i = -1;
-        while (++i < colSpan) {
-            //if table has explicit columns and the column-number isn't
-            //assigned to any column, increment further until the next
-            //column is encountered
-            if (getTable().getColumns() != null) {
-                while (columnIndex <= getTable().getColumns().size()
-                        && !getTable().isColumnNumberUsed(columnIndex)) {
-                    columnIndex++;
-                }
-            }
-            //if column-number is already in use by another cell
-            //in the current row => error!
-            if (((TableFObj) parent).isColumnNumberUsed(columnIndex + i)) {
-                log.error("fo:table-cell overlaps in column "
-                        + (columnIndex + i));
-            }
-        }
-
-        if (parent.getNameId() == FO_TABLE_ROW) {
-            /* parent is a fo:table-row */
-            TableRow row = (TableRow) parent;
-            TableBody body = (TableBody) parent.getParent();
-            
-            if (body.isFirst(row) && getTable().columns == null ) {
-                row.pendingSpans.add(null);
-                if (row.usedColumnIndices == null) {
-                    row.usedColumnIndices = new BitSet();
-                }
-            }
-            //if the current cell spans more than one row,
-            //update pending span list for the next row
-            if (rowSpan > 1) {
-                for (i = colSpan; --i >= 0;) {
-                    row.pendingSpans.set(columnIndex - 1 + i, 
-                            new PendingSpan(rowSpan));
-                }
-            }
-        } else {
-            /* parent is (should be) a fo:table-body/-header/-footer */
-            TableBody body = (TableBody) parent;
-            
-            /* if body.firstRow is still true, and :
-             * a) the cell starts a row,
-             * b) there was a previous cell 
-             * c) that previous cell didn't explicitly end the previous row
-             *  => set firstRow flag to false
-             */
-            if (startsRow() && body.firstRow) {
-                if (!body.lastCellEndedRow(this)) {
-                    body.firstRow = false;
-                }
-            }
-            
-            /* if there were no explicit columns, pendingSpans
-             * will not be properly initialized for the first row...
-             */
-            if (body.firstRow && getTable().columns == null) {
-                for (i = colSpan; --i >= 0;) {
-                    body.pendingSpans.add(null);
-                }
-            }
-            
-            /* if the current cell spans more than one row,
-             * update pending span list for the next row
-             */
-            if (rowSpan > 1) {
-                for (i = colSpan; --i >= 0;) {
-                    body.pendingSpans.set(columnIndex - 1 + i, 
-                            new PendingSpan(rowSpan));
-                }
-            }
-        }
-        //flag column indices used by this cell,
-        //take into account that possibly not all column-numbers
-        //are used by columns in the parent table (if any),
-        //so a cell spanning three columns, might actually
-        //take up more than three columnIndices...
-        int startIndex = columnIndex - 1;
-        int endIndex = startIndex + colSpan;
-        if (getTable().columns != null) {
-            List cols = getTable().columns;
-            int tmpIndex = endIndex;
-            for (i = startIndex; i <= tmpIndex; ++i) {
-                if (i < cols.size() && cols.get(i) == null) {
-                    endIndex++;
-                }
-            }
-        }
-        ((TableFObj) parent).flagColumnIndices(startIndex, endIndex);
-        if (endsRow() && parent.getNameId() != FO_TABLE_ROW) {
-            ((TableBody) parent).firstRow = false;
-            ((TableBody) parent).resetColumnIndex();
-        }
-    }
-    
     /**
      * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
      * XSL Content Model: marker* (%block;)+
@@ -304,7 +200,7 @@
      * @return the Common Border, Padding, and Background Properties.
      */
     public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
-        return commonBorderPaddingBackground;
+        return this.commonBorderPaddingBackground;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableColumn.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableColumn.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableColumn.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableColumn.java Mon Nov 13 01:39:19 2006
@@ -78,10 +78,6 @@
         visibility = pList.get(PR_VISIBILITY).getEnum();
         super.bind(pList);
         
-        if (getTable().isColumnNumberUsed(columnNumber.getValue())) {
-            throw new PropertyException("column-number \"" + columnNumber 
-                    + "\" has already been assigned to a previous column");
-        }
         if (numberColumnsRepeated.getValue() <= 0) {
             throw new PropertyException("number-columns-repeated must be 1 or bigger, "
                     + "but got " + numberColumnsRepeated.getValue());
@@ -104,10 +100,6 @@
      * @see org.apache.fop.fo.FONode#endOfNode
      */
     protected void endOfNode() throws FOPException {
-        //flag column indices used by this column
-        int startIndex = getColumnNumber() - 1;
-        int endIndex = startIndex + getNumberColumnsRepeated();
-        getTable().flagColumnIndices(startIndex, endIndex);
         getFOEventHandler().endColumn(this);
     }
 
@@ -211,6 +203,4 @@
     protected void releasePropertyList() {
         this.pList = null;
     }
-
-}
-
+}
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFObj.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFObj.java Mon Nov 13 01:39:19 2006
@@ -19,13 +19,23 @@
 
 package org.apache.fop.fo.flow;
 
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.datatypes.ValidationPercentBaseContext;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.NumberProperty;
+import org.apache.fop.fo.properties.Property;
+import org.apache.fop.fo.properties.PropertyMaker;
 
 /**
  * Superclass for table-related FOs
@@ -89,13 +99,129 @@
         if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java
                 && getNameId() != FO_TABLE_CELL
                 && getCommonBorderPaddingBackground().hasPadding(
-                        ValidationPercentBaseContext.getPseudoContextForValidationPurposes())) {
-            attributeWarning("padding-* properties are not applicable to " + getName() 
+                        ValidationPercentBaseContext
+                            .getPseudoContextForValidationPurposes())) {
+            attributeWarning(
+                    "padding-* properties are not applicable to " + getName()
                     + ", but a non-zero value for padding was found.");
         }
     }
     
     /**
+     * @see org.apache.fop.fo.FONode#addChildNode(FONode)
+     */
+    protected void addChildNode(FONode child) throws FOPException {
+        if (!inMarker() 
+                && child.getNameId() == FO_TABLE_CELL) {
+            /* update current column index for the table-body/table-row */
+            updateColumnIndex((TableCell) child);
+        }
+        super.addChildNode(child);
+    }
+    
+    private void updateColumnIndex(TableCell cell)
+            throws ValidationException {
+        
+        int rowSpan = cell.getNumberRowsSpanned();
+        int colSpan = cell.getNumberColumnsSpanned();
+        int columnIndex = getCurrentColumnIndex();
+        
+        int i = -1;
+        while (++i < colSpan) {
+            if (isColumnNumberUsed(columnIndex + i)) {
+                /* if column-number is already in use by another cell
+                 * in the current row => error!
+                 */
+                StringBuffer errorMessage = new StringBuffer();
+                errorMessage.append("fo:table-cell overlaps in column ")
+                       .append(columnIndex + i);
+                if (locator.getLineNumber() != -1) {
+                    errorMessage.append(" (line #")
+                        .append(locator.getLineNumber()).append(", column #")
+                        .append(locator.getColumnNumber()).append(")");
+                }
+                throw new ValidationException(errorMessage.toString());
+            }
+        }
+
+        if (getNameId() == FO_TABLE_ROW) {
+            
+            TableRow row = (TableRow) this;
+            TableBody body = (TableBody) parent;
+            
+            for (i = colSpan; --i >= 0;) {
+                row.pendingSpans.add(null);
+            }
+            
+            /* if the current cell spans more than one row,
+             * update pending span list for the next row
+             */
+            if (rowSpan > 1) {
+                for (i = colSpan; --i >= 0;) {
+                    row.pendingSpans.set(columnIndex - 1 + i, 
+                            new PendingSpan(rowSpan));
+                }
+            }
+        } else {
+            
+            TableBody body = (TableBody) this;
+            
+            /* if body.firstRow is still true, and :
+             * a) the cell starts a row,
+             * b) there was a previous cell 
+             * c) that previous cell didn't explicitly end the previous row
+             *  => set firstRow flag to false
+             */
+            if (body.firstRow && cell.startsRow()) {
+                if (!body.previousCellEndedRow()) {
+                    body.firstRow = false;
+                }
+            }
+            
+            /* pendingSpans not initialized for the first row...
+             */
+            if (body.firstRow) {
+                for (i = colSpan; --i >= 0;) {
+                    body.pendingSpans.add(null);
+                }
+            }
+            
+            /* if the current cell spans more than one row,
+             * update pending span list for the next row
+             */
+            if (rowSpan > 1) {
+                for (i = colSpan; --i >= 0;) {
+                    body.pendingSpans.set(columnIndex - 1 + i, 
+                            new PendingSpan(rowSpan));
+                }
+            }
+        }
+
+        /* flag column indices used by this cell,
+         * take into account that possibly not all column-numbers
+         * are used by columns in the parent table (if any),
+         * so a cell spanning three columns, might actually
+         * take up more than three columnIndices...
+         */
+        int startIndex = columnIndex - 1;
+        int endIndex = startIndex + colSpan;
+        if (getTable().columns != null) {
+            List cols = getTable().columns;
+            int tmpIndex = endIndex;
+            for (i = startIndex; i <= tmpIndex; ++i) {
+                if (i < cols.size() && cols.get(i) == null) {
+                    endIndex++;
+                }
+            }
+        }
+        flagColumnIndices(startIndex, endIndex);
+        if (getNameId() != FO_TABLE_ROW && cell.endsRow()) {
+            ((TableBody) this).firstRow = false;
+            ((TableBody) this).resetColumnIndex();
+        }
+    }
+    
+    /**
      * 
      * @param side  the side for which to return the border precedence
      * @return the "border-precedence" value for the given side
@@ -121,7 +247,7 @@
      * 
      * @return the next column number to use
      */
-    public int getCurrentColumnIndex() {
+    protected int getCurrentColumnIndex() {
         return 0;
     }
     
@@ -133,10 +259,10 @@
      * 
      * @param   newIndex    new value for column index
      */
-    public void setCurrentColumnIndex(int newIndex) {
+    protected void setCurrentColumnIndex(int newIndex) {
         //do nothing by default
     }
-    
+        
     /**
      * Checks if a certain column-number is already occupied
      * (overridden for Table, TableBody, TableRow)
@@ -184,10 +310,83 @@
     }
     
     /**
-     * Overridden for Table, TableBody, TableRow
-     * @return true if the usedColumnIndices BitSet exists, and is initialized
+     * PropertyMaker subclass for the column-number property
+     *
      */
-    protected boolean existsUsedColumnIndices() {
-        return false;
+    public static class ColumnNumberPropertyMaker extends NumberProperty.Maker {
+
+        /**
+         * Constructor
+         * @param propId    the id of the property for which the maker should 
+         *                  be created
+         */
+        public ColumnNumberPropertyMaker(int propId) {
+            super(propId);
+        }
+
+        /**
+         * @see PropertyMaker#make(PropertyList)
+         */
+        public Property make(PropertyList propertyList) 
+                throws PropertyException {
+            FObj fo = propertyList.getFObj();
+
+            if (fo.getNameId() == Constants.FO_TABLE_CELL
+                    || fo.getNameId() == Constants.FO_TABLE_COLUMN) {
+                if (fo.getNameId() == Constants.FO_TABLE_CELL
+                        && fo.getParent().getNameId() != Constants.FO_TABLE_ROW
+                        && (propertyList.get(Constants.PR_STARTS_ROW).getEnum() 
+                                == Constants.EN_TRUE)) {
+                    TableBody parent = (TableBody) fo.getParent();
+                    if (!parent.previousCellEndedRow()) {
+                        parent.resetColumnIndex();
+                    }
+                }
+                return new NumberProperty(((TableFObj) fo.getParent())
+                                            .getCurrentColumnIndex());
+            } else {
+                throw new PropertyException(
+                        "column-number property is only allowed"
+                        + " on fo:table-cell or fo:table-column, not on "
+                        + fo.getName());
+            }
+        }
+        
+        /**
+         * Check the value of the column-number property. 
+         * Return the parent's column index (initial value) in case 
+         * of a negative or zero value
+         * 
+         * @see org.apache.fop.fo.properties.PropertyMaker#get(
+         *                      int, PropertyList, boolean, boolean)
+         */
+        public Property get(int subpropId, PropertyList propertyList,
+                            boolean tryInherit, boolean tryDefault) 
+                throws PropertyException {
+            
+            Property p = super.get(0, propertyList, tryInherit, tryDefault);
+            TableFObj fo = (TableFObj) propertyList.getFObj();
+            TableFObj parent = (TableFObj) propertyList.getParentFObj();
+            int columnIndex = p.getNumeric().getValue();
+            
+            if (columnIndex <= 0) {
+                fo.getLogger().warn("Specified negative or zero value for "
+                        + "column-number on " + fo.getName() + ": "
+                        + columnIndex + " forced to " 
+                        + parent.getCurrentColumnIndex());
+                return new NumberProperty(parent.getCurrentColumnIndex());
+            }
+            //TODO: check for non-integer value and round
+                    
+            /* if column-number was explicitly specified, force the 
+             * parent's current column index to the specified value, 
+             * so that the updated index will be the correct initial 
+             * value for the next cell/column (see Rec 7.26.8)
+             */
+            if (propertyList.getExplicit(Constants.PR_COLUMN_NUMBER) != null) {
+                parent.setCurrentColumnIndex(p.getNumeric().getValue());
+            }
+            return p;
+        }
     }
 }

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFooter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFooter.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFooter.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableFooter.java Mon Nov 13 01:39:19 2006
@@ -40,7 +40,6 @@
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        initPendingSpans();
         //getFOEventHandler().startBody(this);
     }
 

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableHeader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableHeader.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableHeader.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableHeader.java Mon Nov 13 01:39:19 2006
@@ -40,7 +40,6 @@
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        initPendingSpans();
         //getFOEventHandler().startHeader(this);
     }
 

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableRow.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableRow.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/flow/TableRow.java Mon Nov 13 01:39:19 2006
@@ -22,6 +22,7 @@
 import java.util.BitSet;
 import java.util.List;
 
+import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
@@ -105,23 +106,29 @@
     }
     
     /**
+     * @see org.apache.fop.fo.FONode#processNode(String, Locator, 
+     *                                  Attributes, PropertyList)
+     */
+    public void processNode(String elementName, Locator locator, 
+            Attributes attlist, PropertyList pList) throws FOPException {
+        if (!inMarker()) {
+            TableBody body = (TableBody) parent;
+            body.resetColumnIndex();
+            pendingSpans = body.pendingSpans;
+            usedColumnIndices = body.usedColumnIndices;
+            while (usedColumnIndices.get(columnIndex - 1)) {
+                columnIndex++;
+            }
+        }
+        super.processNode(elementName, locator, attlist, pList);
+    }
+
+    /**
      * @see org.apache.fop.fo.FONode#startOfNode
      */
     protected void startOfNode() throws FOPException {
-        pendingSpans = ((TableBody) parent).pendingSpans;
-        usedColumnIndices = ((TableBody) parent).usedColumnIndices;
-        while (usedColumnIndices.get(columnIndex - 1)) {
-            columnIndex++;
-        }
-        
         checkId(id);
         getFOEventHandler().startRow(this);
-        if (((TableBody) parent).isFirst(this) 
-                && getTable().columns == null ) {
-            if (pendingSpans == null) {
-                pendingSpans = new java.util.ArrayList();
-            }
-        }
     }
 
     /**
@@ -131,17 +138,10 @@
         if (childNodes == null) {
             missingChildElementError("(table-cell+)");
         }
-        if (((TableBody) parent).isFirst(this) 
-                && getTable().columns == null ) {
-            //force parent body's pendingSpans
-            //to the one accumulated after processing this row
-            ((TableBody) parent).pendingSpans = pendingSpans;
+        if (!inMarker()) {
+            pendingSpans = null;
+            usedColumnIndices = null;
         }
-        ((TableBody) parent).resetColumnIndex();
-        columnIndex = 1;
-        //release references
-        pendingSpans = null;
-        usedColumnIndices = null;
         getFOEventHandler().endRow(this);
     }
 
@@ -155,7 +155,7 @@
         if (!(FO_URI.equals(nsURI) && localName.equals("table-cell"))) {
             invalidChildError(loc, nsURI, localName);
         }
-    }
+    }    
     
     /**
      * @return the "id" property.
@@ -292,12 +292,5 @@
         while (usedColumnIndices.get(columnIndex - 1)) {
             columnIndex++;
         }
-    }
-    
-    /**
-     * @see org.apache.fop.fo.flow.TableFObj#existsUsedColumnIndices()
-     */
-    protected boolean existsUsedColumnIndices() {
-        return (usedColumnIndices != null);
-    }
+    }    
 }

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/pagination/PageSequence.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/pagination/PageSequence.java Mon Nov 13 01:39:19 2006
@@ -539,4 +539,12 @@
         return this.language;
     }
 
+    /**
+     * Releases a page-sequence's children after the page-sequence has been fully processed.
+     */
+    public void releasePageSequence() {
+        this.mainFlow = null;
+        this.flowMap.clear();
+    }
+    
 }

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fo/properties/FontShorthandProperty.java Mon Nov 13 01:39:19 2006
@@ -53,136 +53,142 @@
         public Property make(PropertyList propertyList, 
                 String value, FObj fo) throws PropertyException {
             
-            FontShorthandProperty newProp = new FontShorthandProperty();
-            newProp.setSpecifiedValue(value);
-            
-            String specVal = value;
-            Property prop = null;
-            if ("inherit".equals(specVal)) {
-                for (int i = PROP_IDS.length; --i >= 0;) {
-                    prop = propertyList.getFromParent(PROP_IDS[i]);
-                    newProp.addProperty(prop, i);
-                }
-            } else {
-                /* initialize list with nulls */
-                for (int pos = 6; --pos >= 0;) {
-                    newProp.addProperty(null, pos);
-                }
-                prop = checkEnumValues(specVal);
-                if (prop == null) {
-                    /* not an enum:
-                     * value should consist at least of font-size and font-family
-                     * separated by a space
-                     * mind the possible spaces from quoted font-family names
-                     */
-                    int spaceIndex = value.indexOf(' ');
-                    int quoteIndex = (value.indexOf('\'') == -1)
-                        ? value.indexOf('\"') : value.indexOf('\'');
-                    if (spaceIndex == -1 
-                            || (quoteIndex != -1 && spaceIndex > quoteIndex)) {
-                        /* no spaces or first space appears after the first
-                         * single/double quote, so malformed value string
+            try {
+                FontShorthandProperty newProp = new FontShorthandProperty();
+                newProp.setSpecifiedValue(value);
+                
+                String specVal = value;
+                Property prop = null;
+                if ("inherit".equals(specVal)) {
+                    /* fill the list with the individual properties from the parent */
+                    for (int i = PROP_IDS.length; --i >= 0;) {
+                        prop = propertyList.getFromParent(PROP_IDS[i]);
+                        newProp.addProperty(prop, i);
+                    }
+                } else {
+                    /* initialize list with nulls */
+                    for (int pos = PROP_IDS.length; --pos >= 0;) {
+                        newProp.addProperty(null, pos);
+                    }
+                    prop = checkEnumValues(specVal);
+                    if (prop == null) {
+                        /* not an enum:
+                         * value should consist at least of font-size and font-family
+                         * separated by a space
+                         * mind the possible spaces from quoted font-family names
                          */
-                        throw new PropertyException("Invalid property value: "
-                                + "font=\"" + value + "\"");                        
-                    } 
-                    PropertyMaker m = null;
-                    int fromIndex = spaceIndex + 1;
-                    int toIndex = specVal.length();
-                    /* at least one space that appears before the first
-                     * single/double quote, so extract the individual properties
-                     */
-                    boolean fontFamilyParsed = false;
-                    int commaIndex = value.indexOf(',');
-                    while (!fontFamilyParsed) {
-                        /* value contains a (list of) possibly quoted 
-                         * font-family name(s) 
+                        int spaceIndex = value.indexOf(' ');
+                        int quoteIndex = (value.indexOf('\'') == -1)
+                            ? value.indexOf('\"') : value.indexOf('\'');
+                        if (spaceIndex == -1 
+                                || (quoteIndex != -1 && spaceIndex > quoteIndex)) {
+                            /* no spaces or first space appears after the first
+                             * single/double quote, so malformed value string
+                             */
+                            throw new PropertyException("Invalid property value: "
+                                    + "font=\"" + value + "\"");                        
+                        } 
+                        PropertyMaker m = null;
+                        int fromIndex = spaceIndex + 1;
+                        int toIndex = specVal.length();
+                        /* at least one space that appears before the first
+                         * single/double quote, so extract the individual properties
                          */
-                        if (commaIndex == -1) {
-                            /* no list, just a single name 
-                             * (or first name in the list)
+                        boolean fontFamilyParsed = false;
+                        int commaIndex = value.indexOf(',');
+                        while (!fontFamilyParsed) {
+                            /* value contains a (list of) possibly quoted 
+                             * font-family name(s) 
                              */
-                            if (quoteIndex != -1) {
-                                /* a single name, quoted
-                                 */
-                                fromIndex = quoteIndex;
-                            }
-                            m = FObj.getPropertyMakerFor(PROP_IDS[1]);
-                            prop = m.make(propertyList, specVal.substring(fromIndex), fo);
-                            newProp.addProperty(prop, 1);
-                            fontFamilyParsed = true;                            
-                        } else {
-                            if (quoteIndex != -1 && quoteIndex < commaIndex) {
-                                /* a quoted font-family name as first name
-                                 * in the comma-separated list
-                                 * fromIndex = index of the first quote
+                            if (commaIndex == -1) {
+                                /* no list, just a single name 
+                                 * (or first name in the list)
                                  */
-                                fromIndex = quoteIndex;
-                                quoteIndex = -1;
+                                if (quoteIndex != -1) {
+                                    /* a single name, quoted
+                                     */
+                                    fromIndex = quoteIndex;
+                                }
+                                m = FObj.getPropertyMakerFor(PROP_IDS[1]);
+                                prop = m.make(propertyList, specVal.substring(fromIndex), fo);
+                                newProp.addProperty(prop, 1);
+                                fontFamilyParsed = true;                            
                             } else {
-                                fromIndex = value.lastIndexOf(' ', commaIndex) + 1;
+                                if (quoteIndex != -1 && quoteIndex < commaIndex) {
+                                    /* a quoted font-family name as first name
+                                     * in the comma-separated list
+                                     * fromIndex = index of the first quote
+                                     */
+                                    fromIndex = quoteIndex;
+                                    quoteIndex = -1;
+                                } else {
+                                    fromIndex = value.lastIndexOf(' ', commaIndex) + 1;
+                                }
+                                commaIndex = -1;
                             }
-                            commaIndex = -1;
                         }
-                    }
-                    toIndex = fromIndex - 1;
-                    fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1;
-                    value = specVal.substring(fromIndex, toIndex);
-                    int slashIndex = value.indexOf('/');
-                    String fontSize = value.substring(0, 
-                            (slashIndex == -1) ? value.length() : slashIndex);
-                    m = FObj.getPropertyMakerFor(PROP_IDS[0]);
-                    prop = m.make(propertyList, fontSize, fo);
-                    /* need to make sure subsequent call to LineHeightPropertyMaker.make()
-                     * doesn't generate the default font-size property...
-                     */
-                    propertyList.putExplicit(PROP_IDS[0], prop);
-                    newProp.addProperty(prop, 0);
-                    if (slashIndex != -1) {
-                        /* line-height */
-                        String lineHeight = value.substring(slashIndex + 1);
-                        m = FObj.getPropertyMakerFor(PROP_IDS[2]);
-                        prop = m.make(propertyList, lineHeight, fo);
-                        newProp.addProperty(prop, 2);
-                    }
-                    if (fromIndex != 0) {
                         toIndex = fromIndex - 1;
-                        value = specVal.substring(0, toIndex);
-                        fromIndex = 0;
-                        spaceIndex = value.indexOf(' ');
-                        do {
-                            toIndex = (spaceIndex == -1) ? value.length() : spaceIndex;
-                            String val = value.substring(fromIndex, toIndex);
-                            for (int i = 6; --i >= 3;) {
-                                if (newProp.list.get(i) == null) {
-                                    /* not set */
-                                    m = FObj.getPropertyMakerFor(PROP_IDS[i]);
-                                    val = m.checkValueKeywords(val);
-                                    prop = m.checkEnumValues(val);
-                                    if (prop != null) {
-                                        newProp.addProperty(prop, i);
+                        fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1;
+                        value = specVal.substring(fromIndex, toIndex);
+                        int slashIndex = value.indexOf('/');
+                        String fontSize = value.substring(0, 
+                                (slashIndex == -1) ? value.length() : slashIndex);
+                        m = FObj.getPropertyMakerFor(PROP_IDS[0]);
+                        prop = m.make(propertyList, fontSize, fo);
+                        /* need to make sure subsequent call to LineHeightPropertyMaker.make()
+                         * doesn't generate the default font-size property...
+                         */
+                        propertyList.putExplicit(PROP_IDS[0], prop);
+                        newProp.addProperty(prop, 0);
+                        if (slashIndex != -1) {
+                            /* line-height */
+                            String lineHeight = value.substring(slashIndex + 1);
+                            m = FObj.getPropertyMakerFor(PROP_IDS[2]);
+                            prop = m.make(propertyList, lineHeight, fo);
+                            newProp.addProperty(prop, 2);
+                        }
+                        if (fromIndex != 0) {
+                            toIndex = fromIndex - 1;
+                            value = specVal.substring(0, toIndex);
+                            fromIndex = 0;
+                            spaceIndex = value.indexOf(' ');
+                            do {
+                                toIndex = (spaceIndex == -1) ? value.length() : spaceIndex;
+                                String val = value.substring(fromIndex, toIndex);
+                                for (int i = 6; --i >= 3;) {
+                                    if (newProp.list.get(i) == null) {
+                                        /* not set */
+                                        m = FObj.getPropertyMakerFor(PROP_IDS[i]);
+                                        val = m.checkValueKeywords(val);
+                                        prop = m.checkEnumValues(val);
+                                        if (prop != null) {
+                                            newProp.addProperty(prop, i);
+                                        }
                                     }
                                 }
-                            }
-                            fromIndex = toIndex + 1;
-                            spaceIndex = value.indexOf(' ', fromIndex);
-                        } while (toIndex != value.length());
+                                fromIndex = toIndex + 1;
+                                spaceIndex = value.indexOf(' ', fromIndex);
+                            } while (toIndex != value.length());
+                        }
+                    } else {
+                        //TODO: implement enum values
+                        log.warn("Enum values other than \"inherit\""
+                                + " not yet supported for the font shorthand.");
+                        return null;
                     }
-                } else {
-                    //TODO: implement enum values
-                    log.warn("Enum values other than \"inherit\""
-                            + " not yet supported for the font shorthand.");
-                    return null;
                 }
-            }
-            if (newProp.list.get(0) == null || newProp.list.get(1) == null) {
-                throw new PropertyException("Invalid property value: "
-                        + "font-size and font-family are required for the font shorthand"
-                        + "\nfont=" + value);
-            }
-            return newProp;
+                if (newProp.list.get(0) == null || newProp.list.get(1) == null) {
+                    throw new PropertyException("Invalid property value: "
+                            + "font-size and font-family are required for the font shorthand"
+                            + "\nfont=\"" + value + "\"");
+                }
+                return newProp;
+           } catch (PropertyException pe) {
+               pe.setLocator(propertyList.getFObj().getLocator());
+               pe.setPropertyName(getName());
+               throw pe;
+           }
         }
-
     }
     
     private void addProperty(Property prop, int pos) {

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fonts/FontSetup.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/fonts/FontSetup.java Mon Nov 13 01:39:19 2006
@@ -46,6 +46,9 @@
 // Java
 import java.util.List;
 
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
 /**
  * Default fonts for FOP application; currently this uses PDF's fonts
  * by default.
@@ -194,6 +197,11 @@
             return; //No fonts to process
         }
 
+        if (resolver == null) {
+            //Ensure that we have minimal font resolution capabilities
+            resolver = createMinimalFontResolver();
+        }
+        
         String internalName = null;
         //FontReader reader = null;
 
@@ -229,6 +237,18 @@
         }
     }
 
+    /** @return a new FontResolver to be used by the font subsystem */
+    private static FontResolver createMinimalFontResolver() {
+        return new FontResolver() {
+
+            /** @see org.apache.fop.fonts.FontResolver#resolve(java.lang.String) */
+            public Source resolve(String href) {
+                //Minimal functionality here
+                return new StreamSource(href);
+            }
+            
+        };
+    }
     /**
      * Builds a list of EmbedFontInfo objects for use with the setup() method.
      * @param cfg Configuration object

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Mon Nov 13 01:39:19 2006
@@ -202,6 +202,15 @@
         return null;
     }
     
+    /**
+     * Returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to notify about layout
+     * problems.
+     * @return the listener instance or null if no notifications are needed
+     */
+    protected PageBreakingAlgorithm.PageBreakingLayoutListener getLayoutListener() {
+        return null;
+    }
+    
     /*
      * This method is to contain the logic to determine the LM's
      * getNextKnuthElements() implementation(s) that are to be called. 
@@ -316,7 +325,7 @@
                 log.debug("PLM> start of algorithm (" + this.getClass().getName() 
                         + "), flow BPD =" + flowBPD);
                 PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
-                        getPageProvider(),
+                        getPageProvider(), getLayoutListener(),
                         alignment, alignmentLast, footnoteSeparatorLength, floatSeparatorLength,
                         isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
                 int iOptPageCount;

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java Mon Nov 13 01:39:19 2006
@@ -21,6 +21,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -37,12 +38,14 @@
     
     public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,
             PageSequenceLayoutManager.PageProvider pageProvider,
+            PageBreakingLayoutListener layoutListener,
             int alignment, int alignmentLast,
             MinOptMax footnoteSeparatorLength,
             MinOptMax floatSeparatorLength,
             boolean partOverflowRecovery,
             int columnCount) {
-        super(topLevelLM, pageProvider, alignment, alignmentLast, 
+        super(topLevelLM, pageProvider, layoutListener,
+                alignment, alignmentLast, 
                 footnoteSeparatorLength, floatSeparatorLength, partOverflowRecovery, false, false);
         this.columnCount = columnCount;
         this.considerTooShort = true; //This is important!

Modified: xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java?view=diff&rev=474218&r1=474217&r2=474218
==============================================================================
--- xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_Floats/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java Mon Nov 13 01:39:19 2006
@@ -50,7 +50,7 @@
     /** Maximum adjustment ration */
     protected static final int INFINITE_RATIO = 1000;
 
-    private static final int MAX_RECOVERY_ATTEMPTS = 50;
+    private static final int MAX_RECOVERY_ATTEMPTS = 5;
 
     // constants identifying a subset of the feasible breaks
     /** All feasible breaks are ok. */
@@ -76,7 +76,7 @@
      * The threshold for considering breaks to be acceptable. The adjustment ratio must be
      * inferior to this threshold.
      */
-    private double threshold;
+    protected double threshold;
 
     /**
      * The paragraph of KnuthElements.
@@ -91,22 +91,22 @@
     /** Force the algorithm to find a set of breakpoints, even if no feasible breakpoints
      * exist.
      */
-    private boolean force =  false;
+    boolean force =  false;
     /** If set to true, doesn't ignore break possibilities which are definitely too short. */
     protected boolean considerTooShort = false;
 
     /** When in forced mode, the best node leading to a too long line. The line will be
      * too long anyway, but this one will lead to a paragraph with fewest demerits.
      */
-    private KnuthNode lastTooLong;
+    protected KnuthNode lastTooLong;
     /** When in forced mode, the best node leading to a too short line. The line will be
      * too short anyway, but this one will lead to a paragraph with fewest demerits.
      */
-    private KnuthNode lastTooShort;
+    protected KnuthNode lastTooShort;
     /** The node to be reactivated if no set of feasible breakpoints can be found for this
      * paragraph.
      */
-    private KnuthNode lastDeactivated;
+    protected KnuthNode lastDeactivated;
 
     /** Alignment of the paragraph/page. One of EN_START, EN_JUSTIFY, etc. */
     protected int alignment;
@@ -152,10 +152,13 @@
      */
     protected int totalShrink = 0;
 
+    protected SumsAfter sumsAfter = new SumsAfter();
+
     protected BestRecords best;
 
     /** @see #isPartOverflowRecoveryActivated() */
     private boolean partOverflowRecoveryActivated = true;
+    private KnuthNode lastRecovered;
 
     /**
      * Create a new instance.
@@ -175,15 +178,62 @@
         alignmentLast = alignLast;
         bFirst = first;
         this.partOverflowRecoveryActivated = partOverflowRecovery;
-        this.best = new BestRecords();
+        this.best = new BestRecords(log);
         maxFlaggedPenaltiesCount = maxFlagCount;
     }
 
 
+    protected static class SumsAfter {
+        private KnuthSequence par;
+        private int widthAfter;
+        private int stretchAfter;
+        private int shrinkAfter;
+        private int currentElementIndex = -1;
+
+        void compute(int elementIndex, int totalWidth, int totalStretch, int totalShrink) {
+            if (currentElementIndex == elementIndex) {
+                return;
+            }
+            currentElementIndex = elementIndex;
+            widthAfter = totalWidth;
+            stretchAfter = totalStretch;
+            shrinkAfter = totalShrink;
+            for (int i = elementIndex; i < par.size(); i++) {
+                KnuthElement element = (KnuthElement) par.get(i);
+                if (element.isBox()) {
+                    break;
+                } else if (element.isGlue()) {
+                    widthAfter += element.getW();
+                    stretchAfter += element.getY();
+                    shrinkAfter += element.getZ();
+                } else if (element.isForcedBreak() && i != elementIndex) {
+                    break;
+                }
+            }
+        }
+
+        void initialize(KnuthSequence par) {
+            this.par = par;
+            currentElementIndex = -1;
+        }
+
+        int getWidthAfter() {
+            return widthAfter;
+        }
+
+        int getStretchAfter() {
+            return stretchAfter;
+        }
+
+        int getShrinkAfter() {
+            return shrinkAfter;
+        }
+    }
+
     /**
      * Class recording all the informations of a feasible breaking point.
      */
-    public class KnuthNode {
+    public static class KnuthNode {
         /** index of the breakpoint represented by this node */
         public int position;
 
@@ -258,10 +308,11 @@
     /** Class that stores, for each fitness class, the best active node that could start
      * a line of the corresponding fitness ending at the current element.
      */
-    protected class BestRecords {
+    protected static class BestRecords {
         private static final double INFINITE_DEMERITS = Double.POSITIVE_INFINITY;
         //private static final double INFINITE_DEMERITS = 1E11;
 
+        private Log log;
         private double[] bestDemerits = new double[4];
         private KnuthNode[] bestNode = new KnuthNode[4];
         private double[] bestAdjust = new double[4];
@@ -271,7 +322,8 @@
         /** Points to the fitness class which currently leads to the best demerits. */
         private int bestIndex = -1;
 
-        public BestRecords() {
+        public BestRecords(Log log) {
+            this.log = log;
             reset();
         }
 
@@ -446,7 +498,7 @@
 
         // create an active node representing the starting point
         activeLines = new KnuthNode[20];
-        addNode(0, createNode(firstBoxIndex, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, null));
+        registerActiveNode(createNode(firstBoxIndex, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, null));
 
         if (log.isTraceEnabled()) {
             log.trace("Looping over " + (par.size() - startIndex) + " elements");
@@ -495,6 +547,16 @@
                 }
                 if (lastTooShort == null || lastForced.position == lastTooShort.position) {
                     if (isPartOverflowRecoveryActivated()) {
+                        if (this.lastRecovered == null) {
+                            this.lastRecovered = lastTooLong;
+                            if (log.isDebugEnabled()) {
+                                log.debug("Recovery point: " + lastRecovered);
+                            }
+                        }
+                        if (lastTooLong == null) {
+                            log.debug("lastTooLong null! lastTooShort: "
+                                    + new Boolean(lastTooShort != null));
+                        }
                         // content would overflow, insert empty line/page and try again
                         KnuthNode node = createNode(
                                 lastTooLong.previous.position, lastTooLong.previous.line + 1, 1,
@@ -503,23 +565,34 @@
                                 0, 0, lastTooLong.previous);
                         lastForced = node;
                         node.fitRecoveryCounter = lastTooLong.previous.fitRecoveryCounter + 1;
-                        log.debug("first part doesn't fit into line, recovering: " 
-                                + node.fitRecoveryCounter);
+                        if (log.isDebugEnabled()) {
+                            log.debug("first part doesn't fit into line, recovering: " 
+                                    + node.fitRecoveryCounter);
+                        }
                         if (node.fitRecoveryCounter > getMaxRecoveryAttempts()) {
-                            FONode contextFO = findContextFO(par, node.position + 1);
-                            throw new RuntimeException(FONode.decorateWithContextInfo(
-                                    "Some content could not fit "
-                                    + "into a line/page after " + getMaxRecoveryAttempts() 
-                                    + " attempts. Giving up to avoid an endless loop.", contextFO));
+                            while (lastForced.fitRecoveryCounter > 0) {
+                                lastForced = lastForced.previous;
+                                lastDeactivated = lastForced.previous;
+                                startLine--;
+                                endLine--;
+                            }
+                            lastForced = this.lastRecovered;
+                            this.lastRecovered = null;
+                            startLine = lastForced.line;
+                            endLine = lastForced.line;
+                            log.debug("rolled back...");
                         }
                     } else {
                         lastForced = lastTooLong;
                     }
                 } else {
                     lastForced = lastTooShort;
+                    this.lastRecovered = null;
                 }
 
-                log.debug("Restarting at node " + lastForced);
+                if (log.isDebugEnabled()) {
+                    log.debug("Restarting at node " + lastForced);
+                }
                 i = restartFrom(lastForced, i);
             }
         }
@@ -577,6 +650,7 @@
         this.totalWidth = 0;
         this.totalStretch = 0;
         this.totalShrink = 0;
+        sumsAfter.initialize(par);
     }
 
     /** Creates a new active node for a feasible breakpoint at the given position. Only
@@ -626,7 +700,7 @@
 
     protected int restartFrom(KnuthNode restartingNode, int currentIndex) {
         restartingNode.totalDemerits = 0;
-        addNode(restartingNode.line, restartingNode);
+        registerActiveNode(restartingNode);
         startLine = restartingNode.line;
         endLine = startLine + 1;
         totalWidth = restartingNode.totalWidth;
@@ -682,7 +756,7 @@
                     if (log.isTraceEnabled()) {
                         log.trace("Removing " + node);
                     }
-                    removeNode(line, node);
+                    deactivateNode(node);
                     lastDeactivated = compareNodes(lastDeactivated, node);
                 }
     
@@ -709,33 +783,36 @@
                 if (force && (r <= -1 || r > threshold)) {
                     int fitnessClass = computeFitness(r);
                     double demerits = computeDemerits(node, element, fitnessClass, r);
-                    int newWidth = totalWidth;
-                    int newStretch = totalStretch;
-                    int newShrink = totalShrink;
-
-                    // add the width, stretch and shrink of glue elements after 
-                    // the break
-                    // this does not affect the dimension of the line / page, only
-                    // the values stored in the node; these would be as if the break
-                    // was just before the next box element, thus ignoring glues and
-                    // penalties between the "real" break and the following box
-                    for (int i = elementIdx; i < par.size(); i++) {
-                        KnuthElement tempElement = getElement(i);
-                        if (tempElement.isBox()) {
-                            break;
-                        } else if (tempElement.isGlue()) {
-                            newWidth += tempElement.getW();
-                            newStretch += tempElement.getY();
-                            newShrink += tempElement.getZ();
-                        } else if (tempElement.isForcedBreak() && i != elementIdx) {
-                            break;
-                        }
-                    }
+                    sumsAfter.compute(elementIdx, totalWidth, totalStretch, totalShrink);
+//                    int newWidth = totalWidth;
+//                    int newStretch = totalStretch;
+//                    int newShrink = totalShrink;
+//
+//                    // add the width, stretch and shrink of glue elements after 
+//                    // the break
+//                    // this does not affect the dimension of the line / page, only
+//                    // the values stored in the node; these would be as if the break
+//                    // was just before the next box element, thus ignoring glues and
+//                    // penalties between the "real" break and the following box
+//                    for (int i = elementIdx; i < par.size(); i++) {
+//                        KnuthElement tempElement = getElement(i);
+//                        if (tempElement.isBox()) {
+//                            break;
+//                        } else if (tempElement.isGlue()) {
+//                            newWidth += tempElement.getW();
+//                            newStretch += tempElement.getY();
+//                            newShrink += tempElement.getZ();
+//                        } else if (tempElement.isForcedBreak() && i != elementIdx) {
+//                            break;
+//                        }
+//                    }
 
                     if (r <= -1) {
                         if (lastTooLong == null || demerits < lastTooLong.totalDemerits) {
                             lastTooLong = createNode(elementIdx, line + 1, fitnessClass,
-                                    newWidth, newStretch, newShrink,
+                                    sumsAfter.getWidthAfter(),
+                                    sumsAfter.getStretchAfter(),
+                                    sumsAfter.getShrinkAfter(),
                                     r, availableShrink, availableStretch,
                                     difference, demerits, node);
                             if (log.isTraceEnabled()) {
@@ -751,7 +828,9 @@
                                         difference, fitnessClass);
                             }
                             lastTooShort = createNode(elementIdx, line + 1, fitnessClass,
-                                    newWidth, newStretch, newShrink,
+                                    sumsAfter.getWidthAfter(),
+                                    sumsAfter.getStretchAfter(),
+                                    sumsAfter.getShrinkAfter(),
                                     r, availableShrink, availableStretch,
                                     difference, demerits, node);
                             if (log.isTraceEnabled()) {
@@ -770,33 +849,34 @@
      * @param line number of the previous line; this element will end line number (line+1)
      * @param elementIdx the element's index
      */
-    private void addBreaks(int line, int elementIdx) {
+    void addBreaks(int line, int elementIdx) {
         if (!best.hasRecords()) {
             return;
         }
 
-        int newWidth = totalWidth;
-        int newStretch = totalStretch;
-        int newShrink = totalShrink;
-
-        // add the width, stretch and shrink of glue elements after 
-        // the break
-        // this does not affect the dimension of the line / page, only
-        // the values stored in the node; these would be as if the break
-        // was just before the next box element, thus ignoring glues and
-        // penalties between the "real" break and the following box
-        for (int i = elementIdx; i < par.size(); i++) {
-            KnuthElement tempElement = getElement(i);
-            if (tempElement.isBox()) {
-                break;
-            } else if (tempElement.isGlue()) {
-                newWidth += tempElement.getW();
-                newStretch += tempElement.getY();
-                newShrink += tempElement.getZ();
-            } else if (tempElement.isForcedBreak() && i != elementIdx) {
-                break;
-            }
-        }
+        sumsAfter.compute(elementIdx, totalWidth, totalStretch, totalShrink);
+//        int newWidth = totalWidth;
+//        int newStretch = totalStretch;
+//        int newShrink = totalShrink;
+//
+//        // add the width, stretch and shrink of glue elements after 
+//        // the break
+//        // this does not affect the dimension of the line / page, only
+//        // the values stored in the node; these would be as if the break
+//        // was just before the next box element, thus ignoring glues and
+//        // penalties between the "real" break and the following box
+//        for (int i = elementIdx; i < par.size(); i++) {
+//            KnuthElement tempElement = getElement(i);
+//            if (tempElement.isBox()) {
+//                break;
+//            } else if (tempElement.isGlue()) {
+//                newWidth += tempElement.getW();
+//                newStretch += tempElement.getY();
+//                newShrink += tempElement.getZ();
+//            } else if (tempElement.isForcedBreak() && i != elementIdx) {
+//                break;
+//            }
+//        }
 
         // add nodes to the active nodes list
         double minimumDemerits = best.getMinDemerits() + incompatibleFitnessDemerit;
@@ -809,8 +889,10 @@
                             + " from fitness class " + i);
                 }
                 KnuthNode newNode = createNode(elementIdx, line + 1, i,
-                                               newWidth, newStretch, newShrink);
-                addNode(line + 1, newNode);
+                        sumsAfter.getWidthAfter(),
+                        sumsAfter.getStretchAfter(),
+                        sumsAfter.getShrinkAfter());
+                registerActiveNode(newNode);
             }
         }
         best.reset();
@@ -878,7 +960,7 @@
      * @param r
      * @return the fitness class
      */
-    private int computeFitness(double r) {
+    int computeFitness(double r) {
         if (r < -0.5) {
             return 0;
         } else if (r <= 0.5) {
@@ -987,13 +1069,12 @@
     }
 
     /**
-     * Add a node at the end of the given line's existing active nodes.
-     * If this is the first node in the line, adjust endLine accordingly.
-     * @param line number of the line ending at the node's corresponding breakpoint
-     * @param node the active node to add
+     * Registers a new active node. If this is the first node in the corresponding line,
+     * adjust endLine accordingly.
+     * @param node the active node to register
      */
-    public void addNode(int line, KnuthNode node) {
-        int headIdx = line * 2;
+    public void registerActiveNode(KnuthNode node) {
+        int headIdx = node.line * 2;
         if (headIdx >= activeLines.length) {
             KnuthNode[] oldList = activeLines;
             activeLines = new KnuthNode[headIdx + headIdx];
@@ -1004,21 +1085,20 @@
             activeLines[headIdx + 1].next = node;
         } else {
             activeLines[headIdx] = node;
-            endLine = line + 1;
+            endLine = node.line + 1;
         }
         activeLines[headIdx + 1] = node;
         activeNodeCount++;
     }
 
     /**
-     * Remove the given active node registered for the given line. If there are no more active nodes
-     * for this line, adjust the startLine accordingly.
-     * @param line number of the line ending at the node's corresponding breakpoint
+     * Deactivates the given node. If there are no more active nodes for the corresponding
+     * line, adjust the startLine accordingly.
      * @param node the node to deactivate
      */
-    public void removeNode(int line, KnuthNode node) {
-        int headIdx = line * 2;
-        KnuthNode n = getNode(line);
+    public void deactivateNode(KnuthNode node) {
+        int headIdx = node.line * 2;
+        KnuthNode n = getNode(node.line);
         if (n != node) {
             // nodes could be rightly deactivated in a different order
             KnuthNode prevNode = null;



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