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/04/01 17:09:51 UTC

svn commit: r643433 [5/9] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ lib/ src/codegen/fonts/ src/documentation/ src/documentation/content/ src/documentation/content/xdocs/ src/documentation/content/xdocs/0.93/ src/documentation/content/xd...

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/GridUnit.java Tue Apr  1 08:08:24 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fo.flow.table;
 
-import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
@@ -163,14 +162,6 @@
 
     void setRow(TableRow row) {
         this.row = row;
-    }
-
-    public TableBody getBody() {
-        FONode node = getCell();
-        while (node != null && !(node instanceof TableBody)) {
-            node = node.getParent();
-        }
-        return (TableBody) node;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java Tue Apr  1 08:08:24 2008
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
@@ -71,6 +72,19 @@
                 .getValue() / 2;  // TODO
     }
 
+    /**
+     * Returns the fo:table-header/footer/body element containing this cell.
+     * 
+     * @return the enclosing table part
+     */
+    public TableBody getTableBody() {
+        FONode node = cell.getParent();
+        if (node instanceof TableRow) {
+            node = node.getParent();
+        }
+        return (TableBody) node;
+    }
+
     public TableCellLayoutManager getCellLM() {
         assert cellLM != null;
         return cellLM;
@@ -222,18 +236,6 @@
             contentLength = ElementListUtils.calcContentLength(elements);
         }
         return contentLength;
-    }
-
-    /** @return true if cell/row has an explicit BPD/height */
-    public boolean hasBPD() {
-        if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) {
-            return true;
-        }
-        if (getRow() != null
-                && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) {
-            return true;
-        }
-        return false;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java Tue Apr  1 08:08:24 2008
@@ -21,6 +21,7 @@
 
 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;
