aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2009-10-16 15:53:13 +0000
committerVincent Hennebert <vhennebert@apache.org>2009-10-16 15:53:13 +0000
commit0a05a9f1295e06d158bba4bb7e86f96d4bd845a7 (patch)
tree8897ea2123cf2f1040bd2ebb0314ba5d94ee6fa6 /src/java/org
parentc7e17515ef3e7b09b5a822fe81ffbb1e21da6ff9 (diff)
downloadxmlgraphics-fop-0a05a9f1295e06d158bba4bb7e86f96d4bd845a7.tar.gz
xmlgraphics-fop-0a05a9f1295e06d158bba4bb7e86f96d4bd845a7.zip
Route message for missing alt-text property through event notification system
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@825964 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/events/EventFormatter.xml1
-rw-r--r--src/java/org/apache/fop/fo/FOValidationEventProducer.java13
-rw-r--r--src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/AbstractGraphics.java6
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java3
5 files changed, 20 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml
index 147744a0d..7561f1548 100644
--- a/src/java/org/apache/fop/events/EventFormatter.xml
+++ b/src/java/org/apache/fop/events/EventFormatter.xml
@@ -105,4 +105,5 @@ Any reference to it will be considered a reference to the first occurrence in th
<message key="org.apache.fop.fonts.FontEventAdapter.fontSubstituted">Font "{requested}" not found. Substituting with "{effective}".</message>
<message key="org.apache.fop.fonts.FontEventAdapter.fontLoadingErrorAtAutoDetection">Unable to load font file: {fontURL}.[ Reason: {e}]</message>
<message key="org.apache.fop.fonts.FontEventAdapter.glyphNotAvailable">Glyph "{ch}" (0x{ch,hex}[, {ch,glyph-name}]) not available in font "{fontName}".</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.altTextMissing">Alternate text is missing on {foElement}.{{locator}}</message>
</catalogue>
diff --git a/src/java/org/apache/fop/fo/FOValidationEventProducer.java b/src/java/org/apache/fop/fo/FOValidationEventProducer.java
index 889bf706a..ff005b1b4 100644
--- a/src/java/org/apache/fop/fo/FOValidationEventProducer.java
+++ b/src/java/org/apache/fop/fo/FOValidationEventProducer.java
@@ -36,7 +36,9 @@ public interface FOValidationEventProducer extends EventProducer {
/**
* Provider class for the event producer.
*/
- class Provider {
+ final class Provider {
+
+ private Provider() { }
/**
* Returns an event producer.
@@ -354,4 +356,13 @@ public interface FOValidationEventProducer extends EventProducer {
void unknownFormattingObject(Object source, String elementName,
QName offendingNode, Locator loc);
+ /**
+ * Alternate text is missing for a graphic element.
+ *
+ * @param source the event source
+ * @param foElement name of the element (external-graphic or instream-foreign-object)
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void altTextMissing(Object source, String foElement, Locator loc);
}
diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
index ee2b3886e..f9a556167 100644
--- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
@@ -47,7 +47,7 @@ public class ExtensionElementMapping extends ElementMapping {
propertyAttributes.add("internal-destination");
propertyAttributes.add("disable-column-balancing");
//These are FOP's extension properties for accessibility
- propertyAttributes.add("alt");
+ propertyAttributes.add("alt-text");
}
/**
diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
index bd4152295..eeb06c1df 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
@@ -106,6 +106,12 @@ public abstract class AbstractGraphics extends FObj
scaling = pList.get(PR_SCALING).getEnum();
textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
width = pList.get(PR_WIDTH).getLength();
+ if (getUserAgent().isAccessibilityEnabled()) {
+ String altText = pList.get(PR_X_ALT_TEXT).getString();
+ if (altText.equals("")) {
+ getFOValidationEventProducer().altTextMissing(this, getLocalName(), getLocator());
+ }
+ }
}
/**
diff --git a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
index 2313431f0..cfa0719ea 100644
--- a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
@@ -163,9 +163,6 @@ class PDFLogicalStructureHandler {
if (altTextNode != null) {
structElem.put("Alt", altTextNode.getNodeValue());
} else {
- // TODO route that to event notification system
-// log.warn("fo:" + s
-// + " requires an alternative text attribute fox:alt-text for accessibility");
structElem.put("Alt", "No alternate text specified");
}
}