diff options
author | Peter Hancock <phancock@apache.org> | 2012-01-27 15:36:05 +0000 |
---|---|---|
committer | Peter Hancock <phancock@apache.org> | 2012-01-27 15:36:05 +0000 |
commit | 160d78ce1c348b96e9807f59f3d20bb2226e75c0 (patch) | |
tree | 2649855fe306b6206f7cd9d7b3cf81035b79cee3 /src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java | |
parent | c6fb066a02573904f7ca404605f14c800adf80c5 (diff) | |
download | xmlgraphics-fop-160d78ce1c348b96e9807f59f3d20bb2226e75c0.tar.gz xmlgraphics-fop-160d78ce1c348b96e9807f59f3d20bb2226e75c0.zip |
Associate structure tree elements directly to render content
* Defer the binding of PCData to struct elems using a placeholder mechanism.
* Translate text nodes to marked-content sequences in IF structure tree.
* Replace ptr with structure tree element.
* Re-order table footers so they appear at the end of the structure tree.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImproveAccessibility@1236718 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java')
-rw-r--r-- | src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java index 8ec10b209..3b5b00c33 100644 --- a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java +++ b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java @@ -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 StructureTreeEventHandler { 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(); } } |