aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-02-20 14:18:58 +0000
committerJeremias Maerki <jeremias@apache.org>2009-02-20 14:18:58 +0000
commit863f9e143a65ce4f4335d9dcde55bbbb90bc4502 (patch)
treebe82125a88d82542823c2d5c6fed351fc3061e25 /src/java/org/apache
parent223eb5df1f7597ac5269eb8dce45b6a7450144b8 (diff)
downloadxmlgraphics-fop-863f9e143a65ce4f4335d9dcde55bbbb90bc4502.tar.gz
xmlgraphics-fop-863f9e143a65ce4f4335d9dcde55bbbb90bc4502.zip
JavaBeanified FOUserAgent.accessibilityEnabled().
Moved accessibility initialization out of PDFRenderingUtil because PDFRenderer doesn't support accessibility and both the new and old implementation use this class. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@746248 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/apps/FOUserAgent.java6
-rw-r--r--src/java/org/apache/fop/apps/Fop.java2
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFSerializer.java4
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java16
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java4
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFPainter.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java21
9 files changed, 24 insertions, 35 deletions
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java
index 1e0e3fb86..c0c14de62 100644
--- a/src/java/org/apache/fop/apps/FOUserAgent.java
+++ b/src/java/org/apache/fop/apps/FOUserAgent.java
@@ -623,10 +623,10 @@ public class FOUserAgent {
}
/**
- * check if accessibility is enabled
- * @return boolean
+ * Check if accessibility is enabled.
+ * @return true if accessibility is enabled
*/
- public boolean accessibilityEnabled() {
+ public boolean isAccessibilityEnabled() {
Boolean enabled = (Boolean)this.getRendererOptions().get("accessibility");
if (enabled != null) {
return enabled.booleanValue();
diff --git a/src/java/org/apache/fop/apps/Fop.java b/src/java/org/apache/fop/apps/Fop.java
index e5927fdba..9dfa70325 100644
--- a/src/java/org/apache/fop/apps/Fop.java
+++ b/src/java/org/apache/fop/apps/Fop.java
@@ -111,7 +111,7 @@ public class Fop {
if (foTreeBuilder == null) {
createDefaultHandler();
}
- if (this.foUserAgent.accessibilityEnabled()) {
+ if (this.foUserAgent.isAccessibilityEnabled()) {
return AccessibilityUtil.decorateDefaultHandler(this.foTreeBuilder, foUserAgent);
} else {
return this.foTreeBuilder;
diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
index d7d4a7539..248492a96 100644
--- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
@@ -200,7 +200,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
handler.startPrefixMapping(DocumentNavigationExtensionConstants.PREFIX,
DocumentNavigationExtensionConstants.NAMESPACE);
handler.startElement(EL_DOCUMENT);
- if (this.getUserAgent().accessibilityEnabled()) {
+ if (this.getUserAgent().isAccessibilityEnabled()) {
pageSequenceCounter = 0;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
@@ -269,7 +269,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
}
handler.startElement(EL_PAGE_SEQUENCE, atts);
- if (this.getUserAgent().accessibilityEnabled()) {
+ if (this.getUserAgent().isAccessibilityEnabled()) {
if (doc == null) {
doc = parser.parse(
new ByteArrayInputStream(this.getUserAgent().getReducedFOTree()));
diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
index f7eb3e7b3..3e27fce97 100644
--- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
@@ -214,11 +214,21 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
super.startDocument();
try {
this.pdfDoc = pdfUtil.setupPDFDocument(this.outputStream);
- this.accessEnabled = getUserAgent().accessibilityEnabled();
+ this.accessEnabled = getUserAgent().isAccessibilityEnabled();
if (accessEnabled) {
+ this.pdfDoc.getRoot().makeTagged();
+ log.info("Accessibility is enabled");
+ PDFStructTreeRoot structTreeRoot = this.pdfDoc.getFactory().makeStructTreeRoot();
+ this.pdfDoc.getRoot().setStructTreeRoot(structTreeRoot);
+ PDFStructElem structElemDocument = new PDFStructElem("root", structTreeRoot);
+ this.pdfDoc.assignObjectNumber(structElemDocument);
+ this.pdfDoc.addTrailerObject(structElemDocument);
+ structTreeRoot.addKid(structElemDocument);
+
//TODO: make document language variable, see note on wiki page PDF Accessibility
//TODO: and follow-up emails on fop-dev
this.pdfDoc.getRoot().setLanguage("en");
+
parentTree = new PDFParentTree();
pageSequenceCounter = 0;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -241,7 +251,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
public void endDocument() throws IFException {
try {
pdfDoc.getResources().addFonts(pdfDoc, fontInfo);
- if (getUserAgent().accessibilityEnabled()) {
+ if (getUserAgent().isAccessibilityEnabled()) {
PDFNumsArray nums = parentTree.getNums();
for (int i = 0; i <= this.parentTreeKey; i++) {
PDFArray tArray = new PDFArray();
@@ -288,7 +298,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
public void startPageSequence(String id) throws IFException {
//TODO page sequence title, country and language
- if (getUserAgent().accessibilityEnabled()) {
+ if (getUserAgent().isAccessibilityEnabled()) {
try {
if (doc == null) {
doc = parser.parse(
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
index 074a19bec..925d63bc5 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
@@ -82,7 +82,7 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler, ImageHandler {
float y = (float)pos.getY() / 1000f;
float w = (float)pos.getWidth() / 1000f;
float h = (float)pos.getHeight() / 1000f;
- if (context.getUserAgent().accessibilityEnabled()) {
+ if (context.getUserAgent().isAccessibilityEnabled()) {
String structElemType = pdfContext.getStructElemType();
if (structElemType.length() > 0) {
int sequenceNum = pdfContext.getSequenceNum();
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
index 728fa0601..24d17a2b1 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
@@ -83,7 +83,7 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler, ImageHandl
float y = (float)pos.getY() / 1000f;
float w = (float)pos.getWidth() / 1000f;
float h = (float)pos.getHeight() / 1000f;
- if (context.getUserAgent().accessibilityEnabled()) {
+ if (context.getUserAgent().isAccessibilityEnabled()) {
String structElemType = pdfContext.getStructElemType();
int sequenceNum = pdfContext.getSequenceNum();
generator.placeImage(x, y, w, h, xobj, structElemType, sequenceNum);
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
index 40fabbc5b..c405a2f2a 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
@@ -121,7 +121,7 @@ public class PDFImageHandlerSVG implements ImageHandler {
*/
generator.comment("SVG setup");
generator.saveGraphicsState();
- if (context.getUserAgent().accessibilityEnabled()) {
+ if (context.getUserAgent().isAccessibilityEnabled()) {
String structElemType = pdfContext.getStructElemType();
int sequenceNum = pdfContext.getSequenceNum();
generator.startAccessSequence(structElemType, sequenceNum);
@@ -173,7 +173,7 @@ public class PDFImageHandlerSVG implements ImageHandler {
eventProducer.svgRenderingError(this, e, image.getInfo().getOriginalURI());
}
generator.getState().restore();
- if (context.getUserAgent().accessibilityEnabled()) {
+ if (context.getUserAgent().isAccessibilityEnabled()) {
generator.restoreGraphicsStateAccess();
} else {
generator.restoreGraphicsState();
diff --git a/src/java/org/apache/fop/render/pdf/PDFPainter.java b/src/java/org/apache/fop/render/pdf/PDFPainter.java
index b87569ed3..3fdfccd2e 100644
--- a/src/java/org/apache/fop/render/pdf/PDFPainter.java
+++ b/src/java/org/apache/fop/render/pdf/PDFPainter.java
@@ -82,7 +82,7 @@ public class PDFPainter extends AbstractIFPainter {
this.generator = documentHandler.generator;
this.borderPainter = new PDFBorderPainter(this.generator);
this.state = IFState.create();
- accessEnabled = this.getUserAgent().accessibilityEnabled();
+ accessEnabled = this.getUserAgent().isAccessibilityEnabled();
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
index 8d9536bff..2e3c83126 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
@@ -52,8 +52,6 @@ import org.apache.fop.pdf.PDFMetadata;
import org.apache.fop.pdf.PDFNumsArray;
import org.apache.fop.pdf.PDFOutputIntent;
import org.apache.fop.pdf.PDFPageLabels;
-import org.apache.fop.pdf.PDFStructElem;
-import org.apache.fop.pdf.PDFStructTreeRoot;
import org.apache.fop.pdf.PDFXMode;
import org.apache.fop.util.ColorProfileUtil;
@@ -77,9 +75,6 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
/** the PDF/X mode (Default: disabled) */
protected PDFXMode pdfXMode = PDFXMode.DISABLED;
- /** the accessibility mode (Default: false=disabled) */
- protected boolean accessibility = false;
-
/** the (optional) encryption parameters */
protected PDFEncryptionParams encryptionParams;
@@ -174,12 +169,6 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
if (s != null) {
this.outputProfileURI = s;
}
- // used for accessibility
- setting = userAgent.getRendererOptions().get(ACCESSIBLITY);
- if (setting != null) {
- this.accessibility = booleanValueOf(setting);
- }
-
setting = userAgent.getRendererOptions().get(KEY_DISABLE_SRGB_COLORSPACE);
if (setting != null) {
this.disableSRGBColorSpace = booleanValueOf(setting);
@@ -395,16 +384,6 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
log.debug("PDF/A is active. Conformance Level: " + pdfAMode);
addPDFA1OutputIntent();
}
- if (this.accessibility) {
- this.pdfDoc.getRoot().makeTagged();
- log.info("Accessibility is enabled");
- PDFStructTreeRoot structTreeRoot = this.pdfDoc.getFactory().makeStructTreeRoot();
- this.pdfDoc.getRoot().setStructTreeRoot(structTreeRoot);
- PDFStructElem structElemDocument = new PDFStructElem("root", structTreeRoot);
- this.pdfDoc.assignObjectNumber(structElemDocument);
- this.pdfDoc.addTrailerObject(structElemDocument);
- structTreeRoot.addKid(structElemDocument);
- }
return this.pdfDoc;
}