You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2012/04/05 18:20:17 UTC

svn commit: r1309921 [12/42] - in /xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/area/inline/WordArea.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/area/inline/WordArea.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/area/inline/WordArea.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/area/inline/WordArea.java Thu Apr  5 16:19:19 2012
@@ -19,6 +19,12 @@
 
 package org.apache.fop.area.inline;
 
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.fop.complexscripts.bidi.InlineRun;
+import org.apache.fop.complexscripts.util.CharMirror;
+
 /**
  * A string of characters without spaces
  */
@@ -29,47 +35,275 @@ public class WordArea extends InlineArea
     /** The text for this word area */
     protected String word;
 
-    /** The correction offset for the next area */
-    protected int offset = 0;
-
     /** An array of width for adjusting the individual letters (optional) */
     protected int[] letterAdjust;
 
     /**
+     * An array of resolved bidirectional levels corresponding to each character
+     * in word (optional)
+     */
+    protected int[] levels;
+
+    /**
+     * An array of glyph positioning adjustments to apply to each glyph 'char' in word (optional)
+     */
+    protected int[][] gposAdjustments;
+
+    /**
+     * A flag indicating whether the content of word is reversed in relation to
+     * its original logical order.
+     */
+    protected boolean reversed;
+
+    /**
      * Create a word area
-     * @param w the word string
-     * @param o the offset for the next area
-     * @param la the letter adjust array (may be null)
+     * @param blockProgressionOffset the offset for this area
+     * @param level the bidirectional embedding level (or -1 if not defined) for word as a group
+     * @param word the word string
+     * @param letterAdjust the letter adjust array (may be null)
+     * @param levels array of per-character (glyph) bidirectional levels,
+     * in case word area is heterogenously leveled
+     * @param gposAdjustments array of general position adjustments or null if none apply
+     * @param reversed true if word is known to be reversed at construction time
      */
