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 ph...@apache.org on 2012/02/10 17:51:14 UTC

svn commit: r1242848 [4/5] - in /xmlgraphics/fop/trunk: ./ src/documentation/intermediate-format-ng/ src/java/org/apache/fop/accessibility/ src/java/org/apache/fop/accessibility/fo/ src/java/org/apache/fop/afp/apps/ src/java/org/apache/fop/afp/parser/ ...

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFPainter.java?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFPainter.java Fri Feb 10 16:51:08 2012
@@ -37,6 +37,7 @@ import org.apache.fop.fonts.SingleByteFo
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFNumber;
+import org.apache.fop.pdf.PDFStructElem;
 import org.apache.fop.pdf.PDFTextUtil;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.RenderingContext;
@@ -133,24 +134,24 @@ public class PDFPainter extends Abstract
         PDFXObject xobject = getPDFDoc().getXObject(uri);
         if (xobject != null) {
             if (accessEnabled) {
-                String ptr = getContext().getStructurePointer();
-                prepareImageMCID(ptr);
+                PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
+                prepareImageMCID(structElem);
                 placeImageAccess(rect, xobject);
             } else {
                 placeImage(rect, xobject);
             }
         } else {
             if (accessEnabled) {
-                String ptr = getContext().getStructurePointer();
-                prepareImageMCID(ptr);
+                PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
+                prepareImageMCID(structElem);
             }
             drawImageUsingURI(uri, rect);
             flushPDFDoc();
         }
     }
 
