Author: vhennebert
Date: Wed Oct 7 17:31:13 2009
New Revision: 822808
URL: http://svn.apache.org/viewvc?rev=822808&view=rev
Log:
Fixed support for links and images in the Intermediate Format
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=822808&r1=822807&r2=822808&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
Wed Oct 7 17:31:13 2009
@@ -33,8 +33,6 @@
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.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 @@
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 @@
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 @@
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) {
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=822808&r1=822807&r2=822808&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFSerializer.java
Wed Oct 7 17:31:13 2009
@@ -419,7 +419,7 @@
}
}
- 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 @@
}
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 @@
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());
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java?rev=822808&r1=822807&r2=822808&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
Wed Oct 7 17:31:13 2009
@@ -48,6 +48,8 @@
private IFDocumentNavigationHandler navHandler;
+ private String accessibilityPointer;
+
/**
* Main constructor.
* @param navHandler the navigation handler that will receive the events
@@ -96,6 +98,7 @@
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 @@
}
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 @@
if (id != null) {
action.setID(id);
}
+ if (accessibilityPointer != null) {
+ action.setPtr(accessibilityPointer);
+ }
objectStack.push(action);
} else {
throw new SAXException(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]