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 ac...@apache.org on 2008/06/23 11:46:43 UTC

svn commit: r670500 [1/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/expr/ src/java/org/apache/fop/fo/extensions/xmp/ src/java/org/apache/fop/fo/flow/ sr...

Author: acumiskey
Date: Mon Jun 23 02:46:41 2008
New Revision: 670500

URL: http://svn.apache.org/viewvc?rev=670500&view=rev
Log:
Merged revisions 669423,669436,669835,670217,670222,670323,670325,670332,670335-670336,670341,670344,670401,670409,670411-670412,670422-670424,670492 via svnmerge from 
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r669423 | jeremias | 2008-06-19 09:25:46 +0100 (Thu, 19 Jun 2008) | 1 line
  
  Simplifications and a Checkstyle fix.
........
  r669436 | jeremias | 2008-06-19 10:46:12 +0100 (Thu, 19 Jun 2008) | 2 lines
  
  Separation of concerns:
  Split FOEventHandler into FOEventHandler and FOTreeBuilderContext. The latter contains stuff only used at tree-building stage. FOEventHandler is oriented towards output.
........
  r669835 | acumiskey | 2008-06-20 10:18:56 +0100 (Fri, 20 Jun 2008) | 1 line
  
  Strict/loose validation of <fo:table-footer/> ordering somehow got lost in processing feedback branch merge.
........
  r670217 | acumiskey | 2008-06-21 17:10:03 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Moved the contents of TableBody into a new abstract base class TablePart, which is now subclassed by TableBody, TableHeader and TableFooter.
........
  r670222 | acumiskey | 2008-06-21 17:28:56 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Moved the contents of TableBody into a new abstract base class TablePart, which is now subclassed by TableBody, TableHeader and TableFooter.
........
  r670323 | adelmelle | 2008-06-22 10:07:47 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Addition to r670217
........
  r670325 | adelmelle | 2008-06-22 10:28:56 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Minor javadoc correction
........
  r670332 | adelmelle | 2008-06-22 11:21:03 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Minor tweak: avoid warning when running through Saxon
........
  r670335 | adelmelle | 2008-06-22 11:53:51 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Avoid StackOverflow on TableColumn.toString() during debugging.
........
  r670336 | adelmelle | 2008-06-22 12:01:27 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Minor tweak: use XG Commons version of the interface
........
  r670341 | adelmelle | 2008-06-22 12:18:03 +0100 (Sun, 22 Jun 2008) | 2 lines
  
  Changed FONode.addCharacters() signature to match the characters() event (use 'length' as a parameter instead of 'end')
........
  r670344 | adelmelle | 2008-06-22 12:28:06 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Changed signature for static handleWhiteSpaceFor(), and used internally to make the code a bit more compact
........
  r670401 | adelmelle | 2008-06-22 20:19:17 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Correction: characters() expects a 'length' not an 'endIndex'
........
  r670409 | adelmelle | 2008-06-22 21:18:27 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Very minor tweak: simplify conditional
........
  r670411 | adelmelle | 2008-06-22 21:38:28 +0100 (Sun, 22 Jun 2008) | 2 lines
  
  Deleted deprecated interface; unused after r670336
........
  r670412 | adelmelle | 2008-06-22 21:57:43 +0100 (Sun, 22 Jun 2008) | 6 lines
  
  Partial fix of FOEventHandler call sequence (see also Bugzilla #45237):
  call startOfNode() after addChildNode()
  moved initialization for tableFOs to processNode()
  moved finishing code to a finalizeNode() method (which is now also used by AbstractRetrieveMarker)
  restored protected status of startOfNode()/endOfNode() in fo.flow.table package
........
  r670422 | adelmelle | 2008-06-22 23:10:55 +0100 (Sun, 22 Jun 2008) | 4 lines
  
  Switch FOText to use a java.nio.CharBuffer, and implement the CharSequence interface.
  TextLayoutManager no longer duplicates the char array, operates on the FOText (charAt(i))
  Additionally: endOfNode() for FOText and Character deferred until after white-space handling.
........
  r670423 | adelmelle | 2008-06-22 23:17:00 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Added missing file from r670422
........
  r670424 | adelmelle | 2008-06-22 23:18:53 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Another missing file...
........
  r670492 | lfurini | 2008-06-23 10:24:14 +0100 (Mon, 23 Jun 2008) | 2 lines
  
  Added support for non-zero borders and padding on page regions.
  Testcase included, now disabled because it is supposed to run with relaxed validation switched on.
........

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilderContext.java
      - copied unchanged from r670492, xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilderContext.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableBody.java
      - copied unchanged from r670492, xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/TableBody.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TablePart.java
      - copied unchanged from r670492, xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/TablePart.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/simple-page-master_borders_padding.xml
      - copied unchanged from r670492, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/simple-page-master_borders_padding.xml
Removed:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/XMLizable.java
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/   (props changed)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/Page.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/RegionReference.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOEventHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FONode.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilder.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObj.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObjMixed.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/RecursiveCharIterator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/expr/PropertyException.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Marker.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/Table.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCell.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableColumn.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFooter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableHeader.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableRow.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/pagination/Root.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/CharUtilities.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/testcase2fo.xsl

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun 23 02:46:41 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-668603
+/xmlgraphics/fop/trunk:1-670492

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/Page.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/Page.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/Page.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/Page.java Mon Jun 23 02:46:41 2008
@@ -126,6 +126,10 @@
             } else {
                 rr = new RegionReference(r, rvp);
             }
+            // set borders and padding traits
+            // (a little extensions wrt what prescribed by the specs at 6.4.14)
+            TraitSetter.addBorders(rr, r.getCommonBorderPaddingBackground(), false, false, false, false, null);
+            TraitSetter.addPadding(rr, r.getCommonBorderPaddingBackground(), false, false, false, false, null);
             setRegionReferencePosition(rr, r, rvp.getViewArea());
             rvp.setRegionReference(rr);
             setRegionViewport(r.getNameId(), rvp);
@@ -289,3 +293,4 @@
 
 }
 
+

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/RegionReference.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/RegionReference.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/RegionReference.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/area/RegionReference.java Mon Jun 23 02:46:41 2008
@@ -73,6 +73,18 @@
         blocks.add(child);
     }
 
+    /** {@inheritDoc} */
+    public int getBPD() {
+        // subtract bpd of borders and padding before / after
+        return super.getBPD() - getBorderAndPaddingWidthBefore() - getBorderAndPaddingWidthAfter();
+    }
+    
+    /** {@inheritDoc} */
+    public int getIPD() {
+        // subtract ipd of borders and padding start / end
+        return super.getIPD() - getBorderAndPaddingWidthStart() - getBorderAndPaddingWidthEnd();
+    }
+
     /**
      * Set the Coordinate Transformation Matrix which transforms content
      * coordinates in this region reference area which are specified in
@@ -133,7 +145,7 @@
     public void addBlock(Block block) {
         addChildArea(block);
     }
-
+    
     /**
      * Clone this region.
      * This is used when cloning the page by the page master.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOEventHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOEventHandler.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOEventHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOEventHandler.java Mon Jun 23 02:46:41 2008
@@ -19,9 +19,6 @@
 
 package org.apache.fop.fo;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.xml.sax.SAXException;
 
 import org.apache.fop.apps.FOUserAgent;
@@ -43,6 +40,9 @@
 import org.apache.fop.fo.flow.PageNumberCitationLast;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.flow.table.TableCell;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.flow.table.TableRow;
@@ -75,27 +75,6 @@
     protected FontInfo fontInfo;
 
     /**
-     * The current set of id's in the FO tree.
-     * This is used so we know if the FO tree contains duplicates.
-     */
-    private Set idReferences = new HashSet();
-    
-    /**
-     * The property list maker.
-     */
-    protected PropertyListMaker propertyListMaker;
-
-    /**
-     * The XMLWhitespaceHandler for this tree
-     */
-    protected XMLWhiteSpaceHandler whiteSpaceHandler = new XMLWhiteSpaceHandler();
-    
-    /**
-     * Indicates whether processing descendants of a marker
-     */
-    private boolean inMarker = false;
-    
-    /**
      * Main constructor
      * @param foUserAgent the apps.FOUserAgent instance for this process
      */