-    private void prepareImageMCID(String ptr) {
-        imageMCI = logicalStructureHandler.addImageContentItem(ptr);
+    private void prepareImageMCID(PDFStructElem structElem) {
+        imageMCI = logicalStructureHandler.addImageContentItem(structElem);
     }
 
     /** {@inheritDoc} */
@@ -194,8 +195,8 @@ public class PDFPainter extends Abstract
     /** {@inheritDoc} */
     public void drawImage(Document doc, Rectangle rect) throws IFException {
         if (accessEnabled) {
-            String ptr = getContext().getStructurePointer();
-            prepareImageMCID(ptr);
+            PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
+            prepareImageMCID(structElem);
         }
         drawImageUsingDocument(doc, rect);
         flushPDFDoc();
@@ -294,8 +295,8 @@ public class PDFPainter extends Abstract
             String text)
             throws IFException {
         if (accessEnabled) {
-            String ptr = getContext().getStructurePointer();
-            MarkedContentInfo mci = logicalStructureHandler.addTextContentItem(ptr);
+            PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
+            MarkedContentInfo mci = logicalStructureHandler.addTextContentItem(structElem);
             if (generator.getTextUtil().isInTextObject()) {
                 generator.separateTextElements(mci.tag, mci.mcid);
             }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java?rev=1242848&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java Fri Feb 10 16:51:08 2012
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf;
+
+import java.util.LinkedList;
+import java.util.Locale;
+
+import org.xml.sax.Attributes;
+
+import org.apache.fop.accessibility.StructureTreeElement;
+import org.apache.fop.accessibility.StructureTreeEventHandler;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.pdf.PDFFactory;
+import org.apache.fop.pdf.PDFStructElem;
+
+class PDFStructureTreeBuilder implements StructureTreeEventHandler {
+
+    private PDFFactory pdfFactory;
+
+    private PDFLogicalStructureHandler logicalStructureHandler;
+
+    private EventBroadcaster eventBroadcaster;
+
+    private LinkedList<PDFStructElem> ancestors = new LinkedList<PDFStructElem>();
+
+    void setPdfFactory(PDFFactory pdfFactory) {
+        this.pdfFactory = pdfFactory;
+    }
+
+    void setLogicalStructureHandler(PDFLogicalStructureHandler logicalStructureHandler) {
+        this.logicalStructureHandler = logicalStructureHandler;
+    }
+
+    void setEventBroadcaster(EventBroadcaster eventBroadcaster) {
+        this.eventBroadcaster = eventBroadcaster;
+    }
+
+    public void startPageSequence(Locale locale) {
+        ancestors = new LinkedList<PDFStructElem>();
+        ancestors.add(logicalStructureHandler.createPageSequence(locale));
+    }
+
+    public void endPageSequence() {
+    }
+
+    public StructureTreeElement startNode(String name, Attributes attributes) {
+        PDFStructElem parent = ancestors.getFirst();
+        String role = attributes.getValue("role");
+        PDFStructElem created;
+        created = pdfFactory.makeStructureElement(
+                FOToPDFRoleMap.mapFormattingObject(name, role, parent, eventBroadcaster), parent);
+        parent.addKid(created);
+        ancestors.addFirst(created);
+        return created;
+    }
+
+    public void endNode(String name) {
+        removeFirstAncestor();
+    }
+
+    private void removeFirstAncestor() {
+        ancestors.removeFirst();
+    }
+
+    public StructureTreeElement startImageNode(String name, Attributes attributes) {
+        PDFStructElem parent = ancestors.getFirst();
+        String role = attributes.getValue("role");
+        PDFStructElem created;
+        created = pdfFactory.makeStructureElement(
+                FOToPDFRoleMap.mapFormattingObject(name, role, parent, eventBroadcaster), parent);
+        parent.addKid(created);
+        String altTextNode = attributes.getValue(ExtensionElementMapping.URI, "alt-text");
+        if (altTextNode != null) {
+            created.put("Alt", altTextNode);
+        } else {
+            created.put("Alt", "No alternate text specified");
+        }
+        ancestors.addFirst(created);
+        return created;
+    }
+
+    public StructureTreeElement startReferencedNode(String name, Attributes attributes) {
+        PDFStructElem parent = ancestors.getFirst();
+        String role = attributes.getValue("role");
+        PDFStructElem created;
+        if ("#PCDATA".equals(name)) {
+            created = new PDFStructElem.Placeholder(parent, name);
+        } else {
+            created = pdfFactory.makeStructureElement(
+                    FOToPDFRoleMap.mapFormattingObject(name, role, parent,
+                            eventBroadcaster), parent);
+        }
+        parent.addKid(created);
+        ancestors.addFirst(created);
+        return created;
+    }
+
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Fri Feb 10 16:51:08 2012
@@ -937,10 +937,10 @@ public class RTFHandler extends FOEventH
              */
             //TODO: do this only, if the labels content <> previous labels content
             if (list.getChildCount() > 0) {
-                this.endListBody();
+                this.endListBody(null);
                 this.endList((ListBlock) li.getParent());
                 this.startList((ListBlock) li.getParent());
-                this.startListBody();
+                this.startListBody(null);
 
                 list = (RtfList)builderContext.getContainer(
                         RtfList.class, true, this);
@@ -965,7 +965,7 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void startListLabel() {
+    public void startListLabel(ListItemLabel listItemLabel) {
         if (bDefer) {
             return;
         }
@@ -985,7 +985,7 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void endListLabel() {
+    public void endListLabel(ListItemLabel listItemLabel) {
         if (bDefer) {
             return;
         }
@@ -994,20 +994,20 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void startListBody() {
+    public void startListBody(ListItemBody listItemBody) {
     }
 
     /** {@inheritDoc} */
-    public void endListBody() {
+    public void endListBody(ListItemBody listItemBody) {
     }
 
     // Static Regions
     /** {@inheritDoc} */
-    public void startStatic() {
+    public void startStatic(StaticContent staticContent) {
     }
 
     /** {@inheritDoc} */
-    public void endStatic() {
+    public void endStatic(StaticContent statisContent) {
     }
 
     /** {@inheritDoc} */
@@ -1050,7 +1050,7 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void endLink() {
+    public void endLink(BasicLink basicLink) {
         if (bDefer) {
             return;
         }
@@ -1090,7 +1090,7 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void foreignObject(InstreamForeignObject ifo) {
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
         if (bDefer) {
             return;
         }
@@ -1337,7 +1337,7 @@ public class RTFHandler extends FOEventH
     }
 
     /** {@inheritDoc} */
-    public void leader(Leader l) {
+    public void startLeader(Leader l) {
         if (bDefer) {
             return;
         }
@@ -1353,8 +1353,10 @@ public class RTFHandler extends FOEventH
             RtfTextrun textrun = container.getTextrun();
 
             textrun.addLeader(rtfAttr);
-
-        } catch (Exception e) {
+        } catch (IOException e) {
+            log.error("startLeader: " + e.getMessage());
+            throw new RuntimeException(e.getMessage());
+        } catch (FOPException e) {
             log.error("startLeader: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
@@ -1362,11 +1364,9 @@ public class RTFHandler extends FOEventH
 
     /**
      * @param text FOText object
-     * @param data Array of characters to process.
-     * @param start Offset for characters to process.
-     * @param length Portion of array to process.
+     * @param characters CharSequence of the characters to process.
      */
-    public void text(FOText text, char[] data, int start, int length) {
+    public void text(FOText text, CharSequence characters) {
         if (bDefer) {
             return;
         }
@@ -1381,7 +1381,7 @@ public class RTFHandler extends FOEventH
                 = TextAttributesConverter.convertCharacterAttributes(text);
 
             textrun.pushInlineAttributes(rtfAttr);
-            textrun.addString(new String(data, start, length - start));
+            textrun.addString(characters.toString());
             textrun.popInlineAttributes();
         } catch (IOException ioe) {
             handleIOTrouble(ioe);
@@ -1518,9 +1518,9 @@ public class RTFHandler extends FOEventH
             }
         } else if (foNode instanceof StaticContent) {
             if (bStart) {
-                startStatic();
+                startStatic(null);
             } else {
-                endStatic();
+                endStatic(null);
             }
         } else if (foNode instanceof ExternalGraphic) {
             if (bStart) {
@@ -1528,7 +1528,7 @@ public class RTFHandler extends FOEventH
             }
         } else if (foNode instanceof InstreamForeignObject) {
             if (bStart) {
-                foreignObject( (InstreamForeignObject) foNode );
+                endInstreamForeignObject( (InstreamForeignObject) foNode );
             }
         } else if (foNode instanceof Block) {
             if (bStart) {
@@ -1547,7 +1547,7 @@ public class RTFHandler extends FOEventH
             if (bStart) {
                 startLink( (BasicLink) foNode);
             } else {
-                endLink();
+                endLink(null);
             }
         } else if (foNode instanceof Inline) {
             if (bStart) {
@@ -1558,7 +1558,7 @@ public class RTFHandler extends FOEventH
         } else if (foNode instanceof FOText) {
             if (bStart) {
                 FOText text = (FOText) foNode;
-                text(text, text.getCharArray(), 0, text.length());
+                text(text, text.getCharSequence());
             }
         } else if (foNode instanceof Character) {
             if (bStart) {
@@ -1591,9 +1591,9 @@ public class RTFHandler extends FOEventH
             }
         } else if (foNode instanceof ListItemBody) {
             if (bStart) {
-                startListBody();
+                startListBody(null);
             } else {
-                endListBody();
+                endListBody(null);
             }
         } else if (foNode instanceof ListItem) {
             if (bStart) {
@@ -1603,9 +1603,9 @@ public class RTFHandler extends FOEventH
             }
         } else if (foNode instanceof ListItemLabel) {
             if (bStart) {
-                startListLabel();
+                startListLabel(null);
             } else {
-                endListLabel();
+                endListLabel(null);
             }
         } else if (foNode instanceof Table) {
             if (bStart) {
@@ -1651,7 +1651,7 @@ public class RTFHandler extends FOEventH
             }
         } else if (foNode instanceof Leader) {
             if (bStart) {
-                leader((Leader) foNode);
+                startLeader((Leader) foNode);
             }
         } else if (foNode instanceof PageNumberCitation) {
             if (bStart) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Fri Feb 10 16:51:08 2012
@@ -35,8 +35,6 @@ import javax.xml.transform.sax.Transform
 import javax.xml.transform.stream.StreamResult;
 
 import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
 import org.apache.xmlgraphics.util.QName;
@@ -82,15 +80,12 @@ import org.apache.fop.area.inline.TextAr
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
-import org.apache.fop.fo.extensions.InternalElementMapping;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.XMLHandler;
 import org.apache.fop.util.ColorUtil;
-import org.apache.fop.util.DOM2SAX;
 
 /**
  * Renderer that renders areas to XML for debugging purposes.
@@ -110,8 +105,6 @@ public class XMLRenderer extends Abstrac
     /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */
     protected Renderer mimic;
 
-    private int pageSequenceIndex;
-
     /**
      * @param userAgent the user agent that contains configuration details. This cannot be null.
      */
@@ -452,29 +445,6 @@ public class XMLRenderer extends Abstrac
         }
         transferForeignObjects(pageSequence);
         startElement("pageSequence", atts);
-        if (this.getUserAgent().isAccessibilityEnabled()) {
-            String structureTreeElement = "structureTree";
-            startElement(structureTreeElement);
-            try {
-                this.handler.startPrefixMapping("foi", InternalElementMapping.URI);
-                this.handler.startPrefixMapping("fox", ExtensionElementMapping.URI);
-                NodeList nodes = getUserAgent().getStructureTree().getPageSequence(
-                        pageSequenceIndex++);
-                for (int i = 0, n = nodes.getLength(); i < n; i++) {
-                    Node node = nodes.item(i);
-                    try {
-                        new DOM2SAX(handler).writeFragment(node);
-                    } catch (SAXException e) {
-                        handleSAXException(e);
-                    }
-                }
-                this.handler.endPrefixMapping("fox");
-                this.handler.endPrefixMapping("foi");
-            } catch (SAXException se) {
-                handleSAXException(se);
-            }
-            endElement(structureTreeElement);
-        }
         handleExtensionAttachments(pageSequence.getExtensionAttachments());
         LineArea seqTitle = pageSequence.getTitle();
         if (seqTitle != null) {

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 10 16:51:08 2012
@@ -2,4 +2,5 @@
 /xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/ColorExt.java:745924-830281
 /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/ColorExt.java:603620-746655
 /xmlgraphics/fop/branches/Temp_Color/src/java/org/apache/fop/util/ColorExt.java:956535-1069429
+/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/util/ColorExt.java:1187234-1242827
 /xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/util/ColorExt.java:684572,688085,688696

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LanguageTags.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LanguageTags.java?rev=1242848&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LanguageTags.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LanguageTags.java Fri Feb 10 16:51:08 2012
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util;
+
+import java.util.Locale;
+
+/**
+ * Provides utility methods for manipulating language tags compliant with the
+ * RFC 3066 specification available at http://www.ietf.org/rfc/rfc3066.txt. A
+ * typical language tag is a 2-letter language code sometimes followed by a country
+ * code. For example: en, en-US.
+ */
+public final class LanguageTags {
+
+    private LanguageTags() {
+    }
+
+    /**
+     * Converts the given locale to an RFC 3066 compliant language tag.
+     *
+     * @param locale a locale
+     * @return the corresponding language tag
+     */
+    public static String toLanguageTag(Locale locale) {
+        StringBuffer sb = new StringBuffer(5);
+        sb.append(locale.getLanguage());
+        String country = locale.getCountry();
+        if (country.length() > 0) {
+            sb.append('-');
+            sb.append(country);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Converts an RFC 3066 compliant language tag to a locale.
+     *
+     * @param languageTag language tag to convert
+     * @return the corresponding locale
+     */
+    public static Locale toLocale(String languageTag) {
+        String[] parts = languageTag.split("-");
+        if (parts.length == 1) {
+            return new Locale(parts[0]);
+        } else {
+            return new Locale(parts[0], parts[1]);
+        }
+    }
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/XMLUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/XMLUtil.java?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/XMLUtil.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/XMLUtil.java Fri Feb 10 16:51:08 2012
@@ -21,7 +21,6 @@ package org.apache.fop.util;
 
 import java.awt.Rectangle;
 import java.awt.geom.Rectangle2D;
-import java.util.Locale;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -174,39 +173,4 @@ public final class XMLUtil implements XM
         atts.addAttribute("", localName, localName, XMLUtil.CDATA, value);
     }
 
-    /**
-     * Converts a {@link Locale} instance to an RFC 3066 compliant language identifier.
-     * @param language the language
-     * @return the formatted language identifier
-     */
-    public static String toRFC3066(Locale language) {
-        if (language == null || language.getLanguage().length() == 0) {
-            return null;
-        }
-        StringBuffer sb = new StringBuffer();
-        sb.append(language.getLanguage());
-        if (language.getCountry().length() > 0) {
-            sb.append('-');
-            sb.append(language.getCountry());
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Converts an RFC 3066 compliant language identifier to a {@link Locale} instance.
-     * @param lang the language string
-     * @return the converted locale instance
-     */
-    public static Locale convertRFC3066ToLocale(String lang) {
-        if (lang == null || lang.length() == 0) {
-            return null;
-        }
-        String[] parts = lang.split("-");
-        if (parts.length == 1) {
-            return new Locale(parts[0]);
-        } else {
-            return new Locale(parts[0], parts[1]);
-        }
-    }
-
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Fri Feb 10 16:51:08 2012
@@ -61,6 +61,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="PH" type="add" due-to="VH and PH">
+        Improvements of the Accessibility feature
+      </action>
       <action context="Code" dev="CB" type="add" fixes-bug="52416" due-to="Luis Bernardo">
         Suppress unnecessary "font not found warnings" when generating AFP with raster fonts 
       </action>

Modified: xmlgraphics/fop/trunk/test/accessibility/README
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/README?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/README (original)
+++ xmlgraphics/fop/trunk/test/accessibility/README Fri Feb 10 16:51:08 2012
@@ -1,11 +1,8 @@
 This directory contains sample FO files for testing the accessibility features
 of FOP.
 
-To every FO file in this directory correspond two PDF files in the pdf/ 
-sub-directory: one generated by the painter, one by the renderer. For example, 
-the text_1.fo file has been rendered into pdf/text_1_painter_orig.pdf and 
-pdf/text_1_renderer_orig.pdf. The configuration file config-painter.xconf (resp. 
-config-renderer.xconf) was used.
+Every FO file in this directory has a corresponding PDF file in the pdf/
+sub-directory. The fop.xconf configuration file was used.
 
 The PDF files have been checked with Adobe Acrobat Professional 9, using both 
 the full accessibility checker and the read-aloud feature. The checker reports 
@@ -22,7 +19,7 @@ problem yet part or all of the document 
 
 The purpose of this infrastructure is to be able to quickly re-test the 
 accessibility processing chain when any change has been made to it. The 
-configuration files disable the compression of the PDF streams, so it is 
+configuration file disables the compression of the PDF streams, so it is 
 possible to compare a re-generated PDF with the original one by using a simple 
 diff tool. The files will not be identical because of the different creation 
 dates (and the ID key in the trailer), but apart from that there should be no 
@@ -32,21 +29,13 @@ The rationale is that using a diff tool 
 running Acrobat's accessibility checker and read-aloud feature every time.
 
 
-To re-generate the PDF files using the painter:
-    ../../fop -c config-painter.xconf text_1.fo pdf/text_1_painter.pdf
-    diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf
+To re-generate the PDF files:
+    ../../fop -c fop.xconf text_1.fo pdf/text_1.new.pdf
+    diff pdf/text_1_painter.pdf pdf/text_1.new.pdf
 Or, going through the intermediate format:
-    ../../fop -c config-painter.xconf text_1.fo -if application/pdf text_1_if.xml
-    ../../fop -c config-painter.xconf -ifin text_1_if.xml pdf/text_1_painter.pdf
-    diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf
-
-To re-generate the PDF files using the legacy renderer:
-    ../../fop -c config-renderer.xconf text_1.fo pdf/text_1_renderer.pdf
-    diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf
-Or, going through the intermediate format:
-    ../../fop -c config-renderer.xconf text_1.fo -at application/pdf text_1_at.xml
-    ../../fop -c config-renderer.xconf -atin text_1_at.xml pdf/text_1_renderer.pdf
-    diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf
+    ../../fop -c fop.xconf text_1.fo -if application/pdf text_1_if.xml
+    ../../fop -c fop.xconf -ifin text_1_if.xml pdf/text_1.new.pdf
+    diff pdf/text_1.pdf pdf/text_1.new.pdf
 
 
 $Id$

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_repeat.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_repeat.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_repeat.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body background-image="../resources/images/bgimg72dpi.jpg"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_single.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_single.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_jpg_single.fo Fri Feb 10 16:51:08 2012
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
@@ -25,7 +25,7 @@
         background-position-vertical="50%"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_png_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_png_repeat.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_png_repeat.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_png_repeat.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body background-image="../resources/images/bgimg72dpi.png"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_png_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_png_single.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_png_single.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_png_single.fo Fri Feb 10 16:51:08 2012
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
@@ -25,7 +25,7 @@
         background-position-vertical="50%"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_svg_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_svg_repeat.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_svg_repeat.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_svg_repeat.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body background-image="../resources/images/rgb-circles.svg"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/background-image_svg_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/background-image_svg_single.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/background-image_svg_single.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/background-image_svg_single.fo Fri Feb 10 16:51:08 2012
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
@@ -25,7 +25,7 @@
         background-position-vertical="50%"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/complete.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/complete.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/complete.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/complete.fo Fri Feb 10 16:51:08 2012
@@ -17,7 +17,7 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
@@ -25,7 +25,7 @@
       <fo:region-before extent="12pt"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:static-content flow-name="xsl-region-before">
       <fo:block font-size="8pt" text-align-last="justify">This is the page header<fo:leader/>Page 
         <fo:page-number/></fo:block>
@@ -117,7 +117,7 @@
       <fo:block>And now we are going to see how a second page sequence is handled.</fo:block>
     </fo:flow>
   </fo:page-sequence>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:static-content flow-name="xsl-region-before">
       <fo:block font-size="8pt" text-align-last="justify">This is the page header<fo:leader/>Page 
         <fo:page-number/></fo:block>

Added: xmlgraphics/fop/trunk/test/accessibility/fop.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/fop.xconf?rev=1242848&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/fop.xconf (added)
+++ xmlgraphics/fop/trunk/test/accessibility/fop.xconf Fri Feb 10 16:51:08 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop version="1.0">
+  <accessibility>true</accessibility>
+  <source-resolution>144</source-resolution>
+  <use-cache>false</use-cache>
+  <font-base>../resources/fonts/</font-base>
+  <renderers>
+    <renderer mime="application/pdf">
+      <filterList>
+        <value>null</value>
+      </filterList>
+      <filterList type="image">
+        <value>flate</value>
+        <value>ascii-85</value>
+      </filterList>
+      <fonts>
+        <font embed-url="DejaVuLGCSerif.ttf">
+          <font-triplet name="DejaVu" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Modified: xmlgraphics/fop/trunk/test/accessibility/image_jpg.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/image_jpg.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/image_jpg.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/image_jpg.fo Fri Feb 10 16:51:08 2012
@@ -17,14 +17,14 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>This document contains an image in the JPEG format: <fo:external-graphic 
           src="../resources/images/cmyk.jpg"

Modified: xmlgraphics/fop/trunk/test/accessibility/image_png.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/image_png.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/image_png.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/image_png.fo Fri Feb 10 16:51:08 2012
@@ -17,14 +17,14 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>This document contains an image in the PNG format: <fo:external-graphic 
           src="../resources/images/fop-logo-color-24bit.png"

Modified: xmlgraphics/fop/trunk/test/accessibility/image_svg.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/image_svg.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/image_svg.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/image_svg.fo Fri Feb 10 16:51:08 2012
@@ -17,14 +17,14 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>This document contains an image in the SVG format: <fo:external-graphic 
           src="../resources/images/circles.svg"

Modified: xmlgraphics/fop/trunk/test/accessibility/image_wmf.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/image_wmf.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/image_wmf.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/image_wmf.fo Fri Feb 10 16:51:08 2012
@@ -17,14 +17,14 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="320pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>This document contains an image in the WMF format: <fo:external-graphic 
           src="../resources/images/testChart.wmf"

Modified: xmlgraphics/fop/trunk/test/accessibility/leader.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/leader.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/leader.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/leader.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify" 
       text-align-last="justify">
       <fo:block>This is a text followed by a leader with leader-pattern=​"use-content", the 

Modified: xmlgraphics/fop/trunk/test/accessibility/links.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/links.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/links.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/links.fo Fri Feb 10 16:51:08 2012
@@ -17,14 +17,14 @@
 -->
 <!-- $Id$ -->
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>This is a <fo:wrapper color="blue"><fo:basic-link 
             internal-destination="FOP">link</fo:basic-link></fo:wrapper> to the next 

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_repeat.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_repeat.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_repeat.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_single.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_single.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_jpg_single.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_repeat.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_repeat.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_repeat.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_single.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_single.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_png_single.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_repeat.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_repeat.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_repeat.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_single.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_single.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/background-image_svg_single.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/complete.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/complete.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/complete.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/image_jpg.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/image_jpg.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/image_jpg.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/image_png.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/image_png.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/image_png.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/image_svg.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/image_svg.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/image_svg.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/image_wmf.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/image_wmf.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/image_wmf.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/leader.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/leader.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/leader.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/links.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/links.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/links.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/role.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/role.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/role.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/role_non-standard.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/role_non-standard.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/role_non-standard.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/text_1.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/text_1.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/text_1.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/text_2.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/text_2.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/text_2.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xmlgraphics/fop/trunk/test/accessibility/pdf/text_font-embedding.pdf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/pdf/text_font-embedding.pdf?rev=1242848&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/test/accessibility/pdf/text_font-embedding.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: xmlgraphics/fop/trunk/test/accessibility/role.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/role.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/role.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/role.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" font-family="sans-serif">
       <fo:block role="H1" font-weight="bold" font-size="150%"
         space-before.minimum="1.5em"

Modified: xmlgraphics/fop/trunk/test/accessibility/role_non-standard.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/role_non-standard.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/role_non-standard.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/role_non-standard.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" font-family="sans-serif">
       <fo:block role="H1" font-weight="bold" font-size="150%"
         space-before.minimum="1.5em"

Modified: xmlgraphics/fop/trunk/test/accessibility/text_1.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/text_1.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/text_1.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/text_1.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/text_2.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/text_2.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/text_2.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/text_2.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/accessibility/text_font-embedding.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/accessibility/text_font-embedding.fo?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/accessibility/text_font-embedding.fo (original)
+++ xmlgraphics/fop/trunk/test/accessibility/text_font-embedding.fo Fri Feb 10 16:51:08 2012
@@ -16,14 +16,14 @@
   limitations under the License.
 -->
 <!-- $Id$ -->
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" country="GB">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="page"
       page-height="220pt" page-width="320pt" margin="10pt">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
-  <fo:page-sequence master-reference="page" language="en" country="GB">
+  <fo:page-sequence master-reference="page">
     <fo:flow flow-name="xsl-region-body" hyphenate="true" text-align="justify" font-family="DejaVu">
       <fo:block>Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL 
         formatting objects (XSL-FO) and an output independent formatter. It is a Java application 

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java?rev=1242848&r1=1242847&r2=1242848&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/StandardTestSuite.java Fri Feb 10 16:51:08 2012
@@ -76,7 +76,8 @@ import org.apache.fop.pdf.PDFLibraryTest
         MinOptMaxTestCase.class,
         AdobeStandardEncodingTestCase.class,
         AFMParserTestCase.class,
-        FontEventProcessingTestCase.class
+        FontEventProcessingTestCase.class,
+        org.apache.fop.render.intermediate.IFStructureTreeBuilderTestCase.class
 })
 public class StandardTestSuite {
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/DOMResultUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/DOMResultUtil.java?rev=1242848&r1=1242827&r2=1242848&view=diff
==============================================================================
    (empty)

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java?rev=1242848&r1=1242827&r2=1242848&view=diff
==============================================================================
    (empty)

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl?rev=1242848&r1=1242827&r2=1242848&view=diff
==============================================================================
    (empty)

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/table-footers.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/table-footers.fo?rev=1242848&r1=1242827&r2=1242848&view=diff
==============================================================================
    (empty)

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/wrapCompleteDocumentInTableFooter.xsl
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/fo/wrapCompleteDocumentInTableFooter.xsl?rev=1242848&r1=1242827&r2=1242848&view=diff
==============================================================================
    (empty)

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java?rev=1242848&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java Fri Feb 10 16:51:08 2012
@@ -0,0 +1,531 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
+import org.apache.fop.fo.flow.BasicLink;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.BlockContainer;
+import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Footnote;
+import org.apache.fop.fo.flow.FootnoteBody;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+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;
+import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
+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;
+
+/**
+ * Tests that {@link DelegatingFOEventHandler} does forward every event to its delegate
+ * event handler.
+ */
+public class DelegatingFOEventHandlerTestCase {
+
+    private InputStream document;
+
+    private List<String> expectedEvents;
+
+    private List<String> actualEvents;
+
+    private FODocumentParser documentParser;
+
+    private class DelegatingFOEventHandlerTester extends FOEventHandler {
+
+        DelegatingFOEventHandlerTester(FOUserAgent foUserAgent) {
+            super(foUserAgent);
+        }
+
+        private final StringBuilder eventBuilder = new StringBuilder();
+
+        @Override
+        public void startDocument() throws SAXException {
+            actualEvents.add("start document");
+        }
+
+        @Override
+        public void endDocument() throws SAXException {
+            actualEvents.add("end   document");
+        }
+
+        @Override
+        public void startRoot(Root root) {
+            startElement(root);
+        }
+
+        @Override
+        public void endRoot(Root root) {
+            endElement(root);
+        }
+
+        @Override
+        public void startPageSequence(PageSequence pageSeq) {
+            startElement(pageSeq);
+        }
+
+        @Override
+        public void endPageSequence(PageSequence pageSeq) {
+            endElement(pageSeq);
+        }
+
+        @Override
+        public void startPageNumber(PageNumber pagenum) {
+            startElement(pagenum);
+        }
+
+        @Override
+        public void endPageNumber(PageNumber pagenum) {
+            endElement(pagenum);
+        }
+
+        @Override
+        public void startPageNumberCitation(PageNumberCitation pageCite) {
+            startElement(pageCite);
+        }
+
+        @Override
+        public void endPageNumberCitation(PageNumberCitation pageCite) {
+            endElement(pageCite);
+        }
+
+        @Override
+        public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            startElement(pageLast);
+        }
+
+        @Override
+        public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            endElement(pageLast);
+        }
+
+        @Override
+        public void startFlow(Flow fl) {
+            startElement(fl);
+        }
+
+        @Override
+        public void endFlow(Flow fl) {
+            endElement(fl);
+        }
+
+        @Override
+        public void startBlock(Block bl) {
+            startElement(bl);
+        }
+
+        @Override
+        public void endBlock(Block bl) {
+            endElement(bl);
+        }
+
+        @Override
+        public void startBlockContainer(BlockContainer blc) {
+            startElement(blc);
+        }
+
+        @Override
+        public void endBlockContainer(BlockContainer blc) {
+            endElement(blc);
+        }
+
+        @Override
+        public void startInline(Inline inl) {
+            startElement(inl);
+        }
+
+        @Override
+        public void endInline(Inline inl) {
+            endElement(inl);
+        }
+
+        @Override
+        public void startTable(Table tbl) {
+            startElement(tbl);
+        }
+
+        @Override
+        public void endTable(Table tbl) {
+            endElement(tbl);
+        }
+
+        @Override
+        public void startColumn(TableColumn tc) {
+            startElement(tc);
+        }
+
+        @Override
+        public void endColumn(TableColumn tc) {
+            endElement(tc);
+        }
+
+        @Override
+        public void startHeader(TableHeader header) {
+            startElement(header);
+        }
+
+        @Override
+        public void endHeader(TableHeader header) {
+            endElement(header);
+        }
+
+        @Override
+        public void startFooter(TableFooter footer) {
+            startElement(footer);
+        }
+
+        @Override
+        public void endFooter(TableFooter footer) {
+            endElement(footer);
+        }
+
+        @Override
+        public void startBody(TableBody body) {
+            startElement(body);
+        }
+
+        @Override
+        public void endBody(TableBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startRow(TableRow tr) {
+            startElement(tr);
+        }
+
+        @Override
+        public void endRow(TableRow tr) {
+            endElement(tr);
+        }
+
+        @Override
+        public void startCell(TableCell tc) {
+            startElement(tc);
+        }
+
+        @Override
+        public void endCell(TableCell tc) {
+            endElement(tc);
+        }
+
+        @Override
+        public void startList(ListBlock lb) {
+            startElement(lb);
+        }
+
+        @Override
+        public void endList(ListBlock lb) {
+            endElement(lb);
+        }
+
+        @Override
+        public void startListItem(ListItem li) {
+            startElement(li);
+        }
+
+        @Override
+        public void endListItem(ListItem li) {
+            endElement(li);
+        }
+
+        @Override
+        public void startListLabel(ListItemLabel listItemLabel) {
+            startElement(listItemLabel);
+        }
+
+        @Override
+        public void endListLabel(ListItemLabel listItemLabel) {
+            endElement(listItemLabel);
+        }
+
+        @Override
+        public void startListBody(ListItemBody listItemBody) {
+            startElement(listItemBody);
+        }
+
+        @Override
+        public void endListBody(ListItemBody listItemBody) {
+            endElement(listItemBody);
+        }
+
+        @Override
+        public void startStatic(StaticContent staticContent) {
+            startElement(staticContent);
+        }
+
+        @Override
+        public void endStatic(StaticContent statisContent) {
+            endElement(statisContent);
+        }
+
+        @Override
+        public void startLink(BasicLink basicLink) {
+            startElement(basicLink);
+        }
+
+        @Override
+        public void endLink(BasicLink basicLink) {
+            endElement(basicLink);
+        }
+
+        @Override
+        public void image(ExternalGraphic eg) {
+            startElement(eg);
+            endElement(eg);
+        }
+
+        @Override
+        public void startInstreamForeignObject(InstreamForeignObject ifo) {
+            startElement(ifo);
+        }
+
+        @Override
+        public void endInstreamForeignObject(InstreamForeignObject ifo) {
+            endElement(ifo);
+        }
+
+        @Override
+        public void startFootnote(Footnote footnote) {
+            startElement(footnote);
+        }
+
+        @Override
+        public void endFootnote(Footnote footnote) {
+            endElement(footnote);
+        }
+
+        @Override
+        public void startFootnoteBody(FootnoteBody body) {
+            startElement(body);
+        }
+
+        @Override
+        public void endFootnoteBody(FootnoteBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startLeader(Leader l) {
+            startElement(l);
+        }
+
+        @Override
+        public void endLeader(Leader l) {
+            endElement(l);
+        }
+
+        @Override
+        public void startWrapper(Wrapper wrapper) {
+            startElement(wrapper);
+        }
+
+        @Override
+        public void endWrapper(Wrapper wrapper) {
+            endElement(wrapper);
+        }
+
+        @Override
+        public void character(Character c) {
+            startElement(c);
+            endElement(c);
+        }
+
+        private void startElement(FObj node) {
+            addEvent("start ", node);
+        }
+
+        private void endElement(FObj node) {
+            addEvent("end   ", node);
+        }
+
+        private void addEvent(String event, FObj node) {
+            eventBuilder.append(event);
+            eventBuilder.append(node.getLocalName());
+            addID(node);
+            actualEvents.add(eventBuilder.toString());
+            eventBuilder.setLength(0);
+        }
+
+        private void addID(FObj node) {
+            String id = node.getId();
+            if (id != null && id.length() > 0) {
+                eventBuilder.append(" id=\"");
+                eventBuilder.append(id);
+                eventBuilder.append("\"");
+            }
+        }
+    }
+
+    @Before
+    public void setUp() throws IOException {
+        setUpEvents();
+        loadDocument();
+        createDocumentParser();
+    }
+
+    private void setUpEvents() throws IOException {
+        loadDocument();
+        loadExpectedEvents();
+        actualEvents = new ArrayList<String>(expectedEvents.size());
+    }
+
+    private void loadDocument() {
+        document = getClass().getResourceAsStream("complete_document.fo");
+    }
+
+    private void loadExpectedEvents() throws IOException {
+        expectedEvents = new ArrayList<String>();
+        InputStream xslt = getClass().getResourceAsStream("extract-events.xsl");
+        try {
+            runXSLT(xslt);
+        } finally {
+            closeStream(xslt);
+            closeStream(document);
+        }
+    }
+
+    private void runXSLT(InputStream xslt) {
+        Transformer transformer = createTransformer(xslt);
+        Source fo = new StreamSource(document);
+        Result result = createTransformOutputHandler();
+        try {
+            transformer.transform(fo, result);
+        } catch (TransformerException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private Transformer createTransformer(InputStream xslt) {
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+        try {
+            return transformerFactory.newTransformer(new StreamSource(xslt));
+        } catch (TransformerConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private Result createTransformOutputHandler() {
+        return new SAXResult(new DefaultHandler() {
+
+            private final StringBuilder event = new StringBuilder();
+
+            @Override
+            public void startElement(String uri, String localName, String qName,
+                    Attributes attributes) throws SAXException {
+                event.setLength(0);
+            }
+
+            @Override
+            public void characters(char[] ch, int start, int length) throws SAXException {
+                event.append(ch, start, length);
+            }
+
+            @Override
+            public void endElement(String uri, String localName, String qName) throws SAXException {
+                expectedEvents.add(event.toString());
+            }
+
+        });
+    }
+
+    private void closeStream(InputStream stream) {
+        try {
+            stream.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void createDocumentParser() {
+        documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() {
+
+            public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) {
+                return new DelegatingFOEventHandler(
+                        new DelegatingFOEventHandlerTester(foUserAgent)) {
+                };
+            }
+        });
+    }
+
+    @Test
+    public void testFOEventHandler() throws Exception {
+        documentParser.parse(document);
+        assertArrayEquals(expectedEvents.toArray(), actualEvents.toArray());
+    }
+
+    @After
+    public void unloadDocument() throws IOException {
+        document.close();
+    }
+
+    /**
+     * Prints the given list to {@code System.out}, each element on a new line. For
+     * debugging purpose.
+     *
+     * @param list a list
+     */
+    public void printList(List<?> list) {
+        for (Object element : list) {
+            System.out.println(element);
+        }
+    }
+
+}

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java?rev=1242848&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/FODocumentParser.java Fri Feb 10 16:51:08 2012
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.events.EventListener;
+
+/**
+ * Parse an FO document and run the corresponding FO events through a given
+ * {@link FOEventHandler} instance. That instance is created using the helper
+ * {@link FOEventHandlerFactory}.
+ *
+ * <p>An instance of this class may not be used in multiple threads concurrently.<p>
+ *
+ * <p>An instance of this class may be used multiple times if the given
+ * {@link FOEventHandler} implementation can be used multiple times.
+ */
+public final class FODocumentParser {
+
+    private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+
+    private static final FopFactory FOP_FACTORY = FopFactory.newInstance();
+
+    private final FOEventHandlerFactory foEventHandlerFactory;
+
+    private Fop fop;
+
+    private Transformer transformer;
+
+    private EventListener eventListener;
+
+    /**
+     * A factory to create custom instances of {@link FOEventHandler}.
+     */
+    public static interface FOEventHandlerFactory {
+
+        /**
+         * Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent.
+         *
+         * @param foUserAgent an FO user agent
+         * @return a new {@code FOEventHandler} instance
+         */
+        FOEventHandler newFOEventHandler(FOUserAgent foUserAgent);
+    }
+
+    private FODocumentParser(FOEventHandlerFactory foeEventHandlerFactory) {
+        this.foEventHandlerFactory = foeEventHandlerFactory;
+    }
+
+    /**
+     * Creates and returns a new FO document parser. The given factory will be used to
+     * customize the handler that will receive FO events, using the
+     * {@link FOUserAgent#setFOEventHandlerOverride(FOEventHandler)} method.
+     *
+     * @param foEventHandlerFactory the factory to be used to create {@code
+     * FOEventHandler} instances
+     * @return a new parser
+     */
+    public static FODocumentParser newInstance(FOEventHandlerFactory foEventHandlerFactory) {
+        return new FODocumentParser(foEventHandlerFactory);
+    }
+
+    /**
+     * Sets the event listener to be used if events occurs when parsing the document.
+     *
+     * @param eventListener an event listener
+     */
+    public void setEventListener(EventListener eventListener) {
+        this.eventListener = eventListener;
+    }
+
+    /**
+     * Runs FOP on the given document.
+     *
+     * @param document XSL-FO document to parse
+     * @throws FOPException if an error occurs when initializing FOP
+     * @throws LoadingException if an error occurs when parsing the document
+     */
+    public void parse(InputStream document) throws FOPException, LoadingException {
+        parse(document, createFOUserAgent());
+    }
+
+    /**
+     * Runs FOP on the given document with the supplied {@link FOUserAgent}.
+     *
+     * @param document XSL-FO document to parse
+     * @param foUserAgent The user agent
+     * @throws FOPException if an error occurs when initializing FOP
+     * @throws LoadingException if an error occurs when parsing the document
+     */
+    public void parse(InputStream document, FOUserAgent foUserAgent)
+            throws FOPException, LoadingException {
+        fop = FOP_FACTORY.newFop(foUserAgent);
+        createTransformer();
+        runTransformer(document);
+    }
+
+    /**
+     * Creates a new {@link FOUserAgent}.
+     * @return It
+     */
+    public FOUserAgent createFOUserAgent() {
+        FOUserAgent userAgent = FOP_FACTORY.newFOUserAgent();
+        FOEventHandler foEventHandler = foEventHandlerFactory.newFOEventHandler(userAgent);
+        userAgent.setFOEventHandlerOverride(foEventHandler);
+        if (eventListener != null) {
+            userAgent.getEventBroadcaster().addEventListener(eventListener);
+        }
+        return userAgent;
+    }
+
+    private void createTransformer() {
+        try {
+            transformer = TRANSFORMER_FACTORY.newTransformer();
+        } catch (TransformerConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void runTransformer(InputStream input) throws LoadingException, FOPException {
+        Source source = new StreamSource(input);
+        Result result = new SAXResult(fop.getDefaultHandler());
+        try {
+            transformer.transform(source, result);
+        } catch (TransformerException e) {
+            Throwable cause = e.getCause();
+            throw new LoadingException(cause == null ? e : cause);
+        }
+    }
+}



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