@@ -142,7 +143,7 @@
             FontMetrics metrics = font.getFontMetrics();
             if (metrics instanceof Typeface) {
                 Typeface typeface = (Typeface)metrics;
-                if ("SymbolEncoding".equals(typeface.getEncoding())) {
+                if ("SymbolEncoding".equals(typeface.getEncodingName())) {
                     //SymbolEncoding doesn't have HYPHEN_MINUS, so replace by MINUS_SIGN
                 } else {
                     //only warn if the encoding is not SymbolEncoding
@@ -154,7 +155,7 @@
             FontMetrics metrics = font.getFontMetrics();
             if (metrics instanceof Typeface) {
                 Typeface typeface = (Typeface)metrics;
-                if ("ZapfDingbatsEncoding".equals(typeface.getEncoding())) {
+                if ("ZapfDingbatsEncoding".equals(typeface.getEncodingName())) {
                     //ZapfDingbatsEncoding doesn't have HYPHEN_MINUS, so replace by ' '
                 } else {
                     //only warn if the encoding is not ZapfDingbatsEncoding

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java Tue Apr  1 08:08:24 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
-/* $Id:$ */
+/* $Id$ */
 
 package org.apache.fop.fo.properties;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java Tue Apr  1 08:08:24 2008
@@ -29,7 +29,7 @@
 /**
  * Abstract base class for code point mapping classes (1-byte character encodings).
  */
-public class AbstractCodePointMapping {
+public class AbstractCodePointMapping implements SingleByteEncoding {
 
     private String name;
     private char[] latin1Map;
@@ -114,19 +114,12 @@
         }
     }
 
-    /**
-     * Returns the encoding's name.
-     * @return the name of the encoding
-     */
+    /** {@inheritDoc} */
     public String getName() {
         return this.name;
     }
 
-    /**
-     * Maps a Unicode character to a code point in the encoding.
-     * @param c the Unicode character to map
-     * @return the coid point in the encoding or 0 (=.notdef) if not found
-     */
+    /** {@inheritDoc} */
     public final char mapChar(char c) {
         if (c < 256) {
             char latin1 = latin1Map[c];
@@ -172,8 +165,8 @@
             }
         }
         
-        putFallbackCharacter(c, '\0');
-        return 0;
+        putFallbackCharacter(c, NOT_FOUND_CODE_POINT);
+        return NOT_FOUND_CODE_POINT;
     }
 
     private void putFallbackCharacter(char c, char mapTo) {
@@ -227,11 +220,7 @@
         return -1;
     }
     
-    /**
-     * Returns the array of character names for this encoding.
-     * @return the array of character names
-     *                  (unmapped code points are represented by a ".notdef" value)
-     */
+    /** {@inheritDoc} */
     public String[] getCharNameMap() {
         if (this.charNameMap != null) {
             String[] copy = new String[this.charNameMap.length];

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/CIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/CIDFont.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/CIDFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/CIDFont.java Tue Apr  1 08:08:24 2008
@@ -20,31 +20,14 @@
 package org.apache.fop.fonts;
 
 //Java
-import java.util.Map;
 
 /**
  * Abstract base class for CID fonts.
  */
 public abstract class CIDFont extends CustomFont {
 
-    /**
-     * usedGlyphs contains orginal, new glyph index
-     */
-    public Map usedGlyphs = new java.util.HashMap();
-
-    /**
-     * usedGlyphsIndex contains new glyph, original index
-     */
-    public Map usedGlyphsIndex = new java.util.HashMap();
-    public int usedGlyphsCount = 0;
-
-    /**
-     * usedCharsIndex contains new glyph, original char
-     */
-    public Map usedCharsIndex = new java.util.HashMap();
-
-    //private PDFWArray warray = new PDFWArray();
-    public int width[] = null;
+    /** Contains the character widths for all characters in the font */
+    protected int[] width = null;
 
     // ---- Required ----
     /**
@@ -73,6 +56,11 @@
      */
     public abstract int getSupplement();
 
+    /**
+     * Returns the subset information for this font.
+     * @return the subset information
+     */
+    public abstract CIDSubset getCIDSubset();
 
     // ---- Optional ----
     /**
@@ -88,9 +76,4 @@
         return true;
     }
 
-    /**
-     * Returns a char array containing all Unicode characters that have been accessed.
-     * @return a char array with all used Unicode characters
-     */
-    public abstract char[] getCharsUsed();
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java Tue Apr  1 08:08:24 2008
@@ -199,7 +199,7 @@
 
         // Use default CodePointMapping
         char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
-        if (d != 0) {
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
             c = d;
         } else {
             log.warn("Glyph " + (int) c + " not available in font " + fontName);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java Tue Apr  1 08:08:24 2008
@@ -64,11 +64,10 @@
         this.resolver = resolver;
     }
 
-    /**
-     * String representation of LazyFont
-     */
+    /** {@inheritDoc} */
     public String toString() {
-        return ( "metrics-url=" + metricsFileName + ", embed-url=" + fontEmbedPath + ", kerning=" + useKerning );
+        return ( "metrics-url=" + metricsFileName + ", embed-url=" + fontEmbedPath
+                + ", kerning=" + useKerning );
     }
         
     private void load(boolean fail) {
@@ -80,8 +79,9 @@
                     if (resolver != null) {
                         Source source = resolver.resolve(metricsFileName);
                         if (source == null) {
-                            String err = "Cannot load font: failed to create Source from metrics file " 
-                                + metricsFileName; 
+                            String err
+                                = "Cannot load font: failed to create Source from metrics file " 
+                                    + metricsFileName; 
                             if (fail) {
                                 throw new RuntimeException(err);
                             } else {
@@ -112,8 +112,8 @@
                         src.setSystemId(source.getSystemId()); 
                         reader = new FontReader(src);
                     } else {
-                        reader 
-                            = new FontReader(new InputSource(new URL(metricsFileName).openStream()));
+                        reader = new FontReader(new InputSource(
+                                    new URL(metricsFileName).openStream()));
                     }
                     reader.setKerningEnabled(useKerning);
                     reader.setFontEmbedPath(fontEmbedPath);
@@ -153,12 +153,10 @@
     }
 
     // ---- Font ----
-    /**
-     * {@inheritDoc}
-     */
-    public String getEncoding() {
+    /** {@inheritDoc} */
+    public String getEncodingName() {
         load(true);
-        return realFont.getEncoding();
+        return realFont.getEncodingName();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/MultiByteFont.java Tue Apr  1 08:08:24 2008
@@ -39,6 +39,9 @@
 
     private String namePrefix = null;    // Quasi unique prefix
 
+    private CIDSubset subset = new CIDSubset();
+    
+    /** A map from Unicode indices to glyph indices */
     private BFEntry[] bfentries = null;
 
     /**
@@ -46,15 +49,7 @@
      */
     public MultiByteFont() {
         // Make sure that the 3 first glyphs are included
-        usedGlyphs.put(new Integer(0), new Integer(0));
-        usedGlyphsIndex.put(new Integer(0), new Integer(0));
-        usedGlyphsCount++;
-        usedGlyphs.put(new Integer(1), new Integer(1));
-        usedGlyphsIndex.put(new Integer(1), new Integer(1));
-        usedGlyphsCount++;
-        usedGlyphs.put(new Integer(2), new Integer(2));
-        usedGlyphsIndex.put(new Integer(2), new Integer(2));
-        usedGlyphsCount++;
+        subset.setupFirstThreeGlyphs();
         
         // Create a quasiunique prefix for fontname
         synchronized (this.getClass()) {
@@ -77,37 +72,27 @@
         setFontType(FontType.TYPE0);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int getDefaultWidth() {
         return defaultWidth;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getRegistry() {
         return "Adobe";
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getOrdering() {
         return "UCS";
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int getSupplement() {
         return 0;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public CIDFontType getCIDType() {
         return cidType;
     }
@@ -133,68 +118,47 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean isEmbeddable() {
         return !(getEmbedFileName() == null && getEmbedResourceName() == null);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public String getEncoding() {
+    /** {@inheritDoc} */
+    public CIDSubset getCIDSubset() {
+        return this.subset;
+    }
+    
+    /** {@inheritDoc} */
+    public String getEncodingName() {
         return encoding;
     }
 
-    /**
-     * {@inheritDoc} 
-     */
+    /** {@inheritDoc} */
     public int getWidth(int i, int size) {
         if (isEmbeddable()) {
-            Integer idx = (Integer)usedGlyphsIndex.get(new Integer(i));
-            return size * width[idx.intValue()];
+            int glyphIndex = subset.getGlyphIndexForSubsetIndex(i);
+            return size * width[glyphIndex];
         } else {
             return size * width[i];
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int[] getWidths() {
         int[] arr = new int[width.length];
         System.arraycopy(width, 0, arr, 0, width.length - 1);
-        /*
-        for (int i = 0; i < arr.length; i++)
-            arr[i] *= size;
-        */
         return arr;
     }
 
     /**
-     * Remaps a codepoint based.
-     * @param i codepoint to remap
-     * @return new codepoint
+     * Returns the glyph index for a Unicode character. The method returns 0 if there's no
+     * such glyph in the character map.
+     * @param c the Unicode character index
+     * @return the glyph index (or 0 if the glyph is not available)
      */
-/* unused
-    public Integer reMap(Integer i) {
-        if (isEmbeddable()) {
-            Integer ret = (Integer)usedGlyphsIndex.get(i);
-            if (ret == null) {
-                ret = i;
-            }
-            return ret;
-        } else {
-            return i;
-        }
-
-    }
-*/
-
     private int findGlyphIndex(char c) {
         int idx = (int)c;
-        int retIdx = 0;
+        int retIdx = 0; //.notdef
 
         for (int i = 0; (i < bfentries.length) && retIdx == 0; i++) {
             if (bfentries[i].getUnicodeStart() <= idx
@@ -208,48 +172,30 @@
         return retIdx;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public char mapChar(char c) {
         notifyMapOperation();
-        int retIdx = findGlyphIndex(c);
+        int glyphIndex = findGlyphIndex(c);
 
         if (isEmbeddable()) {
-            // Reencode to a new subset font or get
-            // the reencoded value
-            Integer newIdx = (Integer)usedGlyphs.get(new Integer(retIdx));
-            if (newIdx == null) {
-                usedGlyphs.put(new Integer(retIdx),
-                               new Integer(usedGlyphsCount));
-                usedGlyphsIndex.put(new Integer(usedGlyphsCount),
-                                    new Integer(retIdx));
-                usedCharsIndex.put(new Integer(usedGlyphsCount),
-                                    new Integer((int) c));
-                retIdx = usedGlyphsCount;
-                usedGlyphsCount++;
-            } else {
-                retIdx = newIdx.intValue();
-            }
+            glyphIndex = subset.mapSubsetChar(glyphIndex, c);
         }
 
-        return (char)retIdx;
+        return (char)glyphIndex;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean hasChar(char c) {
         return (findGlyphIndex(c) > 0);
     }
 
-
     /**
-     * Sets the bfentries.
-     * @param bfentries The bfentries to set
+     * Sets the array of BFEntry instances which constitutes the Unicode to glyph index map for
+     * a font. ("BF" means "base font")
+     * @param entries the Unicode to glyph index map
      */
-    public void setBFEntries(BFEntry[] bfentries) {
-        this.bfentries = bfentries;
+    public void setBFEntries(BFEntry[] entries) {
+        this.bfentries = entries;
     }
 
     /**
@@ -277,17 +223,6 @@
     }
 
     /**
-     * Adds a new CID width entry to the font.
-     * @param cidWidthIndex index
-     * @param wds array of widths
-     */
-    /*
-    public void addCIDWidthEntry(int cidWidthIndex, int[] wds) {
-        this.warray.addEntry(cidWidthIndex, wds);
-    }*/
-
-
-    /**
      * Sets the width array.
      * @param wds array of widths.
      */
@@ -300,30 +235,15 @@
      * @return Map Map of used Glyphs
      */
     public Map getUsedGlyphs() {
-        return usedGlyphs;
+        return subset.getSubsetGlyphs();
     }
 
-    /** The invalid Unicode character, suitable as a return value in methods
-     * that need to return an invalid character. */
-    public static final char INVALID_UNICODE_CHAR = 0xFFFF;
-
     /** {@inheritDoc} */
     public char[] getCharsUsed() {
         if (!isEmbeddable()) {
             return null;
         }
-        char[] charArray = new char[usedGlyphsCount];
-        for (int i = 0; i < usedGlyphsCount; i++) {
-            Integer mapValue = (Integer)usedCharsIndex.get(new Integer(i));
-            if (mapValue != null) {
-                char arrayItem = (char) mapValue.intValue();
-                charArray[i] = arrayItem;
-            }
-            else {
-                charArray[i] = INVALID_UNICODE_CHAR;
-            }
-        }
-        return charArray;
+        return subset.getSubsetChars();
     }
 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/SingleByteFont.java Tue Apr  1 08:08:24 2008
@@ -19,6 +19,8 @@
 
 package org.apache.fop.fonts;
 
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -31,14 +33,21 @@
  */
 public class SingleByteFont extends CustomFont {
 
+    /** Code point that is used if no code point for a specific character has been found. */
+    public static final char NOT_FOUND = '#';
+
     /** logger */
     private  static Log log = LogFactory.getLog(SingleByteFont.class);
 
-    private CodePointMapping mapping;
+    private SingleByteEncoding mapping;
 
     private int[] width = null;
 
     private Set warnedChars;
+
+    private Map unencodedCharacters;
+    //Map<Character, UnencodedCharacter>
+    private List additionalEncodings;
     
     /**
      * Main constructor.
@@ -54,7 +63,7 @@
     }
 
     /** {@inheritDoc} */
-    public String getEncoding() {
+    public String getEncodingName() {
         return this.mapping.getName();
     }
 
@@ -62,18 +71,28 @@
      * Returns the code point mapping (encoding) of this font.
      * @return the code point mapping
      */
-    public CodePointMapping getCodePointMapping() {
+    public SingleByteEncoding getEncoding() {
         return this.mapping;
     }
     
     /** {@inheritDoc} */
     public int getWidth(int i, int size) {
-        int idx = i - getFirstChar();
-        if (idx >= 0 && idx < width.length) {
-            return size * width[i - getFirstChar()];
-        } else {
-            return 0;
+        if (i < 256) {
+            int idx = i - getFirstChar();
+            if (idx >= 0 && idx < width.length) {
+                return size * width[i - getFirstChar()];
+            }
+        } else if (this.additionalEncodings != null) {
+            int encodingIndex = (i / 256) - 1;
+            SimpleSingleByteEncoding encoding = getAdditionalEncoding(encodingIndex);
+            int codePoint = i % 256;
+            NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
+            UnencodedCharacter uc
+                = (UnencodedCharacter)this.unencodedCharacters.get(
+                        new Character(nc.getSingleUnicodeValue()));
+            return size * uc.getWidth();
         }
+        return 0;
     }
 
     /** {@inheritDoc} */
@@ -87,30 +106,80 @@
     public char mapChar(char c) {
         notifyMapOperation();
         char d = mapping.mapChar(c);
-        if (d != 0) {
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
             return d;
-        } else {
-            Character ch = new Character(c);
-            if (warnedChars == null) {
-                warnedChars = new java.util.HashSet();
+        }
+        
+        //Check unencoded characters which are available in the font by character name
+        d = mapUnencodedChar(c);
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+            return d;
+        }
+        
+        //Give up, character is not available
+        Character ch = new Character(c);
+        if (warnedChars == null) {
+            warnedChars = new java.util.HashSet();
+        }
+        if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
+            warnedChars.add(ch);
+            if (warnedChars.size() == 8) {
+                log.warn("Many requested glyphs are not available in font " + getFontName());
+            } else {
+                log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c) 
+                        + ", " + Glyphs.charToGlyphName(c)
+                        + ") not available in font " + getFontName());
             }
-            if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
-                warnedChars.add(ch);
-                if (warnedChars.size() == 8) {
-                    log.warn("Many requested glyphs are not available in font " + getFontName());
-                } else {
-                    log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c) 
-                            + ", " + Glyphs.charToGlyphName(c)
-                            + ") not available in font " + getFontName());
+        }
+        return NOT_FOUND;
+    }
+
+    private char mapUnencodedChar(char ch) {
+        if (this.unencodedCharacters != null) {
+            UnencodedCharacter unencoded
+                = (UnencodedCharacter)this.unencodedCharacters.get(new Character(ch));
+            if (unencoded != null) {
+                if (this.additionalEncodings == null) {
+                    this.additionalEncodings = new java.util.ArrayList();
+                }
+                SimpleSingleByteEncoding encoding = null;
+                char mappedStart = 0;
+                int additionalsCount = this.additionalEncodings.size(); 
+                for (int i = 0; i < additionalsCount; i++) {
+                    mappedStart += 256;
+                    encoding = getAdditionalEncoding(i);
+                    char alt = encoding.mapChar(ch);
+                    if (alt != 0) {
+                        return (char)(mappedStart + alt);
+                    }
+                }
+                if (encoding != null && encoding.isFull()) {
+                    encoding = null;
                 }
+                if (encoding == null) {
+                    encoding = new SimpleSingleByteEncoding(
+                            getFontName() + "EncodingSupp" + (additionalsCount + 1));
+                    this.additionalEncodings.add(encoding);
+                    mappedStart += 256;
+                }
+                return (char)(mappedStart + encoding.addCharacter(unencoded.getCharacter()));
             }
-            return '#';
         }
+        return 0;
     }
 
     /** {@inheritDoc} */
     public boolean hasChar(char c) {
-        return (mapping.mapChar(c) > 0);
+        char d = mapping.mapChar(c);
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+            return true;
+        }
+        //Check unencoded characters which are available in the font by character name
+        d = mapUnencodedChar(c);
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+            return true;
+        }
+        return false;
     }
 
     /* ---- single byte font specific setters --- */
@@ -146,13 +215,106 @@
     /**
      * Sets a width for a character.
      * @param index index of the character
-     * @param width the width of the character
+     * @param w the width of the character
      */
-    public void setWidth(int index, int width) {
+    public void setWidth(int index, int w) {
         if (this.width == null) {
             this.width = new int[getLastChar() - getFirstChar() + 1];
         }
-        this.width[index - getFirstChar()] = width;
+        this.width[index - getFirstChar()] = w;
+    }
+
+    /**
+     * Adds an unencoded character (one that is not supported by the primary encoding).
+     * @param ch the named character
+     * @param width the width of the character
+     */
+    public void addUnencodedCharacter(NamedCharacter ch, int width) {
+        if (this.unencodedCharacters == null) {
+            this.unencodedCharacters = new java.util.HashMap();
+        }
+        if (ch.hasSingleUnicodeValue()) {
+            UnencodedCharacter uc = new UnencodedCharacter(ch, width);
+            this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc);
+        } else {
+            //Cannot deal with unicode sequences, so ignore this character
+        }
+    }
+
+    /**
+     * Indicates whether the encoding has additional encodings besides the primary encoding.
+     * @return true if there are additional encodings.
+     */
+    public boolean hasAdditionalEncodings() {
+        return (this.additionalEncodings != null) && (this.additionalEncodings.size() > 0);
+    }
+    
+    /**
+     * Returns the number of additional encodings this single-byte font maintains.
+     * @return the number of additional encodings
+     */
+    public int getAdditionalEncodingCount() {
+        if (hasAdditionalEncodings()) {
+            return this.additionalEncodings.size();
+        } else {
+            return 0;
+        }
+    }
+    
+    /**
+     * Returns an additional encoding.
+     * @param index the index of the additional encoding
+     * @return the additional encoding
+     * @throws IndexOutOfBoundsException if the index is out of bounds
+     */
+    public SimpleSingleByteEncoding getAdditionalEncoding(int index)
+            throws IndexOutOfBoundsException {
+        if (hasAdditionalEncodings()) {
+            return (SimpleSingleByteEncoding)this.additionalEncodings.get(index);
+        } else {
+            throw new IndexOutOfBoundsException("No additional encodings available");
+        }
+    }
+    
+    /**
+     * Returns an array with the widths for an additional encoding.
+     * @param index the index of the additional encoding
+     * @return the width array
+     */
+    public int[] getAdditionalWidths(int index) {
+        SimpleSingleByteEncoding enc = getAdditionalEncoding(index);
+        int[] arr = new int[enc.getLastChar() - enc.getFirstChar() + 1];
+        for (int i = 0, c = arr.length; i < c; i++) {
+            NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
+            UnencodedCharacter uc = (UnencodedCharacter)this.unencodedCharacters.get(
+                    new Character(nc.getSingleUnicodeValue()));
+            arr[i] = uc.getWidth();
+        }
+        return arr;
+    }
+    
+    private static final class UnencodedCharacter {
+        
+        private NamedCharacter character;
+        private int width;
+        
+        public UnencodedCharacter(NamedCharacter character, int width) {
+            this.character = character;
+            this.width = width;
+        }
+        
+        public NamedCharacter getCharacter() {
+            return this.character;
+        }
+        
+        public int getWidth() {
+            return this.width;
+        }
+        
+        /** {@inheritDoc} */
+        public String toString() {
+            return getCharacter().toString();
+        }
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Typeface.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Typeface.java Tue Apr  1 08:08:24 2008
@@ -19,11 +19,8 @@
  
 package org.apache.fop.fonts;
 
-// FOP
-
-
 /**
- * Base class for PDF font classes
+ * Base class for font classes
  */
 public abstract class Typeface implements FontMetrics {
 
@@ -37,7 +34,7 @@
      * Get the encoding of the font.
      * @return the encoding
      */
-    public abstract String getEncoding();
+    public abstract String getEncodingName();
 
     /**
      * Map a Unicode character to a code point in the font.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java Tue Apr  1 08:08:24 2008
@@ -592,8 +592,8 @@
                                         + mtxTab[origIndex.intValue()].getOffset()) < 0) {
                         // origIndex is a composite glyph
                         allComposites.put(origIndex, glyphs.get(origIndex));
-                        List composites =
-                            getIncludedGlyphs(in, (int)entry.getOffset(),
+                        List composites
+                            = getIncludedGlyphs(in, (int)entry.getOffset(),
                                               origIndex);
 
                         // Iterate through all composites pointed to
@@ -651,6 +651,9 @@
         if (!checkTTC(in, name)) {
             throw new IOException("Failed to read font");
         }
+        
+        //Copy the Map as we're going to modify it
+        Map subsetGlyphs = new java.util.HashMap(glyphs);
 
         output = new byte[in.getFileSize()];
 
@@ -661,14 +664,14 @@
         readHorizontalMetrics(in);
         readIndexToLocation(in);
 
-        scanGlyphs(in, glyphs);
+        scanGlyphs(in, subsetGlyphs);
 
         createDirectory();                // Create the TrueType header and directory
 
         createHead(in);
-        createHhea(in, glyphs.size());    // Create the hhea table
-        createHmtx(in, glyphs);           // Create hmtx table
-        createMaxp(in, glyphs.size());    // copy the maxp table
+        createHhea(in, subsetGlyphs.size());    // Create the hhea table
+        createHmtx(in, subsetGlyphs);           // Create hmtx table
+        createMaxp(in, subsetGlyphs.size());    // copy the maxp table
 
         boolean optionalTableFound;
         optionalTableFound = createCvt(in);    // copy the cvt table
@@ -689,8 +692,8 @@
             log.debug("TrueType: prep table not present. Skipped.");
         }
 
-        createLoca(glyphs.size());    // create empty loca table
-        createGlyf(in, glyphs);       //create glyf table and update loca table
+        createLoca(subsetGlyphs.size());    // create empty loca table
+        createGlyf(in, subsetGlyphs);       //create glyf table and update loca table
 
         pad4();
         createCheckSumAdjustment();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMCharMetrics.java Tue Apr  1 08:08:24 2008
@@ -21,6 +21,8 @@
 
 import java.awt.geom.RectangularShape;
 
+import org.apache.fop.fonts.NamedCharacter;
+
 
 /**
  * Holds the metrics of a single character from an AFM file.
@@ -28,8 +30,7 @@
 public class AFMCharMetrics {
 
     private int charCode = -1;
-    private String unicodeSequence;
-    private String charName;
+    private NamedCharacter character;
     private double widthX;
     private double widthY;
     private RectangularShape bBox;
@@ -59,36 +60,45 @@
     }
     
     /**
-     * Returns the Unicode sequence for this character.
-     * @return the Unicode characters
-     *                  (or null if no such Unicode sequence exists for this character)
+     * Returns the named character represented by this instance.
+     * @return the named character (or null if no named character is associated)
      */
-    public String getUnicodeSequence() {
-        return this.unicodeSequence;
+    public NamedCharacter getCharacter() {
+        return this.character;
+    }
+    
+    /**
+     * Sets the named character represented by this instance.
+     * @param ch the named character
+     */
+    public void setCharacter(NamedCharacter ch) {
+        this.character = ch;
     }
     
     /**
-     * Sets the Unicode sequence for this character.
+     * Sets the named character represented by this instance.
+     * @param charName the character name (as defined in the Adobe glyph list)
      * @param unicodeSequence the Unicode sequence
      */
-    public void setUnicodeSequence(String unicodeSequence) {
-        this.unicodeSequence = unicodeSequence;
+    public void setCharacter(String charName, String unicodeSequence) {
+        setCharacter(new NamedCharacter(charName, unicodeSequence));
     }
     
     /**
-     * Returns the PostScript character name.
-     * @return the charName
+     * Returns the Unicode sequence for this character.
+     * @return the Unicode characters
+     *                  (or null if no such Unicode sequence exists for this character)
      */
-    public String getCharName() {
-        return charName;
+    public String getUnicodeSequence() {
+        return (getCharacter() != null ? getCharacter().getUnicodeSequence() : null);
     }
     
     /**
-     * Sets the PostScript character name.
-     * @param charName the charName to set
+     * Returns the PostScript character name.
+     * @return the charName (or null if no character name is associated)
      */
-    public void setCharName(String charName) {
-        this.charName = charName;
+    public String getCharName() {
+        return (getCharacter() != null ? getCharacter().getName() : null);
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMFile.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMFile.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMFile.java Tue Apr  1 08:08:24 2008
@@ -26,7 +26,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.xmlgraphics.fonts.Glyphs;
 import org.apache.xmlgraphics.java2d.Dimension2DDouble;
 
 /**
@@ -315,15 +314,8 @@
     public void addCharMetrics(AFMCharMetrics metrics) {
         String name = metrics.getCharName();
         if (metrics.getUnicodeSequence() == null) {
-            if (name != null) {
-                String u = Glyphs.getUnicodeSequenceForGlyphName(metrics.getCharName());
-                if (u != null) {
-                    metrics.setUnicodeSequence(u);
-                }
-            } else {
-                //Ignore as no Unicode assignment is possible
-                return;
-            }
+            //Ignore as no Unicode assignment is possible
+            return;
         }
         this.charMetrics.add(metrics);
         if (name != null) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMParser.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMParser.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/AFMParser.java Tue Apr  1 08:08:24 2008
@@ -31,6 +31,8 @@
 
 import org.apache.commons.io.IOUtils;
 
+import org.apache.fop.fonts.NamedCharacter;
+
 /**
  * Parses the contents of a Type 1 AFM font metrics file into an object structure ({@link AFMFile}).
  */
@@ -126,7 +128,7 @@
         VALUE_PARSERS.put(W, new NotImplementedYet(W));
         VALUE_PARSERS.put(W0, new NotImplementedYet(W0));
         VALUE_PARSERS.put(W1, new NotImplementedYet(W1));
-        VALUE_PARSERS.put(N, new StringSetter("CharName"));
+        VALUE_PARSERS.put(N, new NamedCharacterSetter("Character"));
         VALUE_PARSERS.put(B, new CharBBox());
         VALUE_PARSERS.put(START_TRACK_KERN, new NotImplementedYet(START_TRACK_KERN));
         VALUE_PARSERS.put(END_TRACK_KERN, new NotImplementedYet(END_TRACK_KERN));
@@ -376,6 +378,19 @@
             String s = getStringValue(line, startpos);
             Object obj = stack.peek();
             setValue(obj, s);
+        }
+    }
+    
+    private static class NamedCharacterSetter extends BeanSetter {
+        
+        public NamedCharacterSetter(String variable) {
+            super(variable);
+        }
+        
+        public void parse(String line, int startpos, Stack stack) throws IOException {
+            NamedCharacter ch = new NamedCharacter(getStringValue(line, startpos));
+            Object obj = stack.peek();
+            setValue(obj, ch);
         }
     }
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java Tue Apr  1 08:08:24 2008
@@ -108,6 +108,11 @@
             throw new java.io.FileNotFoundException(
                     "Neither an AFM nor a PFM file was found for " + this.fontFileURI);
         }
+        if (pfm == null) {      
+            //Cannot do without the PFM for now         
+            throw new java.io.FileNotFoundException(    
+                    "No PFM file was found for " + this.fontFileURI);   
+        }
         buildFont(afm, pfm);
         this.loaded = true;
     }
@@ -122,12 +127,17 @@
         singleFont.setEmbedFileName(this.fontFileURI);
         returnFont = singleFont;
         
+        handleEncoding(afm, pfm);
+        handleFontName(afm, pfm);
+        handleMetrics(afm, pfm);
+    }
+
+    private void handleEncoding(AFMFile afm, PFMFile pfm) {
         //Encoding
         if (afm != null) {
             String encoding = afm.getEncodingScheme();
             if ("AdobeStandardEncoding".equals(encoding)) {
-                //Use WinAnsi in this case as it better fits the usual character set people need
-                singleFont.setEncoding(CodePointMapping.WIN_ANSI_ENCODING);
+                singleFont.setEncoding(CodePointMapping.STANDARD_ENCODING);
             } else {
                 String effEncodingName;
                 if ("FontSpecific".equals(encoding)) {
@@ -142,6 +152,14 @@
                 CodePointMapping mapping = buildCustomEncoding(effEncodingName, afm);
                 singleFont.setEncoding(mapping);
             }
+            List charMetrics = afm.getCharMetrics();
+            for (int i = 0, c = afm.getCharCount(); i < c; i++) {
+                AFMCharMetrics metrics = (AFMCharMetrics)charMetrics.get(i);
+                if (!metrics.hasCharCode() && metrics.getCharacter() != null) {
+                    singleFont.addUnencodedCharacter(metrics.getCharacter(),
+                            (int)Math.round(metrics.getWidthX()));
+                }
+            }
         } else {
             if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) {
                 singleFont.setEncoding(pfm.getCharSetName() + "Encoding");
@@ -151,7 +169,9 @@
                 singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees!
             }
         }
-        
+    }
+
+    private void handleFontName(AFMFile afm, PFMFile pfm) {
         //Font name
         if (afm != null) {
             returnFont.setFontName(afm.getFontName()); //PostScript font name
@@ -168,7 +188,9 @@
             names.add(pfm.getWindowsName()); //emulate afm.getFamilyName()
             returnFont.setFamilyNames(names);
         }
-        
+    }
+
+    private void handleMetrics(AFMFile afm, PFMFile pfm) {
         //Basic metrics
         if (afm != null) {
             if (afm.getCapHeight() != null) {
@@ -268,6 +290,7 @@
         
         if (afm != null) {
             //TODO returnFont.setFlags(flags);
+             
             returnFont.setFirstChar(afm.getFirstChar());
             returnFont.setLastChar(afm.getLastChar());
             Iterator iter = afm.getCharMetrics().iterator();
@@ -279,7 +302,6 @@
             }
             returnFont.replaceKerningMap(afm.createXKerningMapEncoded());
         } else {
-            returnFont.setFlags(pfm.getFlags());
             returnFont.setFirstChar(pfm.getFirstChar());
             returnFont.setLastChar(pfm.getLastChar());
             for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) {
@@ -287,6 +309,7 @@
             }
             returnFont.replaceKerningMap(pfm.getKerning());
         }
+        returnFont.setFlags(pfm.getFlags());
     }
 
     private CodePointMapping buildCustomEncoding(String encodingName, AFMFile afm) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/image/package.html
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/image/package.html?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/image/package.html (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/image/package.html Tue Apr  1 08:08:24 2008
@@ -18,6 +18,6 @@
 <HTML>
 <TITLE>org.apache.fop.image Package</TITLE>
 <BODY>
-<P>Contains image loading adapters for various image sources and the image cache.</P>
+<P>Contains image loading adapters for various image sources.</P>
 </BODY>
 </HTML>

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Tue Apr  1 08:08:24 2008
@@ -272,7 +272,7 @@
      */
     public void doLayout(int flowBPD, boolean autoHeight) {
         LayoutContext childLC = createLayoutContext();
-        childLC.setStackLimit(new MinOptMax(flowBPD));
+        childLC.setStackLimitBP(new MinOptMax(flowBPD));
 
         if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
             //EN_X_FILL is non-standard (by LF)
@@ -495,7 +495,7 @@
                     int averageLineLength = optimizeLineLength(effectiveList, 
                             startElementIndex, endElementIndex);
                     if (averageLineLength != 0) {
-                        childLC.setStackLimit(new MinOptMax(averageLineLength));
+                        childLC.setStackLimitBP(new MinOptMax(averageLineLength));
                     }
                 }
                 /* *** *** non-standard extension *** *** */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -113,7 +113,7 @@
         if (curChildLM != null && !curChildLM.isFinished()) {
             return curChildLM;
         }
-        while (childLMiter.hasNext()) {
+        if (childLMiter.hasNext()) {
             curChildLM = (LayoutManager) childLMiter.next();
             curChildLM.initialize();
             return curChildLM;
@@ -350,6 +350,10 @@
     
     /**
      * Registers the FO's markers on the current PageViewport
+     *
+     * @param isStarting    boolean indicating whether the markers qualify as 'starting'
+     * @param isFirst   boolean indicating whether the markers qualify as 'first'
+     * @param isLast    boolean indicating whether the markers qualify as 'last'
      */
     protected void addMarkersToPage(boolean isStarting, boolean isFirst, boolean isLast) {
         if (this.markers != null) {
@@ -361,10 +365,18 @@
         }
     }
 
+    /**
+     * Registers the FO's id on the current PageViewport
+     */
+    protected void addId() {
+        if (fobj != null) {
+            getPSLM().addIDToPage(fobj.getId());
+        }
+    }
+    
     /** {@inheritDoc} */
     public String toString() {
         return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : ""));
     }
-    
     
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java Tue Apr  1 08:08:24 2008
@@ -117,7 +117,7 @@
             // set space after for each LM, in order to implement
             // display-align = distribute
             lc.setSpaceAfter(layoutContext.getSpaceAfter());
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitsFrom(layoutContext);
             childLM.addAreas(childPosIter, lc);
         }
         

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -38,7 +38,6 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.flow.BlockContainer;
 import org.apache.fop.fo.properties.CommonAbsolutePosition;
-import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
@@ -201,7 +200,7 @@
             = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
         autoHeight = false;
         //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-        int maxbpd = context.getStackLimit().opt;
+        int maxbpd = context.getStackLimitBP().opt;
         int allocBPD;
         if (height.getEnum() == EN_AUTO 
                 || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
@@ -249,7 +248,7 @@
         
         MinOptMax stackLimit = new MinOptMax(relDims.bpd);
 
-        LinkedList returnedList = null;
+        LinkedList returnedList;
         LinkedList contentList = new LinkedList();
         LinkedList returnList = new LinkedList();
         
@@ -280,8 +279,7 @@
                 LayoutContext childLC = new LayoutContext(0);
                 childLC.copyPendingMarksFrom(context);
                 // curLM is a ?
-                childLC.setStackLimit(MinOptMax.subtract(context
-                        .getStackLimit(), stackLimit));
+                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
 
@@ -388,6 +386,9 @@
         }
         addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
+
+        //All child content is processed. Only break-after can occur now, so...        
+        context.clearPendingMarks();
         addKnuthElementsForBreakAfter(returnList, context);
 
         setFinished(true);
@@ -411,7 +412,7 @@
                 if (isFixed()) {
                     availHeight = (int)getCurrentPV().getViewArea().getHeight();
                 } else {
-                    availHeight = context.getStackLimit().opt; 
+                    availHeight = context.getStackLimitBP().opt; 
                 }
                 allocBPD = availHeight;
                 allocBPD -= offset.y;
@@ -444,7 +445,7 @@
                     }
                 }
             } else {
-                int maxbpd = context.getStackLimit().opt;
+                int maxbpd = context.getStackLimitBP().opt;
                 allocBPD = maxbpd;
                 if (!switchedProgressionDirection) {
                     autoHeight = true;
@@ -601,11 +602,7 @@
         }
         
         public boolean isOverflow() {
-            if (isEmpty()) {
-                return false;
-            } else {
-                return (deferredAlg.getPageBreaks().size() > 1);
-            }
+            return !isEmpty() && (deferredAlg.getPageBreaks().size() > 1);
         }
         
         protected LayoutManager getTopLevelLM() {
@@ -625,7 +622,7 @@
 
             while ((curLM = getChildLM()) != null) {
                 LayoutContext childLC = new LayoutContext(0);
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(context.getRefIPD());
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 
@@ -707,7 +704,7 @@
             addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
         }
 
-        LayoutManager childLM = null;
+        LayoutManager childLM;
         LayoutManager lastLM = null;
         LayoutContext lc = new LayoutContext(0);
         lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
@@ -736,7 +733,7 @@
             }
             Position innerPosition = pos;
             if (pos instanceof NonLeafPosition) {
-                innerPosition = ((NonLeafPosition)pos).getPosition();
+                innerPosition = pos.getPosition();
             }
             if (pos instanceof BlockContainerPosition) {
                 if (bcpos != null) {
@@ -772,7 +769,7 @@
             }
         }
 
-        getPSLM().addIDToPage(getBlockContainerFO().getId());
+        addId();
         
         addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
         
@@ -854,7 +851,7 @@
                 // set last area flag
                 lc.setFlags(LayoutContext.LAST_AREA,
                         (layoutContext.isLastArea() && childLM == lastLM));
-                /*LF*/lc.setStackLimit(layoutContext.getStackLimit());
+                /*LF*/lc.setStackLimitBP(layoutContext.getStackLimitBP());
                 // Add the line areas to Area
                 childLM.addAreas(childPosIter, lc);
             }
@@ -873,7 +870,7 @@
         referenceArea = null;
         resetSpaces();
         
-        getPSLM().notifyEndOfLayout(((BlockContainer)getFObj()).getId());
+        getPSLM().notifyEndOfLayout(fobj.getId());
     }
     
     /**
@@ -992,30 +989,21 @@
         
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later
-        return (!getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
-                || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto()
-                || (getParent() instanceof BlockLevelLayoutManager
-                    && ((BlockLevelLayoutManager) getParent()).mustKeepTogether())
-                || (getParent() instanceof InlineLayoutManager
-                    && ((InlineLayoutManager) getParent()).mustKeepTogether()));
+        return super.mustKeepTogether()
+                || !getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
+                || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepWithPrevious() {
         return !getBlockContainerFO().getKeepWithPrevious().getWithinPage().isAuto()
                 || !getBlockContainerFO().getKeepWithPrevious().getWithinColumn().isAuto();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepWithNext() {
         return !getBlockContainerFO().getKeepWithNext().getWithinPage().isAuto()
                 || !getBlockContainerFO().getKeepWithNext().getWithinColumn().isAuto();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -25,6 +25,7 @@
 
 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.LineArea;
@@ -146,7 +147,7 @@
          * @return true if there are more child lms
          */
         public boolean hasNext() {
-            return (curPos < listLMs.size()) ? true : createNextChildLMs(curPos);
+            return (curPos < listLMs.size()) || createNextChildLMs(curPos);
         }
 
         /**
@@ -249,7 +250,7 @@
             addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
         }
 
-        LayoutManager childLM = null;
+        LayoutManager childLM;
         LayoutManager lastLM = null;
         LayoutContext lc = new LayoutContext(0);
         lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
@@ -279,7 +280,7 @@
             Position innerPosition = pos;
             if (pos instanceof NonLeafPosition) {
                 //Not all elements are wrapped
-                innerPosition = ((NonLeafPosition) pos).getPosition();
+                innerPosition = pos.getPosition();
             }
             if (innerPosition == null) {
                 // pos was created by this BlockLM and was inside an element
@@ -308,7 +309,7 @@
             }
         }
 
-        getPSLM().addIDToPage(getBlockFO().getId());
+        addId();
         
         addMarkersToPage(true, isFirst(firstPos), isLast(lastPos));
 
@@ -389,7 +390,7 @@
             // set last area flag
             lc.setFlags(LayoutContext.LAST_AREA,
                     (layoutContext.isLastArea() && childLM == lastLM));
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             // Add the line areas to Area
             childLM.addAreas(childPosIter, lc);
         }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -274,13 +274,14 @@
             if (curLM instanceof LineLayoutManager) {
                 // curLM is a LineLayoutManager
                 // set stackLimit for lines (stack limit is now i-p-direction, not b-p-direction!)
-                childLC.setStackLimit(new MinOptMax(getContentAreaIPD()));
+                childLC.setStackLimitBP(context.getStackLimitBP());
+                childLC.setStackLimitIP(new MinOptMax(getContentAreaIPD()));
                 childLC.setRefIPD(getContentAreaIPD());
             } else {
                 // curLM is a ?
                 //childLC.setStackLimit(MinOptMax.subtract(context
                 //        .getStackLimit(), stackSize));
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(referenceIPD);
             }
 
@@ -293,15 +294,22 @@
             if (returnedList != null
                     && returnedList.size() == 1
                     && ((ListElement) returnedList.getFirst()).isForcedBreak()) {
-                // a descendant of this block has break-before
-                contentList.addAll(returnedList);
 
                 if (curLM.isFinished() && !hasNextChildLM()) {
-                    forcedBreakAfterLast = (BreakElement)contentList.removeLast();
+                    // a descendant of this block has break-before
+                    forcedBreakAfterLast = (BreakElement) returnedList.getFirst();
                     context.clearPendingMarks();
                     break;
                 }
 
+                if (contentList.size() == 0) {
+                    // Empty fo:block, zero-length box makes sure the IDs and/or markers 
+                    // are registered and borders/padding are painted.
+                    returnList.add(new KnuthBox(0, notifyPos(new Position(this)), false));
+                }
+                // a descendant of this block has break-before
+                contentList.addAll(returnedList);
+                
                 /* extension: conversione di tutta la sequenza fin'ora ottenuta */
                 if (bpUnit > 0) {
                     storedList = contentList;
@@ -392,6 +400,9 @@
 
         addKnuthElementsForBorderPaddingAfter(returnList, true);
         addKnuthElementsForSpaceAfter(returnList, alignment);
+        
+        //All child content is processed. Only break-after can occur now, so...        
+        context.clearPendingMarks();
         if (forcedBreakAfterLast == null) {
             addKnuthElementsForBreakAfter(returnList, context);
         }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -99,7 +99,7 @@
             //MinOptMax bpd = context.getStackLimit();
 
             LayoutContext childLC = new LayoutContext(0);
-            childLC.setStackLimit(context.getStackLimit());
+            childLC.setStackLimitBP(context.getStackLimitBP());
             childLC.setRefIPD(context.getRefIPD());
             childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
             

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutContext.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/LayoutContext.java Tue Apr  1 08:08:24 2008
@@ -74,18 +74,29 @@
     private int flags; // Contains some set of flags defined above
     /**
      * Total available stacking dimension for a "galley-level" layout
-     * manager (Line or Flow). It is passed by the parent LM. For LineLM,
-     * the block LM determines this based on indent properties.
+     * manager in block-progression-direction. It is passed by the
+     * parent LM.
      * These LM <b>may</b> wish to pass this information down to lower
      * level LM to allow them to optimize returned break possibilities.
      */
-    private MinOptMax stackLimit;
+    private MinOptMax stackLimitBP;
+    /**
+     * Total available stacking dimension for a "galley-level" layout
+     * manager in inline-progression-direction. It is passed by the
+     * parent LM. For LineLM, the block LM determines this based on
+     * indent properties.
+     * These LM <b>may</b> wish to pass this information down to lower
+     * level LM to allow them to optimize returned break possibilities.
+     */
+    private MinOptMax stackLimitIP;
 
     /** True if current element list is spanning in multi-column layout. */
     private int nextSpan = Constants.NOT_SET;
 
     /** inline-progression-dimension of nearest ancestor reference area */
     private int refIPD;
+    //TODO After the split of stackLimit into stackLimitBP and stackLimitIP there's now some
+    //overlap with refIPD. Need to investigate how best to refactor that.
 
     /** the writing mode established by the nearest ancestor reference area */
     private int writingMode = Constants.EN_LR_TB;
@@ -145,7 +156,7 @@
         this.flags = parentLC.flags;
         this.refIPD = parentLC.refIPD;
         this.writingMode = parentLC.writingMode;
-        this.stackLimit = null; // Don't reference parent MinOptMax!
+        setStackLimitsFrom(parentLC);
         this.leadingSpace = parentLC.leadingSpace; //???
         this.trailingSpace = parentLC.trailingSpace; //???
         this.hyphContext = parentLC.hyphContext;
@@ -166,7 +177,8 @@
     public LayoutContext(int flags) {
         this.flags = flags;
         this.refIPD = 0;
-        stackLimit = new MinOptMax(0);
+        stackLimitBP = new MinOptMax(0);
+        stackLimitIP = new MinOptMax(0);
         leadingSpace = null;
         trailingSpace = null;
     }
@@ -273,12 +285,8 @@
      * Clears all pending marks on the LayoutContext.
      */
     public void clearPendingMarks() {
-        if (this.pendingBeforeMarks != null) {
-            this.pendingBeforeMarks.clear();
-        }
-        if (this.pendingAfterMarks != null) {
-            this.pendingAfterMarks.clear();
-        }
+        this.pendingBeforeMarks = null;
+        this.pendingAfterMarks = null;
     }
     
     /**
@@ -306,15 +314,48 @@
         }
     }
     
-    public void setStackLimit(MinOptMax limit) {
-        stackLimit = limit;
+    /**
+     * Sets the stack limit in block-progression-dimension.
+     * @param limit the stack limit
+     */
+    public void setStackLimitBP(MinOptMax limit) {
+        stackLimitBP = limit;
+    }
+
+    /**
+     * Returns the stack limit in block-progression-dimension.
+     * @return the stack limit
+     */
+    public MinOptMax getStackLimitBP() {
+        return stackLimitBP;
+    }
+
+    /**
+     * Sets the stack limit in inline-progression-dimension.
+     * @param limit the stack limit
+     */
+    public void setStackLimitIP(MinOptMax limit) {
+        stackLimitIP = limit;
     }
 
-    public MinOptMax getStackLimit() {
-        return stackLimit;
+    /**
+     * Returns the stack limit in inline-progression-dimension.
+     * @return the stack limit
+     */
+    public MinOptMax getStackLimitIP() {
+        return stackLimitIP;
     }
 
     /**
+     * Sets (Copies) the stack limits in both directions from another layout context.
+     * @param context the layout context to taje the values from
+     */
+    public void setStackLimitsFrom(LayoutContext context) {
+        setStackLimitBP(context.getStackLimitBP());
+        setStackLimitIP(context.getStackLimitIP());
+    }
+    
+    /**
      * Sets the inline-progression-dimension of the nearest ancestor reference area.
      */
     public void setRefIPD(int ipd) {
@@ -536,22 +577,27 @@
 
     /** {@inheritDoc} */
     public String toString() {
-        return "Layout Context:" +
-        "\nStack Limit: \t" + (getStackLimit() == null ? "null" : getStackLimit().toString()) +
-        "\nTrailing Space: \t" + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) +
-        "\nLeading Space: \t" + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + 
-        "\nReference IPD: \t" + getRefIPD() +
-        "\nSpace Adjust: \t" + getSpaceAdjust() + 
-        "\nIPD Adjust: \t" + getIPDAdjust() +
-        "\nResolve Leading Space: \t" + resolveLeadingSpace() +
-        "\nSuppress Leading Space: \t" + suppressLeadingSpace() +
-        "\nIs First Area: \t" + isFirstArea() + 
-        "\nStarts New Area: \t" + startsNewArea() + 
-        "\nIs Last Area: \t" + isLastArea() +
-        "\nTry Hyphenate: \t" + tryHyphenate() + 
-        "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" 
-            + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending" +
-        "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" 
+        return "Layout Context:"
+        + "\nStack Limit BPD: \t"
+            + (getStackLimitBP() == null ? "null" : getStackLimitBP().toString())
+        + "\nStack Limit IPD: \t"
+            + (getStackLimitIP() == null ? "null" : getStackLimitIP().toString())
+        + "\nTrailing Space: \t"
+            + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString())
+        + "\nLeading Space: \t"
+            + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) 
+        + "\nReference IPD: \t" + getRefIPD()
+        + "\nSpace Adjust: \t" + getSpaceAdjust()
+        + "\nIPD Adjust: \t" + getIPDAdjust()
+        + "\nResolve Leading Space: \t" + resolveLeadingSpace()
+        + "\nSuppress Leading Space: \t" + suppressLeadingSpace()
+        + "\nIs First Area: \t" + isFirstArea()
+        + "\nStarts New Area: \t" + startsNewArea()
+        + "\nIs Last Area: \t" + isLastArea()
+        + "\nTry Hyphenate: \t" + tryHyphenate()
+        + "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" 
+            + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending"
+        + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" 
         + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]";
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java Tue Apr  1 08:08:24 2008
@@ -68,19 +68,16 @@
     }
 
     /**
-     * Extend the minimum length to the given length.
+     * Extends the minimum length to the given length if necessary, and adjusts opt and
+     * max accordingly.
+     * 
      * @param mom the min/opt/max trait
      * @param len the new minimum length
-     * @param optToLen if set adjusts the optimum length to be the smaller of the
-     * minimum length and the given length
      */
-    public static void extendMinimum(MinOptMax mom, int len, boolean optToLen) {
+    public static void extendMinimum(MinOptMax mom, int len) {
         if (mom.min < len) {
             mom.min = len;
             mom.opt = Math.max(mom.min, mom.opt);
-            if (optToLen) {
-                mom.opt = Math.min(mom.min, len);
-            }
             mom.max = Math.max(mom.opt, mom.max);
         }
     }
@@ -111,7 +108,7 @@
                         ? 0 : prop.getMinimum(context).getLength().getValue(context)),
                 (prop.getOptimum(context).isAuto() 
                         ? 0 : prop.getOptimum(context).getLength().getValue(context)),
-                (prop.getMinimum(context).isAuto() 
+                (prop.getMaximum(context).isAuto() 
                         ? Integer.MAX_VALUE 
                         : prop.getMaximum(context).getLength().getValue(context)));
         return mom;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreaker.java Tue Apr  1 08:08:24 2008
@@ -156,7 +156,7 @@
                     // element represents a line with footnote citations
                     bFootnotesPresent = true;
                     LayoutContext footnoteContext = new LayoutContext(context);
-                    footnoteContext.setStackLimit(context.getStackLimit());
+                    footnoteContext.setStackLimitBP(context.getStackLimitBP());
                     footnoteContext.setRefIPD(pslm.getCurrentPV()
                             .getRegionReference(Constants.FO_REGION_BODY).getIPD());
                     LinkedList footnoteBodyLMs = ((KnuthBlockBox) element).getFootnoteBodyLMs();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Tue Apr  1 08:08:24 2008
@@ -364,7 +364,13 @@
         } else {
             // there are no footnotes
         }
-        return getLineWidth(activeNode.line) - actualWidth;
+        int diff = getLineWidth(activeNode.line) - actualWidth;
+        if (autoHeight && diff < 0) {
+            //getLineWidth() for auto-height parts return 0 so the diff will be negative
+            return 0; //...but we don't want to shrink in this case. Stick to optimum.
+        } else {
+            return diff;
+        }
     }
 
     /** Checks whether footnotes from preceding pages may be deferred to the page after

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -93,7 +93,7 @@
         //TODO Empty this method?!?
         // set layout dimensions
         setContentAreaIPD(context.getRefIPD());
-        setContentAreaBPD(context.getStackLimit().opt);
+        setContentAreaBPD(context.getStackLimitBP().opt);
 
         //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. 
         // currently active LM
@@ -111,10 +111,10 @@
             }
 
             // Set up a LayoutContext
-            MinOptMax bpd = context.getStackLimit();
+            MinOptMax bpd = context.getStackLimitBP();
 
             LayoutContext childLC = new LayoutContext(0);
-            childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
+            childLC.setStackLimitBP(MinOptMax.subtract(bpd, stackSize));
             childLC.setRefIPD(context.getRefIPD());
 
             // get elements from curLM
@@ -307,7 +307,7 @@
 
             while ((curLM = getChildLM()) != null) {
                 LayoutContext childLC = new LayoutContext(0);
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(context.getRefIPD());
                 childLC.setWritingMode(context.getWritingMode());
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/TraitSetter.java Tue Apr  1 08:08:24 2008
@@ -29,6 +29,7 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonTextDecoration;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 import org.apache.fop.fonts.Font;
@@ -281,6 +282,90 @@
     }
 
     /**
+     * Add background to an area. This method is mainly used by table-related layout
+     * managers to add background for column, body or row. Since the area corresponding to
+     * border-separation must be filled with the table's background, for every cell an
+     * additional area with the same dimensions is created to hold the background for the
+     * corresponding column/body/row. An additional shift must then be added to
+     * background-position-horizontal/vertical to ensure the background images are
+     * correctly placed. Indeed the placement of images must be made WRT the
+     * column/body/row and not the cell.
+     * 
+     * <p>Note: The area's IPD and BPD must be set before calling this method.</p>
+     * 
+     * <p>TODO the regular
+     * {@link #addBackground(Area, CommonBorderPaddingBackground, PercentBaseContext)}
+     * method should be used instead, and a means to retrieve the original area's
+     * dimensions must be found.</p>
+     * 
+     * <p>TODO the placement of images in the x- or y-direction will be incorrect if
+     * background-repeat is set for that direction.</p>
+     * 
+     * @param area the area to set the traits on
+     * @param backProps the background properties
+     * @param context Property evaluation context
+     * @param ipdShift horizontal shift to affect to the background, in addition to the
+     * value of the background-position-horizontal property
+     * @param bpdShift vertical shift to affect to the background, in addition to the
+     * value of the background-position-vertical property
+     * @param referenceIPD value to use as a reference for percentage calculation
+     * @param referenceBPD value to use as a reference for percentage calculation
+     */
+    public static void addBackground(Area area, 
+            CommonBorderPaddingBackground backProps,
+            PercentBaseContext context,
+            int ipdShift, int bpdShift, int referenceIPD, int referenceBPD) {
+        if (!backProps.hasBackground()) {
+            return;
+        }
+        Trait.Background back = new Trait.Background();
+        back.setColor(backProps.backgroundColor);
+
+        if (backProps.getImageInfo() != null) {
+            back.setURL(backProps.backgroundImage);
+            back.setImageInfo(backProps.getImageInfo());
+            back.setRepeat(backProps.backgroundRepeat);
+            if (backProps.backgroundPositionHorizontal != null) {
+                if (back.getRepeat() == Constants.EN_NOREPEAT 
+                        || back.getRepeat() == Constants.EN_REPEATY) {
+                    if (area.getIPD() > 0) {
+                        PercentBaseContext refContext = new SimplePercentBaseContext(context,
+                                LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL,
+                                (referenceIPD - back.getImageInfo().getSize().getWidthMpt()));
+
+                        back.setHoriz(ipdShift
+                                + backProps.backgroundPositionHorizontal.getValue(refContext));
+                    } else {
+                        // TODO Area IPD has to be set for this to work
+                        log.warn("Horizontal background image positioning ignored"
+                                + " because the IPD was not set on the area."
+                                + " (Yes, it's a bug in FOP)");
+                    }
+                }
+            }
+            if (backProps.backgroundPositionVertical != null) {
+                if (back.getRepeat() == Constants.EN_NOREPEAT 
+                        || back.getRepeat() == Constants.EN_REPEATX) {
+                    if (area.getBPD() > 0) {
+                        PercentBaseContext refContext = new SimplePercentBaseContext(context,
+                                LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL,
+                                (referenceBPD - back.getImageInfo().getSize().getHeightMpt()));
+                        back.setVertical(bpdShift
+                                + backProps.backgroundPositionVertical.getValue(refContext));
+                    } else {
+                        // TODO Area BPD has to be set for this to work
+                        log.warn("Vertical background image positioning ignored"
+                                + " because the BPD was not set on the area."
+                                + " (Yes, it's a bug in FOP)");
+                    }
+                }
+            }
+        }
+
+        area.addTrait(Trait.BACKGROUND, back);
+    }
+
+    /**
      * Add background to an area.
      * Layout managers that create areas with a background can use this to
      * add the background to the area.
@@ -312,7 +397,7 @@
                         back.setHoriz(backProps.backgroundPositionHorizontal.getValue(
                                 new SimplePercentBaseContext(context, 
                                     LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL,
-                                    (width - back.getImageInfo().getSize().getHeightMpt())
+                                    (width - back.getImageInfo().getSize().getWidthMpt())
                                 )
                             ));
                     } else {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -124,13 +124,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    protected void addId() {
-        getPSLM().addIDToPage(fobj.getId());
-    }
-
-    /**
      * Returns the image of foreign object area to be put into
      * the viewport.
      * @return the appropriate area

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java Tue Apr  1 08:08:24 2008
@@ -51,7 +51,7 @@
      * Constructor
      *
      * @param node the formatting object that creates this area
-     * @todo better retrieval of font info
+     * TODO better retrieval of font info
      */
     public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) {
         super(node);
@@ -83,7 +83,7 @@
 
     /** {@inheritDoc} */
     public InlineArea get(LayoutContext context) {
-        curArea = getPageNumberCitationInlineArea(parentLM);
+        curArea = getPageNumberCitationInlineArea();
         return curArea;
     }
     
@@ -99,12 +99,15 @@
     }
     
     /**
-     * if id can be resolved then simply return a word, otherwise
+     * If id can be resolved then simply return a word, otherwise
      * return a resolvable area
+     *
+     * @param parentLM  the parent LayoutManager
+     * @return a corresponding InlineArea
      */
-    private InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) {
+    private InlineArea getPageNumberCitationInlineArea() {
         PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId());
-        TextArea text = null;
+        TextArea text;
         if (page != null) {
             String str = page.getPageNumberString();
             // get page string from parent, build area
@@ -150,9 +153,5 @@
         return width;
     }
 
-    /** {@inheritDoc} */
-    protected void addId() {
-        getPSLM().addIDToPage(fobj.getId());
-    }
 }
 



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