aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2009-10-07 17:31:13 +0000
committerVincent Hennebert <vhennebert@apache.org>2009-10-07 17:31:13 +0000
commitb59502d64ede1cf0737187a9a50623980668af70 (patch)
tree45df2d158ea81741823869677dc57e1352313057
parent834d6b586229731a5a81c8d8e21a8c40c5d809b5 (diff)
downloadxmlgraphics-fop-b59502d64ede1cf0737187a9a50623980668af70.tar.gz
xmlgraphics-fop-b59502d64ede1cf0737187a9a50623980668af70.zip
Fixed support for links and images in the Intermediate Format
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@822808 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFParser.java18
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFSerializer.java8
-rw-r--r--src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java9
3 files changed, 27 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java
index 3dc440692..da96185bf 100644
--- a/src/java/org/apache/fop/render/intermediate/IFParser.java
+++ b/src/java/org/apache/fop/render/intermediate/IFParser.java
@@ -33,8 +33,6 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.sax.SAXTransformerFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
@@ -43,6 +41,9 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.xmlgraphics.util.QName;
import org.apache.fop.accessibility.ParsedStructureTree;
@@ -550,8 +551,7 @@ public class IFParser implements IFConstants {
s = lastAttributes.getValue("word-spacing");
int wordSpacing = (s != null ? Integer.parseInt(s) : 0);
int[] dx = XMLUtil.getAttributeAsIntArray(lastAttributes, "dx");
- String ptr = lastAttributes.getValue("ptr"); // used for accessibility
- establishStructurePointer(ptr);
+ setAccessibilityPointer(lastAttributes);
painter.drawText(x, y, letterSpacing, wordSpacing, dx, content.toString());
resetStructurePointer();
}
@@ -648,8 +648,7 @@ public class IFParser implements IFConstants {
int height = Integer.parseInt(lastAttributes.getValue("height"));
Map foreignAttributes = getForeignAttributes(lastAttributes);
establishForeignAttributes(foreignAttributes);
- String ptr = lastAttributes.getValue("ptr"); // used for accessibility
- establishStructurePointer(ptr);
+ setAccessibilityPointer(lastAttributes);
if (foreignObject != null) {
painter.drawImage(foreignObject,
new Rectangle(x, y, width, height));
@@ -717,6 +716,13 @@ public class IFParser implements IFConstants {
return foreignAttributes;
}
+ private void setAccessibilityPointer(Attributes attributes) {
+ String ptr = attributes.getValue("ptr");
+ if (ptr != null && ptr.length() > 0) {
+ establishStructurePointer(ptr);
+ }
+ }
+
/** {@inheritDoc} */
public void characters(char[] ch, int start, int length) throws SAXException {
if (delegate != null) {
diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
index 281301fbe..b010ee41f 100644
--- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
@@ -419,7 +419,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
}
}
- private void addForeignAttributes(AttributesImpl atts) {
+ private void addForeignAttributes(AttributesImpl atts) throws SAXException {
Map foreignAttributes = getContext().getForeignAttributes();
if (!foreignAttributes.isEmpty()) {
Iterator iter = foreignAttributes.entrySet().iterator();
@@ -646,7 +646,8 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
}
private void addAttribute(AttributesImpl atts,
- org.apache.xmlgraphics.util.QName attribute, String value) {
+ org.apache.xmlgraphics.util.QName attribute, String value) throws SAXException {
+ handler.startPrefixMapping(attribute.getPrefix(), attribute.getNamespaceURI());
XMLUtil.addAttribute(atts, attribute, value);
}
@@ -725,6 +726,9 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
AttributesImpl atts = new AttributesImpl();
atts.addAttribute(null, "rect", "rect",
XMLConstants.CDATA, IFUtil.toString(link.getTargetRect()));
+ if (getUserAgent().isAccessibilityEnabled()) {
+ addAttribute(atts, "ptr", link.getAction().getPtr());
+ }
try {
handler.startElement(DocumentNavigationExtensionConstants.LINK, atts);
serializeXMLizable(link.getAction());
diff --git a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
index 376130838..6a27a929d 100644
--- a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
+++ b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
@@ -48,6 +48,8 @@ public class DocumentNavigationHandler extends DefaultHandler
private IFDocumentNavigationHandler navHandler;
+ private String accessibilityPointer;
+
/**
* Main constructor.
* @param navHandler the navigation handler that will receive the events
@@ -96,6 +98,7 @@ public class DocumentNavigationHandler extends DefaultHandler
throw new SAXException(localName + " must be the root element!");
}
Rectangle targetRect = XMLUtil.getAttributeAsRectangle(attributes, "rect");
+ accessibilityPointer = attributes.getValue("ptr");
Link link = new Link(null, targetRect);
objectStack.push(link);
} else if (GOTO_XY.getLocalName().equals(localName)) {
@@ -118,6 +121,9 @@ public class DocumentNavigationHandler extends DefaultHandler
}
action = new GoToXYAction(id, pageIndex, location);
}
+ if (accessibilityPointer != null) {
+ action.setPtr(accessibilityPointer);
+ }
objectStack.push(action);
} else if (GOTO_URI.getLocalName().equals(localName)) {
String id = attributes.getValue("id");
@@ -128,6 +134,9 @@ public class DocumentNavigationHandler extends DefaultHandler
if (id != null) {
action.setID(id);
}
+ if (accessibilityPointer != null) {
+ action.setPtr(accessibilityPointer);
+ }
objectStack.push(action);
} else {
throw new SAXException(