xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phanc...@apache.org
Subject svn commit: r1236718 [2/3] - in /xmlgraphics/fop/branches/Temp_ImproveAccessibility: ./ src/java/org/apache/fop/accessibility/ src/java/org/apache/fop/accessibility/fo/ src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/f...
Date Fri, 27 Jan 2012 15:36:08 GMT
Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/Inline.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/Inline.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/Inline.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/Inline.java Fri Jan 27 15:36:05 2012
@@ -26,19 +26,17 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.properties.StructurePointerPropertySet;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_inline">
  * <code>fo:inline</code></a> formatting object.
  */
-public class Inline extends InlineLevel implements StructurePointerPropertySet {
+public class Inline extends InlineLevel {
     // The value of properties relevant for fo:inline.
     // See also superclass InlineLevel
     private Length alignmentAdjust;
     private int alignmentBaseline;
     private Length baselineShift;
-    private String ptr;  // used for accessibility
     private int dominantBaseline;
     // Unused but valid items, commented out for performance:
     //     private CommonRelativePosition commonRelativePosition;
@@ -147,16 +145,6 @@ public class Inline extends InlineLevel 
         return dominantBaseline;
     }
 
-    @Override
-    public void setPtr(String ptr) {
-        this.ptr = ptr;
-    }
-
-    /** {@inheritDoc} */
-    public String getPtr() {
-        return ptr;
-    }
-
     /** {@inheritDoc} */
     public String getLocalName() {
         return "inline";

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/PageNumber.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/PageNumber.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/PageNumber.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/PageNumber.java Fri Jan 27 15:36:05 2012
@@ -23,6 +23,7 @@ import java.awt.Color;
 
 import org.xml.sax.Locator;
 
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.Constants;
@@ -36,14 +37,14 @@ import org.apache.fop.fo.properties.Comm
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonTextDecoration;
 import org.apache.fop.fo.properties.SpaceProperty;
-import org.apache.fop.fo.properties.StructurePointerPropertySet;
+import org.apache.fop.fo.properties.StructureTreeElementHolder;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-number">
  * <code>fo:page-number</code></a> object.
  */
 public class PageNumber extends FObj
-        implements StructurePointerPropertySet, CommonAccessibilityHolder {
+        implements StructureTreeElementHolder, CommonAccessibilityHolder {
     // The value of properties relevant for fo:page-number.
     private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
@@ -52,7 +53,7 @@ public class PageNumber extends FObj
     private int alignmentBaseline;
     private Length baselineShift;
     private int dominantBaseline;
-    private String ptr; // used for accessibility
+    private StructureTreeElement structureTreeElement;
     // private ToBeImplementedProperty letterSpacing;
     private SpaceProperty lineHeight;
     /** Holds the text decoration values. May be null */
@@ -176,13 +177,13 @@ public class PageNumber extends FObj
     }
 
     @Override
-    public void setPtr(String ptr) {
-        this.ptr = ptr;
+    public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
+        this.structureTreeElement = structureTreeElement;
     }
 
     /** {@inheritDoc} */
-    public String getPtr() {
-        return ptr;
+    public StructureTreeElement getStructureTreeElement() {
+        return structureTreeElement;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/table/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/table/TableFObj.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/table/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/flow/table/TableFObj.java Fri Jan 27 15:36:05 2012
@@ -36,19 +36,17 @@ import org.apache.fop.fo.properties.Enum
 import org.apache.fop.fo.properties.NumberProperty;
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.PropertyMaker;
-import org.apache.fop.fo.properties.StructurePointerPropertySet;
 import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
 
 /**
  * Common base class for table-related FOs
  */
-public abstract class TableFObj extends FObj implements StructurePointerPropertySet {
+public abstract class TableFObj extends FObj {
 
     private Numeric borderAfterPrecedence;
     private Numeric borderBeforePrecedence;
     private Numeric borderEndPrecedence;
     private Numeric borderStartPrecedence;
-    private String ptr;
 
     ConditionalBorder borderBefore;             // CSOK: VisibilityModifier
     ConditionalBorder borderAfter;              // CSOK: VisibilityModifier
@@ -240,16 +238,6 @@ public abstract class TableFObj extends 
         }
     }
 
-    @Override
-    public void setPtr(String ptr) {
-        this.ptr = ptr;
-    }
-
-    /** {@inheritDoc} */
-    public String getPtr() {
-        return ptr;
-    }
-
     /**
      * Prepares the borders of this element if the collapsing-border model is in use.
      * Conflict resolution with parent elements is done where applicable.

Copied: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructureTreeElementHolder.java (from r1236706, xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructurePointerPropertySet.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructureTreeElementHolder.java?p2=xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructureTreeElementHolder.java&p1=xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructurePointerPropertySet.java&r1=1236706&r2=1236718&rev=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructurePointerPropertySet.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/fo/properties/StructureTreeElementHolder.java Fri Jan 27 15:36:05 2012
@@ -19,16 +19,20 @@
 
 package org.apache.fop.fo.properties;
 
+import org.apache.fop.accessibility.StructureTreeElement;
+
 /**
- * Defines property access methods for internal structure pointer extension properties.
+ * Implementations of this interface can return the element in the document's
+ * structure tree that they resulted into. Used for tagged PDF and other formats
+ * that support a structure tree in addition to paged content.
  */
-public interface StructurePointerPropertySet {
+public interface StructureTreeElementHolder {
 
     /**
-     * Returns the value of the "foi:ptr" property, the internal structure pointer used
-     * for tagged PDF and other formats that support a structure tree in addition to paged content.
-     * @return the "foi:ptr" property
+     * Returns the element in the document's structure tree that corresponds to this instance.
+     *
+     * @return a structure tree element
      */
-    String getPtr();
+    StructureTreeElement getStructureTreeElement();
 
 }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -329,7 +329,6 @@ public class BlockLayoutManager extends 
 
         addMarkersToPage(false, isFirst(firstPos), isLast(lastPos));
 
-        TraitSetter.addPtr(curBlockArea, getBlockFO().getPtr());  // used for accessibility
         TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(),
                 effSpaceBefore, effSpaceAfter);
         flush();

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/TraitSetter.java Fri Jan 27 15:36:05 2012
@@ -22,6 +22,7 @@ package org.apache.fop.layoutmgr;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.datatypes.LengthBase;
@@ -29,9 +30,9 @@ import org.apache.fop.datatypes.PercentB
 import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonTextDecoration;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.MinOptMax;
@@ -591,13 +592,14 @@ public final class TraitSetter {
     }
 
     /**
-     * Adds the ptr trait to the area.
+     * Sets the structure tree element associated to the given area.
+     *
      * @param area the area to set the traits on
-     * @param ptr string
+     * @param structureTreeElement the element the area is associated to in the document structure
      */
-    public static void addPtr(Area area, String ptr) {
-        if (ptr != null && ptr.length() > 0) {
-            area.addTrait(Trait.PTR, ptr);
+    public static void addStructureTreeElement(Area area, StructureTreeElement structureTreeElement) {
+        if (structureTreeElement != null) {
+            area.addTrait(Trait.STRUCTURE_TREE_ELEMENT, structureTreeElement);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -85,7 +85,7 @@ public abstract class AbstractGraphicsLa
         transferForeignAttributes(viewportArea);
 
         InlineViewport vp = new InlineViewport(viewportArea);
-        TraitSetter.addPtr(vp, fobj.getPtr());  // used for accessibility
+        TraitSetter.addStructureTreeElement(vp, fobj.getStructureTreeElement());
         TraitSetter.setProducerID(vp, fobj.getId());
         vp.setIPD(imageLayout.getViewportSize().width);
         vp.setBPD(imageLayout.getViewportSize().height);

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -136,7 +136,7 @@ public abstract class AbstractPageNumber
         text.setBaselineOffset(font.getAscender());
         TraitSetter.addFontTraits(text, font);
         text.addTrait(Trait.COLOR, fobj.getColor());
-        TraitSetter.addPtr(text, fobj.getPtr());   // used for accessibility
+        TraitSetter.addStructureTreeElement(text, fobj.getStructureTreeElement());
         TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -59,7 +59,7 @@ public class BasicLinkLayoutManager exte
     private void setupBasicLinkArea(InlineArea area) {
         BasicLink fobj = (BasicLink) this.fobj;
         // internal destinations take precedence:
-        TraitSetter.addPtr(area, fobj.getPtr()); // used for accessibility
+        TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
         if (fobj.hasInternalDestination()) {
             String idref = fobj.getInternalDestination();
             PageSequenceLayoutManager pslm = getPSLM();

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -87,7 +87,7 @@ public class CharacterLayoutManager exte
         }
         TraitSetter.setProducerID(text, node.getId());
         TraitSetter.addTextDecoration(text, node.getTextDecoration());
-        TraitSetter.addPtr(text, node.getPtr()); // used for accessibility
+        TraitSetter.addStructureTreeElement(text, node.getStructureTreeElement());
         return text;
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -19,13 +19,13 @@
 
 package org.apache.fop.layoutmgr.inline;
 
+import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.fo.flow.PageNumber;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.Trait;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.MinOptMax;
@@ -85,7 +85,7 @@ public class PageNumberLayoutManager ext
         text.setBaselineOffset(font.getAscender());
         TraitSetter.addFontTraits(text, font);
         text.addTrait(Trait.COLOR, fobj.getColor());
-        TraitSetter.addPtr(text, fobj.getPtr()); // used for accessibility
+        TraitSetter.addStructureTreeElement(text, fobj.getStructureTreeElement());
         TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
 
         return text;

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Fri Jan 27 15:36:05 2012
@@ -31,8 +31,6 @@ import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FOText;
-import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.properties.StructurePointerPropertySet;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontSelector;
 import org.apache.fop.layoutmgr.InlineKnuthSequence;
@@ -438,7 +436,7 @@ public class TextLayoutManager extends L
             setText();
             TraitSetter.addFontTraits(textArea, font);
             textArea.addTrait(Trait.COLOR, foText.getColor());
-            TraitSetter.addPtr(textArea, getPtr()); // used for accessibility
+            TraitSetter.addStructureTreeElement(textArea, foText.getStructureTreeElement());
             TraitSetter.addTextDecoration(textArea, foText.getTextDecoration());
             TraitSetter.addFontTraits(textArea, font);
             return textArea;
@@ -577,20 +575,6 @@ public class TextLayoutManager extends L
         }
     }
 
-    /**
-     * used for accessibility
-     * @return ptr of fobj
-     */
-    private String getPtr() {
-        FObj fobj = parentLayoutManager.getFObj();
-        if (fobj instanceof StructurePointerPropertySet) {
-            return (((StructurePointerPropertySet) fobj).getPtr());
-        } else {
-            //No structure pointer applicable
-            return null;
-        }
-    }
-
     private AreaInfo getAreaInfo(int index) {
         return (AreaInfo) areaInfos.get(index);
     }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/pdf/PDFStructElem.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/pdf/PDFStructElem.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/pdf/PDFStructElem.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/pdf/PDFStructElem.java Fri Jan 27 15:36:05 2012
@@ -19,18 +19,29 @@
 
 package org.apache.fop.pdf;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.util.LanguageTags;
 
 /**
  * Class representing a PDF Structure Element.
  */
-public class PDFStructElem extends PDFDictionary {
+public class PDFStructElem extends PDFDictionary implements StructureTreeElement {
 
     private PDFStructElem parentElement;
 
     /**
+     * Elements to be added to the kids array.
+     */
+    protected List<PDFObject> kids;
+
+    /**
      * Creates a new structure element.
      *
      * @param parent parent of this element
@@ -57,21 +68,12 @@ public class PDFStructElem extends PDFDi
 
     /** {@inheritDoc} */
     public void setParent(PDFObject parent) {
-        if (parent != null) {
+        if (parent != null && parent.hasObjectNumber()) {
            put("P", new PDFReference(parent));
         }
     }
 
     /**
-     * Returns the kids of this structure element.
-     *
-     * @return the value of the K entry
-     */
-    private PDFArray getKids() {
-        return (PDFArray) get("K");
-    }
-
-    /**
      * Add a kid to this structure element. This element will then add itself to
      * its parent structure element if it has not already, and so will the
      * parent, and so on.
@@ -79,24 +81,10 @@ public class PDFStructElem extends PDFDi
      * @param kid element to be added
      */
     public void addKid(PDFObject kid) {
-        PDFArray kids = getKids();
         if (kids == null) {
-            kids = new PDFArray();
-            put("K", kids);
+            kids = new ArrayList<PDFObject>();
         }
         kids.add(kid);
-        joinHierarchy();
-    }
-
-    private boolean containsKid(PDFObject kid) {
-        PDFArray kids = getKids();
-        return kids != null && kids.contains(kid);
-    }
-
-    private void joinHierarchy() {
-        if (parentElement != null && !parentElement.containsKid(this)) {
-            parentElement.addKid(this);
-        }
     }
 
     /**
@@ -109,7 +97,6 @@ public class PDFStructElem extends PDFDi
      */
     public void setMCIDKid(int mcid) {
         put("K", mcid);
-        joinHierarchy();
     }
 
     /**
@@ -127,7 +114,7 @@ public class PDFStructElem extends PDFDi
      * @return the value of the S entry
      */
     public PDFName getStructureType() {
-        return (PDFName)get("S");
+        return (PDFName) get("S");
     }
 
     /**
@@ -154,6 +141,63 @@ public class PDFStructElem extends PDFDi
      * @return the value of the Lang entry (<code>null</code> if no language was specified)
      */
     public String getLanguage() {
-        return (String)get("Lang");
+        return (String) get("Lang");
+    }
+
+    @Override
+    protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
+        attachKids();
+        super.writeDictionary(out, writer);
     }
+
+    /**
+     * Attaches all valid kids to the kids array.
+     *
+     * @return true iff 1+ kids were added to the kids array
+     */
+    protected boolean attachKids() {
+        List<PDFObject> validKids = new ArrayList<PDFObject>();
+        if (kids != null) {
+            for (PDFObject kid : kids) {
+                if (kid instanceof Placeholder)  {
+                    if (((Placeholder) kid).attachKids()) {
+                        validKids.add(kid);
+                    }
+                } else {
+                    validKids.add(kid);
+                }
+            }
+        }
+        boolean kidsAttached = !validKids.isEmpty();
+        if (kidsAttached) {
+            PDFArray array = new PDFArray();
+            for (PDFObject ob : validKids) {
+                array.add(ob);
+            }
+            put("K", array);
+        }
+        return kidsAttached;
+    }
+
+    public static class Placeholder extends PDFStructElem {
+
+        @Override
+        public void outputInline(OutputStream out, Writer writer) throws IOException {
+            if (kids != null) {
+                assert kids.size() > 0;
+                for (int i = 0; i < kids.size(); i++) {
+                    if (i > 0) {
+                        writer.write(' ');
+                    }
+                    Object obj = kids.get(i);
+                    formatObject(obj, out, writer);
+                }
+            }
+        }
+
+        public Placeholder(PDFObject parent, String name) {
+            super(parent, new PDFName(name));
+        }
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFContext.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFContext.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFContext.java Fri Jan 27 15:36:05 2012
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.apps.FOUserAgent;
 
 /**
@@ -46,7 +47,7 @@ public class IFContext {
 
     private Locale language;
 
-    private String structurePointer;
+    private StructureTreeElement structureTreeElement;
 
     private String id = "";
 
@@ -132,29 +133,31 @@ public class IFContext {
     }
 
     /**
-     * Sets the structure pointer for the following painted marks. This method is used when
-     * accessibility features are enabled.
-     * @param ptr the structure pointer
+     * Sets the structure tree element to which the subsequently painted marks
+     * will correspond. This method is used when accessibility features are
+     * enabled.
+     *
+     * @param structureTreeElement the structure tree element
      */
-    public void setStructurePointer(String ptr) {
-        this.structurePointer = ptr;
+    public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
+        this.structureTreeElement = structureTreeElement;
     }
 
     /**
-     * Resets the current structure pointer.
-     * @see #setStructurePointer(String)
+     * Resets the current structure tree element.
+     * @see #setStructureTreeElement(String)
      */
-    public void resetStructurePointer() {
-        setStructurePointer(null);
+    public void resetStructureTreeElement() {
+        setStructureTreeElement(null);
     }
 
     /**
-     * Returns the current structure pointer.
-     * @return the structure pointer (or null if no pointer is active)
-     * @see #setStructurePointer(String)
+     * Returns the current structure tree element.
+     * @return the structure tree element (or null if no element is active)
+     * @see #setStructureTreeElement(String)
      */
-    public String getStructurePointer() {
-        return this.structurePointer;
+    public StructureTreeElement getStructureTreeElement() {
+        return this.structureTreeElement;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFParser.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFParser.java Fri Jan 27 15:36:05 2012
@@ -49,11 +49,13 @@ import org.apache.commons.logging.LogFac
 import org.apache.xmlgraphics.util.QName;
 
 import org.apache.fop.accessibility.AccessibilityEventProducer;
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.accessibility.StructureTreeEventHandler;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.ElementMappingRegistry;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.extensions.InternalElementMapping;
 import org.apache.fop.render.intermediate.extensions.DocumentNavigationExtensionConstants;
 import org.apache.fop.render.intermediate.extensions.DocumentNavigationHandler;
 import org.apache.fop.traits.BorderProps;
@@ -158,6 +160,9 @@ public class IFParser implements IFConst
 
         private Attributes pageSequenceAttributes;
 
+        private Map<String, StructureTreeElement> structureTreeElements =
+                new HashMap<String, StructureTreeElement>();
+
         private final class StructureTreeHandler extends DefaultHandler {
 
             private final StructureTreeEventHandler structureTreeEventHandler;
@@ -177,7 +182,23 @@ public class IFParser implements IFConst
             public void startElement(String uri, String localName, String qName,
                     Attributes attributes) throws SAXException {
                 if (!"structure-tree".equals(localName)) {
-                    structureTreeEventHandler.startNode(localName, attributes);
+                    if (localName.equals("marked-content")) {
+                        localName = "#PCDATA";
+                    }
+                    String structID = attributes.getValue(InternalElementMapping.URI,
+                            InternalElementMapping.STRUCT_ID);
+                    if (structID == null) {
+                        structureTreeEventHandler.startNode(localName, attributes);
+                    } else if (localName.equals("external-graphic")
+                            || localName.equals("instream-foreign-object")) {
+                        StructureTreeElement structureTreeElement =
+                            structureTreeEventHandler.startImageNode(localName, attributes);
+                        structureTreeElements.put(structID, structureTreeElement);
+                    } else {
+                        StructureTreeElement structureTreeElement =
+                            structureTreeEventHandler.startReferencedNode(localName, attributes);
+                        structureTreeElements.put(structID, structureTreeElement);
+                    }
                 }
             }
 
@@ -225,14 +246,6 @@ public class IFParser implements IFConst
             documentHandler.getContext().resetForeignAttributes();
         }
 
-        private void establishStructurePointer(String ptr) {
-            documentHandler.getContext().setStructurePointer(ptr);
-        }
-
-        private void resetStructurePointer() {
-            documentHandler.getContext().resetStructurePointer();
-        }
-
         /** {@inheritDoc} */
         public void startElement(String uri, String localName, String qName, Attributes attributes)
                     throws SAXException {
@@ -276,7 +289,7 @@ public class IFParser implements IFConst
                 } else if (DocumentNavigationExtensionConstants.NAMESPACE.equals(uri)) {
                     if (this.navParser == null) {
                         this.navParser = new DocumentNavigationHandler(
-                                this.documentHandler.getDocumentNavigationHandler());
+                                this.documentHandler.getDocumentNavigationHandler(), structureTreeElements);
                     }
                     delegate = this.navParser;
                     delegateDepth++;
@@ -604,9 +617,9 @@ public class IFParser implements IFConst
                 s = lastAttributes.getValue("word-spacing");
                 int wordSpacing = (s != null ? Integer.parseInt(s) : 0);
                 int[] dx = XMLUtil.getAttributeAsIntArray(lastAttributes, "dx");
-                setStructurePointer(lastAttributes);
+                establishStructureTreeElement(lastAttributes);
                 painter.drawText(x, y, letterSpacing, wordSpacing, dx, content.toString());
-                resetStructurePointer();
+                resetStructureTreeElement();
             }
 
             public boolean ignoreCharacters() {
@@ -701,7 +714,7 @@ public class IFParser implements IFConst
                 int height = Integer.parseInt(lastAttributes.getValue("height"));
                 Map<QName, String> foreignAttributes = getForeignAttributes(lastAttributes);
                 establishForeignAttributes(foreignAttributes);
-                setStructurePointer(lastAttributes);
+                establishStructureTreeElement(lastAttributes);
                 if (foreignObject != null) {
                     painter.drawImage(foreignObject,
                             new Rectangle(x, y, width, height));
@@ -715,7 +728,7 @@ public class IFParser implements IFConst
                     painter.drawImage(uri, new Rectangle(x, y, width, height));
                 }
                 resetForeignAttributes();
-                resetStructurePointer();
+                resetStructureTreeElement();
                 inForeignObject = false;
             }
 
@@ -769,13 +782,20 @@ public class IFParser implements IFConst
             return foreignAttributes;
         }
 
-        private void setStructurePointer(Attributes attributes) {
-            String ptr = attributes.getValue("ptr");
-            if (ptr != null && ptr.length() > 0) {
-                establishStructurePointer(ptr);
+        private void establishStructureTreeElement(Attributes attributes) {
+            String structRef = attributes.getValue(InternalElementMapping.URI,
+                    InternalElementMapping.STRUCT_REF);
+            if (structRef != null && structRef.length() > 0) {
+                assert structureTreeElements.containsKey(structRef);
+                StructureTreeElement structureTreeElement = structureTreeElements.get(structRef);
+                documentHandler.getContext().setStructureTreeElement(structureTreeElement);
             }
         }
 
+        private void resetStructureTreeElement() {
+            documentHandler.getContext().resetStructureTreeElement();
+        }
+
         /** {@inheritDoc} */
         public void characters(char[] ch, int start, int length) throws SAXException {
             if (delegate != null) {

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFRenderer.java Fri Jan 27 15:36:05 2012
@@ -50,6 +50,7 @@ import org.apache.xmlgraphics.xmp.schema
 import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
 
 import org.apache.fop.Version;
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
@@ -629,12 +630,12 @@ public class IFRenderer extends Abstract
         documentHandler.getContext().resetForeignAttributes();
     }
 
-    private void establishStructurePointer(String ptr) {
-        documentHandler.getContext().setStructurePointer(ptr);
+    private void establishStructureTreeElement(StructureTreeElement structureTreeElement) {
+        documentHandler.getContext().setStructureTreeElement(structureTreeElement);
     }
 
     private void resetStructurePointer() {
-        documentHandler.getContext().resetStructurePointer();
+        documentHandler.getContext().resetStructureTreeElement();
     }
 
     /** {@inheritDoc} */
@@ -851,8 +852,9 @@ public class IFRenderer extends Abstract
 
     /** {@inheritDoc} */
     public void renderInlineViewport(InlineViewport viewport) {
-        String ptr = (String) viewport.getTrait(Trait.PTR);
-        establishStructurePointer(ptr);
+        StructureTreeElement structElem =
+                (StructureTreeElement) viewport.getTrait(Trait.STRUCTURE_TREE_ELEMENT);
+        establishStructureTreeElement(structElem);
         pushdID(viewport);
         Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD());
         viewportDimensionStack.push(dim);
@@ -912,7 +914,6 @@ public class IFRenderer extends Abstract
         // stuff we only need if a link must be created:
         Rectangle ipRect = null;
         AbstractAction action = null;
-        String ptr = (String) ip.getTrait(Trait.PTR); // used for accessibility
         // make sure the rect is determined *before* calling super!
         int ipp = currentIPPosition;
         int bpp = currentBPPosition + ip.getOffset();
@@ -956,7 +957,9 @@ public class IFRenderer extends Abstract
 
         // warn if link trait found but not allowed, else create link
         if (linkTraitFound) {
-            action.setStructurePointer(ptr);  // used for accessibility
+            StructureTreeElement structElem =
+                    (StructureTreeElement) ip.getTrait(Trait.STRUCTURE_TREE_ELEMENT);
+            action.setStructureTreeElement(structElem);
             Link link = new Link(action, ipRect);
             this.deferredLinks.add(link);
         }
@@ -1009,8 +1012,8 @@ public class IFRenderer extends Abstract
 
         String fontName = getInternalFontNameForArea(text);
         int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
-        String ptr = (String)text.getTrait(Trait.PTR); // used for accessibility
-        establishStructurePointer(ptr);
+        StructureTreeElement structElem = (StructureTreeElement) text.getTrait(Trait.STRUCTURE_TREE_ELEMENT);
+        establishStructureTreeElement(structElem);
 
         // This assumes that *all* CIDFonts use a /ToUnicode mapping
         Typeface tf = getTypeface(fontName);

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java Fri Jan 27 15:36:05 2012
@@ -38,9 +38,11 @@ import org.apache.xmlgraphics.util.QName
 import org.apache.xmlgraphics.util.XMLizable;
 
 import org.apache.fop.accessibility.StructureTreeEventHandler;
+import org.apache.fop.fo.extensions.InternalElementMapping;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.render.PrintRendererConfigurator;
 import org.apache.fop.render.RenderingContext;
+import org.apache.fop.render.intermediate.IFStructureTreeBuilder.IFStructureTreeElement;
 import org.apache.fop.render.intermediate.extensions.AbstractAction;
 import org.apache.fop.render.intermediate.extensions.Bookmark;
 import org.apache.fop.render.intermediate.extensions.BookmarkTree;
@@ -163,6 +165,7 @@ public class IFSerializer extends Abstra
             handler.startPrefixMapping(XLINK_PREFIX, XLINK_NAMESPACE);
             handler.startPrefixMapping(DocumentNavigationExtensionConstants.PREFIX,
                     DocumentNavigationExtensionConstants.NAMESPACE);
+            handler.startPrefixMapping(InternalElementMapping.STANDARD_PREFIX, InternalElementMapping.URI);
             handler.startElement(EL_DOCUMENT);
         } catch (SAXException e) {
             throw new IFException("SAX error in startDocument()", e);
@@ -439,7 +442,7 @@ public class IFSerializer extends Abstra
             addAttribute(atts, "width", Integer.toString(rect.width));
             addAttribute(atts, "height", Integer.toString(rect.height));
             addForeignAttributes(atts);
-            addStructurePointerAttribute(atts);
+            addStructureReference(atts);
             handler.element(EL_IMAGE, atts);
         } catch (SAXException e) {
             throw new IFException("SAX error in startGroup()", e);
@@ -467,7 +470,7 @@ public class IFSerializer extends Abstra
             addAttribute(atts, "width", Integer.toString(rect.width));
             addAttribute(atts, "height", Integer.toString(rect.height));
             addForeignAttributes(atts);
-            addStructurePointerAttribute(atts);
+            addStructureReference(atts);
             handler.startElement(EL_IMAGE, atts);
             new DOM2SAX(handler).writeDocument(doc, true);
             handler.endElement(EL_IMAGE);
@@ -582,7 +585,7 @@ public class IFSerializer extends Abstra
             if (dx != null) {
                 addAttribute(atts, "dx", IFUtil.toString(dx));
             }
-            addStructurePointerAttribute(atts);
+            addStructureReference(atts);
             handler.startElement(EL_TEXT, atts);
             char[] chars = text.toCharArray();
             handler.characters(chars, 0, chars.length);
@@ -682,13 +685,22 @@ public class IFSerializer extends Abstra
         XMLUtil.addAttribute(atts, localName, value);
     }
 
-    private void addStructurePointerAttribute(AttributesImpl atts) {
-        String ptr = getContext().getStructurePointer();
-        if (ptr != null) {
-            addAttribute(atts, "ptr", ptr);
+    private void addStructureReference(AttributesImpl atts) {
+        IFStructureTreeElement structureTreeElement =
+                (IFStructureTreeElement) getContext().getStructureTreeElement();
+        if (structureTreeElement != null) {
+            addStructRefAttribute(atts, structureTreeElement.id);
         }
     }
 
+    private void addStructRefAttribute(AttributesImpl atts, String id) {
+        atts.addAttribute(InternalElementMapping.URI,
+                InternalElementMapping.STRUCT_REF,
+                InternalElementMapping.STANDARD_PREFIX + ":" + InternalElementMapping.STRUCT_REF,
+                XMLConstants.CDATA,
+                id);
+    }
+
     private void addID() throws SAXException {
         String id = getContext().getID();
         if (!currentID.equals(id)) {
@@ -773,7 +785,8 @@ public class IFSerializer extends Abstra
         atts.addAttribute(null, "rect", "rect",
                 XMLConstants.CDATA, IFUtil.toString(link.getTargetRect()));
         if (getUserAgent().isAccessibilityEnabled()) {
-            addAttribute(atts, "ptr", link.getAction().getStructurePointer());
+            addStructRefAttribute(atts,
+                    ((IFStructureTreeElement) link.getAction().getStructureTreeElement()).id);
         }
         try {
             handler.startElement(DocumentNavigationExtensionConstants.LINK, atts);

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java Fri Jan 27 15:36:05 2012
@@ -26,10 +26,14 @@ import java.util.Locale;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
 import org.xml.sax.helpers.DefaultHandler;
 
 import org.apache.fop.accessibility.StructureTree2SAXEventAdapter;
+import org.apache.fop.accessibility.StructureTreeElement;
 import org.apache.fop.accessibility.StructureTreeEventHandler;
+import org.apache.fop.fo.extensions.InternalElementMapping;
+import org.apache.fop.util.XMLUtil;
 
 /**
  * Saves structure tree events as SAX events in order to replay them when it's
@@ -37,42 +41,17 @@ import org.apache.fop.accessibility.Stru
  */
 final class IFStructureTreeBuilder implements StructureTreeEventHandler {
 
-    private StructureTreeEventHandler delegate;
-
-    private final List<SAXEventRecorder> pageSequenceEventRecorders = new ArrayList<SAXEventRecorder>();
+    static final class IFStructureTreeElement implements StructureTreeElement {
 
-    /**
-     * Replay SAX events for a page sequence.
-     * @param handler The handler that receives SAX events
-     * @param pageSequenceIndex The index of the page sequence
-     * @throws SAXException
-     */
-    public void replayEventsForPageSequence(ContentHandler handler,
-            int pageSequenceIndex) throws SAXException {
-        pageSequenceEventRecorders.get(pageSequenceIndex).replay(handler);
-    }
+        final String id;
 
-    /** {@inheritDoc} */
-    public void startPageSequence(Locale locale) {
-        SAXEventRecorder eventRecorder = new SAXEventRecorder();
-        pageSequenceEventRecorders.add(eventRecorder);
-        delegate = StructureTree2SAXEventAdapter.newInstance(eventRecorder);
-        delegate.startPageSequence(locale);
-    }
-
-    /** {@inheritDoc} */
-    public void endPageSequence() {
-         delegate.endPageSequence();
-    }
-
-    /** {@inheritDoc} */
-    public void startNode(String name, Attributes attributes) {
-        delegate.startNode(name, attributes);
-    }
+        IFStructureTreeElement() {
+            this.id = null;
+        }
 
-    /** {@inheritDoc} */
-    public void endNode(String name) {
-        delegate.endNode(name);
+        IFStructureTreeElement(String id) {
+            this.id = id;
+        }
     }
 
     /** A SAX handler that records events to replay them later. */
@@ -159,22 +138,22 @@ final class IFStructureTreeBuilder imple
         public void startElement(String uri, String localName, String qName,
                 Attributes attributes) throws SAXException {
             events.add(new StartElement(uri, localName, qName, attributes));
-        };
+        }
 
         @Override
         public void endElement(String uri, String localName, String qName) throws SAXException {
             events.add(new EndElement(uri, localName, qName));
-        };
+        }
 
         @Override
         public void startPrefixMapping(String prefix, String uri) throws SAXException {
             events.add(new StartPrefixMapping(prefix, uri));
-        };
+        }
 
         @Override
         public void endPrefixMapping(String prefix) throws SAXException {
             events.add(new EndPrefixMapping(prefix));
-        };
+        }
 
         /**
          * Replays the recorded events.
@@ -187,4 +166,69 @@ final class IFStructureTreeBuilder imple
             }
         }
     }
+
+    private StructureTreeEventHandler delegate;
+
+    private final List<SAXEventRecorder> pageSequenceEventRecorders = new ArrayList<SAXEventRecorder>();
+
+    private int idCounter;
+
+    /**
+     * Replay SAX events for a page sequence.
+     * @param handler The handler that receives SAX events
+     * @param pageSequenceIndex The index of the page sequence
+     * @throws SAXException
+     */
+    public void replayEventsForPageSequence(ContentHandler handler,
+            int pageSequenceIndex) throws SAXException {
+        pageSequenceEventRecorders.get(pageSequenceIndex).replay(handler);
+    }
+
+    public void startPageSequence(Locale locale) {
+        SAXEventRecorder eventRecorder = new SAXEventRecorder();
+        pageSequenceEventRecorders.add(eventRecorder);
+        delegate = StructureTree2SAXEventAdapter.newInstance(eventRecorder);
+        delegate.startPageSequence(locale);
+    }
+
+    public void endPageSequence() {
+         delegate.endPageSequence();
+    }
+
+    public StructureTreeElement startNode(String name, Attributes attributes) {
+        delegate.startNode(name, attributes);
+        return new IFStructureTreeElement();
+    }
+
+    public void endNode(String name) {
+        delegate.endNode(name);
+    }
+
+    public StructureTreeElement startImageNode(String name, Attributes attributes) {
+        String id = getNextID();
+        AttributesImpl atts = addIDAttribute(attributes, id);
+        delegate.startImageNode(name, atts);
+        return new IFStructureTreeElement(id);
+    }
+
+    public StructureTreeElement startReferencedNode(String name, Attributes attributes) {
+        String id = getNextID();
+        AttributesImpl atts = addIDAttribute(attributes, id);
+        delegate.startReferencedNode(name, atts);
+        return new IFStructureTreeElement(id);
+    }
+
+    private String getNextID() {
+        return Integer.toHexString(idCounter++);
+    }
+
+    private AttributesImpl addIDAttribute(Attributes attributes, String id) {
+        AttributesImpl atts = new AttributesImpl(attributes);
+        atts.addAttribute(InternalElementMapping.URI,
+                InternalElementMapping.STRUCT_ID,
+                InternalElementMapping.STANDARD_PREFIX + ":" + InternalElementMapping.STRUCT_ID,
+                XMLUtil.CDATA,
+                id);
+        return atts;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/AbstractAction.java Fri Jan 27 15:36:05 2012
@@ -21,13 +21,15 @@ package org.apache.fop.render.intermedia
 
 import org.apache.xmlgraphics.util.XMLizable;
 
+import org.apache.fop.accessibility.StructureTreeElement;
+
 /**
  * Abstract base class for document actions, like "go-to" actions with absolute page coordinates.
  */
 public abstract class AbstractAction implements XMLizable {
 
     private String id;
-    private String structurePointer;
+    private StructureTreeElement structureTreeElement;
 
     /**
      * Sets an ID to make the action referencable.
@@ -47,18 +49,18 @@ public abstract class AbstractAction imp
 
     /**
      * Sets the structure element corresponding to this action.
-     * @param structurePointer a reference to the structure element
+     * @param structureTreeElement a reference to the structure element
      */
-    public void setStructurePointer(String structurePointer) {
-        this.structurePointer = structurePointer;
+    public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
+        this.structureTreeElement = structureTreeElement;
     }
 
     /**
      * Returns the structure element corresponding to this action.
      * @return the reference to the structure element
      */
-    public String getStructurePointer() {
-        return structurePointer;
+    public StructureTreeElement getStructureTreeElement() {
+        return structureTreeElement;
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java Fri Jan 27 15:36:05 2012
@@ -21,6 +21,7 @@ package org.apache.fop.render.intermedia
 
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.util.Map;
 import java.util.Stack;
 
 import org.xml.sax.Attributes;
@@ -30,6 +31,8 @@ import org.xml.sax.helpers.DefaultHandle
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.accessibility.StructureTreeElement;
+import org.apache.fop.fo.extensions.InternalElementMapping;
 import org.apache.fop.render.intermediate.IFDocumentNavigationHandler;
 import org.apache.fop.render.intermediate.IFException;
 import org.apache.fop.util.XMLUtil;
@@ -48,14 +51,20 @@ public class DocumentNavigationHandler e
 
     private IFDocumentNavigationHandler navHandler;
 
-    private String structurePointer;
+    private StructureTreeElement structureTreeElement;
+
+    private Map<String, StructureTreeElement> structureTreeElements;
 
     /**
      * Main constructor.
      * @param navHandler the navigation handler that will receive the events
+     * @param structureTreeElements the elements representing the structure of the document
      */
-    public DocumentNavigationHandler(IFDocumentNavigationHandler navHandler) {
+    public DocumentNavigationHandler(IFDocumentNavigationHandler navHandler,
+            Map<String, StructureTreeElement> structureTreeElements) {
         this.navHandler = navHandler;
+        assert structureTreeElements != null;
+        this.structureTreeElements = structureTreeElements;
     }
 
     /** {@inheritDoc} */
@@ -98,7 +107,8 @@ public class DocumentNavigationHandler e
                     throw new SAXException(localName + " must be the root element!");
                 }
                 Rectangle targetRect = XMLUtil.getAttributeAsRectangle(attributes, "rect");
-                structurePointer = attributes.getValue("ptr");
+                structureTreeElement = structureTreeElements.get(
+                        attributes.getValue(InternalElementMapping.URI, InternalElementMapping.STRUCT_REF));
                 Link link = new Link(null, targetRect);
                 objectStack.push(link);
             } else if (GOTO_XY.getLocalName().equals(localName)) {
@@ -121,8 +131,8 @@ public class DocumentNavigationHandler e
                     }
                     action = new GoToXYAction(id, pageIndex, location);
                 }
-                if (structurePointer != null) {
-                    action.setStructurePointer(structurePointer);
+                if (structureTreeElement != null) {
+                    action.setStructureTreeElement(structureTreeElement);
                 }
                 objectStack.push(action);
             } else if (GOTO_URI.getLocalName().equals(localName)) {
@@ -134,8 +144,8 @@ public class DocumentNavigationHandler e
                 if (id != null) {
                     action.setID(id);
                 }
-                if (structurePointer != null) {
-                    action.setStructurePointer(structurePointer);
+                if (structureTreeElement != null) {
+                    action.setStructureTreeElement(structureTreeElement);
                 }
                 objectStack.push(action);
             } else {

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java Fri Jan 27 15:36:05 2012
@@ -31,6 +31,7 @@ import org.apache.fop.pdf.PDFFactory;
 import org.apache.fop.pdf.PDFGoTo;
 import org.apache.fop.pdf.PDFLink;
 import org.apache.fop.pdf.PDFOutline;
+import org.apache.fop.pdf.PDFStructElem;
 import org.apache.fop.render.intermediate.IFDocumentNavigationHandler;
 import org.apache.fop.render.intermediate.IFException;
 import org.apache.fop.render.intermediate.extensions.AbstractAction;
@@ -111,10 +112,9 @@ public class PDFDocumentNavigationHandle
         PDFLink pdfLink = getPDFDoc().getFactory().makeLink(
                 targetRect2D, pdfAction);
         if (pdfLink != null) {
-            String ptr = link.getAction().getStructurePointer();
-            if (documentHandler.getUserAgent().isAccessibilityEnabled()
-                    && ptr != null && ptr.length() > 0) {
-                documentHandler.getLogicalStructureHandler().addLinkContentItem(pdfLink, ptr);
+            PDFStructElem structure = (PDFStructElem) link.getAction().getStructureTreeElement();
+            if (documentHandler.getUserAgent().isAccessibilityEnabled() && structure != null) {
+                documentHandler.getLogicalStructureHandler().addLinkContentItem(pdfLink, structure);
             }
             documentHandler.currentPage.addAnnotation(pdfLink);
         }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java Fri Jan 27 15:36:05 2012
@@ -19,9 +19,7 @@
 
 package org.apache.fop.render.pdf;
 
-import java.util.HashMap;
 import java.util.Locale;
-import java.util.Map;
 
 import org.apache.fop.pdf.PDFArray;
 import org.apache.fop.pdf.PDFDictionary;
@@ -47,11 +45,6 @@ class PDFLogicalStructureHandler {
 
     private final PDFDocument pdfDoc;
 
-    /**
-     * Map of references to the corresponding structure elements.
-     */
-    private final Map<String, PDFStructElem> structTreeMap = new HashMap<String, PDFStructElem>();
-
     private final PDFParentTree parentTree = new PDFParentTree();
 
     private int parentTreeKey;
@@ -151,100 +144,79 @@ class PDFLogicalStructureHandler {
         parentTree.getNums().put(currentPage.getStructParents(), pageParentTreeArray);
     }
 
-    private MarkedContentInfo addToParentTree(String structurePointer) {
-        PDFStructElem parent = (PDFStructElem) structTreeMap.get(structurePointer);
-        if (parent == null) {
-            return ARTIFACT;
-        } else {
-            pageParentTreeArray.add(parent);
-            String type = parent.getStructureType().toString();
-            int mcid = pageParentTreeArray.length() - 1;
-            return new MarkedContentInfo(type, mcid, parent);
-        }
+    private MarkedContentInfo addToParentTree(PDFStructElem structureTreeElement) {
+        PDFStructElem parent = (structureTreeElement instanceof PDFStructElem.Placeholder)
+                ? structureTreeElement.getParentStructElem()
+                : structureTreeElement;
+        pageParentTreeArray.add(parent);
+        String type = parent.getStructureType().toString();
+        int mcid = pageParentTreeArray.length() - 1;
+        return new MarkedContentInfo(type, mcid, structureTreeElement);
     }
 
     /**
      * Adds a content item corresponding to text into the structure tree, if
      * there is a structure element associated to it.
      *
-     * @param structurePointer reference to the parent structure element of the
-     * piece of text
+     * @param structElem the parent structure element of the piece of text
      * @return the necessary information for bracketing the content as a
      * marked-content sequence. If there is no element in the structure tree
      * associated to that content, returns an instance whose
      * {@link MarkedContentInfo#tag} value is <code>null</code>. The content
      * must then be treated as an artifact.
      */
-    MarkedContentInfo addTextContentItem(String structurePointer) {
-        MarkedContentInfo mci = addToParentTree(structurePointer);
-        if (mci != ARTIFACT) {
+    MarkedContentInfo addTextContentItem(PDFStructElem structElem) {
+        if (structElem == null) {
+            return ARTIFACT;
+        } else {
+            MarkedContentInfo mci = addToParentTree(structElem);
             PDFDictionary contentItem = new PDFDictionary();
             contentItem.put("Type", MCR);
             contentItem.put("Pg", this.currentPage);
             contentItem.put("MCID", mci.mcid);
             mci.parent.addKid(contentItem);
+            return mci;
         }
-        return mci;
     }
 
     /**
      * Adds a content item corresponding to an image into the structure tree, if
      * there is a structure element associated to it.
      *
-     * @param structurePointer reference to the parent structure element of the
-     * image
+     * @param structElem the parent structure element of the image
      * @return the necessary information for bracketing the content as a
      * marked-content sequence. If there is no element in the structure tree
      * associated to that image, returns an instance whose
-     * {@link MarkedContentInfo#tag} value is <code>null</code>. The image
-     * must then be treated as an artifact.
+     * {@link MarkedContentInfo#tag} value is <code>null</code>. The image must
+     * then be treated as an artifact.
      */
-    MarkedContentInfo addImageContentItem(String structurePointer) {
-        MarkedContentInfo mci = addToParentTree(structurePointer);
-        if (mci != ARTIFACT) {
+    MarkedContentInfo addImageContentItem(PDFStructElem structElem) {
+        if (structElem == null) {
+            return ARTIFACT;
+        } else {
+            MarkedContentInfo mci = addToParentTree(structElem);
             mci.parent.setMCIDKid(mci.mcid);
             mci.parent.setPage(this.currentPage);
+            return mci;
         }
-        return mci;
     }
 
-    // While the PDF spec allows images to be referred as PDF objects, this
-    // makes the Acrobat Pro checker complain that the image is not accessible.
-    // Its alt-text is still read aloud though. Using marked-content sequences
-    // like for text works.
-//    MarkedContentInfo addImageObject(String parentReference) {
-//        MarkedContentInfo mci = addToParentTree(parentReference);
-//        if (mci != ARTIFACT) {
-//            PDFDictionary contentItem = new PDFDictionary();
-//            contentItem.put("Type", OBJR);
-//            contentItem.put("Pg", this.currentPage);
-//            contentItem.put("Obj", null);
-//            mci.parent.addKid(contentItem);
-//        }
-//        return mci;
-//    }
-
     /**
      * Adds a content item corresponding to the given link into the structure
      * tree.
      *
      * @param link a link
-     * @param structurePointer reference to the corresponding parent structure element
+     * @param structureTreeElement its parent structure element
      */
-    void addLinkContentItem(PDFLink link, String structurePointer) {
+    void addLinkContentItem(PDFLink link, PDFStructElem structureTreeElement) {
         int structParent = getNextParentTreeKey();
         link.setStructParent(structParent);
         PDFDictionary contentItem = new PDFDictionary();
         contentItem.put("Type", OBJR);
         contentItem.put("Pg", this.currentPage);
         contentItem.put("Obj", link);
-        PDFStructElem parent = (PDFStructElem) structTreeMap.get(structurePointer);
-        parentTree.getNums().put(structParent, parent);
-        parent.addKid(contentItem);
-    }
-
-    void addStructurePointer(String ptr, PDFStructElem structElem) {
-        structTreeMap.put(ptr, structElem);
+        parentTree.getNums().put(structParent, structureTreeElement);
+        structureTreeElement.addKid(contentItem);
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java Fri Jan 27 15:36:05 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);
             }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java Fri Jan 27 15:36:05 2012
@@ -24,10 +24,10 @@ 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.fo.extensions.InternalElementMapping;
 import org.apache.fop.pdf.PDFFactory;
 import org.apache.fop.pdf.PDFStructElem;
 
@@ -61,33 +61,64 @@ class PDFStructureTreeBuilder implements
     public void endPageSequence() {
     }
 
-    public void startNode(String name, Attributes attributes) {
+    public StructureTreeElement startNode(String name, Attributes attributes) {
         PDFStructElem parent = ancestors.getFirst();
         String role = attributes.getValue("role");
-        PDFStructElem created = pdfFactory.makeStructureElement(
-                FOToPDFRoleMap.mapFormattingObject(name, role, parent,
-                        eventBroadcaster), parent);
-        if (ancestors.size() <= 2) { // TODO remove
-            parent.addKid(created);
-        }
-        String ptr = attributes.getValue(InternalElementMapping.URI, "ptr");
-        if (ptr != null) {
-            logicalStructureHandler.addStructurePointer(ptr, created);
+        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 void endImageNode(String name) {
+        removeFirstAncestor();
+    }
 
-        if (name.equals("external-graphic") || name.equals("instream-foreign-object")) {
-            String altTextNode = attributes.getValue(ExtensionElementMapping.URI, "alt-text");
-            if (altTextNode != null) {
-                created.put("Alt", altTextNode);
-            } else {
-                created.put("Alt", "No alternate text specified");
-            }
+    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;
     }
 
-    public void endNode(String name) {
-        ancestors.removeFirst();
+    public void endReferencedNode(String name) {
+        removeFirstAncestor();
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/src/java/org/apache/fop/render/rtf/RTFHandler.java Fri Jan 27 15:36:05 2012
@@ -117,13 +117,13 @@ import org.apache.fop.render.rtf.rtflib.
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem;
+import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel;
 import org.apache.fop.render.rtf.rtflib.tools.BuilderContext;
 import org.apache.fop.render.rtf.rtflib.tools.PercentContext;
 import org.apache.fop.render.rtf.rtflib.tools.TableContext;
@@ -1362,11 +1362,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 +1379,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);
@@ -1558,7 +1556,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) {

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_repeat.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_repeat.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_repeat.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_single.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_single.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_jpg_single.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_repeat.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_repeat.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_repeat.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_single.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_single.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_png_single.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_repeat.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_repeat.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_repeat.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_repeat.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_single.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_single.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_single.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/background-image_svg_single.fo Fri Jan 27 15:36:05 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/branches/Temp_ImproveAccessibility/test/accessibility/complete.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/complete.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/complete.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/complete.fo Fri Jan 27 15:36:05 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>

Modified: xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/image_jpg.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/image_jpg.fo?rev=1236718&r1=1236717&r2=1236718&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/image_jpg.fo (original)
+++ xmlgraphics/fop/branches/Temp_ImproveAccessibility/test/accessibility/image_jpg.fo Fri Jan 27 15:36:05 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"



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


Mime
View raw message