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 [2/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...

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java Mon Jun 23 02:46:41 2008
@@ -34,6 +34,8 @@
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.PropertyMaker;
 import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
+import org.xml.sax.Locator;
+import org.xml.sax.Attributes;
 
 /**
  * Common base class for table-related FOs
@@ -207,8 +209,8 @@
     }
 
     /** {@inheritDoc} */
-    public void startOfNode() throws FOPException {
-        super.startOfNode();
+    public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
+        super.processNode(elementName, locator, attlist, pList);
         Table table = getTable();
         if (!inMarker() && !table.isSeparateBorderModel()) {
             collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
@@ -216,15 +218,7 @@
             setCollapsedBorders();
         }
     }
-
-    /*
-     * TODO made public so that RetrieveMarker can access it.
-     */
-    /** {@inheritDoc} */
-    public void endOfNode() throws FOPException {
-        super.endOfNode();
-    }
-
+    
     /**
      * Prepares the borders of this element if the collapsing-border model is in use.
      * Conflict resolution with parent elements is done where applicable.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFooter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFooter.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFooter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFooter.java Mon Jun 23 02:46:41 2008
@@ -28,7 +28,7 @@
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-footer">
  * <code>fo:table-footer</code></a> object.
  */
-public class TableFooter extends TableBody {
+public class TableFooter extends TablePart {
 
     /**
      * Create a TableFooter instance with the given {@link FONode}
@@ -41,17 +41,15 @@
     }
 
     /** {@inheritDoc} */
-    public void startOfNode() throws FOPException {
+    protected void startOfNode() throws FOPException {
         super.startOfNode();
+        getFOEventHandler().startFooter(this);
     }
 
     /** {@inheritDoc} */
-    public void endOfNode() throws FOPException {
-        if (!(tableRowsFound || tableCellsFound)) {
-            missingChildElementError("marker* (table-row+|table-cell+)");
-        } else {
-            finishLastRowGroup();
-        }
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endFooter(this);
     }
 
     /** {@inheritDoc} */
@@ -67,8 +65,4 @@
         return FO_TABLE_FOOTER;
     }
 
-    /** {@inheritDoc} */
-    protected boolean isTableFooter() {
-        return true;
-    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableHeader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableHeader.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableHeader.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableHeader.java Mon Jun 23 02:46:41 2008
@@ -28,7 +28,7 @@
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-header">
  * <code>fo:table-header</code></a> object.
  */
-public class TableHeader extends TableBody {
+public class TableHeader extends TablePart {
 
     /**
      * Create a TableHeader instance with the given {@link FONode}
@@ -40,17 +40,15 @@
     }
 
     /** {@inheritDoc} */
-    public void startOfNode() throws FOPException {
+    protected void startOfNode() throws FOPException {
         super.startOfNode();
+        getFOEventHandler().startHeader(this);
     }
 
     /** {@inheritDoc} */
-    public void endOfNode() throws FOPException {
-        if (!(tableRowsFound || tableCellsFound)) {
-            missingChildElementError("marker* (table-row+|table-cell+)");
-        } else {
-            finishLastRowGroup();
-        }
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endHeader(this);
     }
 
     /** {@inheritDoc} */
@@ -66,8 +64,4 @@
         return FO_TABLE_HEADER;
     }
 
-    /** {@inheritDoc} */
-    protected boolean isTableHeader() {
-        return true;
-    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableRow.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableRow.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableRow.java Mon Jun 23 02:46:41 2008
@@ -78,32 +78,38 @@
     /** {@inheritDoc} */
     public void processNode(String elementName, Locator locator,
             Attributes attlist, PropertyList pList) throws FOPException {
+        super.processNode(elementName, locator, attlist, pList);
         if (!inMarker()) {
-            TableBody body = (TableBody) parent;
-            pendingSpans = body.pendingSpans;
-            columnNumberManager = body.columnNumberManager;
+            TablePart part = (TablePart) parent;
+            pendingSpans = part.pendingSpans;
+            columnNumberManager = part.columnNumberManager;
         }
-        super.processNode(elementName, locator, attlist, pList);
     }
 
     /** {@inheritDoc} */
     protected void addChildNode(FONode child) throws FOPException {
         if (!inMarker()) {
             TableCell cell = (TableCell) child;
-            TableBody body = (TableBody) getParent();
-            addTableCellChild(cell, body.isFirst(this));
+            TablePart part = (TablePart) getParent();
+            addTableCellChild(cell, part.isFirst(this));
         }
         super.addChildNode(child);
     }
 
     /** {@inheritDoc} */
-    public void startOfNode() throws FOPException {
+    protected void startOfNode() throws FOPException {
         super.startOfNode();
         getFOEventHandler().startRow(this);
     }
 
     /** {@inheritDoc} */
-    public void endOfNode() throws FOPException {
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endRow(this);
+    }
+
+    /** {@inheritDoc} */
+    public void finalizeNode() throws FOPException {
         if (firstChild == null) {
             missingChildElementError("(table-cell+)");
         }
@@ -111,9 +117,8 @@
             pendingSpans = null;
             columnNumberManager = null;
         }
-        getFOEventHandler().endRow(this);
     }
-
+    
     /**
      * {@inheritDoc} String, String)
      * <br>XSL Content Model: (table-cell+)
@@ -129,8 +134,8 @@
     }
 
     /** {@inheritDoc} */
-    TableBody getTablePart() {
-        return (TableBody) parent;
+    TablePart getTablePart() {
+        return (TablePart) parent;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java Mon Jun 23 02:46:41 2008
@@ -82,7 +82,7 @@
     }
 
     /** {@inheritDoc} */
-    void endRow(final TableBody part) {
+    void endRow(final TablePart part) {
         events.add(new Event() {
             public void play(RowGroupBuilder rowGroupBuilder) {
                 rowGroupBuilder.endRow(part);
@@ -91,7 +91,7 @@
     }
 
     /** {@inheritDoc} */
-    void startTablePart(final TableBody part) {
+    void startTablePart(final TablePart part) {
         events.add(new Event() {
             public void play(RowGroupBuilder rowGroupBuilder) {
                 rowGroupBuilder.startTablePart(part);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/pagination/Root.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/pagination/Root.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/pagination/Root.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/pagination/Root.java Mon Jun 23 02:46:41 2008
@@ -27,6 +27,7 @@
 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.PropertyList;
 import org.apache.fop.fo.ValidationException;
@@ -59,6 +60,11 @@
     private int totalPagesGenerated = 0;
 
     /**
+     * Context class used while building the FO tree.
+     */
+    private FOTreeBuilderContext builderContext;
+    
+    /**
      * FOEventHandler object for this FO Tree
      */
     private FOEventHandler foEventHandler = null;
@@ -164,10 +170,23 @@
         return foEventHandler;   
     }
 
-     /**
-     * Gets the last page number generated by the previous page-sequence
-     * @return the last page number, 0 if no page sequences yet generated
+    /**
+     * Sets the builder context for this FO tree.
+     * @param context the builder context to be used
      */
+    public void setBuilderContext(FOTreeBuilderContext context) {
+        this.builderContext = context;
+    }
+
+    /** {@inheritDoc} */
+    public FOTreeBuilderContext getBuilderContext() {
+        return this.builderContext;
+    }
+    
+    /**
+    * Gets the last page number generated by the previous page-sequence
+    * @return the last page number, 0 if no page sequences yet generated
+    */
     public int getEndingPageNumberOfPreviousSequence() {
         return endingPageNumberOfPreviousSequence;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java Mon Jun 23 02:46:41 2008
@@ -23,7 +23,6 @@
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
-import org.apache.fop.fo.properties.LengthProperty;
 
 /**
  * Custom Maker for page-height / page-width
@@ -54,8 +53,8 @@
         Property p = super.get(0, propertyList, tryInherit, tryDefault);    
         FObj fo = propertyList.getFObj();
         String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT)
-            ? fo.getFOEventHandler().getUserAgent().getPageHeight()
-                    : fo.getFOEventHandler().getUserAgent().getPageWidth();
+            ? fo.getUserAgent().getPageHeight()
+                    : fo.getUserAgent().getPageWidth();
         
         if (p.getEnum() == Constants.EN_INDEFINITE) {
             int otherId = (propId == Constants.PR_PAGE_HEIGHT) 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java Mon Jun 23 02:46:41 2008
@@ -88,7 +88,7 @@
     /**
      * Selects a font which is able to display the most of the given characters.
      * 
-     * @param textArray
+     * @param charSeq
      *            Text to go through
      * @param firstIndex
      *            first index within text.
@@ -100,9 +100,10 @@
      *            the Percent-based context needed for creating the actual font.
      * @return a Font object.
      */
-    public static Font selectFontForCharactersInText(char[] textArray,
+    public static Font selectFontForCharactersInText(CharSequence charSeq,
             int firstIndex, int breakIndex, FOText text,
             PercentBaseContext context) {
+
         final FontInfo fi = text.getFOEventHandler().getFontInfo();
         final CommonFont commonFont = text.getCommonFont();
         final FontTriplet[] fontkeys = commonFont.getFontState(fi);
@@ -115,7 +116,7 @@
                     commonFont.fontSize.getValue(context));
             fonts[fontnum] = font;
             for (int pos = firstIndex; pos < breakIndex; pos++) {
-                if (font.hasChar(textArray[pos])) {
+                if (font.hasChar(charSeq.charAt(pos))) {
                     fontCount[fontnum]++;
                 }
             }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java Mon Jun 23 02:46:41 2008
@@ -41,8 +41,8 @@
 import org.apache.fop.fo.flow.ExternalGraphic;
 import org.apache.fop.fo.flow.Footnote;
 import org.apache.fop.fo.flow.Inline;
-import org.apache.fop.fo.flow.InlineLevel;
 import org.apache.fop.fo.flow.InlineContainer;
+import org.apache.fop.fo.flow.InlineLevel;
 import org.apache.fop.fo.flow.InstreamForeignObject;
 import org.apache.fop.fo.flow.Leader;
 import org.apache.fop.fo.flow.ListBlock;
@@ -224,7 +224,7 @@
     public static class FOTextLayoutManagerMaker extends Maker {
         public void make(FONode node, List lms) {
             FOText foText = (FOText) node;
-            if (foText.endIndex - foText.startIndex > 0) {
+            if (foText.length() > 0) {
                 lms.add(new TextLayoutManager(foText));
             }
         }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Mon Jun 23 02:46:41 2008
@@ -61,20 +61,20 @@
      * Number of word-spaces?
      */
     private class AreaInfo {
-        private final short startIndex;
-        private final short breakIndex;
-        private final short wordSpaceCount;
-        private short letterSpaceCount;
+        private final int startIndex;
+        private final int breakIndex;
+        private final int wordSpaceCount;
+        private int letterSpaceCount;
         private final MinOptMax areaIPD;
         private final boolean isHyphenated;
         private final boolean isSpace;
         private boolean breakOppAfter;
         private final Font font;
 
-        AreaInfo(final short startIndex,
-                        final short breakIndex,
-                        final short wordSpaceCount,
-                        final short letterSpaceCount,
+        AreaInfo(final int startIndex,
+                        final int breakIndex,
+                        final int wordSpaceCount,
+                        final int letterSpaceCount,
                         final MinOptMax areaIPD,
                         final boolean isHyphenated,
                         final boolean isSpace,
@@ -132,7 +132,7 @@
     private static final MinOptMax ZERO_MINOPTMAX = new MinOptMax(0);
 
     private final FOText foText;
-    private final char[] textArray;
+
     /**
      * Contains an array of widths to adjust for kerning. The first entry can
      * be used to influence the start position of the first letter. The entry i+1 defines the
@@ -143,7 +143,7 @@
     /** Font used for the space between words. */
     private Font spaceFont = null;
     /** Start index of next TextArea */
-    private short nextStart = 0;
+    private int nextStart = 0;
     /** size of a space character (U+0020) glyph in current font */
     private int spaceCharIPD;
     private MinOptMax wordSpaceIPD;
@@ -155,8 +155,8 @@
 
     private boolean hasChanged = false;
     private int returnedIndex = 0;
-    private short thisStart = 0;
-    private short tempStart = 0;
+    private int thisStart = 0;
+    private int tempStart = 0;
     private List changeList = null;
 
     private AlignmentContext alignmentContext = null;
@@ -177,10 +177,7 @@
         super();
         this.foText = node;
 
-        this.textArray = new char[node.endIndex - node.startIndex];
-        System.arraycopy(node.ca, node.startIndex, this.textArray, 0,
-            node.endIndex - node.startIndex);
-        this.letterAdjustArray = new MinOptMax[this.textArray.length + 1];
+        this.letterAdjustArray = new MinOptMax[node.length() + 1];
 
         this.vecAreaInfo = new java.util.ArrayList();
     }
@@ -205,6 +202,8 @@
     /** {@inheritDoc} */
     public void initialize() {
 
+        this.foText.resetBuffer();
+        
         this.spaceFont = FontSelector.selectFontForCharacterInText(' ', this.foText, this);
 
         // With CID fonts, space isn't neccesary currentFontState.width(32)
@@ -296,7 +295,7 @@
             int letterSpaceCount, final int firstAreaInfoIndex,
             final int lastAreaInfoIndex, final MinOptMax realWidth, final LayoutContext context) {
 
-        // TODO: These two statements (if, for) where like this before my recent
+        // TODO: These two statements (if, for) were like this before my recent
         // changes. However, it seems as if they should use the AreaInfo from
         // firstAreaInfoIndex.. lastAreaInfoIndex rather than just the last ai.
         // This needs to be checked.
@@ -441,7 +440,7 @@
                 // areaInfo stores information about spaces
                 // add the spaces - except zero-width spaces - to the TextArea
                 for (int j = areaInfo.startIndex; j < areaInfo.breakIndex; j++) {
-                    final char spaceChar = this.textArray[j];
+                    final char spaceChar = this.foText.charAt(j);
                     if (!CharUtilities.isZeroWidthSpace(spaceChar)) {
                         textArea.addSpace(spaceChar, 0,
                                 CharUtilities.isAdjustableSpace(spaceChar));
@@ -469,8 +468,15 @@
                     for (int j = wordStartIndex; j <= i; j++) {
                         final AreaInfo ai = (AreaInfo) this.vecAreaInfo.get(j);
                         int lsCount = ai.letterSpaceCount;
-                        wordChars.append(this.textArray, ai.startIndex,
-                                ai.breakIndex - ai.startIndex);
+                        /* TODO: in Java 5, StringBuffer has an append() variant
+                         * for CharSequence, so the below iteration can be replaced
+                         * by:
+                         *  wordChars.append(this.foText, ai.startIndex,
+                         *       ai.breakIndex - ai.startIndex);
+                         */
+                        for (int ci = ai.startIndex; ci < ai.breakIndex; ci++) {
+                            wordChars.append(this.foText.charAt(ci));
+                        }
                         for (int k = 0; k < ai.breakIndex - ai.startIndex; k++) {
                             final MinOptMax adj = this.letterAdjustArray[ai.startIndex + k];
                             if (letter > 0) {
@@ -522,7 +528,7 @@
             || CharUtilities.isNonBreakableSpace(ch)
             || CharUtilities.isFixedWidthSpace(ch);
     }
-    
+
     /** {@inheritDoc} */
     public List getNextKnuthElements(final LayoutContext context, final int alignment) {
         this.lineStartBAP = context.getLineStartBorderAndPaddingWidth();
@@ -540,8 +546,8 @@
         boolean inWord = false;
         boolean inWhitespace = false;
         char ch = 0;
-        while (this.nextStart < this.textArray.length) {
-            ch = this.textArray[this.nextStart];
+        while (this.nextStart < this.foText.length()) {
+            ch = this.foText.charAt(this.nextStart);
             boolean breakOpportunity = false;
             final byte breakAction = this.keepTogether ? LineBreakStatus.PROHIBITED_BREAK
                     : lbs.nextChar(ch);
@@ -560,10 +566,10 @@
                     TextLayoutManager.LOG.error("Unexpected breakAction: " + breakAction);
             }
             if (inWord) {
-                if (breakOpportunity 
+                if (breakOpportunity
                         || TextLayoutManager.isSpace(ch)
                         || CharUtilities.isExplicitBreak(ch)) {
-                    // this.textArray[lastIndex] == CharUtilities.SOFT_HYPHEN
+                    // this.foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN
                     prevAi = this.processWord(alignment, sequence, prevAi, ch,
                             breakOpportunity, true);
                 }
@@ -588,24 +594,24 @@
                     || ch == CharUtilities.NBSPACE) {
                 // preserved space or non-breaking space:
                 // create the AreaInfo object
-                ai = new AreaInfo(this.nextStart, (short) (this.nextStart + 1),
-                        (short) 1, (short) 0, this.wordSpaceIPD, false, true,
+                ai = new AreaInfo(this.nextStart, this.nextStart + 1,
+                        1, 0, this.wordSpaceIPD, false, true,
                         breakOpportunity, this.spaceFont);
-                this.thisStart = (short) (this.nextStart + 1);
+                this.thisStart = this.nextStart + 1;
             } else if (CharUtilities.isFixedWidthSpace(ch) || CharUtilities.isZeroWidthSpace(ch)) {
                 // create the AreaInfo object
                 final Font font = FontSelector.selectFontForCharacterInText(ch,
                         this.foText, this);
                 final MinOptMax ipd = new MinOptMax(font.getCharWidth(ch));
-                ai = new AreaInfo(this.nextStart, (short) (this.nextStart + 1),
-                        (short) 0, (short) 0, ipd, false, true,
+                ai = new AreaInfo(this.nextStart, this.nextStart + 1,
+                        0, 0, ipd, false, true,
                         breakOpportunity, font);
-                this.thisStart = (short) (this.nextStart + 1);
+                this.thisStart = this.nextStart + 1;
             } else if (CharUtilities.isExplicitBreak(ch)) {
                 //mandatory break-character: only advance index
-                this.thisStart = (short) (this.nextStart + 1);
+                this.thisStart = this.nextStart + 1;
             }
-            
+
             inWord = !TextLayoutManager.isSpace(ch)
                     && !CharUtilities.isExplicitBreak(ch);
             inWhitespace = ch == CharUtilities.SPACE
@@ -619,17 +625,17 @@
         } else if (inWhitespace) {
             this.processWhitespace(alignment, sequence, true);
         } else if (ai != null) {
-            ai = this.processLeftoverAi(alignment, sequence, ai, ch,
+            this.processLeftoverAi(alignment, sequence, ai, ch,
                     ch == CharUtilities.ZERO_WIDTH_SPACE);
         } else if (CharUtilities.isExplicitBreak(ch)) {
-            sequence = this.processLinebreak(returnList, sequence);
+            this.processLinebreak(returnList, sequence);
         }
 
         if (((List) ListUtil.getLast(returnList)).isEmpty()) {
             //Remove an empty sequence because of a trailing newline
             ListUtil.removeLast(returnList);
         }
-        
+
         this.setFinished(true);
         if (returnList.isEmpty()) {
             return null;
@@ -663,24 +669,20 @@
 
     private AreaInfo processWhitespace(final int alignment,
             final KnuthSequence sequence, final boolean breakOpportunity) {
-        AreaInfo ai;
-        AreaInfo prevAi;
         // End of whitespace
         // create the AreaInfo object
-        ai = new AreaInfo(this.thisStart, this.nextStart,
-                (short) (this.nextStart - this.thisStart), (short) 0,
+        AreaInfo ai = new AreaInfo(this.thisStart, this.nextStart,
+                this.nextStart - this.thisStart, 0,
                 MinOptMax.multiply(this.wordSpaceIPD, this.nextStart
                         - this.thisStart), false, true,
                 breakOpportunity, this.spaceFont);
         this.vecAreaInfo.add(ai);
-        prevAi = ai;
 
         // create the elements
         this.addElementsForASpace(sequence, alignment, ai, this.vecAreaInfo.size() - 1);
-        ai = null;
 
         this.thisStart = this.nextStart;
-        return prevAi;
+        return ai;
     }
 
     private AreaInfo processWord(final int alignment, final KnuthSequence sequence,
@@ -688,21 +690,21 @@
             final boolean checkEndsWithHyphen) {
         AreaInfo ai;
         //Word boundary found, process widths and kerning
-        short lastIndex = this.nextStart;
+        int lastIndex = this.nextStart;
         while (lastIndex > 0
-                && this.textArray[lastIndex - 1] == CharUtilities.SOFT_HYPHEN) {
+                && this.foText.charAt(lastIndex - 1) == CharUtilities.SOFT_HYPHEN) {
             lastIndex--;
         }
         final boolean endsWithHyphen = checkEndsWithHyphen
-                && this.textArray[lastIndex] == CharUtilities.SOFT_HYPHEN;
+                && this.foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
         final Font font = FontSelector
-                .selectFontForCharactersInText(this.textArray,
+                .selectFontForCharactersInText(this.foText,
                         this.thisStart, lastIndex, this.foText, this);
         final int wordLength = lastIndex - this.thisStart;
         final boolean kerning = font.hasKerning();
         final MinOptMax wordIPD = new MinOptMax(0);
         for (int i = this.thisStart; i < lastIndex; i++) {
-            final char c = this.textArray[i];
+            final char c = this.foText.charAt(i);
 
             //character width
             final int charWidth = font.getCharWidth(c);
@@ -712,10 +714,10 @@
             if (kerning) {
                 int kern = 0;
                 if (i > this.thisStart) {
-                    final char previous = this.textArray[i - 1];
+                    final char previous = this.foText.charAt(i - 1);
                     kern = font.getKernValue(previous, c) * font.getFontSize() / 1000;
                 } else if (prevAi != null && !prevAi.isSpace && prevAi.breakIndex > 0) {
-                    final char previous = this.textArray[prevAi.breakIndex - 1];
+                    final char previous = this.foText.charAt(prevAi.breakIndex - 1);
                     kern = font.getKernValue(previous, c) * font.getFontSize() / 1000;
                 }
                 if (kern != 0) {
@@ -730,7 +732,7 @@
                 && lastIndex > 0
                 && endsWithHyphen) {
             final int kern = font.getKernValue(
-                    this.textArray[lastIndex - 1], ch)
+                    this.foText.charAt(lastIndex - 1), ch)
                     * font.getFontSize() / 1000;
             if (kern != 0) {
                 this.addToLetterAdjust(lastIndex, kern);
@@ -746,8 +748,8 @@
         wordIPD.add(MinOptMax.multiply(this.letterSpaceIPD, iLetterSpaces));
 
         // create the AreaInfo object
-        ai = new AreaInfo(this.thisStart, lastIndex, (short) 0,
-                (short) iLetterSpaces, wordIPD,
+        ai = new AreaInfo(this.thisStart, lastIndex, 0,
+                iLetterSpaces, wordIPD,
                 endsWithHyphen,
                 false, breakOpportunity, font);
         prevAi = ai;
@@ -776,7 +778,7 @@
             final AreaInfo ai = (AreaInfo) this.vecAreaInfo.get(idx);
             ai.letterSpaceCount++;
             ai.areaIPD.add(this.letterSpaceIPD);
-            if (TextLayoutManager.BREAK_CHARS.indexOf(this.textArray[this.tempStart - 1]) >= 0) {
+            if (TextLayoutManager.BREAK_CHARS.indexOf(this.foText.charAt(this.tempStart - 1)) >= 0) {
                 // the last character could be used as a line break
                 // append new elements to oldList
                 oldListIterator = oldList.listIterator(oldList.size());
@@ -867,7 +869,7 @@
 
             //log.info("Word: " + new String(textArray, startIndex, stopIndex - startIndex));
             for (int i = startIndex; i < stopIndex; i++) {
-                final char c = this.textArray[i];
+                final char c = this.foText.charAt(i);
                 newIPD.add(new MinOptMax(font.getCharWidth(c)));
                 //if (i > startIndex) {
                 if (i < stopIndex) {
@@ -899,8 +901,8 @@
                     this.changeList = new LinkedList();
                 }
                 this.changeList.add(new PendingChange(new AreaInfo(
-                        (short) startIndex, (short) stopIndex, (short) 0,
-                        (short) (isWordEnd ? stopIndex - startIndex - 1
+                        startIndex, stopIndex, 0,
+                        (isWordEnd ? stopIndex - startIndex - 1
                                 : stopIndex - startIndex), newIPD,
                         hyphenFollows, false, false, font),
                         ((LeafPosition) pos).getLeafPos()));
@@ -973,7 +975,9 @@
         final int leafValue = ((LeafPosition) pos).getLeafPos();
         if (leafValue != -1) {
             final AreaInfo ai = (AreaInfo) this.vecAreaInfo.get(leafValue);
-            sbChars.append(this.textArray, ai.startIndex, ai.breakIndex - ai.startIndex);
+            for (int i = ai.startIndex; i < ai.breakIndex; ++i) {
+                sbChars.append(this.foText.charAt(i));
+            }
         }
     }
 
@@ -999,7 +1003,7 @@
                         mainPosition, true));
             }
         } else {
-            if (this.textArray[ai.startIndex] != CharUtilities.SPACE
+            if (this.foText.charAt(ai.startIndex) != CharUtilities.SPACE
                     || this.foText.getWhitespaceTreatment() == Constants.EN_PRESERVE) {
                 // a breaking space that needs to be preserved
                 this.addElementsForBreakingSpace(baseList, alignment, ai,
@@ -1153,7 +1157,7 @@
         // or it ends with a character that can be used as a line break
         if (ai.isHyphenated) {
             MinOptMax widthIfNoBreakOccurs = null;
-            if (ai.breakIndex < this.textArray.length) {
+            if (ai.breakIndex < this.foText.length()) {
                 //Add in kerning in no-break condition
                 widthIfNoBreakOccurs = this.letterAdjustArray[ai.breakIndex];
             }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Mon Jun 23 02:46:41 2008
@@ -32,7 +32,7 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KnuthElement;
@@ -94,7 +94,7 @@
         this.firstRowOnPageIndex = -1;
     }
 
-    void startTablePart(TableBody tablePart) {
+    void startTablePart(TablePart tablePart) {
         CommonBorderPaddingBackground background = tablePart.getCommonBorderPaddingBackground();
         if (background.hasBackground()) {
             tablePartBackground = background;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Mon Jun 23 02:46:41 2008
@@ -31,7 +31,7 @@
 import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+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;
@@ -439,7 +439,7 @@
                     -startIndent);
         }
 
-        TableBody body = primaryGridUnit.getTableBody();
+        TablePart body = primaryGridUnit.getTablePart();
         if (body.getCommonBorderPaddingBackground().hasBackground()) {
             painter.registerPartBackgroundArea(
                     getBackgroundArea(paddingRectBPD, borderBeforeWidth));

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Mon Jun 23 02:46:41 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr.table;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -35,7 +34,7 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.ElementListUtils;
@@ -324,7 +323,7 @@
         this.usedBPD = 0;
         RowPainter painter = new RowPainter(this, layoutContext);
 
-        List tablePositions = new ArrayList();
+        List tablePositions = new java.util.ArrayList();
         List headerElements = null;
         List footerElements = null;
         Position firstPos = null;
@@ -417,9 +416,9 @@
         }
     }
 
-    private void addHeaderFooterAreas(List elements, TableBody part, RowPainter painter,
+    private void addHeaderFooterAreas(List elements, TablePart part, RowPainter painter,
             boolean lastOnPage) {
-        List lst = new ArrayList(elements.size());
+        List lst = new java.util.ArrayList(elements.size());
         for (Iterator iter = new KnuthPossPosIter(elements); iter.hasNext();) {
             Position pos = (Position) iter.next();
             /*
@@ -446,32 +445,32 @@
     private void addBodyAreas(Iterator iterator, RowPainter painter,
             boolean lastOnPage) {
         painter.startBody();
-        List lst = new ArrayList();
+        List lst = new java.util.ArrayList();
         TableContentPosition pos = (TableContentPosition) iterator.next();
         boolean isFirstPos = pos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP)
                 && pos.getRow().getFlag(EffRow.FIRST_IN_PART);
-        TableBody body = pos.getTableBody();
+        TablePart part = pos.getTablePart();
         lst.add(pos);
         while (iterator.hasNext()) {
             pos = (TableContentPosition) iterator.next();
-            if (pos.getTableBody() != body) {
-                addTablePartAreas(lst, painter, body, isFirstPos, true, false, false);
+            if (pos.getTablePart() != part) {
+                addTablePartAreas(lst, painter, part, isFirstPos, true, false, false);
                 isFirstPos = true;
                 lst.clear();
-                body = pos.getTableBody();
+                part = pos.getTablePart();
             }
             lst.add(pos);
         }
         boolean isLastPos = pos.getFlag(TableContentPosition.LAST_IN_ROWGROUP)
                 && pos.getRow().getFlag(EffRow.LAST_IN_PART);
-        addTablePartAreas(lst, painter, body, isFirstPos, isLastPos, true, lastOnPage);
+        addTablePartAreas(lst, painter, part, isFirstPos, isLastPos, true, lastOnPage);
         painter.endBody();
     }
 
     /**
      * Adds the areas corresponding to a single fo:table-header/footer/body element.
      */
-    private void addTablePartAreas(List positions, RowPainter painter, TableBody body,
+    private void addTablePartAreas(List positions, RowPainter painter, TablePart body,
             boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) {
         getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
                 true, isFirstPos, isLastPos);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java Mon Jun 23 02:46:41 2008
@@ -22,7 +22,7 @@
 import java.util.List;
 
 import org.apache.fop.fo.flow.table.EffRow;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.Position;
 
@@ -80,8 +80,8 @@
         return row;
     }
 
-    TableBody getTableBody() {
-        return ((CellPart) cellParts.get(0)).pgu.getTableBody();
+    TablePart getTablePart() {
+        return ((CellPart) cellParts.get(0)).pgu.getTablePart();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java Mon Jun 23 02:46:41 2008
@@ -28,6 +28,7 @@
 import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 
 
 /**
@@ -69,7 +70,7 @@
             case FOOTER:
                 rowGroupsIter = table.getTableFooter().getRowGroups().iterator();
                 break;
-            default:
+            case BODY:
                 List rowGroupsList = new LinkedList();
                 // TODO this is ugly
                 for (FONodeIterator iter = table.getChildNodes(); iter.hasNext();) {
@@ -79,6 +80,9 @@
                     }
                 }
                 rowGroupsIter = rowGroupsList.iterator();
+                break;
+            default:
+                throw new IllegalArgumentException("Unrecognised TablePart: " + tablePart);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Mon Jun 23 02:46:41 2008
@@ -38,6 +38,7 @@
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.CTM;
 import org.apache.fop.area.NormalFlow;
+import org.apache.fop.area.RegionReference;
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.ForeignObject;
@@ -96,19 +97,20 @@
      */
     protected void handleRegionTraits(RegionViewport region) {
         Rectangle2D viewArea = region.getViewArea();
+        RegionReference referenceArea = region.getRegionReference();
         float startx = (float)(viewArea.getX() / 1000f);
         float starty = (float)(viewArea.getY() / 1000f);
         float width = (float)(viewArea.getWidth() / 1000f);
         float height = (float)(viewArea.getHeight() / 1000f);
 
-        if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) {
-            currentBPPosition = region.getBorderAndPaddingWidthBefore();
-            currentIPPosition = region.getBorderAndPaddingWidthStart();
-        }
-        drawBackAndBorders(region, startx, starty, width, height);
+        // adjust the current position according to region borders and padding
+        currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore();
+        currentIPPosition = referenceArea.getBorderAndPaddingWidthStart();
+        // draw background (traits are in the RegionViewport)
+        // and borders (traits are in the RegionReference)
+        drawBackAndBorders(region, referenceArea, startx, starty, width, height);
     }
 
-    
     /**
      * Draw the background and borders.
      * This draws the background and border traits for an area given
@@ -123,14 +125,57 @@
     protected void drawBackAndBorders(Area area,
                     float startx, float starty,
                     float width, float height) {
+        drawBackAndBorders(area, area, startx, starty, width, height);
+    }
+
+    /**
+     * Draw the background and borders.
+     * This draws the background and border traits for an area given
+     * the position.
+     *
+     * @param backgroundArea the area to get the background traits from
+     * @param borderArea the area to get the border traits from
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     */
+    protected void drawBackAndBorders(Area backgroundArea, Area borderArea,
+                    float startx, float starty,
+                    float width, float height) {
         // draw background then border
 
-        BorderProps bpsBefore = (BorderProps)area.getTrait(Trait.BORDER_BEFORE);
-        BorderProps bpsAfter = (BorderProps)area.getTrait(Trait.BORDER_AFTER);
-        BorderProps bpsStart = (BorderProps)area.getTrait(Trait.BORDER_START);
-        BorderProps bpsEnd = (BorderProps)area.getTrait(Trait.BORDER_END);
+        BorderProps bpsBefore = (BorderProps)borderArea.getTrait(Trait.BORDER_BEFORE);
+        BorderProps bpsAfter = (BorderProps)borderArea.getTrait(Trait.BORDER_AFTER);
+        BorderProps bpsStart = (BorderProps)borderArea.getTrait(Trait.BORDER_START);
+        BorderProps bpsEnd = (BorderProps)borderArea.getTrait(Trait.BORDER_END);
 
-        Trait.Background back = (Trait.Background)area.getTrait(Trait.BACKGROUND);
+        drawBackground(startx, starty, width, height,
+                (Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND), 
+                bpsBefore, bpsAfter, bpsStart, bpsEnd);
+        drawBorders(startx, starty, width, height,
+                bpsBefore, bpsAfter, bpsStart, bpsEnd);        
+    }
+
+    /**
+     * Draw the background.
+     * This draws the background given the position and the traits.
+     *
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     * @param back the background traits
+     * @param bpsBefore the border-before traits
+     * @param bpsAfter the border-after traits
+     * @param bpsStart the border-start traits
+     * @param bpsEnd the border-end traits
+     */
+    protected void drawBackground(float startx, float starty,
+                    float width, float height,
+                    Trait.Background back,
+                    BorderProps bpsBefore, BorderProps bpsAfter,
+                    BorderProps bpsStart, BorderProps bpsEnd) {
         if (back != null) {
             endTextObject();
 
@@ -201,7 +246,25 @@
                 restoreGraphicsState();
             }
         }
+    }
 
+    /**
+     * Draw the borders.
+     * This draws the border traits given the position and the traits.
+     *
+     * @param startx the start x position
+     * @param starty the start y position
+     * @param width the width of the area
+     * @param height the height of the area
+     * @param bpsBefore the border-before traits
+     * @param bpsAfter the border-after traits
+     * @param bpsStart the border-start traits
+     * @param bpsEnd the border-end traits
+     */
+    protected void drawBorders(float startx, float starty,
+                    float width, float height,
+                    BorderProps bpsBefore, BorderProps bpsAfter,
+                    BorderProps bpsStart, BorderProps bpsEnd) {
         Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
         drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/RTFHandler.java Mon Jun 23 02:46:41 2008
@@ -76,6 +76,8 @@
 import org.apache.fop.fo.flow.PageNumber;
 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.TablePart;
 import org.apache.fop.fo.flow.table.TableCell;
 import org.apache.fop.fo.flow.table.TableColumn;
 import org.apache.fop.fo.flow.table.TableHeader;
@@ -611,25 +613,29 @@
     /**
      * {@inheritDoc}
      */
-    public void startHeader(TableBody th) {
+    public void startHeader(TableHeader header) {
+        startPart(header);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void endHeader(TableBody th) {
+    public void endHeader(TableHeader header) {
+        endPart(header);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void startFooter(TableBody tf) {
+    public void startFooter(TableFooter footer) {
+        startPart(footer);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void endFooter(TableBody tf) {
+    public void endFooter(TableFooter footer) {
+        endPart(footer);
     }
 
     /**
@@ -687,31 +693,25 @@
         }
     }
 
-     /**
-     * {@inheritDoc}
-     */
-    public void startBody(TableBody tb) {
+    private void startPart(TablePart part) {
         if (bDefer) {
             return;
         }
 
         try {
-            RtfAttributes atts = TableAttributesConverter.convertTableBodyAttributes(tb);
+            RtfAttributes atts = TableAttributesConverter.convertTablePartAttributes(part);
 
             RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
             tbl.setHeaderAttribs(atts);
         } catch (IOException ioe) {
             handleIOTrouble(ioe);
         } catch (Exception e) {
-            log.error("startBody: " + e.getMessage());
+            log.error("startPart: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
-        }
+        }        
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void endBody(TableBody tb) {
+    private void endPart(TablePart tb) {
         if (bDefer) {
             return;
         }
@@ -722,9 +722,25 @@
         } catch (IOException ioe) {
             handleIOTrouble(ioe);
         } catch (Exception e) {
-            log.error("endBody: " + e.getMessage());
+            log.error("endPart: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
-        }
+        }        
+    }
+
+    
+     /**
+     * {@inheritDoc}
+     */
+    public void startBody(TableBody body) {
+        startPart(body);
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void endBody(TableBody body) {
+        endPart(body);
     }
 
     /**
@@ -1552,7 +1568,7 @@
         } else if (foNode instanceof FOText) {
             if (bStart) {
                 FOText text = (FOText) foNode;
-                text(text, text.ca, text.startIndex, text.endIndex);
+                text(text, text.getCharArray(), 0, text.length());
             }
         } else if (foNode instanceof Character) {
             if (bStart) {
@@ -1607,6 +1623,18 @@
             } else {
                 endTable( (Table) foNode);
             }
+        } else if (foNode instanceof TableHeader) {
+            if (bStart) {
+                startHeader( (TableHeader) foNode);
+            } else {
+                endHeader( (TableHeader) foNode);
+            }
+        } else if (foNode instanceof TableFooter) {
+            if (bStart) {
+                startFooter( (TableFooter) foNode);
+            } else {
+                endFooter( (TableFooter) foNode);
+            }
         } else if (foNode instanceof TableBody) {
             if (bStart) {
                 startBody( (TableBody) foNode);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java Mon Jun 23 02:46:41 2008
@@ -24,12 +24,11 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TablePart;
 import org.apache.fop.fo.flow.table.TableCell;
 import org.apache.fop.fo.flow.table.TableHeader;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.FixedLength;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
 
@@ -91,7 +90,7 @@
      *
      * @throws ConverterException On convertion error
      */
-    static RtfAttributes convertTableBodyAttributes(TableBody fobj)
+    static RtfAttributes convertTablePartAttributes(TablePart part)
             throws FOPException {
         FOPRtfAttributes attrib = new FOPRtfAttributes();
         return attrib;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/CharUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/CharUtilities.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/CharUtilities.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/CharUtilities.java Mon Jun 23 02:46:41 2008
@@ -54,10 +54,14 @@
     public static final int XMLWHITESPACE = 4;
 
 
+    /** null char */
+    public static final char NULL_CHAR = '\u0000';
     /** linefeed character */
     public static final char LINEFEED_CHAR = '\n';
     /** carriage return */
     public static final char CARRIAGE_RETURN = '\r';
+    /** normal tab */
+    public static final char TAB = '\t';
     /** normal space */
     public static final char SPACE = '\u0020';
     /** non-breaking space */
@@ -80,9 +84,12 @@
     public static final char PARAGRAPH_SEPARATOR = '\u2029';
     /** missing ideograph */
     public static final char MISSING_IDEOGRAPH = '\u25A1';
+    /** Ideogreaphic space */
+    public static final char IDEOGRAPHIC_SPACE = '\u3000';
     /** Unicode value indicating the the character is "not a character". */
     public static final char NOT_A_CHARACTER = '\uFFFF';
 
+    
     /**
      * Utility class: Constructor prevents instantiating when subclassed.
      */
@@ -97,11 +104,18 @@
      * @return the determined character class
      */
     public static int classOf(char c) {
-        if (c == CODE_EOT) { return EOT; }
-        if (c == '\n') { return LINEFEED; }
-        if (c == ' ' || c == '\r' || c == '\t') { return XMLWHITESPACE; }
-        if (isAnySpace(c)) { return UCWHITESPACE; }
-        return NONWHITESPACE;
+        switch (c) {
+            case CODE_EOT:
+                return EOT;
+            case LINEFEED_CHAR:
+                return LINEFEED;
+            case SPACE:
+            case CARRIAGE_RETURN:
+            case TAB:
+                return XMLWHITESPACE;
+            default:
+                return isAnySpace(c) ? UCWHITESPACE : NONWHITESPACE;
+        }
     }
 
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml Mon Jun 23 02:46:41 2008
@@ -53,6 +53,10 @@
   
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="LF" type="add">
+        Allowing non-zero borders and padding on page regions when
+        relaxed validation is turned on.
+      </action>
       <action context="Layout" dev="LF" type="fix">
         Fixed an inconsistency in footnote handling that led to unnecessary
         empty areas in pages whose last normal line contains footnotes

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java Mon Jun 23 02:46:41 2008
@@ -108,7 +108,7 @@
         super();
     }
 
-    private static GridUnit getGridUnit(TableBody part) {
+    private static GridUnit getGridUnit(TablePart part) {
         return (GridUnit) ((List) ((List) part.getRowGroups().get(0)).get(0)).get(0);
     }
 
@@ -137,8 +137,8 @@
         do {
             String baseErrorMsge = "table " + Integer.toString(tableNum) + " (0-based), ";
             Table table = (Table) tableIterator.next();
-            TableBody body = (TableBody) table.getChildNodes().nextNode();
-            GridUnit gu = getGridUnit(body);
+            TablePart part = (TablePart) table.getChildNodes().nextNode();
+            GridUnit gu = getGridUnit(part);
 
             String errorMsge = baseErrorMsge + "border-before";
             checkBorder(errorMsge, gu.borderBefore.normal, 8000, Color.black);
@@ -163,14 +163,14 @@
             int borderNum = 0;
             Table table = (Table) tableIterator.next();
 
-            TableBody header = table.getTableHeader();
+            TableHeader header = table.getTableHeader();
             GridUnit gu = getGridUnit(header);
             checkBorder(errorMsge, gu.borderBefore.normal,
                     resolvedBordersHF[tableNum][borderNum++]);
             checkBorder(errorMsge, gu.borderBefore.rest,
                     resolvedBordersHF[tableNum][borderNum++]);
 
-            TableBody footer = table.getTableFooter();
+            TableFooter footer = table.getTableFooter();
             gu = getGridUnit(footer);
             checkBorder(errorMsge, gu.borderAfter.normal,
                     resolvedBordersHF[tableNum][borderNum++]);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java Mon Jun 23 02:46:41 2008
@@ -38,12 +38,12 @@
      * given array, and that the number of rows inside each row group is equal to the
      * corresponding integer in the array.
      * 
-     * @param body a body whose row groups are to be checked
+     * @param part a table part whose row groups are to be checked
      * @param expectedRowLengths expected lengths of all the row groups of this part of
      * the table
      */
-    private void checkTablePartRowGroups(TableBody body, int[] expectedRowLengths) {
-        Iterator rowGroupIter = body.getRowGroups().iterator();
+    private void checkTablePartRowGroups(TablePart part, int[] expectedRowLengths) {
+        Iterator rowGroupIter = part.getRowGroups().iterator();
         for (int i = 0; i < expectedRowLengths.length; i++) {
             assertTrue(rowGroupIter.hasNext());
             List rowGroup = (List) rowGroupIter.next();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml Mon Jun 23 02:46:41 2008
@@ -216,4 +216,11 @@
     <description>A soft hyphen should be a preferred as break compared to a
     normal hyphenation point but is not.</description>
   </testcase>
+  <testcase>
+    <name>Borders and padding on page regions</name>
+    <file>simple-page-master_borders_padding.xml</file>
+    <description>Borders and padding on regions are now implemented but 
+    relaxed validation must be switched on, otherwise there is a validation
+    exception.</description>
+  </testcase>
 </disabled-testcases>

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/testcase2fo.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/testcase2fo.xsl?rev=670500&r1=670499&r2=670500&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/testcase2fo.xsl (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/testcase2fo.xsl Mon Jun 23 02:46:41 2008
@@ -50,16 +50,12 @@
           </xsl:when>
           <xsl:otherwise>
             <!-- if variable isn't defined, just copy -->
-            <xsl:copy>
-              <xsl:apply-templates select="node()" mode="copy"/>
-            </xsl:copy>
+            <xsl:copy-of select="." />
           </xsl:otherwise>
         </xsl:choose>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:copy>
-          <xsl:apply-templates select="node()" mode="copy"/>
-        </xsl:copy>
+        <xsl:copy-of select="." />
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>



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