diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-02-19 18:04:18 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-02-19 18:04:18 +0000 |
commit | 223eb5df1f7597ac5269eb8dce45b6a7450144b8 (patch) | |
tree | b6475383dd7fca2a53402b19d22b682276d8d6d1 /src/java/org/apache/fop/pdf/PDFTextUtil.java | |
parent | 51c210eea6bf627053854359388c1ad14203c0aa (diff) | |
download | xmlgraphics-fop-223eb5df1f7597ac5269eb8dce45b6a7450144b8.tar.gz xmlgraphics-fop-223eb5df1f7597ac5269eb8dce45b6a7450144b8.zip |
Bugzilla #46705:
Accessibility and Tagged PDF Support
Submitted by: Jost Klopfstein <jost.klopfstein.at.gmail.com>
Changes to patch by jeremias:
- Some style fixes
- Various simplifications
- Removal of dead code
- Addressed some issues raised in Bugzilla (work in progress)
- Fixed a couple of bugs on leader handling detected while testing (an NPE remains in leader_leader-pattern_use-content.xml)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@745949 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFTextUtil.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFTextUtil.java | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFTextUtil.java b/src/java/org/apache/fop/pdf/PDFTextUtil.java index 6640f9b80..bb8816995 100644 --- a/src/java/org/apache/fop/pdf/PDFTextUtil.java +++ b/src/java/org/apache/fop/pdf/PDFTextUtil.java @@ -48,6 +48,7 @@ public abstract class PDFTextUtil { public static final int TR_CLIP = 7; private boolean inTextObject = false; + private boolean artifactMode = false; private String startText; private String endText; private boolean useMultiByte; @@ -116,6 +117,15 @@ public abstract class PDFTextUtil { } /** + * Indicates whether we are in a text object and if that text object represents + * an artifact. + * @return true if in artifact-mode text object + */ + public boolean inArtifactMode() { + return this.artifactMode; + } + + /** * Called when a new text object should be started. Be sure to call setFont() before * issuing any text painting commands. */ @@ -128,11 +138,51 @@ public abstract class PDFTextUtil { } /** + * Begin of a regular text object, used for accessibility + * @param mcid of text object + * @param structElemType of parent + */ + public void beginTextObjectAccess(int mcid, String structElemType) { + if (inTextObject) { + throw new IllegalStateException("Already in text object"); + } + write(structElemType + " <</MCID " + + String.valueOf(mcid) + ">>\nBDC\nBT\n"); + this.inTextObject = true; + } + + /** + * Begin of a text object marked as artifact (fo:leader in XSL-FO) text object. + * Used for accessibility. + */ + public void beginArtifactTextObject() { + if (inTextObject) { + throw new IllegalStateException("Already in text object"); + } + write("/Artifact\nBMC\nBT\n"); + this.inTextObject = true; + this.artifactMode = true; + } + + /** * Called when a text object should be ended. */ public void endTextObject() { + endTextObject(false); + } + + /** + * Called when a text object should be ended. + * @param accessEnabled indicating if accessibility is turned on or not + */ + public void endTextObject(boolean accessEnabled) { checkInTextObject(); - write("ET\n"); + if (accessEnabled) { + write("ET\nEMC\n"); + } else { + write("ET\n"); + } + this.artifactMode = false; this.inTextObject = false; initValues(); } |