Author: jeremias
Date: Fri Feb 20 14:18:58 2009
New Revision: 746248
URL: http://svn.apache.org/viewvc?rev=746248&view=rev
Log:
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.
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/FOUserAgent.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/Fop.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/pdf/PDFDocumentHandler.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/FOUserAgent.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/FOUserAgent.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/FOUserAgent.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/FOUserAgent.java
Fri Feb 20 14:18:58 2009
@@ -623,10 +623,10 @@
}
/**
- * 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();
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/Fop.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/Fop.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/Fop.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/apps/Fop.java
Fri Feb 20 14:18:58 2009
@@ -111,7 +111,7 @@
if (foTreeBuilder == null) {
createDefaultHandler();
}
- if (this.foUserAgent.accessibilityEnabled()) {
+ if (this.foUserAgent.isAccessibilityEnabled()) {
return
AccessibilityUtil.decorateDefaultHandler(this.foTreeBuilder, foUserAgent);
} else {
return this.foTreeBuilder;
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=746248&r1=746247&r2=746248&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
Fri Feb 20 14:18:58 2009
@@ -200,7 +200,7 @@
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 @@
}
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()));
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
Fri Feb 20 14:18:58 2009
@@ -214,11 +214,21 @@
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 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 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(
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
Fri Feb 20 14:18:58 2009
@@ -82,7 +82,7 @@
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();
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
Fri Feb 20 14:18:58 2009
@@ -83,7 +83,7 @@
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);
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
Fri Feb 20 14:18:58 2009
@@ -121,7 +121,7 @@
*/
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 @@
eventProducer.svgRenderingError(this, e,
image.getInfo().getOriginalURI());
}
generator.getState().restore();
- if (context.getUserAgent().accessibilityEnabled()) {
+ if (context.getUserAgent().isAccessibilityEnabled()) {
generator.restoreGraphicsStateAccess();
} else {
generator.restoreGraphicsState();
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFPainter.java
Fri Feb 20 14:18:58 2009
@@ -82,7 +82,7 @@
this.generator = documentHandler.generator;
this.borderPainter = new PDFBorderPainter(this.generator);
this.state = IFState.create();
- accessEnabled = this.getUserAgent().accessibilityEnabled();
+ accessEnabled = this.getUserAgent().isAccessibilityEnabled();
}
/** {...@inheritdoc} */
Modified:
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java?rev=746248&r1=746247&r2=746248&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
(original)
+++
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
Fri Feb 20 14:18:58 2009
@@ -52,8 +52,6 @@
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 @@
/** 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 @@
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 @@
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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]