@@ -106,14 +85,6 @@
     }
 
     /**
-     * Retuns the set of ID references.
-     * @return the ID references
-     */
-    public Set getIDReferences() {
-        return idReferences;
-    }
-
-    /**
      * Returns the User Agent object associated with this FOEventHandler.
      * @return the User Agent object
      */
@@ -130,54 +101,6 @@
     }
 
     /**
-     * Return the propertyListMaker.
-     * 
-     * @return the currently active {@link PropertyListMaker}
-     */
-    public PropertyListMaker getPropertyListMaker() {
-        return propertyListMaker;
-    }
-     
-    /**
-     * Set a new propertyListMaker.
-     * 
-     * @param propertyListMaker the new {@link PropertyListMaker} to use
-     */
-    public void setPropertyListMaker(PropertyListMaker propertyListMaker) {
-        this.propertyListMaker = propertyListMaker;
-    }
-    
-    /**
-     * Return the XMLWhiteSpaceHandler
-     * @return the whiteSpaceHandler
-     */
-    public XMLWhiteSpaceHandler getXMLWhiteSpaceHandler() {
-        return whiteSpaceHandler;
-    }
-
-    /**
-     * Switch to or from marker context
-     * (used by FOTreeBuilder when processing
-     *  a marker)
-     * 
-     * @param inMarker  true if a marker is being processed; 
-     *                  false otherwise
-     *
-     */
-    protected void switchMarkerContext(boolean inMarker) {
-        this.inMarker = inMarker;
-    }
-    
-    /**
-     * Check whether in marker context
-     * 
-     * @return true if a marker is being processed
-     */
-    protected boolean inMarker() {
-        return this.inMarker;
-    }
-    
-    /**
      * This method is called to indicate the start of a new document run.
      * @throws SAXException In case of a problem
      */
@@ -337,44 +260,44 @@
 
     /**
      *
-     * @param th TableBody that is starting;
+     * @param header TableHeader that is starting;
      */