-    public WordArea(String w, int o, int[] la) {
-        word = w;
-        offset = o;
-        this.letterAdjust = la;
+    public WordArea
+        ( int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels,
+          int[][] gposAdjustments, boolean reversed ) {
+        super ( blockProgressionOffset, level );
+        int length = ( word != null ) ? word.length() : 0;
+        this.word = word;
+        this.letterAdjust = maybeAdjustLength ( letterAdjust, length );
+        this.levels = maybePopulateLevels ( levels, level, length );
+        this.gposAdjustments = maybeAdjustLength ( gposAdjustments, length );
+        this.reversed = reversed;
     }
 
     /**
-     * @return Returns the word.
+     * Create a word area
+     * @param blockProgressionOffset the offset for this area
+     * @param level the bidirectional embedding level (or -1 if not defined) for word as a group
+     * @param word the word string
+     * @param letterAdjust the letter adjust array (may be null)
+     * @param levels array of per-character (glyph) bidirectional levels,
+     * in case word area is heterogenously leveled
+     * @param gposAdjustments array of general position adjustments or null if none apply
      */
+    public WordArea
+        ( int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels,
+          int[][] gposAdjustments ) {
+        this ( blockProgressionOffset, level, word, letterAdjust, levels, gposAdjustments, false );
+    }
+
+    /** @return Returns the word. */
     public String getWord() {
         return word;
     }
 
+    /** @return the array of letter adjust widths */
+    public int[] getLetterAdjustArray() {
+        return this.letterAdjust;
+    }
+
     /**
-     * @return Returns the offset.
+     * Obtain per-character (glyph) bidi levels.
+     * @return a (possibly empty) array of levels or null (if none resolved)
      */
-    public int getOffset() {
-        return offset;
+    public int[] getBidiLevels() {
+        return levels;
     }
+
     /**
-     * @param o The offset to set.
+     * <p>Obtain per-character (glyph) bidi levels over a specified subsequence.</p>
+     * <p>If word has been reversed, then the subsequence is over the reversed word.</p>
+     * @param start starting (inclusive) index of subsequence
+     * @param end ending (exclusive) index of subsequence
+     * @return a (possibly null) array of per-character (glyph) levels over the specified
+     * sequence
      */
-    public void setOffset(int o) {
-        offset = o;
+    public int[] getBidiLevels ( int start, int end ) {
+        assert start <= end;
+        if ( this.levels != null ) {
+            int n = end - start;
+            int[] levels = new int [ n ];
+            for ( int i = 0; i < n; i++ ) {
+                levels[i] = this.levels [ start + i ];
+            }
+            return levels;
+        } else {
+            return null;
+        }
     }
 
-    /** @return the array of letter adjust widths */
-    public int[] getLetterAdjustArray() {
-        return this.letterAdjust;
+    /**
+     * <p>Obtain per-character (glyph) level at a specified index position.</p>
+     * <p>If word has been reversed, then the position is relative to the reversed word.</p>
+     * @param position the index of the (possibly reversed) character from which to obtain the
+     * level
+     * @return a resolved bidirectional level or, if not specified, then -1
+     */
+    public int bidiLevelAt ( int position ) {
+        if ( position > word.length() ) {
+            throw new IndexOutOfBoundsException();
+        } else if ( levels != null ) {
+            return levels [ position ];
+        } else {
+            return -1;
+        }
+    }
+
+    @Override
+    public List collectInlineRuns ( List runs ) {
+        assert runs != null;
+        InlineRun r;
+        if ( getBidiLevels() != null ) {
+            r = new InlineRun ( this, getBidiLevels() );
+        } else {
+            r = new InlineRun ( this, -1, word.length() );
+        }
+        runs.add ( r );
+        return runs;
+    }
+
+    /**
+     * Obtain per-character (glyph) position adjustments.
+     * @return a (possibly empty) array of adjustments, each having four elements, or null
+     * if no adjustments apply
+     */
+    public int[][] getGlyphPositionAdjustments() {
+        return gposAdjustments;
+    }
+
+    /**
+     * <p>Obtain per-character (glyph) position adjustments at a specified index position.</p>
+     * <p>If word has been reversed, then the position is relative to the reversed word.</p>
+     * @param position the index of the (possibly reversed) character from which to obtain the
+     * level
+     * @return an array of adjustments or null if none applies
+     */
+    public int[] glyphPositionAdjustmentsAt ( int position ) {
+        if ( position > word.length() ) {
+            throw new IndexOutOfBoundsException();
+        } else if ( gposAdjustments != null ) {
+            return gposAdjustments [ position ];
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * <p>Reverse characters and corresponding per-character levels and glyph position
+     * adjustments.</p>
+     * @param mirror if true, then perform mirroring if mirrorred characters
+     */
+    public void reverse ( boolean mirror ) {
+        if ( word.length() > 0 ) {
+            word = ( ( new StringBuffer ( word ) ) .reverse() ) .toString();
+            if ( levels != null ) {
+                reverse ( levels );
+            }
+            if ( gposAdjustments != null ) {
+                reverse ( gposAdjustments );
+            }
+            reversed = !reversed;
+            if ( mirror ) {
+                word = CharMirror.mirror ( word );
+            }
+        }
+    }
+
+    /**
+     * <p>Perform mirroring on mirrorable characters.</p>
+     */
+    public void mirror() {
+        if ( word.length() > 0 ) {
+            word = CharMirror.mirror ( word );
+        }
+    }
+
+    /**
+     * <p>Determined if word has been reversed (in relation to original logical order).</p>
+     * <p>If a word is reversed, then both its characters (glyphs) and corresponding per-character
+     * levels are in reverse order.</p>
+     * <p>Note: this information is used in order to process non-spacing marks during rendering as
+     * well as provide hints for caret direction.</p>
+     * @return true if word is reversed
+     */
+    public boolean isReversed() {
+        return reversed;
+    }
+
+    /*
+     * If int[] array is not of specified length, then create
+     * a new copy of the first length entries.
+     */
+    private static int[] maybeAdjustLength ( int[] ia, int length ) {
+        if ( ia != null ) {
+            if ( ia.length == length ) {
+                return ia;
+            } else {
+                int[] iaNew = new int [ length ];
+                for ( int i = 0, n = ia.length; i < n; i++ ) {
+                    if ( i < length ) {
+                        iaNew [ i ] = ia [ i ];
+                    } else {
+                        break;
+                    }
+                }
+                return iaNew;
+            }
+        } else {
+            return ia;
+        }
+    }
+
+    /*
+     * If int[][] matrix is not of specified length, then create
+     * a new shallow copy of the first length entries.
+     */
+    private static int[][] maybeAdjustLength ( int[][] im, int length ) {
+        if ( im != null ) {
+            if ( im.length == length ) {
+                return im;
+            } else {
+                int[][] imNew = new int [ length ][];
+                for ( int i = 0, n = im.length; i < n; i++ ) {
+                    if ( i < length ) {
+                        imNew [ i ] = im [ i ];
+                    } else {
+                        break;
+                    }
+                }
+                return imNew;
+            }
+        } else {
+            return im;
+        }
+    }
+
+    private static int[] maybePopulateLevels ( int[] levels, int level, int count ) {
+        if ( ( levels == null ) && ( level >= 0 ) ) {
+            levels = new int[count];
+            Arrays.fill ( levels, level );
+        }
+        return maybeAdjustLength ( levels, count );
+    }
+
+    private static void reverse ( int[] a ) {
+        for ( int i = 0, n = a.length, m = n / 2; i < m; i++ ) {
+            int k = n - i - 1;
+            int t = a [ k ];
+            a [ k ] = a [ i ];
+            a [ i ] = t;
+        }
+    }
+
+    private static void reverse ( int[][] aa ) {
+        for ( int i = 0, n = aa.length, m = n / 2; i < m; i++ ) {
+            int k = n - i - 1;
+            int[] t = aa [ k ];
+            aa [ k ] = aa [ i ];
+            aa [ i ] = t;
+        }
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/CommandLineOptions.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/CommandLineOptions.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/CommandLineOptions.java Thu Apr  5 16:19:19 2012
@@ -118,6 +118,8 @@ public class CommandLineOptions {
     private int targetResolution = 0;
     /* control memory-conservation policy */
     private boolean conserveMemoryPolicy = false;
+    /* true if a complex script features are enabled */
+    private boolean useComplexScriptFeatures = true;
 
     private FopFactory factory = FopFactory.newInstance();
     private FOUserAgent foUserAgent;
@@ -181,6 +183,9 @@ public class CommandLineOptions {
                 addXSLTParameter("fop-output-format", getOutputFormat());
                 addXSLTParameter("fop-version", Version.getVersion());
                 foUserAgent.setConserveMemoryPolicy(conserveMemoryPolicy);
+                if (!useComplexScriptFeatures) {
+                    foUserAgent.setComplexScriptFeaturesEnabled(false);
+                }
             } else {
                 return false;
             }
@@ -203,17 +208,14 @@ public class CommandLineOptions {
                 System.err.println("Couldn't set system look & feel!");
             }
 
-            AWTRenderer renderer = new AWTRenderer(true);
-            renderer.setRenderable(inputHandler); //set before user agent!
-            renderer.setUserAgent(foUserAgent);
+            AWTRenderer renderer = new AWTRenderer(foUserAgent, inputHandler, true, true);
             foUserAgent.setRendererOverride(renderer);
         } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)
                && mimicRenderer != null) {
             // render from FO to Intermediate Format
             Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(
                    foUserAgent, mimicRenderer);
-            XMLRenderer xmlRenderer = new XMLRenderer();
-            xmlRenderer.setUserAgent(foUserAgent);
+            XMLRenderer xmlRenderer = new XMLRenderer(foUserAgent);
 
             //Tell the XMLRenderer to mimic the target renderer
             xmlRenderer.mimicRenderer(targetRenderer);
@@ -381,6 +383,16 @@ public class CommandLineOptions {
                 getPDFEncryptionParams().setAllowEditContent(false);
             } else if (args[i].equals("-noannotations")) {
                 getPDFEncryptionParams().setAllowEditAnnotations(false);
+            } else if (args[i].equals("-nocs")) {
+                useComplexScriptFeatures = false;
+            } else if (args[i].equals("-nofillinforms")) {
+                getPDFEncryptionParams().setAllowFillInForms(false);
+            } else if (args[i].equals("-noaccesscontent")) {
+                getPDFEncryptionParams().setAllowAccessContent(false);
+            } else if (args[i].equals("-noassembledoc")) {
+                getPDFEncryptionParams().setAllowAssembleDocument(false);
+            } else if (args[i].equals("-noprinthq")) {
+                getPDFEncryptionParams().setAllowPrintHq(false);
             } else if (args[i].equals("-version")) {
                 printVersion();
                 return false;
@@ -1170,6 +1182,7 @@ public class CommandLineOptions {
             + "  -q                quiet mode  \n"
             + "  -c cfg.xml        use additional configuration file cfg.xml\n"
             + "  -l lang           the language to use for user information \n"
+            + "  -nocs             disable complex script features\n"
             + "  -r                relaxed/less strict validation (where available)\n"
             + "  -dpi xxx          target resolution in dots per inch (dpi) where xxx is a number\n"
             + "  -s                for area tree XML, down to block areas only\n"
@@ -1181,6 +1194,14 @@ public class CommandLineOptions {
             + "  -nocopy           PDF file will be encrypted without copy content permission\n"
             + "  -noedit           PDF file will be encrypted without edit content permission\n"
             + "  -noannotations    PDF file will be encrypted without edit annotation permission\n"
+            + "  -nofillinforms    PDF file will be encrypted without"
+            + " fill in interactive form fields permission\n"
+            + "  -noaccesscontent  PDF file will be encrypted without"
+            + " extract text and graphics permission\n"
+            + "  -noassembledoc    PDF file will be encrypted without"
+            + " assemble the document permission\n"
+            + "  -noprinthq        PDF file will be encrypted without"
+            + " print high quality permission\n"
             + "  -a                enables accessibility features (Tagged PDF etc., default off)\n"
             + "  -pdfprofile prof  PDF file will be generated with the specified profile\n"
             + "                    (Examples for prof: PDF/A-1b or PDF/X-3:2003)\n\n"

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/InputHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/InputHandler.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/InputHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/cli/InputHandler.java Thu Apr  5 16:19:19 2012
@@ -116,8 +116,8 @@ public class InputHandler implements Err
             String baseURL = null;
 
             try {
-                baseURL = new File(sourcefile.getAbsolutePath()).
-                        getParentFile().toURI().toURL().toExternalForm();
+                baseURL = new File(sourcefile.getAbsolutePath())
+                        .getParentFile().toURI().toURL().toExternalForm();
             } catch (Exception e) {
                 baseURL = "";
             }

Copied: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java (from r1307575, xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java?p2=xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java&r1=1307575&r2=1309921&rev=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/complexscripts/fonts/OTFAdvancedTypographicTableReader.java Thu Apr  5 16:19:19 2012
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.fonts.truetype.TTFDirTabEntry;
 import org.apache.fop.fonts.truetype.TTFFile;
+import org.apache.fop.fonts.truetype.TTFTableName;
 
 // CSOFF: AvoidNestedBlocksCheck
 // CSOFF: NoWhitespaceAfterCheck
@@ -126,7 +127,7 @@ public final class OTFAdvancedTypographi
         return gpos;
     }
 
-    private void readLangSysTable(String tableTag, long langSysTable, String langSysTag) throws IOException {
+    private void readLangSysTable(TTFTableName tableTag, long langSysTable, String langSysTag) throws IOException {
         in.seekSet(langSysTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " lang sys table: " + langSysTag );
@@ -168,7 +169,7 @@ public final class OTFAdvancedTypographi
 
     private static String defaultTag = "dflt";
 
-    private void readScriptTable(String tableTag, long scriptTable, String scriptTag) throws IOException {
+    private void readScriptTable(TTFTableName tableTag, long scriptTable, String scriptTag) throws IOException {
         in.seekSet(scriptTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " script table: " + scriptTag );
@@ -221,7 +222,7 @@ public final class OTFAdvancedTypographi
         seLanguages = null;
     }
 
-    private void readScriptList(String tableTag, long scriptList) throws IOException {
+    private void readScriptList(TTFTableName tableTag, long scriptList) throws IOException {
         in.seekSet(scriptList);
         // read script record count
         int ns = in.readTTFUShort();
@@ -250,7 +251,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readFeatureTable(String tableTag, long featureTable, String featureTag, int featureIndex) throws IOException {
+    private void readFeatureTable(TTFTableName tableTag, long featureTable, String featureTag, int featureIndex) throws IOException {
         in.seekSet(featureTable);
         if (log.isDebugEnabled()) {
             log.debug(tableTag + " feature table: " + featureTag );
@@ -278,7 +279,7 @@ public final class OTFAdvancedTypographi
         seFeatures.put ( "f" + featureIndex, new Object[] { featureTag, lul } );
     }
 
-    private void readFeatureList(String tableTag, long featureList) throws IOException {
+    private void readFeatureList(TTFTableName tableTag, long featureList) throws IOException {
         in.seekSet(featureList);
         // read feature record count
         int nf = in.readTTFUShort();
@@ -3144,9 +3145,9 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readLookupTable(String tableTag, int lookupSequence, long lookupTable) throws IOException {
-        boolean isGSUB = tableTag.equals ( "GSUB" );
-        boolean isGPOS = tableTag.equals ( "GPOS" );
+    private void readLookupTable(TTFTableName tableTag, int lookupSequence, long lookupTable) throws IOException {
+        boolean isGSUB = tableTag.equals ( TTFTableName.GSUB );
+        boolean isGPOS = tableTag.equals ( TTFTableName.GPOS );
         in.seekSet(lookupTable);
         // read lookup type
         int lt = in.readTTFUShort();
@@ -3197,7 +3198,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readLookupList(String tableTag, long lookupList) throws IOException {
+    private void readLookupList(TTFTableName tableTag, long lookupList) throws IOException {
         in.seekSet(lookupList);
         // read lookup record count
         int nl = in.readTTFUShort();
@@ -3232,7 +3233,7 @@ public final class OTFAdvancedTypographi
      * @param lookupList offset to lookup list from beginning of font file
      * @throws IOException In case of a I/O problem
      */
-    private void readCommonLayoutTables(String tableTag, long scriptList, long featureList, long lookupList) throws IOException {
+    private void readCommonLayoutTables(TTFTableName tableTag, long scriptList, long featureList, long lookupList) throws IOException {
         if ( scriptList > 0 ) {
             readScriptList ( tableTag, scriptList );
         }
@@ -3244,7 +3245,7 @@ public final class OTFAdvancedTypographi
         }
     }
 
-    private void readGDEFClassDefTable(String tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFClassDefTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // subtable is a bare class definition table
@@ -3256,7 +3257,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFAttachmentTable(String tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFAttachmentTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // read coverage offset
@@ -3274,7 +3275,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFLigatureCaretTable(String tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFLigatureCaretTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // read coverage offset
@@ -3304,7 +3305,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkAttachmentTable(String tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFMarkAttachmentTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // subtable is a bare class definition table
@@ -3316,7 +3317,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkGlyphsTableFormat1(String tableTag, int lookupSequence, long subtableOffset, int subtableFormat) throws IOException {
+    private void readGDEFMarkGlyphsTableFormat1(TTFTableName tableTag, int lookupSequence, long subtableOffset, int subtableFormat) throws IOException {
         initATSubState();
         in.seekSet(subtableOffset);
         // skip over format (already known)
@@ -3350,7 +3351,7 @@ public final class OTFAdvancedTypographi
         resetATSubState();
     }
 
-    private void readGDEFMarkGlyphsTable(String tableTag, int lookupSequence, long subtableOffset) throws IOException {
+    private void readGDEFMarkGlyphsTable(TTFTableName tableTag, int lookupSequence, long subtableOffset) throws IOException {
         in.seekSet(subtableOffset);
         // read mark set subtable format
         int sf = in.readTTFUShort();
@@ -3366,11 +3367,11 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGDEF() throws IOException {
-        String tableTag = "GDEF";
+        TTFTableName tableTag = TTFTableName.GDEF;
         // Initialize temporary state
         initATState();
         // Read glyph definition (GDEF) table
-        TTFDirTabEntry dirTab = ttf.getDirectoryEntry ( tableTag );
+        TTFDirTabEntry dirTab = ttf.getDirectoryEntry( tableTag );
         if ( gdef != null ) {
             if (log.isDebugEnabled()) {
                 log.debug(tableTag + ": ignoring duplicate table");
@@ -3439,7 +3440,7 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGSUB() throws IOException {
-        String tableTag = "GSUB";
+        TTFTableName tableTag = TTFTableName.GSUB;
         // Initialize temporary state
         initATState();
         // Read glyph substitution (GSUB) table
@@ -3476,7 +3477,7 @@ public final class OTFAdvancedTypographi
      * @throws IOException In case of a I/O problem
      */
     private void readGPOS() throws IOException {
-        String tableTag = "GPOS";
+        TTFTableName tableTag = TTFTableName.GPOS;
         // Initialize temporary state
         initATState();
         // Read glyph positioning (GPOS) table

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/datatypes/LengthBase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/datatypes/LengthBase.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/datatypes/LengthBase.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/datatypes/LengthBase.java Thu Apr  5 16:19:19 2012
@@ -21,10 +21,12 @@ package org.apache.fop.datatypes;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 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.util.CompareUtil;
 
 /**
  * Models a length which can be used as a factor in a percentage length
@@ -142,5 +144,30 @@ public class LengthBase implements Perce
     public Length getBaseLength() {
         return baseLength;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + CompareUtil.getHashCode(baseLength);
+        result = prime * result + baseType;
+        result = prime * result + CompareUtil.getHashCode(fobj);
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof LengthBase)) {
+            return false;
+        }
+        LengthBase other = (LengthBase) obj;
+        return CompareUtil.equal(baseLength, other.baseLength)
+                && baseType == other.baseType
+                && CompareUtil.equal(fobj, other.fobj);
+    }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/Event.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/Event.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/Event.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/Event.java Thu Apr  5 16:19:19 2012
@@ -38,7 +38,7 @@ public class Event extends EventObject {
     private String eventKey;
 
     private EventSeverity severity;
-    private Map params;
+    private Map<String, Object> params;
 
     /**
      * Creates a new Event.
@@ -47,7 +47,8 @@ public class Event extends EventObject {
      * @param severity the severity level
      * @param params the event parameters (a map of name/value pairs)
      */
-    public Event(Object source, String eventID, EventSeverity severity, Map params) {
+    public Event(Object source, String eventID, EventSeverity severity, Map<String, Object> params)
+    {
         super(source);
         int pos = eventID.lastIndexOf('.');
         if (pos < 0 || pos == eventID.length() - 1) {
@@ -122,7 +123,7 @@ public class Event extends EventObject {
      * Returns an unmodifiable {@link java.util.Map} with all event parameters.
      * @return the parameter map
      */
-    public Map getParams() {
+    public Map<String, Object> getParams() {
         return Collections.unmodifiableMap(this.params);
     }
 
@@ -138,7 +139,7 @@ public class Event extends EventObject {
      * This class is a fluent builder class for building up the parameter map.
      */
     public static class ParamsBuilder {
-        private Map params;
+        private Map<String, Object> params;
 
         /**
          * Adds a new parameter (a name/value pair).
@@ -148,7 +149,7 @@ public class Event extends EventObject {
          */
         public ParamsBuilder param(String name, Object value) {
             if (this.params == null) {
-                this.params = new java.util.HashMap();
+                this.params = new java.util.HashMap<String, Object>();
             }
             this.params.put(name, value);
             return this;
@@ -158,7 +159,7 @@ public class Event extends EventObject {
          * Returns the accumulated parameter map.
          * @return the accumulated parameter map
          */
-        public Map build() {
+        public Map<String, Object> build() {
             return this.params;
         }
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/EventExceptionManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/EventExceptionManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/EventExceptionManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/EventExceptionManager.java Thu Apr  5 16:19:19 2012
@@ -32,11 +32,12 @@ public final class EventExceptionManager
     private EventExceptionManager() {
     }
 
-    private static final Map EXCEPTION_FACTORIES = new java.util.HashMap();
+    private static final Map<String, ExceptionFactory> EXCEPTION_FACTORIES
+        = new java.util.HashMap<String, ExceptionFactory>();
 
     static {
-        Iterator iter;
-        iter = Service.providers(ExceptionFactory.class, true);
+        Iterator<Object> iter;
+        iter = Service.providers(ExceptionFactory.class);
         while (iter.hasNext()) {
             ExceptionFactory factory = (ExceptionFactory)iter.next();
             EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory);
@@ -63,7 +64,7 @@ public final class EventExceptionManager
             String msg = EventFormatter.format(event);
             //Get original exception as cause if it is given as one of the parameters
             Throwable t = null;
-            Iterator iter = event.getParams().values().iterator();
+            Iterator<Object> iter = event.getParams().values().iterator();
             while (iter.hasNext()) {
                 Object o = iter.next();
                 if (o instanceof Throwable) {
@@ -96,6 +97,6 @@ public final class EventExceptionManager
          * Returns the {@link Exception} class created by this factory.
          * @return the exception class
          */
-        Class getExceptionClass();
+        Class<? extends Exception> getExceptionClass();
     }
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/LoggingEventListener.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/LoggingEventListener.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/LoggingEventListener.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/LoggingEventListener.java Thu Apr  5 16:19:19 2012
@@ -19,6 +19,9 @@
 
 package org.apache.fop.events;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -36,6 +39,8 @@ public class LoggingEventListener implem
     private Log log;
     private boolean skipFatal;
 
+    private final Set<String> loggedMessages = new HashSet<String>();
+
     /**
      * Creates an instance logging to the default log category of this class.
      */
@@ -77,7 +82,20 @@ public class LoggingEventListener implem
         if (severity == EventSeverity.INFO) {
             log.info(msg);
         } else if (severity == EventSeverity.WARN) {
-            log.warn(msg);
+            // we want to prevent logging of duplicate messages in situations where they are likely
+            // to occur; for instance, warning related to layout do not repeat (since line number
+            // will be different) and as such we do not try to filter them here; on the other hand,
+            // font related warnings are very likely to repeat and we try to filter them out here;
+            // the same may happen with missing images (but not implemented yet).
+            String eventGroupID = event.getEventGroupID();
+            if (eventGroupID.equals("org.apache.fop.fonts.FontEventProducer")) {
+                if (!loggedMessages.contains(msg)) {
+                    loggedMessages.add(msg);
+                    log.warn(msg);
+                }
+            } else {
+                log.warn(msg);
+            }
         } else if (severity == EventSeverity.ERROR) {
             if (event.getParam("e") != null) {
                 log.error(msg, (Throwable)event.getParam("e"));
@@ -96,5 +114,4 @@ public class LoggingEventListener implem
             assert false;
         }
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/PropertyExceptionFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/PropertyExceptionFactory.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/PropertyExceptionFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/PropertyExceptionFactory.java Thu Apr  5 16:19:19 2012
@@ -40,8 +40,8 @@ public class PropertyExceptionFactory im
     }
 
     /** {@inheritDoc} */
-    public Class getExceptionClass() {
+    public Class<PropertyException> getExceptionClass() {
         return PropertyException.class;
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java Thu Apr  5 16:19:19 2012
@@ -36,8 +36,8 @@ public class UnsupportedOperationExcepti
     }
 
     /** {@inheritDoc} */
-    public Class getExceptionClass() {
+    public Class<UnsupportedOperationException> getExceptionClass() {
         return UnsupportedOperationException.class;
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/ValidationExceptionFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/ValidationExceptionFactory.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/ValidationExceptionFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/events/ValidationExceptionFactory.java Thu Apr  5 16:19:19 2012
@@ -43,9 +43,9 @@ public class ValidationExceptionFactory 
     }
 
     /** {@inheritDoc} */
-    public Class getExceptionClass() {
+    public Class<ValidationException> getExceptionClass() {
         return ValidationException.class;
     }
 
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/Constants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/Constants.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/Constants.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/Constants.java Thu Apr  5 16:19:19 2012
@@ -26,7 +26,7 @@ package org.apache.fop.fo;
  * <li>Input and output formats</li>
  * <li>Formatting objects (<em>FO_XXX</em>)</li>
  * <li>Formatting properties (<em>PR_XXX</em>)</li>
- * <li>Enumerated values used in formatting properties (<em>EN_XXX</em>)</li>
+ * <li>Enumerated values used in formatting properties and traits (<em>EN_XXX</em>)</li>
  * </ul>
  */
 public interface Constants {
@@ -771,16 +771,22 @@ public interface Constants {
      * multi-column layouts.
      */
     int PR_X_DISABLE_COLUMN_BALANCING = 273;
-    /** Property constant - FOP proprietary: FOP internal use for accessibility */
-    int PR_X_PTR = 274;
     /**
      * Property constant - FOP proprietary: alternative text for e-g and i-f-o.
      * Used for accessibility.
      */
-    int PR_X_ALT_TEXT = 275;
+    int PR_X_ALT_TEXT = 274;
+    /** Property constant - FOP proprietary prototype (in XSL-FO 2.0 Requirements) */
+    int PR_X_XML_BASE = 275;
+    /**
+     * Property constant - FOP proprietary extension (see NumberConverter) used
+     * to perform additional control over number conversion when generating page
+     * numbers.
+     */
+    int PR_X_NUMBER_CONVERSION_FEATURES = 276;
 
     /** Number of property constants defined */
-    int PROPERTY_COUNT = 275;
+    int PROPERTY_COUNT = 276;
 
     // compound property constants
 
@@ -1208,6 +1214,16 @@ public interface Constants {
     int EN_NO_LINK = 199;
     /** Enumeration constant -- XSL 1.1 */
     int EN_ALTERNATE = 200;
+    /** Enumeration constant -- for *-direction traits */
+    int EN_LR = 201; // left to right
+    /** Enumeration constant -- for *-direction traits */
+    int EN_RL = 202; // right to left
+    /** Enumeration constant -- for *-direction traits */
+    int EN_TB = 203; // top to bottom
+    /** Enumeration constant -- for *-direction traits */
+    int EN_BT = 204; // bottom to top
+    /** Enumeration constant */
+    int EN_TB_LR = 205; // for top-to-bottom, left-to-right writing mode
     /** Number of enumeration constants defined */
-    int ENUM_COUNT = 200;
+    int ENUM_COUNT = 205;
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMapping.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMapping.java Thu Apr  5 16:19:19 2012
@@ -30,7 +30,7 @@ import org.apache.xmlgraphics.util.QName
 
 /**
  * Abstract base class for Element Mappings (including FO Element Mappings)
- * which provide the framework of valid elements and attibutes for a given
+ * which provide the framework of valid elements and attributes for a given
  * namespace.
  */
 public abstract class ElementMapping {
@@ -38,7 +38,7 @@ public abstract class ElementMapping {
     public static final String DEFAULT = "<default>";
 
     /** The HashMap table of formatting objects defined by the ElementMapping */
-    protected HashMap foObjs = null;
+    protected HashMap<String, Maker> foObjs = null;
     //Please don't change that to java.util.Map as that can break extensions.
 
     /** The namespace for the ElementMapping */
@@ -49,7 +49,7 @@ public abstract class ElementMapping {
      *
      * @return Table of Maker objects for this ElementMapping
      */
-    public HashMap getTable() {
+    public HashMap<String, Maker> getTable() {
         if (foObjs == null) {
             initialize();
         }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMappingRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMappingRegistry.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMappingRegistry.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/ElementMappingRegistry.java Thu Apr  5 16:19:19 2012
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.w3c.dom.DOMImplementation;
-
 import org.xml.sax.Locator;
 
 import org.apache.commons.logging.Log;
@@ -42,18 +41,20 @@ import org.apache.fop.fo.ElementMapping.
 public class ElementMappingRegistry {
 
     /** logging instance */
-    protected Log log = LogFactory.getLog(ElementMappingRegistry.class);
+    private static final Log LOG = LogFactory.getLog(ElementMappingRegistry.class);
 
     /**
      * Table mapping element names to the makers of objects
      * representing formatting objects.
      */
-    protected Map fobjTable = new java.util.HashMap();
+    protected Map<String, Map<String, Maker>> fobjTable
+    = new java.util.HashMap<String, Map<String, Maker>>();
 
     /**
      * Map of mapped namespaces and their associated ElementMapping instances.
      */
-    protected Map namespaces = new java.util.HashMap();
+    protected Map<String, ElementMapping> namespaces
+    = new java.util.HashMap<String, ElementMapping>();
 
     /**
      * Main constructor. Adds all default element mapping as well as detects ElementMapping
@@ -70,14 +71,14 @@ public class ElementMappingRegistry {
      */
     private void setupDefaultMappings() {
         // add mappings from available services
-        Iterator providers = Service.providers(ElementMapping.class, false);
+        Iterator<String> providers = Service.providerNames(ElementMapping.class);
         if (providers != null) {
             while (providers.hasNext()) {
-                String mapping = (String)providers.next();
+                String mapping = providers.next();
                 try {
                     addElementMapping(mapping);
                 } catch (IllegalArgumentException e) {
-                    log.warn("Error while adding element mapping", e);
+                    LOG.warn("Error while adding element mapping", e);
                 }
 
             }
@@ -129,13 +130,13 @@ public class ElementMappingRegistry {
      */
     public Maker findFOMaker(String namespaceURI, String localName, Locator locator)
                 throws FOPException {
-        Map table = (Map)fobjTable.get(namespaceURI);
+        Map<String, Maker> table = fobjTable.get(namespaceURI);
         Maker fobjMaker = null;
         if (table != null) {
-            fobjMaker = (Maker)table.get(localName);
+            fobjMaker = table.get(localName);
             // try default
             if (fobjMaker == null) {
-                fobjMaker = (Maker)table.get(ElementMapping.DEFAULT);
+                fobjMaker = table.get(ElementMapping.DEFAULT);
             }
         }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOElementMapping.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOElementMapping.java Thu Apr  5 16:19:19 2012
@@ -24,6 +24,8 @@ import java.util.HashMap;
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
+
 /**
  * Element mapping class for all XSL-FO elements.
  */
@@ -32,6 +34,9 @@ public class FOElementMapping extends El
     /** The XSL-FO namespace URI */
     public static final String URI = "http://www.w3.org/1999/XSL/Format";
 
+     /** Standard prefix */
+    public static final String STANDARD_PREFIX = "fo";
+
     /**
      * Basic constructor; inititializes the namespace URI for the fo: namespace
      */
@@ -44,7 +49,7 @@ public class FOElementMapping extends El
      */
     protected void initialize() {
         if (foObjs == null) {
-            foObjs = new HashMap();
+            foObjs = new HashMap<String, Maker>();
 
             // Declarations and Pagination and Layout Formatting Objects
             foObjs.put("root", new RootMaker());
@@ -141,7 +146,7 @@ public class FOElementMapping extends El
 
     /** {@inheritDoc} */
     public String getStandardPrefix() {
-        return "fo";
+        return STANDARD_PREFIX;
     }
 
     /** {@inheritDoc} */
@@ -205,7 +210,9 @@ public class FOElementMapping extends El
 
     static class PageSequenceMasterMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
-            return new org.apache.fop.fo.pagination.PageSequenceMaster(parent);
+            return new org.apache.fop.fo.pagination.PageSequenceMaster(parent,
+                    BlockLevelEventProducer.Provider.get(
+                            parent.getUserAgent().getEventBroadcaster()));
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOEventHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOEventHandler.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOEventHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FOEventHandler.java Thu Apr  5 16:19:19 2012
@@ -22,6 +22,7 @@ package org.apache.fop.fo;
 import org.xml.sax.SAXException;
 
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.fo.extensions.ExternalDocument;
 import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.Block;
@@ -35,9 +36,12 @@ import org.apache.fop.fo.flow.InstreamFo
 import org.apache.fop.fo.flow.Leader;
 import org.apache.fop.fo.flow.ListBlock;
 import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+import org.apache.fop.fo.flow.ListItemLabel;
 import org.apache.fop.fo.flow.PageNumber;
 import org.apache.fop.fo.flow.PageNumberCitation;
 import org.apache.fop.fo.flow.PageNumberCitationLast;
+import org.apache.fop.fo.flow.Wrapper;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
 import org.apache.fop.fo.flow.table.TableCell;
@@ -47,6 +51,8 @@ import org.apache.fop.fo.flow.table.Tabl
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.Root;
+import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.fonts.FontEventAdapter;
 import org.apache.fop.fonts.FontInfo;
 
@@ -83,6 +89,10 @@ public abstract class FOEventHandler {
         this.fontInfo.setEventListener(new FontEventAdapter(foUserAgent.getEventBroadcaster()));
     }
 
+    /** Constructor for sub-classes that do not need an {@link FOUserAgent} instance. */
+    protected FOEventHandler() {
+    }
+
     /**
      * Returns the User Agent object associated with this FOEventHandler.
      * @return the User Agent object
@@ -113,6 +123,14 @@ public abstract class FOEventHandler {
     public void endDocument() throws SAXException {
     }
 
+    /** {@inheritDoc} */
+    public void startRoot(Root root) {
+    }
+
+    /** {@inheritDoc} */
+    public void endRoot(Root root) {
+    }
+
     /**
      *
      * @param pageSeq PageSequence that is starting.
@@ -359,39 +377,45 @@ public abstract class FOEventHandler {
 
     /**
      * Process start of a ListLabel.
+     * @param listItemLabel ListItemLabel that is starting
      */
-    public void startListLabel() {
+    public void startListLabel(ListItemLabel listItemLabel) {
     }
 
     /**
      * Process end of a ListLabel.
+     * @param listItemLabel ListItemLabel that is ending
      */
-    public void endListLabel() {
+    public void endListLabel(ListItemLabel listItemLabel) {
     }
 
     /**
      * Process start of a ListBody.
+     * @param listItemBody ListItemBody that is starting
      */
-    public void startListBody() {
+    public void startListBody(ListItemBody listItemBody) {
     }
 
     /**
      * Process end of a ListBody.
+     * @param listItemBody ListItemBody that is ending
      */
-    public void endListBody() {
+    public void endListBody(ListItemBody listItemBody) {
     }
 
     // Static Regions
     /**
      * Process start of a Static.
+     * @param staticContent StaticContent that is starting
      */
-    public void startStatic() {
+    public void startStatic(StaticContent staticContent) {
     }
 
     /**
      * Process end of a Static.
+     * @param statisContent StaticContent that is ending
      */
-    public void endStatic() {
+    public void endStatic(StaticContent statisContent) {
     }
 
 
@@ -409,15 +433,16 @@ public abstract class FOEventHandler {
 
     /**
      * Process start of a Link.
-     * @param basicLink BasicLink that is ending
+     * @param basicLink BasicLink that is starting
      */
     public void startLink(BasicLink basicLink) {
     }
 
     /**
      * Process end of a Link.
+     * @param basicLink BasicLink that is ending
      */
-    public void endLink() {
+    public void endLink(BasicLink basicLink) {
     }
 
     /**
@@ -434,10 +459,17 @@ public abstract class FOEventHandler {
     }
 
     /**
-     * Process an InstreamForeignObject.
-     * @param ifo InstreamForeignObject to process.
+     * Process the start of an InstreamForeignObject.
+     * @param ifo InstreamForeignObject that is starting
      */
-    public void foreignObject(InstreamForeignObject ifo) {
+    public void startInstreamForeignObject(InstreamForeignObject ifo) {
+    }
+
+    /**
+     * Process the end of an InstreamForeignObject.
+     * @param ifo InstreamForeignObject that is ending
+     */
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
     }
 
     /**
@@ -469,10 +501,33 @@ public abstract class FOEventHandler {
     }
 
     /**
-     * Process a Leader.
-     * @param l Leader to process.
+     * Process the start of a Leader.
+     * @param l Leader that is starting
+     */
+    public void startLeader(Leader l) {
+    }
+
+    /**
+     * Process the end of a Leader.
+     * @param l Leader that is ending
+     */
+    public void endLeader(Leader l) {
+    }
+
+    /**
+     * Process the start of a wrapper.
+     *
+     * @param wrapper wrapper that is starting
      */
-    public void leader(Leader l) {
+    public void startWrapper(Wrapper wrapper) {
+    }
+
+    /**
+     * Process the ending of a wrapper.
+     *
+     * @param wrapper wrapper that is ending
+     */
+    public void endWrapper(Wrapper wrapper) {
     }
 
     /**
@@ -484,11 +539,9 @@ public abstract class FOEventHandler {
 
     /**
      * Process character data.
-     * @param data Array of characters to process.
-     * @param start Offset for characters to process.
-     * @param length Portion of array to process.
+     * @param foText text to process
      */
-    public void characters(char[] data, int start, int length) {
+    public void characters(FOText foText) {
     }
 
     /**
@@ -505,5 +558,13 @@ public abstract class FOEventHandler {
     public void endExternalDocument(ExternalDocument document) {
     }
 
+    /**
+     * Get formatting results.
+     * @return the FormattingResults instance for this document
+     */
+    public FormattingResults getResults() {
+        return null;
+    }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FONode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FONode.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FONode.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fo/FONode.java Thu Apr  5 16:19:19 2012
@@ -20,8 +20,10 @@
 package org.apache.fop.fo;
 
 // Java
+import java.util.Iterator;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Stack;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
@@ -32,8 +34,10 @@ import org.apache.commons.logging.LogFac
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fo.extensions.InternalElementMapping;
@@ -864,6 +868,122 @@ public abstract class FONode implements 
     }
 
     /**
+     * Determine if node has a delimited text range boundary. N.B. that we report
+     * this to be true by default, while specific subclasses override this method to report false.
+     * @param boundary one of {EN_BEFORE, EN_AFTER, or EN_BOTH} enumeration constants
+     * @return true if indicated boundary (or boundaries) constitute a delimited text range
+     * boundary.
+     */
+    public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+        return true;
+    }
+
+    /**
+     * Collect the sequence of delimited text ranges, where each new
+     * range is pushed onto RANGES.
+     * @param ranges a stack of delimited text ranges
+     * @return the (possibly) updated stack of delimited text ranges
+     */
+    public Stack collectDelimitedTextRanges ( Stack ranges ) {
+        // if boundary before, then push new range
+        if ( isRangeBoundaryBefore() ) {
+            maybeNewRange ( ranges );
+        }
+        // get current range, if one exists
+        DelimitedTextRange currentRange;
+        if ( ranges.size() > 0 ) {
+            currentRange = (DelimitedTextRange) ranges.peek();
+        } else {
+            currentRange = null;
+        }
+        // proceses this node
+        ranges = collectDelimitedTextRanges ( ranges, currentRange );
+        // if boundary after, then push new range
+        if ( isRangeBoundaryAfter() ) {
+            maybeNewRange ( ranges );
+        }
+        return ranges;
+    }
+
+    /**
+     * Collect the sequence of delimited text ranges, where each new
+     * range is pushed onto RANGES, where default implementation collects ranges
+     * of child nodes.
+     * @param ranges a stack of delimited text ranges
+     * @param currentRange the current range or null (if none)
+     * @return the (possibly) updated stack of delimited text ranges
+     */
+    protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+        for ( Iterator it = getChildNodes(); ( it != null ) && it.hasNext();) {
+            ranges = ( (FONode) it.next() ).collectDelimitedTextRanges ( ranges );
+        }
+        return ranges;
+    }
+
+    /**
+     * Determine if this node is a new bidi RANGE block item.
+     * @return true if this node is a new bidi RANGE block item
+     */
+    public boolean isBidiRangeBlockItem() {
+        return false;
+    }
+
+    /**
+     * Conditionally add a new delimited text range to RANGES, where new range is
+     * associated with current FONode. A new text range is added unless all of the following are
+     * true:
+     * <ul>
+     * <li>there exists a current range RCUR in RANGES</li>
+     * <li>RCUR is empty</li>
+     * <li>the node of the RCUR is the same node as FN or a descendent node of FN</li>
+     * </ul>
+     * @param ranges stack of delimited text ranges
+     * @return new range (if constructed and pushed onto stack) or current range (if any) or null
+     */
+    private DelimitedTextRange maybeNewRange ( Stack ranges ) {
+        DelimitedTextRange rCur = null; // current range (top of range stack)
+        DelimitedTextRange rNew = null; // new range to be pushed onto range stack
+        if ( ranges.empty() ) {
+            if ( isBidiRangeBlockItem() ) {
+                rNew = new DelimitedTextRange(this);
+            }
+        } else {
+            rCur = (DelimitedTextRange) ranges.peek();
+            if ( rCur != null ) {
+                if ( !rCur.isEmpty() || !isSelfOrDescendent ( rCur.getNode(), this ) ) {
+                    rNew = new DelimitedTextRange(this);
+                }
+            }
+        }
+        if ( rNew != null ) {
+            ranges.push ( rNew );
+        } else {
+            rNew = rCur;
+        }
+        return rNew;
+    }
+
+    private boolean isRangeBoundaryBefore() {
+        return isDelimitedTextRangeBoundary ( Constants.EN_BEFORE );
+    }
+
+    private boolean isRangeBoundaryAfter() {
+        return isDelimitedTextRangeBoundary ( Constants.EN_AFTER );
+    }
+
+    /**
+     * Determine if node N2 is the same or a descendent of node N1.
+     */
+    private static boolean isSelfOrDescendent ( FONode n1, FONode n2 ) {
+        for ( FONode n = n2; n != null; n = n.getParent() ) {
+            if ( n == n1 ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * Base iterator interface over a FO's children
      */
     public interface FONodeIterator extends ListIterator {
@@ -912,4 +1032,13 @@ public abstract class FONode implements 
 
     }
 
+    /**
+     * Sets the structure tree element.
+     *
+     * @param structureTreeElement set.
+     */
+    public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
+        throw new UnsupportedOperationException();
+    }
+
 }



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