You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2007/11/21 21:50:34 UTC

svn commit: r597205 [2/3] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ examples/fo/basic/ src/codegen/fonts/ src/documentation/ src/documentation/content/xdocs/ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/jav...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/flow/table/VariableColRowGroupBuilder.java Wed Nov 21 12:50:23 2007
@@ -19,9 +19,12 @@
 
 package org.apache.fop.fo.flow.table;
 
+import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.fop.layoutmgr.table.EmptyGridUnit;
+import org.apache.fop.fo.ValidationException;
+
 
 /**
  * A row group builder accommodating a variable number of columns. More flexible, but less
@@ -31,34 +34,78 @@
 
     VariableColRowGroupBuilder(Table t) {
         super(t);
-        numberOfColumns = 1;
     }
 
     /**
-     * Fills the given row group with empty grid units if necessary, so that it matches
-     * the given number of columns.
-     * 
-     * @param rowGroup a List of List of GridUnit
-     * @param numberOfColumns the number of columns that the row group must have
+     * Each event is recorded and will be played once the table is finished, and the final
+     * number of columns known.
      */
-    static void fillWithEmptyGridUnits(List rowGroup, int numberOfColumns) {
-        for (int i = 0; i < rowGroup.size(); i++) {
-            List effRow = (List) rowGroup.get(i);
-            for (int j = effRow.size(); j < numberOfColumns; j++) {
-                effRow.add(new EmptyGridUnit(null, null, null, j));
+    private static interface Event {
+        /**
+         * Plays this event
+         * 
+         * @param rowGroupBuilder the delegate builder which will actually create the row
+         * groups
+         * @throws ValidationException if a row-spanning cell overflows its parent body
+         */
+        void play(RowGroupBuilder rowGroupBuilder) throws ValidationException;
+    }
+
+    /** The queue of events sent to this builder. */
+    private List events = new LinkedList();
+
+    /** {@inheritDoc} */
+    void addTableCell(final TableCell cell) {
+        events.add(new Event() {
+            public void play(RowGroupBuilder rowGroupBuilder) {
+                rowGroupBuilder.addTableCell(cell);
             }
-        }
+        });
     }
 
-    /**
-     * Updates the current row group to match the given number of columns, by adding empty
-     * grid units if necessary.
-     * 
-     * @param numberOfColumns new number of columns
-     */
-    void ensureNumberOfColumns(int numberOfColumns) {
-        this.numberOfColumns = numberOfColumns;
-        fillWithEmptyGridUnits(rows, numberOfColumns);
+    /** {@inheritDoc} */
+    void startRow(final TableRow tableRow) {
+        events.add(new Event() {
+            public void play(RowGroupBuilder rowGroupBuilder) {
+                rowGroupBuilder.startRow(tableRow);
+            }
+        });
     }
 
+    /** {@inheritDoc} */
+    void endRow(final TableCellContainer container) {
+        events.add(new Event() {
+            public void play(RowGroupBuilder rowGroupBuilder) {
+                rowGroupBuilder.endRow(container);
+            }
+        });
+    }
+
+    /** {@inheritDoc} */
+    void startTablePart(final TableBody part) {
+        events.add(new Event() {
+            public void play(RowGroupBuilder rowGroupBuilder) {
+                rowGroupBuilder.startTablePart(part);
+            }
+        });
+    }
+
+    /** {@inheritDoc} */
+    void endTablePart(final TableBody tableBody) throws ValidationException {
+        // TODO catch the ValidationException sooner?
+        events.add(new Event() {
+            public void play(RowGroupBuilder rowGroupBuilder) throws ValidationException {
+                rowGroupBuilder.endTablePart(tableBody);
+            }
+        });
+    }
+
+    /** {@inheritDoc} */
+    void endTable(final TableBody lastTablePart) throws ValidationException {
+        RowGroupBuilder delegate = new FixedColRowGroupBuilder(table);
+        for (Iterator eventIter = events.iterator(); eventIter.hasNext();) {
+            ((Event) eventIter.next()).play(delegate);
+        }
+        delegate.endTable(lastTablePart);
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java Wed Nov 21 12:50:23 2007
@@ -25,7 +25,6 @@
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.image.FopImage;
@@ -125,6 +124,25 @@
         }
     }
 
+    /**
+     * A border info with style none. Used as a singleton, in the collapsing-border model,
+     * for elements which don't specify any border on some of their sides.
+     */
+    private static BorderInfo defaultBorderInfo;
+
+    /**
+     * Returns a default BorderInfo of style none.
+     * 
+     * @return a BorderInfo instance with style set to {@link Constants#EN_NONE}
+     */
+    public static synchronized BorderInfo getDefaultBorderInfo() {
+        if (defaultBorderInfo == null) {
+            /* It is enough to set color and width to null, as they should never be consulted */
+            defaultBorderInfo = new BorderInfo(Constants.EN_NONE, null, null);
+        }
+        return defaultBorderInfo;
+    }
+
     private BorderInfo[] borderInfo = new BorderInfo[4];
     private CondLengthProperty[] padding = new CondLengthProperty[4];
 
@@ -139,7 +157,6 @@
      * Construct a CommonBorderPaddingBackground object.
      * 
      * @param pList The PropertyList to get properties from.
-     * @param fobj The FO to create this instance for.
      * @throws PropertyException if there's an error while binding the properties
      */
     public CommonBorderPaddingBackground(PropertyList pList) throws PropertyException {
@@ -229,7 +246,11 @@
      * @return the border info for a side
      */
     public BorderInfo getBorderInfo(int side) {
-        return this.borderInfo[side];
+        if (this.borderInfo[side] == null) {
+            return getDefaultBorderInfo();
+        } else {
+            return this.borderInfo[side];
+        }
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonHyphenation.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonHyphenation.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CommonHyphenation.java Wed Nov 21 12:50:23 2007
@@ -19,9 +19,13 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fonts.FontMetrics;
+import org.apache.fop.fonts.Typeface;
 
 /**
  * Store all common hyphenation properties.
@@ -29,6 +33,9 @@
  * Public "structure" allows direct member access.
  */
 public final class CommonHyphenation {
+
+    /** Logger */
+    protected static Log log = LogFactory.getLog(CommonHyphenation.class);
     
     private static final PropertyCache cache = new PropertyCache();
     
@@ -111,7 +118,71 @@
         
     }
     
-    /** {@inheritDoc */
+    private static final char HYPHEN_MINUS = '-';
+    private static final char MINUS_SIGN = '\u2212';
+    
+    /**
+     * Returns the effective hyphenation character for a font. The hyphenation character specified
+     * in XSL-FO may be substituted if it's not available in the font.
+     * @param font the font
+     * @return the effective hyphenation character.
+     */
+    public char getHyphChar(org.apache.fop.fonts.Font font) {
+        char hyphChar = hyphenationCharacter.getCharacter();
+        if (font.hasChar(hyphChar)) {
+            return hyphChar; //short-cut
+        }
+        char effHyphChar = hyphChar;
+        boolean warn = false;
+        if (font.hasChar(HYPHEN_MINUS)) {
+            effHyphChar = HYPHEN_MINUS;
+            warn = true;
+        } else if (font.hasChar(MINUS_SIGN)) {
+            effHyphChar = MINUS_SIGN;
+            FontMetrics metrics = font.getFontMetrics();
+            if (metrics instanceof Typeface) {
+                Typeface typeface = (Typeface)metrics;
+                if ("SymbolEncoding".equals(typeface.getEncoding())) {
+                    //SymbolEncoding doesn't have HYPHEN_MINUS, so replace by MINUS_SIGN
+                } else {
+                    //only warn if the encoding is not SymbolEncoding
+                    warn = true;
+                }
+            }
+        } else {
+            effHyphChar = ' ';
+            FontMetrics metrics = font.getFontMetrics();
+            if (metrics instanceof Typeface) {
+                Typeface typeface = (Typeface)metrics;
+                if ("ZapfDingbatsEncoding".equals(typeface.getEncoding())) {
+                    //ZapfDingbatsEncoding doesn't have HYPHEN_MINUS, so replace by ' '
+                } else {
+                    //only warn if the encoding is not ZapfDingbatsEncoding
+                    warn = true;
+                }
+            }
+        }
+        if (warn) {
+            log.warn("Substituted specified hyphenation character (0x"
+                    + Integer.toHexString(hyphChar)
+                    + ") with 0x" + Integer.toHexString(effHyphChar) 
+                    + " because the font doesn't have the specified hyphenation character: " 
+                    + font.getFontTriplet());
+        }
+        return effHyphChar;
+    }
+    
+    /**
+     * Returns the IPD for the hyphenation character for a font.
+     * @param font the font
+     * @return the IPD in millipoints for the hyphenation character.
+     */
+    public int getHyphIPD(org.apache.fop.fonts.Font font) {
+        char hyphChar = getHyphChar(font);
+        return font.getCharWidth(hyphChar);
+    }
+    
+    /** {@inheritDoc} */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java Wed Nov 21 12:50:23 2007
@@ -46,6 +46,11 @@
         this.tb_rl = tb_rl;
     }
     
+    /**
+     * Controls whether the PropertyMaker accesses the parent property list or the current
+     * property list for determining the writing mode.
+     * @param useParent true if the parent property list should be used.
+     */
     public void setUseParent(boolean useParent) {
         this.useParent = useParent;
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyCache.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyCache.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/properties/PropertyCache.java Wed Nov 21 12:50:23 2007
@@ -76,6 +76,10 @@
             this.ref = old.ref;
             this.hash = old.hash;
         }
+
+        public boolean isCleared() {
+            return (ref == null || ref.get() == null);
+        }
         
     }
     
@@ -116,10 +120,8 @@
                 
                 int index = this.hash & (table.length - 1);
                 CacheEntry first = table[index];
-                WeakReference ref;
                 for (CacheEntry e = first; e != null; e = e.next) {
-                    ref = e.ref;
-                    if (ref != null && ref.get() == null) {
+                    if (e.isCleared()) {
                         /* remove obsolete entry
                         /* 1. clear value, cause interference for non-blocking get() */
                         e.ref = null;
@@ -127,7 +129,9 @@
                         /* 2. clone the segment, without the obsolete entry */
                         CacheEntry head = e.next;
                         for (CacheEntry c = first; c != e; c = c.next) {
-                            head = new CacheEntry(c, head);
+                            if (!c.isCleared()) {
+                                head = new CacheEntry(c, head);
+                            }
                         }
                         table[index] = head;
                         segment.count--;
@@ -177,7 +181,7 @@
                 /* launch cleanup in a separate thread, 
                  * so it acquires its own lock, and put()
                  * can return immediately */
-                Thread cleaner = new Thread(new CacheCleaner(hash));
+                Thread cleaner = new Thread(new CacheCleaner(hash), "FOP PropertyCache Cleaner");
                 cleaner.start();
             }
         }
@@ -273,11 +277,13 @@
                     for (int i = table.length; --i >= 0;) {
                         for (CacheEntry c = table[i]; c != null; c = c.next) {
                             ref = c.ref;
-                            if ((o = ref.get()) != null) {
-                                hash = hash(o);
-                                idx = hash & newLength;
-                                newTable[idx] = new CacheEntry(c, newTable[idx]);
-                                segments[hash & SEGMENT_MASK].count++;
+                            if (ref != null) {
+                                if ((o = ref.get()) != null) {
+                                    hash = hash(o);
+                                    idx = hash & newLength;
+                                    newTable[idx] = new CacheEntry(c, newTable[idx]);
+                                    segments[hash & SEGMENT_MASK].count++;
+                                }
                             }
                         }
                     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java Wed Nov 21 12:50:23 2007
@@ -81,6 +81,14 @@
     }
 
     /**
+     * Returns the associated font metrics object.
+     * @return the font metrics
+     */
+    public FontMetrics getFontMetrics() {
+        return this.metric;
+    }
+    
+    /**
      * Returns the font's ascender.
      * @return the ascender
      */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java Wed Nov 21 12:50:23 2007
@@ -47,13 +47,13 @@
     protected static Log log = LogFactory.getLog(FontInfo.class);
 
     /** Map containing fonts that have been used */
-    private Map usedFonts;
+    private Map usedFonts; //Map<String,FontMetrics> (String = font key)
     
     /** look up a font-triplet to find a font-name */
-    private Map triplets;
+    private Map triplets; //Map<FontTriplet,String> (String = font key)
     
     /** look up a font-name to get a font (that implements FontMetrics at least) */
-    private Map fonts;
+    private Map fonts; //Map<String,FontMetrics> (String = font key)
     
     /** collection of missing fonts; used to make sure the user gets 
      *  a warning for a missing font only once (not every time the font is used)
@@ -290,21 +290,30 @@
      */
     public FontTriplet[] fontLookup(String[] families, String style,
                              int weight) {
+        if (families.length == 0) {
+            throw new IllegalArgumentException("Specify at least one font family");
+        }
         FontTriplet triplet;
         List tmpTriplets = new ArrayList();
-        for (int i = 0; i < families.length; i++) {
+        for (int i = 0, c = families.length; i < c; i++) {
             triplet = fontLookup(families[i], style, weight, (i >= families.length - 1));
             if (triplet != null) {
                 tmpTriplets.add(triplet);
             }
         }
         if (tmpTriplets.size() != 0) {
-            FontTriplet[] triplets = (FontTriplet[]) tmpTriplets.toArray(TRIPLETS_TYPE);
-            return (FontTriplet[]) triplets;
+            return (FontTriplet[]) tmpTriplets.toArray(TRIPLETS_TYPE);
+        }
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0, c = families.length; i < c; i++) {
+            if (i > 0) {
+                sb.append(", ");
+            }
+            sb.append(families[i]);
         }
         throw new IllegalStateException(
                     "fontLookup must return an array with at least one "
-                    + "FontTriplet on the last call.");
+                    + "FontTriplet on the last call. Lookup: " + sb.toString());
     }
     
     private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) {
@@ -399,13 +408,21 @@
     }
 
     /**
-     * Gets a Map of all registred fonts.
+     * Gets a Map of all registered fonts.
      * @return a read-only Map with font key/FontMetrics pairs
      */
     public Map getFonts() {
         return java.util.Collections.unmodifiableMap(this.fonts);
     }
 
+    /**
+     * Gets a Map of all registered font triplets.
+     * @return a read-only Map with FontTriplet/font key pairs
+     */
+    public Map getFontTriplets() {
+        return java.util.Collections.unmodifiableMap(this.triplets);
+    }
+    
     /**
      * This is used by the renderers to retrieve all the
      * fonts used in the document.

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java Wed Nov 21 12:50:23 2007
@@ -110,7 +110,10 @@
         String effURI;
         boolean type1 = isType1(fontFileURI);
         if (type1) {
-            effURI = fontFileURI.substring(0, fontFileURI.length() - 4) + ".pfm";
+            String pfmExt = fontFileURI.substring(
+                    fontFileURI.length() - 3, fontFileURI.length());
+            pfmExt = pfmExt.substring(0, 2) + (Character.isUpperCase(pfmExt.charAt(2)) ? "M" : "m");
+            effURI = fontFileURI.substring(0, fontFileURI.length() - 4) + "." + pfmExt;
         } else {
             effURI = fontFileURI;
         }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/LazyFont.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/LazyFont.java Wed Nov 21 12:50:23 2007
@@ -27,10 +27,12 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
+import org.xml.sax.InputSource;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
-import org.xml.sax.InputSource;
 
 /**
  * This class is used to defer the loading of a font until it is really used.
@@ -95,8 +97,10 @@
                             in = new java.net.URL(source.getSystemId()).openStream();
                         }
                         if (in == null) {
-                            String err = "Cannot load font: failed to create InputStream from"
-                                + " Source for metrics file " + metricsFileName; 
+                            String err = "Cannot load font: After URI resolution, the returned"
+                                + " Source object does not contain an InputStream"
+                                + " or a valid URL (system identifier) for metrics file: "
+                                + metricsFileName; 
                             if (fail) {
                                 throw new RuntimeException(err);
                             } else {

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/SingleByteFont.java Wed Nov 21 12:50:23 2007
@@ -103,8 +103,8 @@
         if (d != 0) {
             return d;
         } else {
-            log.warn("Glyph " + (int) c + " not available in font "
-                    + getFontName());
+            log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c) 
+                    + ") not available in font " + getFontName());
             return '#';
         }
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Wed Nov 21 12:50:23 2007
@@ -21,11 +21,14 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.regex.Pattern;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fonts.CachedFontInfo;
@@ -62,7 +65,7 @@
         }
 
         // default style and weight triplet vales (fallback)
-        String strippedName = customFont.getStrippedFontName();
+        String strippedName = stripQuotes(customFont.getStrippedFontName());
         String subName = customFont.getFontSubName();
         String searchName = strippedName.toLowerCase();
         if (subName != null) {
@@ -74,7 +77,7 @@
 
         //Full Name usually includes style/weight info so don't use these traits
         //If we still want to use these traits, we have to make FontInfo.fontLookup() smarter
-        String fullName = customFont.getFullName();
+        String fullName = stripQuotes(customFont.getFullName());
         triplets.add(new FontTriplet(fullName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
         if (!fullName.equals(strippedName)) {
             triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
@@ -82,12 +85,18 @@
         Set familyNames = customFont.getFamilyNames();
         Iterator iter = familyNames.iterator();
         while (iter.hasNext()) {
-            String familyName = (String)iter.next();
+            String familyName = stripQuotes((String)iter.next());
             if (!fullName.equals(familyName)) {
                 triplets.add(new FontTriplet(familyName, style, weight));
             }
         }
     }
+    
+    private final Pattern quotePattern = Pattern.compile("'");
+    
+    private String stripQuotes(String name) {
+        return quotePattern.matcher(name).replaceAll("");
+    }
 
     private String guessStyle(CustomFont customFont, String fontName) {
         // style
@@ -136,7 +145,13 @@
         long fileLastModified = -1;
         if (fontCache != null) {
             try {
-                fileLastModified = fontUrl.openConnection().getLastModified();
+                URLConnection conn = fontUrl.openConnection();
+                try {
+                    fileLastModified = conn.getLastModified();
+                } finally {
+                    //An InputStream is created even if it's not accessed, but we need to close it.
+                    IOUtils.closeQuietly(conn.getInputStream());
+                }
             } catch (IOException e) {
                 // Should never happen, because URL must be local
                 log.debug("IOError: " + e.getMessage());

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFile.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFile.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/truetype/TTFFile.java Wed Nov 21 12:50:23 2007
@@ -27,6 +27,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.FontUtil;
 import org.apache.fop.fonts.Glyphs;
 
 /**
@@ -543,7 +544,11 @@
      * @return String The PostScript name
      */
     public String getPostScriptName() {
-        return postScriptName;
+        if (postScriptName.length() == 0) {
+            return FontUtil.stripWhiteSpace(getFullName());
+        } else {
+            return postScriptName;
+        }
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/PFMFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/PFMFile.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/PFMFile.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/PFMFile.java Wed Nov 21 12:50:23 2007
@@ -28,6 +28,7 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.Glyphs;
 
 /**
@@ -297,22 +298,24 @@
      * @return The name of the charset.
      */
     public String getCharSetName() {
+        //TODO Had to remove the detection for Expert(Subset) encoding. The PFM is not suitable
+        //for detecting these character sets. We have to parse the AFM for that.
         switch (dfCharSet) {
         case 0:
             return "WinAnsi"; // AKA ISOAdobe
-        case 1:
-            return "Expert";
         case 2:
             if ("Symbol".equals(getPostscriptName())) {
                 return "Symbol";
-            } else {
-                return "ExpertSubset";
             }
+            break;
         case 128:
             return "Shift-JIS (Japanese)";
         default:
-            return "Unknown (" + dfCharSet + ", 0x" + Integer.toHexString(dfCharSet) + ")";
+            log.warn("Unknown charset detected (" + dfCharSet
+                    + ", 0x" + Integer.toHexString(dfCharSet)
+                    + "). Trying fallback to WinAnsi.");
         }
+        return "WinAnsi"; 
     }
 
     /**
@@ -403,6 +406,15 @@
     }
 
     /**
+     * Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character 
+     * set or a subset of it).
+     * @return true if the font is non-symbolic
+     */
+    public boolean isNonSymbolic() {
+        return (dfCharSet != 2); //!= Symbol fonts
+    }
+    
+    /**
      * Returns the characteristics flags for the font as
      * needed for a PDF font descriptor (See PDF specs).
      *
@@ -411,19 +423,22 @@
     public int getFlags() {
         int flags = 0;
         if (!getIsProportional()) {
-            flags |= 1;
+            flags |= 1; //bit 1: FixedPitch
         }
-        if ((dfPitchAndFamily & 16) == 16) {
-            flags |= 2;
+        if (isNonSymbolic()) {
+            flags |= 32; //bit 6: Nonsymbolic
+        } else {
+            flags |= 4; //bit 3: Symbolic
         }
-        if ((dfPitchAndFamily & 64) == 64) {
-            flags |= 4;
+        //int serif = dfPitchAndFamily & 0xFFFE;
+        if ((dfPitchAndFamily & 16) != 0) {
+            flags |= 2; //bit 2: Serif
         }
-        if (dfCharSet == 0) {
-            flags |= 6;
+        if ((dfPitchAndFamily & 64) != 0) {
+            flags |= 8; //bit 4: Script
         }
         if (dfItalic != 0) {
-            flags |= 7;
+            flags |= 64; //bit 7: Italic
         }
         return flags;
     }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java Wed Nov 21 12:50:23 2007
@@ -56,7 +56,13 @@
         pfm.load(in);
         singleFont = new SingleByteFont();
         singleFont.setFontType(FontType.TYPE1);
-        singleFont.setEncoding(pfm.getCharSetName() + "Encoding");
+        if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) {
+            singleFont.setEncoding(pfm.getCharSetName() + "Encoding");
+        } else {
+            log.warn("The PFM reports an unsupported encoding (" 
+                    + pfm.getCharSetName() + "). The font may not work as expected.");
+            singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees!
+        }
         singleFont.setResolver(this.resolver);
         returnFont = singleFont;
         returnFont.setFontName(pfm.getPostscriptName());
@@ -73,7 +79,7 @@
         returnFont.setDescender(pfm.getLowerCaseDescent());
         returnFont.setFontBBox(pfm.getFontBBox());
         returnFont.setFirstChar(pfm.getFirstChar());
-        returnFont.setLastChar(pfm.getFirstChar());
+        returnFont.setLastChar(pfm.getLastChar());
         returnFont.setFlags(pfm.getFlags());
         returnFont.setStemV(pfm.getStemV());
         returnFont.setItalicAngle(pfm.getItalicAngle());

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/image/JpegImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/image/JpegImage.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/image/JpegImage.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/image/JpegImage.java Wed Nov 21 12:50:23 2007
@@ -19,11 +19,9 @@
  
 package org.apache.fop.image;
 
-// Java
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_Profile;
 
-// FOP
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.fop.util.CMYKColorSpace;
@@ -100,13 +98,14 @@
                         this.width = calcBytes(this.raw[index + 7],
                                                  this.raw[index + 8]);
 
-                        if (this.raw[index + 9] == 1) {
+                        int numComponents = this.raw[index + 9];
+                        if (numComponents == 1) {
                             this.colorSpace = ColorSpace.getInstance(
                               ColorSpace.CS_GRAY);
-                        } else if (this.raw[index + 9] == 3) {
+                        } else if (numComponents == 3) {
                             this.colorSpace = ColorSpace.getInstance(
                               ColorSpace.CS_LINEAR_RGB);
-                        } else if (this.raw[index + 9] == 4) {
+                        } else if (numComponents == 4) {
                             // howto create CMYK color space
                             /*
                             this.colorSpace = ColorSpace.getInstance(
@@ -193,6 +192,14 @@
                 log.warn("An ICC profile is present but it is invalid (" 
                         + iae.getMessage() + "). The color profile will be ignored. (" 
                         + this.getOriginalURI() + ")");
+            }
+            if (iccProfile.getNumComponents() != this.colorSpace.getNumComponents()) {
+                log.warn("The number of components of the ICC profile ("
+                        + iccProfile.getNumComponents() 
+                        + ") doesn't match the image ("
+                        + this.colorSpace.getNumComponents()
+                        + "). Ignoring the ICC color profile.");
+                this.iccProfile = null;
             }
         } else if (this.colorSpace == null) {
             log.error("ColorSpace not specified for JPEG image");

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LineBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LineBreakingAlgorithm.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LineBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/LineBreakingAlgorithm.java Wed Nov 21 12:50:23 2007
@@ -97,11 +97,14 @@
             addedPositions = 0;
         }
 
-        if (difference + bestActiveNode.availableShrink < 0) {
-            if (super.log.isWarnEnabled()) {
-                super.log.warn(FONode.decorateWithContextInfo(
-                        "Line " + (addedPositions + 1) 
-                        + " of a paragraph overflows the available area.", thisLLM.getFObj()));
+        if (log.isWarnEnabled()) {
+            int lack = difference + bestActiveNode.availableShrink; 
+            if (lack < 0) {
+                String textDiff = (lack < -50000 ? "more than 50 points" : (-lack) + "mpt");
+                log.warn(FONode.decorateWithContextInfo
+                         ("Line " + (addedPositions + 1) 
+                          + " of a paragraph overflows the available area by "
+                          + textDiff + ".", thisLLM.getFObj()));
             }
         }
         

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -19,7 +19,12 @@
 
 package org.apache.fop.layoutmgr.inline;
 
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.fop.area.Trait;
 import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
@@ -32,16 +37,10 @@
 import org.apache.fop.layoutmgr.LeafPosition;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Trait;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 import org.apache.fop.util.CharUtilities;
 
-import java.util.List;
-import java.util.LinkedList;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.layoutmgr.inline.AlignmentContext;
-
 /**
  * LayoutManager for the fo:character formatting object
  */
@@ -70,7 +69,7 @@
         font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
         SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing());
         letterSpaceIPD = ls.getSpace();
-        hyphIPD = font.getCharWidth(fobj.getCommonHyphenation().hyphenationCharacter.getCharacter());
+        hyphIPD = fobj.getCommonHyphenation().getHyphIPD(font);
         borderProps = fobj.getCommonBorderPaddingBackground();
         setCommonBorderPaddingBackground(borderProps);
         org.apache.fop.area.inline.TextArea chArea = getCharacterInlineArea(fobj);

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -19,22 +19,20 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import org.apache.fop.fo.flow.PageNumberCitationLast;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.UnresolvedPageNumber;
 import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.UnresolvedPageNumber;
+import org.apache.fop.fo.flow.PageNumberCitationLast;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.LayoutManager;
 
 /**
  * LayoutManager for the fo:page-number-citation-last formatting object
  */
-public class PageNumberCitationLastLayoutManager extends PageNumberCitationLayoutManager {
+public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitationLayoutManager {
 
-    private PageNumberCitationLast fobj;
-    
     /**
      * Constructor
      *

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -19,33 +19,19 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import org.apache.fop.fo.flow.PageNumberCitation;
 import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.Resolvable;
-import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.UnresolvedPageNumber;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.area.inline.UnresolvedPageNumber;
+import org.apache.fop.fo.flow.PageNumberCitation;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.LayoutManager;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.TraitSetter;
 
 /**
  * LayoutManager for the fo:page-number-citation formatting object
  */
-public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
+public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationLayoutManager {
 
-    private PageNumberCitation fobj;
-    /** Font for the page-number-citation */
-    protected Font font;
-    
-    /** Indicates whether the page referred to by the citation has been resolved yet */
-    protected boolean resolved = false;
-    
     /**
      * Constructor
      *
@@ -54,50 +40,15 @@
      */
     public PageNumberCitationLayoutManager(PageNumberCitation node) {
         super(node);
-        fobj = node;
     }
     
     /** {@inheritDoc} */
-    public void initialize() {
-        FontInfo fi = fobj.getFOEventHandler().getFontInfo();
-        FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
-        font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
-        setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected AlignmentContext makeAlignmentContext(LayoutContext context) {
-        return new AlignmentContext(
-                font
-                , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
-                , fobj.getAlignmentAdjust()
-                , fobj.getAlignmentBaseline()
-                , fobj.getBaselineShift()
-                , fobj.getDominantBaseline()
-                , context.getAlignmentContext()
-            );
-    }
-
-    /** {@inheritDoc} */
     public InlineArea get(LayoutContext context) {
         curArea = getPageNumberCitationInlineArea(parentLM);
         return curArea;
     }
     
     /**
-     * {@inheritDoc}
-     *                                                                      , LayoutContext) 
-     */
-    public void addAreas(PositionIterator posIter, LayoutContext context) {
-        super.addAreas(posIter, context);
-        if (!resolved) {
-            getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea);
-        }
-    }
-    
-    /**
      * if id can be resolved then simply return a word, otherwise
      * return a resolvable area
      */
@@ -124,34 +75,5 @@
         return text;
     }
     
-    /**
-     * Updates the traits for the generated text area. 
-     * @param text the text area
-     */
-    protected void updateTextAreaTraits(TextArea text) {
-        TraitSetter.setProducerID(text, fobj.getId());
-        text.setBPD(font.getAscender() - font.getDescender());
-        text.setBaselineOffset(font.getAscender());
-        TraitSetter.addFontTraits(text, font);
-        text.addTrait(Trait.COLOR, fobj.getColor());
-        TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
-    }
-    
-    /**
-     * @param str string to be measured
-     * @return width (in millipoints ??) of the string
-     */
-    protected int getStringWidth(String str) {
-        int width = 0;
-        for (int count = 0; count < str.length(); count++) {
-            width += font.getCharWidth(str.charAt(count));
-        }
-        return width;
-    }
-
-    /** {@inheritDoc} */
-    protected void addId() {
-        getPSLM().addIDToPage(fobj.getId());
-    }
 }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -20,8 +20,8 @@
 package org.apache.fop.layoutmgr.inline;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
@@ -195,7 +195,7 @@
         // With CID fonts, space isn't neccesary currentFontState.width(32)
         spaceCharIPD = font.getCharWidth(' ');
         // Use hyphenationChar property
-        hyphIPD = font.getCharWidth(foText.getCommonHyphenation().hyphenationCharacter.getCharacter());
+        hyphIPD = foText.getCommonHyphenation().getHyphIPD(font);
         
         SpaceVal ls = SpaceVal.makeLetterSpacing(foText.getLetterSpacing());
         halfLS = new SpaceVal(MinOptMax.multiply(ls.getSpace(), 0.5),
@@ -508,7 +508,7 @@
                         && i == lastIndex 
                         && areaInfo.bHyphenated) {
                         // add the hyphenation character
-                        wordChars.append(foText.getCommonHyphenation().hyphenationCharacter.getCharacter());
+                        wordChars.append(foText.getCommonHyphenation().getHyphChar(font));
                     }
                     textArea.addWord(wordChars.toString(), 0, letterAdjust);
                     wordStartIndex = -1;

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java Wed Nov 21 12:50:23 2007
@@ -22,6 +22,9 @@
 import java.util.List;
 import java.util.ListIterator;
 
+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.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
@@ -74,7 +77,7 @@
         }
         if (pgu.isLastGridUnitRowSpan() && pgu.getRow() != null) {
             makeBoxForWholeRow |= pgu.getRow().mustKeepTogether();
-            makeBoxForWholeRow |= pgu.getTable().mustKeepTogether();
+            makeBoxForWholeRow |= tableLM.getTable().mustKeepTogether();
         }
         if (makeBoxForWholeRow) {
             elementList = new java.util.ArrayList(1);
@@ -94,7 +97,7 @@
         this.previousRowsLength = previousRowsLength;
         nextStepLength = previousRowsLength;
         totalLength = previousRowsLength + ElementListUtils.calcContentLength(elementList);
-        if (pgu.getTable().isSeparateBorderModel()) {
+        if (tableLM.getTable().isSeparateBorderModel()) {
             borderBefore = pgu.getBorders().getBorderBeforeWidth(false)
                     + tableLM.getHalfBorderSeparationBPD();
             borderAfter = pgu.getBorders().getBorderAfterWidth(false)
@@ -239,6 +242,8 @@
      * @return true if this cell's next step is inferior or equal to the next minimal step
      */
     boolean contributesContent() {
+        // return includedInLastStep() && the cell hasn't finished yet, otherwise there's
+        // nothing more to contribute
         return includedInLastStep() && end >= start;
     }
 
@@ -248,7 +253,7 @@
      * @return true if this cell's first step is inferior or equal to the current one 
      */
     boolean hasStarted() {
-        return includedLength > 0;
+        return includedLength >= 0;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java Wed Nov 21 12:50:23 2007
@@ -20,8 +20,8 @@
 package org.apache.fop.layoutmgr.table;
 
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.flow.table.BorderSpecification;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 
 /**
  * This class is a superclass for the two collapsing border models defined
@@ -37,10 +37,7 @@
     protected static final int START = CommonBorderPaddingBackground.START;
     /** end side */
     protected static final int END = CommonBorderPaddingBackground.END;
-    
-    /** Flag: current grid unit is either start or end of the table. */
-    public static final int VERTICAL_START_END_OF_TABLE = 1;
-    
+
     /** Indicates that the cell is/starts in the first row being painted on a particular page */
     //public static final int FIRST_ROW_IN_TABLE_PART = 1;
     /** Indicates that the cell is/ends in the last row being painted on a particular page */
@@ -53,7 +50,7 @@
     //These statics are used singleton-style. No MT issues here.
     private static CollapsingBorderModel collapse = null;
     private static CollapsingBorderModel collapseWithPrecedence = null;
-    
+
     /**
      * @param borderCollapse border collapse control
      * @return the border model for the cell
@@ -74,12 +71,12 @@
                 throw new IllegalArgumentException("Illegal border-collapse mode.");
         }
     }
-    
+
     /**
      * @param side the side on the current cell
      * @return the adjacent side on the neighbouring cell
      */
-    public static int getOtherSide(int side) {
+    public/*TODO*/ static int getOtherSide(int side) {
         switch (side) {
             case CommonBorderPaddingBackground.BEFORE:
                 return CommonBorderPaddingBackground.AFTER;
@@ -93,23 +90,32 @@
                 throw new IllegalArgumentException("Illegal parameter: side");
         }
     }
-    
+
     /**
      * @param side the side to investigate
      * @return true if the adjacent cell is before or after
      */
     protected boolean isVerticalRelation(int side) {
-        return (side == CommonBorderPaddingBackground.BEFORE 
+        return (side == CommonBorderPaddingBackground.BEFORE
                 || side == CommonBorderPaddingBackground.AFTER);
     }
 
-    
+    private static int compareInt(int value1, int value2) {
+        if (value1 < value2) {
+            return -1;
+        } else if (value1 == value2) {
+            return 0;
+        } else {
+            return 1;
+        }
+    }
+
     /**
      * See rule 4 in 6.7.10 for the collapsing border model.
      * @param style the border style to get the preference value for
      * @return the preference value of the style
      */
-    public int getPreferenceValue(int style) {
+    private static int getStylePreferenceValue(int style) {
         switch (style) {
             case Constants.EN_DOUBLE: return 0;
             case Constants.EN_SOLID: return -1;
@@ -122,14 +128,62 @@
             default: throw new IllegalStateException("Illegal border style: " + style);
         }
     }
-    
+
     /**
-     * Determines the winning BorderInfo.
-     * @param current grid unit of the current element
-     * @param neighbour grid unit of the neighbouring element
-     * @return the winning BorderInfo
-     */
-    public abstract BorderInfo determineWinner(
-            GridUnit current, GridUnit neighbour, int side, int flags);
-    
+     * Compares the two given styles (see {@link Constants}).
+     * 
+     * @param style1 a style constant
+     * @param style2 another style constant
+     * @return a value &lt; 0 if style1 has less priority than style2, 0 if both are
+     * equal, a value &gt; 0 if style1 has more priority than style2
+     */
+    static int compareStyles(int style1, int style2) {
+        int value1 = getStylePreferenceValue(style1);
+        int value2 = getStylePreferenceValue(style2);
+        return compareInt(value1, value2);
+    }
+
+    private static int getHolderPreferenceValue(int id) {
+        switch (id) {
+        case Constants.FO_TABLE_CELL: return 0;
+        case Constants.FO_TABLE_ROW: return -1;
+        case Constants.FO_TABLE_HEADER:
+        case Constants.FO_TABLE_FOOTER:
+        case Constants.FO_TABLE_BODY:
+            return -2;
+        case Constants.FO_TABLE_COLUMN: return -3;
+        // TODO colgroup
+        case Constants.FO_TABLE: return -4;
+        default: throw new IllegalStateException();
+        }
+    }
+
+    /**
+     * Compares the two given FO ids ({@link Constants}.FO*) in terms of border
+     * declaration.
+     * 
+     * @param id1 a FO id ({@link Constants#FO_TABLE}, {@link Constants#FO_TABLE_BODY},
+     * etc.)
+     * @param id2 another FO id
+     * @return a value &lt; 0 if id1 has less priority than id2, 0 if both are equal, a
+     * value &gt; 0 if id1 has more priority than id2
+     */
+    static int compareFOs(int id1, int id2) {
+        int p1 = getHolderPreferenceValue(id1);
+        int p2 = getHolderPreferenceValue(id2);
+        return compareInt(p1, p2);
+    }
+
+    /**
+     * Returns the border which wins the border conflict resolution. In case the two
+     * borders are equivalent (identical, or only the color is different), null is
+     * returned.
+     * 
+     * @param border1 a border specification
+     * @param border2 another border specification
+     * @return the winning border, null if the two borders are equivalent
+     */
+    public abstract BorderSpecification determineWinner(BorderSpecification border1,
+            BorderSpecification border2);
+
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModelEyeCatching.java Wed Nov 21 12:50:23 2007
@@ -20,11 +20,7 @@
 package org.apache.fop.layoutmgr.table;
 
 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.TableCell;
-import org.apache.fop.fo.flow.table.TableColumn;
-import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.flow.table.BorderSpecification;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 
 /**
@@ -34,268 +30,45 @@
  */
 public class CollapsingBorderModelEyeCatching extends CollapsingBorderModel {
 
-    public BorderInfo determineWinner(GridUnit currentGridUnit, 
-            GridUnit otherGridUnit, int side, int flags) {
-        final boolean vertical = isVerticalRelation(side);
-        final int otherSide = getOtherSide(side);
-        
-        //Get cells
-        TableCell currentCell = currentGridUnit.getCell();
-        TableCell otherCell = null;
-        if (otherGridUnit != null) {
-            otherCell = otherGridUnit.getCell();
-        }
-        
-        //Get rows
-        TableRow currentRow = currentGridUnit.getRow();
-        TableRow otherRow = null;
-        if (vertical && otherCell != null) {
-            otherRow = otherGridUnit.getRow();
-        }
-        
-        //get bodies
-        TableBody currentBody = currentGridUnit.getBody();
-        TableBody otherBody = null;
-        if (otherRow != null) {
-            otherBody = otherGridUnit.getBody();
-        }
-
-        //get columns
-        TableColumn currentColumn = currentGridUnit.getColumn();
-        TableColumn otherColumn = null;
-        if (otherGridUnit != null) {
-            otherColumn = otherGridUnit.getColumn();
-        }
-        
-        //TODO get column groups
-        
-        //Get table
-        Table table = currentGridUnit.getTable();
-        
-        //----------------------------------------------------------------------
-        //We're creating two arrays containing the applicable BorderInfos for
-        //each cell in question.
-        //0 = cell, 1 = row, 2 = row group (body), 3 = column, 
-        //4 = col group (spanned column, see 6.7.3), 5 = table
-
-        BorderInfo[] current = new BorderInfo[6];
-        BorderInfo[] other = new BorderInfo[6];
-        //cell
-        current[0] = currentGridUnit.getOriginalBorderInfoForCell(side);
-        if (otherGridUnit != null) {
-            other[0] = otherGridUnit.getOriginalBorderInfoForCell(otherSide);
-        }
-        if ((currentRow != null) 
-                && (side == BEFORE 
-                    || side == AFTER
-                    || (currentGridUnit.getFlag(GridUnit.IN_FIRST_COLUMN) && side == START)
-                    || (currentGridUnit.getFlag(GridUnit.IN_LAST_COLUMN) && side == END))) {
-            //row
-            current[1] = currentRow.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherRow != null) {
-            //row
-            other[1] = otherRow.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        if (currentBody != null
-                && ((side == BEFORE && currentGridUnit.getFlag(GridUnit.FIRST_IN_PART))
-                || (side == AFTER && currentGridUnit.getFlag(GridUnit.LAST_IN_PART))
-                || (currentGridUnit.getFlag(GridUnit.IN_FIRST_COLUMN) && side == START)
-                || (currentGridUnit.getFlag(GridUnit.IN_LAST_COLUMN) && side == END))) {
-            //row group (=body, table-header or table-footer)
-            current[2] = currentBody.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherGridUnit != null
-                && otherBody != null
-                && ((otherSide == BEFORE && otherGridUnit.getFlag(GridUnit.FIRST_IN_PART))
-                    || (otherSide == AFTER && otherGridUnit.getFlag(GridUnit.LAST_IN_PART)))) {
-            //row group (=body, table-header or table-footer)
-            other[2] = otherBody.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        if ((side == BEFORE && otherGridUnit == null)
-                || (side == AFTER && otherGridUnit == null)
-                || (side == START)
-                || (side == END)) {
-            //column
-            current[3] = currentColumn.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        if (otherColumn != null) {
-            //column
-            other[3] = otherColumn.getCommonBorderPaddingBackground().getBorderInfo(otherSide);
-        }
-        //TODO current[4] and other[4] for column groups
-        if (otherGridUnit == null
-            && ((side == BEFORE && (flags & VERTICAL_START_END_OF_TABLE) > 0)
-                    || (side == AFTER && (flags & VERTICAL_START_END_OF_TABLE) > 0)
-                    || (side == START)
-                    || (side == END))) {
-            //table
-            current[5] = table.getCommonBorderPaddingBackground().getBorderInfo(side);
-        }
-        //other[6] is always null, since it's always the same table
-        
-        BorderInfo resolved = null;
-        
-        // *** Rule 1 ***
-        resolved = doRule1(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 2 ***
-        if (!doRule2(current, other)) {
-        }
-        
-        // *** Rule 3 ***
-        resolved = doRule3(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 4 ***
-        resolved = doRule4(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        // *** Rule 5 ***
-        resolved = doRule5(current, other);
-        if (resolved != null) {
-            return resolved;
-        }
-        
-        return null; //no winner, no border
-    }
-
-    private BorderInfo doRule1(BorderInfo[] current, BorderInfo[] other) {
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getStyle() == Constants.EN_HIDDEN)) {
-                return current[i];
-            }
-            if ((other[i] != null) && (other[i].getStyle() == Constants.EN_HIDDEN)) {
-                return other[i];
-            }
-        }
-        return null;
-    }
-    
-    private boolean doRule2(BorderInfo[] current, BorderInfo[] other) {
-        boolean found = false;
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getStyle() != Constants.EN_NONE)) {
-                found = true;
-                break;
+    /** {@inheritDoc} */
+    public BorderSpecification determineWinner(BorderSpecification border1,
+            BorderSpecification border2) {
+        BorderInfo bi1 = border1.getBorderInfo();
+        BorderInfo bi2 = border2.getBorderInfo();
+        // Rule 1
+        if (bi1.getStyle() == Constants.EN_HIDDEN) {
+            return border1;
+        } else if (bi2.getStyle() == Constants.EN_HIDDEN) {
+            return border2;
+        }
+        // Rule 2
+        if (bi2.getStyle() == Constants.EN_NONE) {
+            return border1;
+        } else if (bi1.getStyle() == Constants.EN_NONE) {
+            return border2;
+        }
+        // Rule 3
+        int width1 = bi1.getRetainedWidth();
+        int width2 = bi2.getRetainedWidth();
+        if (width1 > width2) {
+            return border1;
+        } else if (width1 == width2) {
+            int cmp = compareStyles(bi1.getStyle(), bi2.getStyle());
+            if (cmp > 0) {
+                return border1;
+            } else if (cmp < 0) {
+                return border2;
             }
-            if ((other[i] != null) && (other[i].getStyle() != Constants.EN_NONE)) {
-                found = true;
-                break;
-            }
-        }
-        return found;
-    }
-
-    private BorderInfo doRule3(BorderInfo[] current, BorderInfo[] other) {
-        int width = 0;
-        //Find max border width
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getRetainedWidth() > width)) {
-                width = current[i].getRetainedWidth();
-            }
-            if ((other[i] != null) && (other[i].getRetainedWidth() > width)) {
-                width = other[i].getRetainedWidth();
-            }
-        }
-        BorderInfo widest = null;
-        int count = 0;
-        //See if there's only one with the widest border
-        for (int i = 0; i < current.length; i++) {
-            if ((current[i] != null) && (current[i].getRetainedWidth() == width)) {
-                count++;
-                if (widest == null) {
-                    widest = current[i];
-                }
-            } else {
-                current[i] = null; //Discard the narrower ones
-            }
-            if ((other[i] != null) && (other[i].getRetainedWidth() == width)) {
-                count++;
-                if (widest == null) {
-                    widest = other[i];
-                }
-            } else {
-                other[i] = null; //Discard the narrower ones
-            }
-        }
-        if (count == 1) {
-            return widest;
         } else {
-            return null;
+            return border2;
         }
-    }
-
-    private BorderInfo doRule4(BorderInfo[] current, BorderInfo[] other) {
-        int pref = getPreferenceValue(Constants.EN_INSET); //Lowest preference
-        //Find highest preference value
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                int currPref = getPreferenceValue(current[i].getStyle());
-                if (currPref > pref) {
-                    pref = currPref;
-                }
-            }
-            if (other[i] != null) {
-                int currPref = getPreferenceValue(other[i].getStyle());
-                if (currPref > pref) {
-                    pref = currPref;
-                }
-            }
-        }
-        BorderInfo preferred = null;
-        int count = 0;
-        //See if there's only one with the preferred border style
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                int currPref = getPreferenceValue(current[i].getStyle());
-                if (currPref == pref) {
-                    count++;
-                    if (preferred == null) {
-                        preferred = current[i];
-                    }
-                    break;
-                }
-            } else {
-                current[i] = null; //Discard the ones that are not preferred
-            }
-            if (other[i] != null) {
-                int currPref = getPreferenceValue(other[i].getStyle());
-                if (currPref == pref) {
-                    count++;
-                    if (preferred == null) {
-                        preferred = other[i];
-                    }
-                    break;
-                }
-            } else {
-                other[i] = null; //Discard the ones that are not preferred
-            }
-        }
-        if (count == 1) {
-            return preferred;
-        } else {
-            return null;
-        }
-    }
-
-    private BorderInfo doRule5(BorderInfo[] current, BorderInfo[] other) {
-        for (int i = 0; i < current.length; i++) {
-            if (current[i] != null) {
-                return current[i];
-            }
-            if (other[i] != null) {
-                return other[i];
-            }
+        // Rule 4
+        int cmp = compareFOs(border1.getHolder(), border2.getHolder());
+        if (cmp > 0) {
+            return border1;
+        } else if (cmp < 0) {
+            return border2;
         }
         return null;
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/GridUnitPart.java Wed Nov 21 12:50:23 2007
@@ -19,6 +19,9 @@
 
 package org.apache.fop.layoutmgr.table;
 
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+
 /**
  * Represents a non-dividable part of a grid unit. Used by the table stepper.
  */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -26,6 +26,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
+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.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.LengthRangeProperty;
@@ -47,21 +50,12 @@
 
     private TableLayoutManager tableLM;
 
-    private TableRowIterator bodyIter;
-    private TableRowIterator headerIter;
-    private TableRowIterator footerIter;
-    private TableRowIterator thisIter;
     private TableStepper tableStepper;
 
-    RowGroupLayoutManager(TableLayoutManager tableLM, EffRow[] rowGroup, TableRowIterator bodyIter,
-            TableRowIterator headerIter, TableRowIterator footerIter, TableRowIterator thisIter,
+    RowGroupLayoutManager(TableLayoutManager tableLM, EffRow[] rowGroup,
             TableStepper tableStepper) {
         this.tableLM = tableLM;
         this.rowGroup = rowGroup;
-        this.bodyIter = bodyIter;
-        this.headerIter = headerIter;
-        this.footerIter = footerIter;
-        this.thisIter = thisIter;
         this.tableStepper = tableStepper;
     }
 
@@ -97,10 +91,6 @@
 
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
         LinkedList returnList = new LinkedList();
-        //Border resolution
-        if (!tableLM.getTable().isSeparateBorderModel()) {
-            resolveNormalBeforeAfterBordersForRowGroup();
-        }
 
         //Reset keep-with-next when remaining inside the table.
         //The context flag is only used to propagate keep-with-next to the outside.
@@ -134,107 +124,6 @@
     }
 
     /**
-     * Resolves normal borders for a row group.
-     * @param iter Table row iterator to operate on
-     */
-    private void resolveNormalBeforeAfterBordersForRowGroup() {
-        for (int rgi = 0; rgi < rowGroup.length; rgi++) {
-            EffRow row = rowGroup[rgi];
-            EffRow prevRow = thisIter.getPrecedingRow(row);
-            EffRow nextRow = thisIter.getFollowingRow(row);
-            if ((prevRow == null) && (thisIter == bodyIter) && (headerIter != null)) {
-                prevRow = headerIter.getLastRow();
-            }
-            if ((nextRow == null) && (thisIter == headerIter)) {
-                nextRow = bodyIter.getFirstRow();
-            }
-            if ((nextRow == null) && (thisIter == bodyIter) && (footerIter != null)) {
-                nextRow = footerIter.getFirstRow();
-            }
-            if ((prevRow == null) && (thisIter == footerIter)) {
-                //TODO This could be bad for memory consumption because it already causes the
-                //whole body iterator to be prefetched!
-                prevRow = bodyIter.getLastRow();
-            }
-            log.debug("prevRow-row-nextRow: " + prevRow + " - " + row + " - " + nextRow);
-            
-            //Determine the grid units necessary for getting all the borders right
-            int guCount = row.getGridUnits().size();
-            if (prevRow != null) {
-                guCount = Math.max(guCount, prevRow.getGridUnits().size());
-            }
-            if (nextRow != null) {
-                guCount = Math.max(guCount, nextRow.getGridUnits().size());
-            }
-            GridUnit gu = row.getGridUnit(0);
-            //Create empty grid units to hold resolved borders of neighbouring cells
-            //TODO maybe this needs to be done differently (and sooner)
-            for (int i = 0; i < guCount - row.getGridUnits().size(); i++) {
-                //TODO This block is untested!
-                int pos = row.getGridUnits().size() + i;
-                row.getGridUnits().add(new EmptyGridUnit(gu.getRow(), 
-                        tableLM.getColumns().getColumn(pos + 1), gu.getBody(), 
-                        pos));
-            }
-            
-            //Now resolve normal borders
-            if (tableLM.getTable().isSeparateBorderModel()) {
-                //nop, borders are already assigned at this point
-            } else {
-                for (int i = 0; i < row.getGridUnits().size(); i++) {
-                    gu = row.getGridUnit(i);
-                    GridUnit other;
-                    int flags = 0;
-                    if (prevRow != null && i < prevRow.getGridUnits().size()) {
-                        other = prevRow.getGridUnit(i);
-                    } else {
-                        other = null;
-                    }
-                    if (other == null 
-                            || other.isEmpty() 
-                            || gu.isEmpty() 
-                            || gu.getPrimary() != other.getPrimary()) {
-                        if ((thisIter == bodyIter)
-                                && gu.getFlag(GridUnit.FIRST_IN_TABLE)
-                                && (headerIter == null)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        if ((thisIter == headerIter)
-                                && gu.getFlag(GridUnit.FIRST_IN_TABLE)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        gu.resolveBorder(other, 
-                                CommonBorderPaddingBackground.BEFORE, flags);
-                    }
-                    
-                    flags = 0;
-                    if (nextRow != null && i < nextRow.getGridUnits().size()) {
-                        other = nextRow.getGridUnit(i);
-                    } else {
-                        other = null;
-                    }
-                    if (other == null 
-                            || other.isEmpty() 
-                            || gu.isEmpty() 
-                            || gu.getPrimary() != other.getPrimary()) {
-                        if ((thisIter == bodyIter)
-                                && gu.getFlag(GridUnit.LAST_IN_TABLE)
-                                && (footerIter == null)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        if ((thisIter == footerIter)
-                                && gu.getFlag(GridUnit.LAST_IN_TABLE)) {
-                            flags |= CollapsingBorderModel.VERTICAL_START_END_OF_TABLE;
-                        }
-                        gu.resolveBorder(other, 
-                                CommonBorderPaddingBackground.AFTER, flags);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
      * Creates Knuth elements for a row group (see TableRowIterator.getNextRowGroup()).
      * @param context Active LayoutContext
      * @param alignment alignment indicator
@@ -263,7 +152,7 @@
             int maxCellHeight = 0;
             int effRowContentHeight = 0;
             for (int j = 0; j < row.getGridUnits().size(); j++) {
-//                assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size(); // TODO vh
+                assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size();
                 maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size());
                 GridUnit gu = row.getGridUnit(j);
                 if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan())) 
@@ -271,6 +160,7 @@
                     PrimaryGridUnit primary = gu.getPrimary();
                     
                     if (gu.isPrimary()) {
+                        primary.createCellLM(); // TODO a new LM must be created for every new static-content
                         primary.getCellLM().setParent(tableLM);
                      
                         //Determine the table-row if any

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Wed Nov 21 12:50:23 2007
@@ -25,6 +25,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+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.TableRow;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 import org.apache.fop.layoutmgr.ElementListUtils;

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -23,8 +23,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.Trait;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
+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.TableCell;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
@@ -32,18 +37,16 @@
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
 import org.apache.fop.layoutmgr.KnuthPenalty;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.ListElement;
-import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.SpaceResolver;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-import org.apache.fop.area.Trait;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -230,8 +233,15 @@
         }
 
         returnedList = new LinkedList();
-        wrapPositionElements(contentList, returnList);
-
+        if (contentList.size() > 0) {
+            wrapPositionElements(contentList, returnList);
+        } else {
+            // In relaxed validation mode, table-cells having no children are authorised.
+            // Add a zero-width block here to not have to take this special case into
+            // account later
+            // Copied from BlockStackingLM
+            returnList.add(new KnuthBox(0, notifyPos(new Position(this)), true));
+        }
         //Space resolution
         SpaceResolver.resolveElementList(returnList);
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Wed Nov 21 12:50:23 2007
@@ -31,6 +31,8 @@
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.GridUnit;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
 import org.apache.fop.fo.flow.table.TableRow;
@@ -75,15 +77,12 @@
     public TableContentLayoutManager(TableLayoutManager parent) {
         this.tableLM = parent;
         Table table = getTableLM().getTable();
-        this.bodyIter = new TableRowIterator(table, getTableLM().getColumns(),
-                TableRowIterator.BODY);
+        this.bodyIter = new TableRowIterator(table, TableRowIterator.BODY);
         if (table.getTableHeader() != null) {
-            headerIter = new TableRowIterator(table, 
-                    getTableLM().getColumns(), TableRowIterator.HEADER);
+            headerIter = new TableRowIterator(table, TableRowIterator.HEADER);
         }
         if (table.getTableFooter() != null) {
-            footerIter = new TableRowIterator(table, 
-                    getTableLM().getColumns(), TableRowIterator.FOOTER);
+            footerIter = new TableRowIterator(table, TableRowIterator.FOOTER);
         }
     }
     
@@ -212,7 +211,7 @@
         int breakBetween = Constants.EN_AUTO;
         while ((rowGroup = iter.getNextRowGroup()) != null) {
             RowGroupLayoutManager rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup,
-                    bodyIter, headerIter, footerIter, iter, stepper);
+                    stepper);
             if (breakBetween == Constants.EN_AUTO) {
                 // TODO improve
                 breakBetween = rowGroupLM.getBreakBefore();
@@ -233,7 +232,8 @@
         // Break after the table's last row
         // TODO should eventually be handled at the table level
         if (breakBetween != Constants.EN_AUTO) {
-            if (returnList.size() > 0) {
+            if (returnList.size() > 0 && ((ListElement) returnList.getLast()).isPenalty()) {
+                // May be a glue if the unbroken height is greater than the broken heights
                 BreakElement breakPoss = (BreakElement) returnList.getLast();
                 breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
                 breakPoss.setBreakClass(breakBetween);

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java?rev=597205&r1=597204&r2=597205&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java Wed Nov 21 12:50:23 2007
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.fop.fo.flow.table.EffRow;
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.Position;
 



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