-    public void startHeader(TableBody th) {
+    public void startHeader(TableHeader header) {
     }
 
     /**
      *
-     * @param th TableBody that is ending.
+     * @param header TableHeader that is ending.
      */
-    public void endHeader(TableBody th) {
+    public void endHeader(TableHeader header) {
     }
 
     /**
      *
-     * @param tf TableFooter that is starting.
+     * @param footer TableFooter that is starting.
      */
-    public void startFooter(TableBody tf) {
+    public void startFooter(TableFooter footer) {
     }
 
     /**
      *
-     * @param tf TableFooter that is ending.
+     * @param footer TableFooter that is ending.
      */
-    public void endFooter(TableBody tf) {
+    public void endFooter(TableFooter footer) {
     }
 
     /**
      *
-     * @param tb TableBody that is starting.
+     * @param body TableBody that is starting.
      */
-    public void startBody(TableBody tb) {
+    public void startBody(TableBody body) {
     }
 
     /**
      *
-     * @param tb TableBody that is ending.
+     * @param body TableBody that is ending.
      */
-    public void endBody(TableBody tb) {
+    public void endBody(TableBody body) {
     }
 
     /**
@@ -566,7 +489,7 @@
      * @param start Offset for characters to process.
      * @param length Portion of array to process.
      */
-    public void characters(char data[], int start, int length) {
+    public void characters(char[] data, int start, int length) {
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FONode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FONode.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FONode.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FONode.java Mon Jun 23 02:46:41 2008
@@ -22,7 +22,6 @@
 // Java
 import java.util.ListIterator;
 import java.util.Map;
-import java.util.NoSuchElementException;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
@@ -158,11 +157,19 @@
     }
 
     /**
+     * Returns the context class providing information used during FO tree building.
+     * @return the builder context
+     */
+    public FOTreeBuilderContext getBuilderContext() {
+        return parent.getBuilderContext();
+    }
+    
+    /**
      * Indicates whether this node is a child of an fo:marker.
      * @return true if this node is a child of an fo:marker
      */
     protected boolean inMarker() {
-        return getFOEventHandler().inMarker();
+        return getBuilderContext().inMarker();
     }
 
     /**
@@ -267,12 +274,12 @@
      *
      * @param data array of characters containing text to be added
      * @param start starting array element to add
-     * @param end ending array element to add
+     * @param length number of elements to add
      * @param pList currently applicable PropertyList
      * @param locator location in the XSL-FO source file.
      * @throws FOPException if there's a problem during processing
      */
-    protected void addCharacters(char[] data, int start, int end,
+    protected void addCharacters(char[] data, int start, int length,
                                  PropertyList pList,
                                  Locator locator) throws FOPException {
         // ignore
@@ -291,11 +298,16 @@
      * Primarily used for making final content model validation checks
      * and/or informing the {@link FOEventHandler} that the end of this FO
      * has been reached.
+     * The default implementation simply calls {@link #finalizeNode()}, without
+     * sending any event to the {@link FOEventHandler}.
+     * <br/><i>Note: the recommended way to override this method in subclasses is</i>
+     * <br/><br/><code>super.endOfNode(); // invoke finalizeNode()
+     * <br/>getFOEventHandler().endXXX(); // send endOfNode() notification</code>
      *
      * @throws FOPException if there's a problem during processing
      */
     protected void endOfNode() throws FOPException {
-        // do nothing by default
+        this.finalizeNode();
     }
 
     /**
@@ -320,6 +332,20 @@
     }
 
     /**
+     * Finalize this node.
+     * This method can be overridden by subclasses to perform finishing
+     * tasks (cleanup, validation checks, ...) without triggering
+     * endXXX() events in the {@link FOEventHandler}.
+     * The method is called by the default {@link #endOfNode()}
+     * implementation.
+     * 
+     * @throws FOPException in case there was an error
+     */
+    public void finalizeNode() throws FOPException {
+        // do nothing by default
+    }
+
+    /**
      * Return the parent node of this node
      *
      * @return the parent node of this node

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java Mon Jun 23 02:46:41 2008
@@ -20,6 +20,7 @@
 package org.apache.fop.fo;
 
 import java.awt.Color;
+import java.nio.CharBuffer;
 import java.util.NoSuchElementException;
 
 import org.xml.sax.Locator;
@@ -33,48 +34,17 @@
 import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.util.CharUtilities;
 
 /**
  * A text node (PCDATA) in the formatting object tree.
- *
- * Unfortunately the BufferManager implementation holds
- * onto references to the character data in this object
- * longer than the lifetime of the object itself, causing
- * excessive memory consumption and OOM errors.
  */
-public class FOText extends FONode {
+public class FOText extends FONode implements CharSequence {
 
-    /**
-     * the character array containing the text
-     */
-    public char[] ca;
-
-    /**
-     * The starting valid index of the ca array 
-     * to be processed.
-     *
-     * This value is originally equal to 0, but becomes 
-     * incremented during leading whitespace removal by the flow.Block class,  
-     * via the TextCharIterator.remove() method below.
-     */
-    public int startIndex = 0;
+    /** the <code>CharBuffer</code> containing the text */
+    private CharBuffer charBuffer;
 
-    /**
-     * The ending valid index of the ca array 
-     * to be processed.
-     *
-     * This value is originally equal to ca.length, but becomes 
-     * decremented during between-word whitespace removal by the 
-     * XMLWhiteSpaceHandler via the TextCharIterator.remove() 
-     * method below.
-     */
-    public int endIndex = 0;
-
-    /** properties relevant for PCDATA */
-    /* TODO: these are basically always the same as the parent FObj or FObjMixed
-     *      so maybe those can be removed, and the accessors could  
-     *      dispatch the call to the parent?
-     */
+    /** properties relevant for #PCDATA */
     private CommonFont commonFont;
     private CommonHyphenation commonHyphenation;
     private Color color;
@@ -105,10 +75,10 @@
      * which FOText nodes are descendants of the same block.
      */
     private Block ancestorBlock = null;
-    
+
     /** Holds the text decoration values. May be null */
     private CommonTextDecoration textDecoration;
-    
+
     private static final int IS_WORD_CHAR_FALSE = 0;
     private static final int IS_WORD_CHAR_TRUE = 1;
     private static final int IS_WORD_CHAR_MAYBE = 2;
@@ -123,37 +93,61 @@
     }
 
     /** {@inheritDoc} */
-    protected void addCharacters(char[] data, int start, int end,
+    protected void addCharacters(char[] data, int start, int length,
             PropertyList list, Locator locator) throws FOPException {
 
-        int length = end - start;
-        int calength = 0;
-        char[] nca;
-        if (ca != null) {
-            calength = ca.length;
-            nca = new char[calength + length];
-            System.arraycopy(ca, 0, nca, 0, calength);
+        if (this.charBuffer == null) {
+            // buffer not yet initialized, do so now
+            this.charBuffer = CharBuffer.allocate(length);
         } else {
-            nca = new char[length];
+            // allocate a larger buffer, and transfer contents
+            int newLength = this.charBuffer.limit() + length;
+            CharBuffer newBuffer = CharBuffer.allocate(newLength);
+            this.charBuffer.rewind();
+            newBuffer.put(this.charBuffer);
+            this.charBuffer = newBuffer;
         }
-        System.arraycopy(data, start, nca, calength, length);
-        endIndex = nca.length;
-        this.ca = nca;
-     }
+        // append characters
+        this.charBuffer.put(data, start, length);
+
+    }
 
     /**
-     * {@inheritDoc} 
+     * Return the array of characters for this instance.
+     *
+     * @return  a char array containing the text
      */
+    public char[] getCharArray() {
+
+        if (this.charBuffer == null) {
+            return null;
+        }
+
+        if (this.charBuffer.hasArray()) {
+            return this.charBuffer.array();
+        }
+
+        // only if the buffer implementation has
+        // no accessible backing array, return a new one
+        char[] ca = new char[this.charBuffer.limit()];
+        this.charBuffer.rewind();
+        this.charBuffer.get(ca);
+        return ca;
+
+    }
+
+    /** {@inheritDoc} */
     public FONode clone(FONode parent, boolean removeChildren)
             throws FOPException {
         FOText ft = (FOText) super.clone(parent, removeChildren);
         if (removeChildren) {
-            //not really removing, but just make sure the char array 
-            //pointed to is really a different one, and reset any
-            //possible whitespace-handling effects
-            if (ca != null) {
-                ft.ca = new char[ca.length];
-                System.arraycopy(ca, 0, ft.ca, 0, ca.length);
+            // not really removing, just make sure the char buffer
+            // pointed to is really a different one
+            if (this.charBuffer != null) {
+                ft.charBuffer = CharBuffer.allocate(this.charBuffer.limit());
+                this.charBuffer.rewind();
+                ft.charBuffer.put(this.charBuffer);
+                ft.charBuffer.rewind();
             }
         }
         ft.prevFOTextThisBlock = null;
@@ -162,29 +156,33 @@
         return ft;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
-        commonFont = pList.getFontProps();
-        commonHyphenation = pList.getHyphenationProps();
-        color = pList.get(Constants.PR_COLOR).getColor(getUserAgent());
-        keepTogether = pList.get(Constants.PR_KEEP_TOGETHER).getKeep();
-        lineHeight = pList.get(Constants.PR_LINE_HEIGHT).getSpace();
-        letterSpacing = pList.get(Constants.PR_LETTER_SPACING);
-        whiteSpaceCollapse = pList.get(Constants.PR_WHITE_SPACE_COLLAPSE).getEnum();
-        whiteSpaceTreatment = pList.get(Constants.PR_WHITE_SPACE_TREATMENT).getEnum();
-        textTransform = pList.get(Constants.PR_TEXT_TRANSFORM).getEnum();
-        wordSpacing = pList.get(Constants.PR_WORD_SPACING);
-        wrapOption = pList.get(Constants.PR_WRAP_OPTION).getEnum();
-        textDecoration = pList.getTextDecorationProps();
-        baselineShift = pList.get(Constants.PR_BASELINE_SHIFT).getLength();
+        this.commonFont = pList.getFontProps();
+        this.commonHyphenation = pList.getHyphenationProps();
+        this.color = pList.get(Constants.PR_COLOR).getColor(getUserAgent());
+        this.keepTogether = pList.get(Constants.PR_KEEP_TOGETHER).getKeep();
+        this.lineHeight = pList.get(Constants.PR_LINE_HEIGHT).getSpace();
+        this.letterSpacing = pList.get(Constants.PR_LETTER_SPACING);
+        this.whiteSpaceCollapse = pList.get(Constants.PR_WHITE_SPACE_COLLAPSE).getEnum();
+        this.whiteSpaceTreatment = pList.get(Constants.PR_WHITE_SPACE_TREATMENT).getEnum();
+        this.textTransform = pList.get(Constants.PR_TEXT_TRANSFORM).getEnum();
+        this.wordSpacing = pList.get(Constants.PR_WORD_SPACING);
+        this.wrapOption = pList.get(Constants.PR_WRAP_OPTION).getEnum();
+        this.textDecoration = pList.getTextDecorationProps();
+        this.baselineShift = pList.get(Constants.PR_BASELINE_SHIFT).getLength();
     }
 
     /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().characters(
+                this.getCharArray(), 0, this.charBuffer.limit());
+    }
+
+    /** {@inheritDoc} */
+    public void finalizeNode() {
         textTransform();
-        getFOEventHandler().characters(ca, startIndex, endIndex);
     }
 
     /**
@@ -198,16 +196,20 @@
      */
     public boolean willCreateArea() {
         if (whiteSpaceCollapse == Constants.EN_FALSE
-                && endIndex - startIndex > 0) {
+                && this.charBuffer.limit() > 0) {
             return true;
         }
 
-        for (int i = startIndex; i < endIndex; i++) {
-            char ch = ca[i];
-            if (!((ch == ' ')
-                    || (ch == '\n')
-                    || (ch == '\r')
-                    || (ch == '\t'))) { // whitespace
+        char ch;
+        this.charBuffer.rewind();
+        while (this.charBuffer.hasRemaining()) {
+            ch = this.charBuffer.get();
+            if (!((ch == CharUtilities.SPACE)
+                    || (ch == CharUtilities.LINEFEED_CHAR)
+                    || (ch == CharUtilities.CARRIAGE_RETURN)
+                    || (ch == CharUtilities.TAB))) {
+                // not whitespace
+                this.charBuffer.rewind();
                 return true;
             }
         }
@@ -222,7 +224,7 @@
     }
 
      /**
-     * This method is run as part of the ancestor Block's flushText(), to 
+     * This method is run as part of the ancestor Block's flushText(), to
      * create xref pointers to the previous FOText objects within the same Block
      * @param  ancestorBlock the ancestor fo:block
      */
@@ -230,7 +232,7 @@
         this.ancestorBlock = ancestorBlock;
         // if the last FOText is a sibling, point to it, and have it point here
         if (ancestorBlock.lastFOTextProcessed != null) {
-            if (ancestorBlock.lastFOTextProcessed.ancestorBlock 
+            if (ancestorBlock.lastFOTextProcessed.ancestorBlock
                     == this.ancestorBlock) {
                 prevFOTextThisBlock = ancestorBlock.lastFOTextProcessed;
                 prevFOTextThisBlock.nextFOTextThisBlock = this;
@@ -241,16 +243,47 @@
     }
 
     /**
-     * This method is run as part of the Constructor, to handle the
-     * text-transform property.
+     * This method is run as part of endOfNode(), to handle the
+     * text-transform property for accumulated FOText
      */
     private void textTransform() {
-        if (getFOEventHandler().inMarker() 
+        if (getBuilderContext().inMarker()
                 || textTransform == Constants.EN_NONE) {
             return;
         }
-        for (int i = 0; i < endIndex; i++) {
-            ca[i] = charTransform(i);
+
+        this.charBuffer.rewind();
+        CharBuffer tmp = this.charBuffer.slice();
+        char c;
+        int lim = this.charBuffer.limit();
+        int pos = -1;
+        while (++pos < lim) {
+            c = this.charBuffer.get();
+            switch (textTransform) {
+                case Constants.EN_UPPERCASE:
+                    tmp.put(Character.toUpperCase(c));
+                    break;
+                case Constants.EN_LOWERCASE:
+                    tmp.put(Character.toLowerCase(c));
+                    break;
+                case Constants.EN_CAPITALIZE:
+                    if (isStartOfWord(pos)) {
+                        /*
+                         Use toTitleCase here. Apparently, some languages use
+                         a different character to represent a letter when using
+                         initial caps than when all of the letters in the word
+                         are capitalized. We will try to let Java handle this.
+                        */
+                        tmp.put(Character.toTitleCase(c));
+                    } else {
+                        tmp.put(c);
+                    }
+                    break;
+                default:
+                     //should never happen as the property subsystem catches that case
+                    assert false;
+                    //nop
+            }
         }
     }
 
@@ -261,7 +294,7 @@
      * well, such as word-spacing. The definition of "word" is somewhat ambiguous
      * and appears to be definable by the user agent.
      *
-     * @param i index into ca[]
+     * @param i index into charBuffer
      *
      * @return True if the character at this location is the start of a new
      * word.
@@ -269,33 +302,33 @@
     private boolean isStartOfWord(int i) {
         char prevChar = getRelativeCharInBlock(i, -1);
         /* All we are really concerned about here is of what type prevChar
-           is. If inputChar is not part of a word, then the Java
-           conversions will (we hope) simply return inputChar.
-        */
-        switch (isWordChar(prevChar)) {
-        case IS_WORD_CHAR_TRUE:
-            return false;
-        case IS_WORD_CHAR_FALSE:
-            return true;
-        /* "MAYBE" implies that additional context is needed. An example is a
-         * single-quote, either straight or closing, which might be interpreted
-         * as a possessive or a contraction, or might be a closing quote.
+         * is. If inputChar is not part of a word, then the Java
+         * conversions will (we hope) simply return inputChar.
          */
-        case IS_WORD_CHAR_MAYBE:
-            char prevPrevChar = getRelativeCharInBlock(i, -2);
-            switch (isWordChar(prevPrevChar)) {
+        switch (isWordChar(prevChar)) {
             case IS_WORD_CHAR_TRUE:
                 return false;
             case IS_WORD_CHAR_FALSE:
                 return true;
+            /* "MAYBE" implies that additional context is needed. An example is a
+             * single-quote, either straight or closing, which might be interpreted
+             * as a possessive or a contraction, or might be a closing quote.
+             */
             case IS_WORD_CHAR_MAYBE:
-                return true;
+                char prevPrevChar = getRelativeCharInBlock(i, -2);
+                switch (isWordChar(prevPrevChar)) {
+                case IS_WORD_CHAR_TRUE:
+                    return false;
+                case IS_WORD_CHAR_FALSE:
+                    return true;
+                case IS_WORD_CHAR_MAYBE:
+                    return true;
+                default:
+                    return false;
+            }
             default:
                 return false;
         }
-        default:
-            return false;
-        }
     }
 
     /**
@@ -304,7 +337,7 @@
      * block as one unit, allowing text in adjoining FOText objects to be
      * returned if the parameters are outside of the current object.
      *
-     * @param i index into ca[]
+     * @param i index into the CharBuffer
      * @param offset signed integer with relative position within the
      *   block of the character to return. To return the character immediately
      *   preceding i, pass -1. To return the character immediately after i,
@@ -313,30 +346,34 @@
      * the offset points to an area outside of the block.
      */
     private char getRelativeCharInBlock(int i, int offset) {
+
+        int charIndex = i + offset;
         // The easy case is where the desired character is in the same FOText
-        if (((i + offset) >= 0) && ((i + offset) <= this.endIndex)) {
-            return ca[i + offset];
+        if (charIndex >= 0 && charIndex < this.length()) {
+            return this.charAt(i + offset);
         }
+
         // For now, we can't look at following FOText nodes
         if (offset > 0) {
-             return '\u0000';
-         }
+             return CharUtilities.NULL_CHAR;
+        }
+
         // Remaining case has the text in some previous FOText node
         boolean foundChar = false;
-        char charToReturn = '\u0000';
+        char charToReturn = CharUtilities.NULL_CHAR;
         FOText nodeToTest = this;
         int remainingOffset = offset + i;
         while (!foundChar) {
             if (nodeToTest.prevFOTextThisBlock == null) {
-                foundChar = true;
                 break;
             }
             nodeToTest = nodeToTest.prevFOTextThisBlock;
-            if ((nodeToTest.endIndex + remainingOffset) >= 0) {
-                charToReturn = nodeToTest.ca[nodeToTest.endIndex + remainingOffset];
+            int diff = nodeToTest.length() + remainingOffset - 1;
+            if (diff >= 0) {
+                charToReturn = nodeToTest.charAt(diff);
                 foundChar = true;
             } else {
-                remainingOffset = remainingOffset + nodeToTest.endIndex;
+                remainingOffset += diff;
             }
         }
         return charToReturn;
@@ -367,39 +404,6 @@
     }
 
     /**
-     * Transforms one character in ca[] using the text-transform property.
-     *
-     * @param i the index into ca[]
-     * @return char with transformed value
-     */
-    private char charTransform(int i) {
-        switch (textTransform) {
-        /* put NONE first, as this is probably the common case */
-        case Constants.EN_NONE:
-            return ca[i];
-        case Constants.EN_UPPERCASE:
-            return Character.toUpperCase(ca[i]);
-        case Constants.EN_LOWERCASE:
-            return Character.toLowerCase(ca[i]);
-        case Constants.EN_CAPITALIZE:
-            if (isStartOfWord(i)) {
-                /*
-                 Use toTitleCase here. Apparently, some languages use
-                 a different character to represent a letter when using
-                 initial caps than when all of the letters in the word
-                 are capitalized. We will try to let Java handle this.
-                */
-                return Character.toTitleCase(ca[i]);
-            } else {
-                return ca[i];
-            }
-        default:
-            assert false; //should never happen as the property subsystem catches that case
-            return ca[i];
-        }
-    }
-
-    /**
      * Determines whether the input char should be considered part of a
      * "word". This is used primarily to determine whether the character
      * immediately following starts a new word, but may have other uses.
@@ -484,57 +488,64 @@
     }
 
     private class TextCharIterator extends CharIterator {
-        private int curIndex = 0;
 
-        /* Current space removal process:  just increment the startIndex
-           to "remove" leading spaces from ca, until an unremoved character
-           is found.  Then perform arraycopy's to remove extra spaces
-           between words.  nextCharCalled is used to determine if an 
-           unremoved character has already been found--if its value > 2
-           than it means that has occurred (it is reset to zero each time we 
-           remove a space via incrementing the startIndex.)  */
-        private int nextCharCalled = 0;
-        
+        int currentPosition = 0;
+
+        boolean canRemove = false;
+        boolean canReplace = false;
+
+        /** {@inheritDoc} */
         public boolean hasNext() {
-           if (curIndex == 0) {
-//             log.debug("->" + new String(ca) + "<-");
-          }
-           return (curIndex < endIndex);
+           return (this.currentPosition < charBuffer.limit());
         }
 
+        /** {@inheritDoc} */
         public char nextChar() {
-            if (curIndex < endIndex) {
-                nextCharCalled++;
-                // Just a char class? Don't actually care about the value!
-                return ca[curIndex++];
+
+            if (this.currentPosition < charBuffer.limit()) {
+                this.canRemove = true;
+                this.canReplace = true;
+                return charBuffer.get(currentPosition++);
             } else {
                 throw new NoSuchElementException();
             }
+
         }
 
+        /** {@inheritDoc} */
         public void remove() {
-            if (curIndex < endIndex && nextCharCalled < 2) {
-                startIndex++;
-                nextCharCalled = 0;
-//              log.debug("removeA: " + new String(ca, startIndex, endIndex - startIndex));
-            } else if (curIndex < endIndex) {
-                // copy from curIndex to end to curIndex-1
-                System.arraycopy(ca, curIndex, ca, curIndex - 1, 
-                    endIndex - curIndex);
-                endIndex--;
-                curIndex--;
-//              log.debug("removeB: " + new String(ca, startIndex, endIndex - startIndex));
-            } else if (curIndex == endIndex) {
-//              log.debug("removeC: " + new String(ca, startIndex, endIndex - startIndex));
-                endIndex--;
-                curIndex--;
+
+            if (this.canRemove) {
+                charBuffer.position(currentPosition);
+                // Slice the buffer at the current position
+                CharBuffer tmp = charBuffer.slice();
+                // Reset position to before current character
+                charBuffer.position(--currentPosition);
+                if (tmp.hasRemaining()) {
+                    // Transfer any remaining characters
+                    charBuffer.mark();
+                    charBuffer.put(tmp);
+                    charBuffer.reset();
+                }
+                // Decrease limit
+                charBuffer.limit(charBuffer.limit() - 1);
+                // Make sure following calls fail, unless nextChar() was called
+                this.canRemove = false;
+            } else {
+                throw new IllegalStateException();
             }
+
         }
 
+        /** {@inheritDoc} */
         public void replaceChar(char c) {
-            if (curIndex > 0 && curIndex <= endIndex) {
-                ca[curIndex - 1] = c;
+
+            if (this.canReplace) {
+                charBuffer.put(currentPosition - 1, c);
+            } else {
+                throw new IllegalStateException();
             }
+
         }
 
     }
@@ -560,7 +571,7 @@
         return color;
     }
 
-    /** 
+    /**
      * @return the "keep-together" property.
      */
     public KeepProperty getKeepTogether() {
@@ -571,40 +582,40 @@
      * @return the "letter-spacing" property.
      */
     public Property getLetterSpacing() {
-        return letterSpacing; 
+        return letterSpacing;
     }
-    
+
     /**
      * @return the "line-height" property.
      */
     public SpaceProperty getLineHeight() {
         return lineHeight;
     }
-    
+
     /**
      * @return the "white-space-treatment" property
      */
     public int getWhitespaceTreatment() {
         return whiteSpaceTreatment;
     }
-    
+
     /**
      * @return the "word-spacing" property.
      */
     public Property getWordSpacing() {
-        return wordSpacing; 
+        return wordSpacing;
     }
-    
+
     /**
      * @return the "wrap-option" property.
      */
     public int getWrapOption() {
-        return wrapOption; 
+        return wrapOption;
     }
-    
+
     /** @return the "text-decoration" property. */
     public CommonTextDecoration getTextDecoration() {
-        return textDecoration; 
+        return textDecoration;
     }
 
     /** @return the baseline-shift property */
@@ -614,14 +625,12 @@
 
     /** {@inheritDoc} */
     public String toString() {
-        StringBuffer sb = new StringBuffer(super.toString());
-        sb.append(" (").append(ca).append(")");
-        return sb.toString();
+        return (this.charBuffer == null) ? "" : this.charBuffer.toString();
     }
- 
+
     /** {@inheritDoc} */
     public String getLocalName() {
-        return null;
+        return "#PCDATA";
     }
 
     /** {@inheritDoc} */
@@ -631,10 +640,34 @@
 
     /** {@inheritDoc} */
     protected String gatherContextInfo() {
-        if (getLocator() != null) {
+        if (this.locator != null) {
             return super.gatherContextInfo();
         } else {
-            return new String(ca).trim();
+            return this.toString();
         }
-    }    
-}
\ No newline at end of file
+    }
+
+    /** {@inheritDoc} */
+    public char charAt(int position) {
+        return this.charBuffer.get(position);
+    }
+
+    /** {@inheritDoc} */
+    public CharSequence subSequence(int start, int end) {
+        return this.charBuffer.subSequence(start, end);
+    }
+
+    /** {@inheritDoc} */
+    public int length() {
+        return this.charBuffer.limit();
+    }
+
+    /**
+     * Resets the backing <code>java.nio.CharBuffer</code>
+     */
+    public void resetBuffer() {
+        if (this.charBuffer != null) {
+            this.charBuffer.rewind();
+        }
+    }
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOTreeBuilder.java Mon Jun 23 02:46:41 2008
@@ -66,6 +66,9 @@
     
     /** Current delegate ContentHandler to receive the SAX events */
     protected ContentHandler delegate;
+
+    /** Provides information used during tree building stage. */
+    private FOTreeBuilderContext builderContext;
     
     /** The object that handles formatting and rendering to a stream */
     private FOEventHandler foEventHandler;
@@ -101,7 +104,8 @@
         //one of the RTF-, MIF- etc. Handlers.
         foEventHandler = foUserAgent.getRendererFactory().createFOEventHandler(
                 foUserAgent, outputFormat, stream);
-        foEventHandler.setPropertyListMaker(new PropertyListMaker() {
+        builderContext = new FOTreeBuilderContext();
+        builderContext.setPropertyListMaker(new PropertyListMaker() {
             public PropertyList make(FObj fobj, PropertyList parentPropertyList) {
                 return new StaticPropertyList(fobj, parentPropertyList);
             }
@@ -140,7 +144,7 @@
             log.debug("Building formatting object tree");
         }
         foEventHandler.startDocument();
-        this.mainFOHandler = new MainFOHandler(); 
+        this.mainFOHandler = new MainFOHandler();
         this.mainFOHandler.startDocument();
         this.delegate = this.mainFOHandler;
     }
@@ -150,8 +154,7 @@
         this.delegate.endDocument();
         if (this.rootFObj == null && empty) {
             FOValidationEventProducer eventProducer
-                = FOValidationEventProducer.Provider.get(
-                    foEventHandler.getUserAgent().getEventBroadcaster());
+                = FOValidationEventProducer.Provider.get(userAgent.getEventBroadcaster());
             eventProducer.emptyDocument(this);
         }
         rootFObj = null;
@@ -221,7 +224,7 @@
         } else {
             //No formatting results available for output formats no 
             //involving the layout engine.
-            return null;   
+            return null;
         }
     }
     
@@ -254,7 +257,7 @@
                         || !localName.equals("root")) {
                     FOValidationEventProducer eventProducer
                         = FOValidationEventProducer.Provider.get(
-                                foEventHandler.getUserAgent().getEventBroadcaster());
+                                userAgent.getEventBroadcaster());
                     eventProducer.invalidFORoot(this, FONode.getNodeString(namespaceURI, localName),
                             getEffectiveLocator());
                 }
@@ -271,6 +274,7 @@
                 foNode = fobjMaker.make(currentFObj);
                 if (rootFObj == null) {
                     rootFObj = (Root) foNode;
+                    rootFObj.setBuilderContext(builderContext);
                     rootFObj.setFOEventHandler(foEventHandler);
                 }
                 propertyList = foNode.createPropertyList(
@@ -278,13 +282,12 @@
                 foNode.processNode(localName, getEffectiveLocator(), 
                                     attlist, propertyList);
                 if (foNode.getNameId() == Constants.FO_MARKER) {
-                    if (foEventHandler.inMarker()) {
+                    if (builderContext.inMarker()) {
                         nestedMarkerDepth++;
                     } else {
-                        foEventHandler.switchMarkerContext(true);
+                        builderContext.switchMarkerContext(true);
                     }
                 }
-                foNode.startOfNode();
             } catch (IllegalArgumentException e) {
                 throw new SAXException(e);
             }
@@ -310,9 +313,16 @@
             }
 
             currentFObj = foNode;
-            if (propertyList != null && !foEventHandler.inMarker()) {
+            if (propertyList != null && !builderContext.inMarker()) {
                 currentPropertyList = propertyList;
             }
+
+            // fo:characters can potentially be removed during
+            // white-space handling.
+            // Do not notify the FOEventHandler.
+            if (currentFObj.getNameId() != Constants.FO_CHARACTER) {
+                currentFObj.startOfNode();
+            }
         }
 
         /** {@inheritDoc} */
@@ -329,17 +339,22 @@
                         + ") vs. " + localName + " (" + uri + ")");
             }
             
-            currentFObj.endOfNode();
+            // fo:characters can potentially be removed during
+            // white-space handling.
+            // Do not notify the FOEventHandler.
+            if (currentFObj.getNameId() != Constants.FO_CHARACTER) {
+                currentFObj.endOfNode();
+            }
             
             if (currentPropertyList != null
                     && currentPropertyList.getFObj() == currentFObj
-                    && !foEventHandler.inMarker()) {
+                    && !builderContext.inMarker()) {
                 currentPropertyList = currentPropertyList.getParentPropertyList();
             }
             
             if (currentFObj.getNameId() == Constants.FO_MARKER) {
                 if (nestedMarkerDepth == 0) {
-                    foEventHandler.switchMarkerContext(false);
+                    builderContext.switchMarkerContext(false);
                 } else {
                     nestedMarkerDepth--;
                 }
@@ -356,7 +371,7 @@
         public void characters(char[] data, int start, int length) 
             throws FOPException {
             if (currentFObj != null) {
-                currentFObj.addCharacters(data, start, start + length, 
+                currentFObj.addCharacters(data, start, length, 
                         currentPropertyList, getEffectiveLocator());
             }
         }
@@ -379,7 +394,7 @@
             if (maker instanceof UnknownXMLObj.Maker) {
                 FOValidationEventProducer eventProducer
                     = FOValidationEventProducer.Provider.get(
-                        foEventHandler.getUserAgent().getEventBroadcaster());
+                        userAgent.getEventBroadcaster());
                 eventProducer.unknownFormattingObject(this, currentFObj.getName(),
                         new QName(namespaceURI, localName),
                         getEffectiveLocator());

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObj.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObj.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObj.java Mon Jun 23 02:46:41 2008
@@ -130,7 +130,7 @@
      */
     protected PropertyList createPropertyList(PropertyList parent, 
                     FOEventHandler foEventHandler) throws FOPException {
-        return foEventHandler.getPropertyListMaker().make(this, parent);
+        return getBuilderContext().getPropertyListMaker().make(this, parent);
     }
 
     /**
@@ -165,7 +165,7 @@
      */
     private void checkId(String id) throws ValidationException {
         if (!inMarker() && !id.equals("")) {
-            Set idrefs = getFOEventHandler().getIDReferences();
+            Set idrefs = getBuilderContext().getIDReferences();
             if (!idrefs.contains(id)) {
                 idrefs.add(id);
             } else {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObjMixed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObjMixed.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObjMixed.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FObjMixed.java Mon Jun 23 02:46:41 2008
@@ -28,29 +28,29 @@
  * (= those that can contain both child {@link FONode}s and <code>#PCDATA</code>).
  */
 public abstract class FObjMixed extends FObj {
-    
+
     /** Represents accumulated, pending FO text. See {@link #flushText()}. */
-    protected FOText ft = null;
-    
+    private FOText ft = null;
+
     /** Used for white-space handling; start CharIterator at node ... */
     protected FONode currentTextNode;
-    
+
     /** Used in creating pointers between subsequent {@link FOText} nodes
-     *  in the same {@link org.apache.fop.fo.flow.Block} 
+     *  in the same {@link org.apache.fop.fo.flow.Block}
      *  (for handling text-transform) */
     protected FOText lastFOTextProcessed = null;
-    
+
     /**
      * Base constructor
-     * 
+     *
      * @param parent FONode that is the parent of this object
      */
     protected FObjMixed(FONode parent) {
         super(parent);
     }
-    
+
     /** {@inheritDoc} */
-    protected void addCharacters(char[] data, int start, int end,
+    protected void addCharacters(char[] data, int start, int length,
                                  PropertyList pList,
                                  Locator locator) throws FOPException {
         if (ft == null) {
@@ -60,113 +60,124 @@
                 ft.bind(pList);
             }
         }
-        ft.addCharacters(data, start, end, null, null);
+        ft.addCharacters(data, start, length, null, null);
     }
 
     /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
-        flushText();
-        if (!inMarker()
-                || getNameId() == FO_MARKER) {
-            getFOEventHandler().whiteSpaceHandler
-                .handleWhiteSpace(this, currentTextNode);
-        }
+
         super.endOfNode();
+        if (!inMarker() || getNameId() == FO_MARKER) {
+            // send character[s]() events to the FOEventHandler
+            sendCharacters();
+        }
+        
     }
 
     /**
-     * Handles white-space for the node that is passed in, 
+     * Handles white-space for the node that is passed in,
      * starting at its current text-node
-     * (used by {@link org.apache.fop.fo.flow.RetrieveMarker} 
+     * (used by {@link org.apache.fop.fo.flow.RetrieveMarker}
      *  to trigger 'end-of-node' white-space handling)
-     *  
+     *
      * @param fobj  the node for which to handle white-space
+     * @param nextChild the next child to be added
      */
-    protected static void handleWhiteSpaceFor(FObjMixed fobj) {
-        fobj.getFOEventHandler().getXMLWhiteSpaceHandler()
-            .handleWhiteSpace(fobj, fobj.currentTextNode);
+    protected static void handleWhiteSpaceFor(FObjMixed fobj, FONode nextChild) {
+        fobj.getBuilderContext().getXMLWhiteSpaceHandler()
+            .handleWhiteSpace(fobj, fobj.currentTextNode, nextChild);
     }
-    
+
     /**
-     * Adds accumulated text as one FOText instance, unless
-     * the one instance's <code>char</code> array contains more than 
-     * <code>Short.MAX_VALUE</code> characters. In the latter case the 
-     * instance is split up into more manageable chunks.
-     * 
+     * Creates block-pointers between subsequent FOText nodes
+     * in the same Block. (used for handling text-transform)
+     *
+     * TODO: !! Revisit: does not take into account fo:characters !!
+     *
      * @throws FOPException if there is a problem during processing
      */
-    protected void flushText() throws FOPException {
+    private void flushText() throws FOPException {
         if (ft != null) {
             FOText lft = ft;
             /* make sure nested calls to itself have no effect */
             ft = null;
-            FOText tmpText;
-            int indexStart = 0;
-            int indexEnd = (lft.ca.length > Short.MAX_VALUE 
-                            ? Short.MAX_VALUE : lft.ca.length) - 1;
-            int charCount = 0;
-            short tmpSize;
-            while (charCount < lft.ca.length) {
-                tmpSize = (short) (indexEnd - indexStart + 1);
-                charCount += tmpSize;
-                tmpText = (FOText) lft.clone(this, false);
-                tmpText.ca = new char[tmpSize];
-                tmpText.startIndex = 0;
-                tmpText.endIndex = tmpSize;
-                System.arraycopy(lft.ca, indexStart, 
-                                tmpText.ca, 0, indexEnd - indexStart + 1);
-                if (getNameId() == FO_BLOCK) {
-                    tmpText.createBlockPointers((org.apache.fop.fo.flow.Block) this);
-                    this.lastFOTextProcessed = tmpText;
-                } else if (getNameId() != FO_MARKER
-                        && getNameId() != FO_TITLE
-                        && getNameId() != FO_BOOKMARK_TITLE) {
-                    FONode fo = parent;
-                    int foNameId = fo.getNameId();
-                    while (foNameId != FO_BLOCK
-                            && foNameId != FO_MARKER
-                            && foNameId != FO_TITLE
-                            && foNameId != FO_BOOKMARK_TITLE
-                            && foNameId != FO_PAGE_SEQUENCE) {
-                        fo = fo.getParent();
-                        foNameId = fo.getNameId();
-                    }
-                    if (foNameId == FO_BLOCK) {
-                        tmpText.createBlockPointers((org.apache.fop.fo.flow.Block) fo);
-                        ((FObjMixed) fo).lastFOTextProcessed = tmpText;
-                    } else if (foNameId == FO_PAGE_SEQUENCE
-                                && tmpText.willCreateArea()) {
-                        log.error("Could not create block pointers."
-                                + " FOText w/o Block ancestor.");
-                    }
+            if (getNameId() == FO_BLOCK) {
+                lft.createBlockPointers((org.apache.fop.fo.flow.Block) this);
+                this.lastFOTextProcessed = lft;
+            } else if (getNameId() != FO_MARKER
+                    && getNameId() != FO_TITLE
+                    && getNameId() != FO_BOOKMARK_TITLE) {
+                FONode fo = parent;
+                int foNameId = fo.getNameId();
+                while (foNameId != FO_BLOCK
+                        && foNameId != FO_MARKER
+                        && foNameId != FO_TITLE
+                        && foNameId != FO_BOOKMARK_TITLE
+                        && foNameId != FO_PAGE_SEQUENCE) {
+                    fo = fo.getParent();
+                    foNameId = fo.getNameId();
+                }
+                if (foNameId == FO_BLOCK) {
+                    lft.createBlockPointers((org.apache.fop.fo.flow.Block) fo);
+                    ((FObjMixed) fo).lastFOTextProcessed = lft;
+                } else if (foNameId == FO_PAGE_SEQUENCE
+                            && lft.willCreateArea()) {
+                    log.error("Could not create block pointers."
+                            + " FOText w/o Block ancestor.");
+                }
+            }
+            this.addChildNode(lft);
+        }
+    }
+
+    private void sendCharacters() throws FOPException {
+
+        if (this.currentTextNode != null) {
+            FONodeIterator nodeIter
+                    = this.getChildNodes(this.currentTextNode);
+            FONode node;
+            while (nodeIter.hasNext()) {
+                node = nodeIter.nextNode();
+                assert (node instanceof FOText
+                        || node.getNameId() == FO_CHARACTER);
+                if (node.getNameId() == FO_CHARACTER) {
+                    node.startOfNode();
                 }
-                tmpText.endOfNode();
-                addChildNode(tmpText);
-                indexStart = indexEnd + 1;
-                indexEnd = (((lft.ca.length - charCount) < Short.MAX_VALUE)
-                    ? lft.ca.length : charCount + Short.MAX_VALUE) - 1;
+                node.endOfNode();
             }
         }
+        this.currentTextNode = null;
     }
 
     /** {@inheritDoc} */
     protected void addChildNode(FONode child) throws FOPException {
+
         flushText();
         if (!inMarker()) {
             if (child instanceof FOText || child.getNameId() == FO_CHARACTER) {
-                if (currentTextNode == null) {
-                    currentTextNode = child;
+                if (this.currentTextNode == null) {
+                    this.currentTextNode = child;
                 }
             } else {
                 // handle white-space for all text up to here
-                getFOEventHandler().whiteSpaceHandler
-                    .handleWhiteSpace(this, currentTextNode, child);
-                currentTextNode = null;
+                handleWhiteSpaceFor(this, child);
+                // send character[s]() events to the FOEventHandler
+                sendCharacters();
             }
         }
         super.addChildNode(child);
     }
-    
+
+    /** {@inheritDoc} */
+    public void finalizeNode() throws FOPException {
+
+        flushText();
+        if (!inMarker() || getNameId() == FO_MARKER) {
+            handleWhiteSpaceFor(this, null);
+        }
+
+    }
+
     /**
      * Returns a {@link CharIterator} over this FO's character content
      * 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/RecursiveCharIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/RecursiveCharIterator.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/RecursiveCharIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/RecursiveCharIterator.java Mon Jun 23 02:46:41 2008
@@ -113,7 +113,7 @@
      */
     public boolean hasNext() {
         while (curCharIter != null) {
-            if (curCharIter.hasNext() == false) {
+            if (!curCharIter.hasNext()) {
                 getNextCharIter();
             } else {
                 return true;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/expr/PropertyException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/expr/PropertyException.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/expr/PropertyException.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/expr/PropertyException.java Mon Jun 23 02:46:41 2008
@@ -37,7 +37,7 @@
 
     /**
      * Constructor
-     * @param the Exception causing this PropertyException
+     * @param cause the Exception causing this PropertyException
      */
     public PropertyException(Exception cause) {
         super(cause);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java Mon Jun 23 02:46:41 2008
@@ -22,7 +22,7 @@
 import java.io.Serializable;
 
 import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.util.XMLizable;
+import org.apache.xmlgraphics.util.XMLizable;
 import org.apache.xmlgraphics.xmp.Metadata;
 import org.apache.xmlgraphics.xmp.XMPConstants;
 import org.xml.sax.ContentHandler;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java Mon Jun 23 02:46:41 2008
@@ -16,20 +16,22 @@
  */
 
 /* $Id$ */
+
 package org.apache.fop.fo.flow;
 
+import java.util.Iterator;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FObjMixed;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.flow.table.TableFObj;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.apps.FOPException;
-import org.xml.sax.Locator;
-
-import java.util.Iterator;
+import org.apache.fop.fo.flow.table.TableFObj;
 
 /**
  * Abstract base class for the <a href="http://www.w3.org/TR/xsl/#fo_retrieve-marker">
@@ -80,7 +82,7 @@
     }
 
     private PropertyList createPropertyListFor(FObj fo, PropertyList parent) {
-        return getFOEventHandler().getPropertyListMaker().make(fo, parent);
+        return getBuilderContext().getPropertyListMaker().make(fo, parent);
     }
 
     private void cloneSingleNode(FONode child, FONode newParent,
@@ -100,16 +102,10 @@
                         getLocator(),
                         pList,
                         newPropertyList);
-                if (newChild instanceof TableFObj) {
-                    // TODO calling startOfNode (and endOfNode, below) on other fobjs may
-                    // have undesirable side-effects. This is really ugly and will need to
-                    // be addressed sooner or later
-                    ((TableFObj) newChild).startOfNode();
-                }
                 addChildTo(newChild, (FObj) newParent);
                 if (newChild.getNameId() == FO_TABLE) {
                     Table t = (Table) child;
-                    cloneSubtree(t.getColumns().listIterator(),
+                    cloneSubtree(t.getColumns().iterator(),
                             newChild, marker, newPropertyList);
                     cloneSingleNode(t.getTableHeader(),
                             newChild, marker, newPropertyList);
@@ -118,18 +114,15 @@
                 }
                 cloneSubtree(child.getChildNodes(), newChild,
                         marker, newPropertyList);
-                if (newChild instanceof TableFObj) {
-                    // TODO this is ugly
-                    ((TableFObj) newChild).endOfNode();
-                }
             } else if (child instanceof FOText) {
                 FOText ft = (FOText) newChild;
                 ft.bind(parentPropertyList);
                 addChildTo(newChild, (FObj) newParent);
             }
-            if (newChild instanceof FObjMixed) {
-                handleWhiteSpaceFor((FObjMixed) newChild);
-            }
+
+            // trigger end-of-node white-space handling
+            // and finalization for table-FOs
+            newChild.finalizeNode();
         }
     }
 
@@ -167,7 +160,7 @@
         }
         cloneSubtree(marker.getChildNodes(), this,
                         marker, propertyList);
-        handleWhiteSpaceFor(this);
+        handleWhiteSpaceFor(this, null);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Marker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Marker.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Marker.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Marker.java Mon Jun 23 02:46:41 2008
@@ -26,8 +26,8 @@
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOTreeBuilderContext;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FObjMixed;
 import org.apache.fop.fo.PropertyList;
@@ -84,10 +84,10 @@
     
     /** {@inheritDoc} */
     protected void startOfNode() {
-        FOEventHandler foEventHandler = getFOEventHandler(); 
+        FOTreeBuilderContext builderContext = getBuilderContext(); 
         // Push a new property list maker which will make MarkerPropertyLists.
-        savePropertyListMaker = foEventHandler.getPropertyListMaker();
-        foEventHandler.setPropertyListMaker(new PropertyListMaker() {
+        savePropertyListMaker = builderContext.getPropertyListMaker();
+        builderContext.setPropertyListMaker(new PropertyListMaker() {
             public PropertyList make(FObj fobj, PropertyList parentPropertyList) {
                 PropertyList pList = new MarkerPropertyList(fobj, parentPropertyList);
                 descendantPropertyLists.put(fobj, pList);
@@ -100,7 +100,7 @@
     protected void endOfNode() throws FOPException {
         super.endOfNode();
         // Pop the MarkerPropertyList maker.
-        getFOEventHandler().setPropertyListMaker(savePropertyListMaker);
+        getBuilderContext().setPropertyListMaker(savePropertyListMaker);
         savePropertyListMaker = null;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/BorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/BorderResolver.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/BorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/BorderResolver.java Mon Jun 23 02:46:41 2008
@@ -40,7 +40,7 @@
      * 
      * @param part the part that has started
      */
-    void startPart(TableBody part);
+    void startPart(TablePart part);
 
     /**
      * Receives notification of the end of a table-header/footer/body.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/CollapsingBorderResolver.java Mon Jun 23 02:46:41 2008
@@ -73,7 +73,7 @@
      */
     private abstract class Resolver {
 
-        protected TableBody tablePart;
+        protected TablePart tablePart;
 
         protected boolean firstInPart;
 
@@ -177,7 +177,7 @@
             }
         }
 
-        void startPart(TableBody part) {
+        void startPart(TablePart part) {
             tablePart = part;
             firstInPart = true;
             borderStartTableAndBody = collapsingBorderModel.determineWinner(table.borderStart,
@@ -415,8 +415,8 @@
     }
 
     /** {@inheritDoc} */
-    public void startPart(TableBody part) {
-        if (part.isTableHeader()) {
+    public void startPart(TablePart part) {
+        if (part instanceof TableHeader) {
             delegate = new ResolverInHeader();
         } else {
             if (leadingBorders == null || table.omitHeaderAtBreak()) {
@@ -427,7 +427,7 @@
                     leadingBorders.add(border);
                 }
             }
-            if (part.isTableFooter()) {
+            if (part instanceof TableFooter) {
                 resolverInFooter = new ResolverInFooter();
                 delegate = resolverInFooter;
             } else {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java Mon Jun 23 02:46:41 2008
@@ -143,8 +143,8 @@
     }
 
     /** {@inheritDoc} */
-    void endRow(TableBody body) {
-        handleRowEnd(body);
+    void endRow(TablePart part) {
+        handleRowEnd(part);
     }
 
     private void handleRowEnd(TableCellContainer container) {
@@ -172,7 +172,7 @@
     }
 
     /** {@inheritDoc} */
-    void startTablePart(TableBody part) {
+    void startTablePart(TablePart part) {
         firstInPart = true;
         borderResolver.startPart(part);
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java Mon Jun 23 02:46:41 2008
@@ -78,12 +78,12 @@
      * 
      * @return the enclosing table part
      */
-    public TableBody getTableBody() {
+    public TablePart getTablePart() {
         FONode node = cell.getParent();
         if (node instanceof TableRow) {
             node = node.getParent();
         }
-        return (TableBody) node;
+        return (TablePart) node;
     }
 
     public TableCellLayoutManager getCellLM() {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/RowGroupBuilder.java Mon Jun 23 02:46:41 2008
@@ -57,7 +57,7 @@
 
     /**
      * Receives notification of the end of the current row. If the current row finishes
-     * the row group, the {@link TableBody#addRowGroup(List)} method of the parent table
+     * the row group, the {@link TablePart#addRowGroup(List)} method of the parent table
      * part will be called.
      */
     abstract void endTableRow();
@@ -65,21 +65,21 @@
     /**
      * Receives notification of the end of the current row, when the source contains no
      * fo:table-row element. If the current row finishes the row group, the
-     * {@link TableBody#addRowGroup(List)} method of the given table part will be called.
+     * {@link TablePart#addRowGroup(List)} method of the given table part will be called.
      * 
      * <p>If the source does contain explicit fo:table-row elements, then the
      * {@link #endTableRow()} method will be called instead.</p>
      * 
      * @param part the part containing the current row
      */
-    abstract void endRow(TableBody part);
+    abstract void endRow(TablePart part);
 
     /**
      * Receives notification of the start of a table-header/footer/body.
      * 
      * @param part the part being started
      */
-    abstract void startTablePart(TableBody part);
+    abstract void startTablePart(TablePart part);
 
     /**
      * Receives notification of the end of a table-header/footer/body. The current

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/SeparateBorderResolver.java Mon Jun 23 02:46:41 2008
@@ -31,7 +31,7 @@
     }
 
     /** {@inheritDoc} */
-    public void startPart(TableBody part) {
+    public void startPart(TablePart part) {
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/Table.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/Table.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/Table.java Mon Jun 23 02:46:41 2008
@@ -76,8 +76,8 @@
     private ColumnNumberManager columnNumberManager = new ColumnNumberManager();
 
     /** the table-header and -footer */
-    private TableBody tableHeader = null;
-    private TableBody tableFooter = null;
+    private TableHeader tableHeader = null;
+    private TableFooter tableFooter = null;
 
     /** used for validation */
     private boolean tableColumnFound = false;
@@ -157,10 +157,8 @@
         this.propList = pList;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void startOfNode() throws FOPException {
+    /** {@inheritDoc} */
+    protected void startOfNode() throws FOPException {
         super.startOfNode();
         getFOEventHandler().startTable(this);
     }
@@ -200,7 +198,9 @@
                 } else {
                     tableFooterFound = true;
                     if (tableBodyFound) {
-                        nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)", true);
+                        if (getUserAgent().validateStrictly()) {
+                            nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)", true);
+                        }
                         if (!isSeparateBorderModel()) {
                             TableEventProducer eventProducer = TableEventProducer.Provider.get(
                                     getUserAgent().getEventBroadcaster());
@@ -216,11 +216,15 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void endOfNode() throws FOPException {
+    /** {@inheritDoc} */
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endTable(this);
+    }
 
+    /** {@inheritDoc} */
+    public void finalizeNode() throws FOPException {
+        
         if (!tableBodyFound) {
            missingChildElementError(
                    "(marker*,table-column*,table-header?,table-footer?"
@@ -242,13 +246,10 @@
             this.propList = null;
             rowGroupBuilder = null;
         }
-        getFOEventHandler().endTable(this);
-
+        
     }
-
-    /**
-     * {@inheritDoc}
-     */
+    
+    /** {@inheritDoc} */
     protected void addChildNode(FONode child) throws FOPException {
 
         int childId = child.getNameId();
@@ -277,10 +278,10 @@
             }
             switch (childId) {
             case FO_TABLE_FOOTER:
-                tableFooter = (TableBody) child;
+                tableFooter = (TableFooter) child;
                 break;
             case FO_TABLE_HEADER:
-                tableHeader = (TableBody) child;
+                tableHeader = (TableHeader) child;
                 break;
             default:
                 super.addChildNode(child);
@@ -402,12 +403,12 @@
     }
 
     /** @return the body for the table-header. */
-    public TableBody getTableHeader() {
+    public TableHeader getTableHeader() {
         return tableHeader;
     }
 
     /** @return the body for the table-footer. */
-    public TableBody getTableFooter() {
+    public TableFooter getTableFooter() {
         return tableFooter;
     }
 
@@ -521,17 +522,17 @@
         return FO_TABLE;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public FONode clone(FONode parent, boolean removeChildren)
         throws FOPException {
         Table clone = (Table) super.clone(parent, removeChildren);
-        clone.columnsFinalized = false;
         if (removeChildren) {
             clone.columns = new ArrayList();
+            clone.columnsFinalized = false;
+            clone.columnNumberManager = new ColumnNumberManager();
             clone.tableHeader = null;
             clone.tableFooter = null;
+            clone.rowGroupBuilder = null;
         }
         return clone;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCell.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCell.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCell.java Mon Jun 23 02:46:41 2008
@@ -81,7 +81,7 @@
         startsRow = pList.get(PR_STARTS_ROW).getEnum();
         // For properly computing columnNumber
         if (startsRow() && getParent().getNameId() != FO_TABLE_ROW) {
-            ((TableBody) getParent()).signalNewRow();
+            ((TablePart) getParent()).signalNewRow();
         }
         endsRow = pList.get(PR_ENDS_ROW).getEnum();
         columnNumber = pList.get(PR_COLUMN_NUMBER).getNumeric().getValue();
@@ -91,17 +91,24 @@
     }
 
     /** {@inheritDoc} */
-    public void startOfNode() throws FOPException {
+    protected void startOfNode() throws FOPException {
         super.startOfNode();
         getFOEventHandler().startCell(this);
     }
 
     /**
      * Make sure content model satisfied, if so then tell the
-     * FOEventHandler that we are at the end of the flow.
+     * FOEventHandler that we are at the end of the table-cell.
      * {@inheritDoc}
      */
-    public void endOfNode() throws FOPException {
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endCell(this);
+    }
+
+    /** {@inheritDoc} */
+    public void finalizeNode() throws FOPException {
+        
         if (!blockItemFound) {
             missingChildElementError("marker* (%block;)+", true);
         }
@@ -111,9 +118,9 @@
                     getUserAgent().getEventBroadcaster());
             eventProducer.startEndRowUnderTableRowWarning(this, getLocator());
         }
-        getFOEventHandler().endCell(this);
+        
     }
-
+    
     /**
      * {@inheritDoc}
      * <br>XSL Content Model: marker* (%block;)+

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java Mon Jun 23 02:46:41 2008
@@ -95,9 +95,9 @@
     /**
      * Returns the enclosing table-header/footer/body of this container.
      * 
-     * @return <code>this</code> for TableBody, or the parent element for TableRow
+     * @return <code>this</code> for TablePart, or the parent element for TableRow
      */
-    abstract TableBody getTablePart();
+    abstract TablePart getTablePart();
 
     /** {@inheritDoc} */
     public ColumnNumberManager getColumnNumberManager() {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableColumn.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableColumn.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableColumn.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableColumn.java Mon Jun 23 02:46:41 2008
@@ -239,7 +239,7 @@
             sb.append(" number-columns-spanned=")
                 .append(getNumberColumnsSpanned());
         }
-        sb.append(" column-width=").append(getColumnWidth());
+        sb.append(" column-width=").append(((Property)getColumnWidth()).getString());
         return sb.toString();
     }
 



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