mirror of
https://github.com/apache/xmlgraphics-fop.git
synced 2024-09-14 00:01:49 +02:00
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
This commit is contained in:
parent
834d6b5862
commit
b59502d64e
@ -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) {
|
||||
|
@ -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());
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user