You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2009/02/19 19:04:51 UTC

svn commit: r745949 [3/3] - in /xmlgraphics/fop/branches/Temp_Accessibility: ./ src/java/META-INF/services/ src/java/org/apache/fop/accessibility/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/cli/ src/java/org/apa...

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingContext.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingContext.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFRenderingContext.java Thu Feb 19 18:04:18 2009
@@ -34,6 +34,11 @@
     private PDFContentGenerator generator;
     private FontInfo fontInfo;
     private PDFPage page;
+    /** Temp. val. for accessibility, used in PDFImageHandlerRenderedImage */
+    private String structElemType = "";
+
+    /** Temp. val. for accessibility, used in PDFImageHandlerRenderedImage */
+    private int mcid = -1;
 
     /**
      * Main constructor.
@@ -79,4 +84,35 @@
         return this.fontInfo;
     }
 
+    /**
+     * Used for accessibility, used in PDFPainter.drawImage
+     * @param value to be stored
+     */
+    public void setMCID(int value) {
+        mcid = value;
+    }
+
+    /**
+     * Used for accessibility
+     * @return mcid
+     */
+    public int getSequenceNum() {
+        return mcid;
+    }
+
+    /**
+     * Used for accessibility
+     * @param s the type of the structure element
+     */
+    public void setStructElemType(String s) {
+        structElemType = s;
+    }
+
+    /**
+     * Used for accessibility
+     * @return the type of the structure element
+     */
+    public String getStructElemType() {
+        return structElemType;
+    }
 }

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=745949&r1=745948&r2=745949&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 Thu Feb 19 18:04:18 2009
@@ -52,6 +52,8 @@
 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;
 
@@ -75,6 +77,9 @@
     /** 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;
 
@@ -169,6 +174,12 @@
         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);
@@ -384,6 +395,16 @@
             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;
     }
 

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSPainter.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSPainter.java Thu Feb 19 18:04:18 2009
@@ -176,7 +176,7 @@
     }
 
     /** {@inheritDoc} */
-    public void drawImage(String uri, Rectangle rect) throws IFException {
+    public void drawImage(String uri, Rectangle rect, String ptr) throws IFException {
         try {
             endTextObject();
         } catch (IOException ioe) {
@@ -186,7 +186,7 @@
     }
 
     /** {@inheritDoc} */
-    public void drawImage(Document doc, Rectangle rect) throws IFException {
+    public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException {
         try {
             endTextObject();
         } catch (IOException ioe) {
@@ -338,7 +338,7 @@
 
     /** {@inheritDoc} */
     public void drawText(int x, int y, int letterSpacing, int wordSpacing,
-            int[] dx, String text) throws IFException {
+            int[] dx, String text, String ptr) throws IFException {
         try {
             //Note: dy is currently ignored
             PSGenerator generator = getGenerator();

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/ps/PSRenderer.java Thu Feb 19 18:04:18 2009
@@ -345,7 +345,7 @@
     }
 
     /** {@inheritDoc} */
-    protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
+    protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes, String ptr) {
         endTextObject();
         int x = currentIPPosition + (int)Math.round(pos.getX());
         int y = currentBPPosition + (int)Math.round(pos.getY());
@@ -1233,7 +1233,7 @@
      * {@inheritDoc}
      */
     public void renderImage(Image image, Rectangle2D pos) {
-        drawImage(image.getURL(), pos, image.getForeignAttributes());
+        drawImage(image.getURL(), pos, image.getForeignAttributes(), "");
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/txt/TXTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/txt/TXTRenderer.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/txt/TXTRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/txt/TXTRenderer.java Thu Feb 19 18:04:18 2009
@@ -443,7 +443,7 @@
     }
 
     /** {@inheritDoc} */
-    protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) {
+    protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes, String ptr) {
         //No images are painted here
     }
 

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/DOM2SAX.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/DOM2SAX.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/DOM2SAX.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/DOM2SAX.java Thu Feb 19 18:04:18 2009
@@ -77,6 +77,15 @@
             contentHandler.endDocument();
         }
     }
+    
+    /**
+     * Writes the given fragment using the given ContentHandler.
+     * @param node DOM node
+     * @throws SAXException In case of a problem while writing XML
+     */
+    public void writeFragment(Node node) throws SAXException {
+        writeNode(node);
+    }
 
     /**
      * Begin the scope of namespace prefix. Forward the event to the SAX handler

Modified: xmlgraphics/fop/branches/Temp_Accessibility/src/sandbox/org/apache/fop/render/svg/SVGPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/sandbox/org/apache/fop/render/svg/SVGPainter.java?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/src/sandbox/org/apache/fop/render/svg/SVGPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/src/sandbox/org/apache/fop/render/svg/SVGPainter.java Thu Feb 19 18:04:18 2009
@@ -193,7 +193,7 @@
     }
 
     /** {@inheritDoc} */
-    public void drawImage(String uri, Rectangle rect) throws IFException {
+    public void drawImage(String uri, Rectangle rect, String ptr) throws IFException {
         try {
             establish(MODE_NORMAL);
 
@@ -243,7 +243,7 @@
     }
 
     /** {@inheritDoc} */
-    public void drawImage(Document doc, Rectangle rect) throws IFException {
+    public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException {
         try {
             establish(MODE_NORMAL);
 
@@ -325,8 +325,10 @@
     }
 
     /** {@inheritDoc} */
-    public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text)
-                throws IFException {
+
+    public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, 
+            String text, String ptr) throws IFException {
+        //Note: ptr is ignored as it is only needed for accessibility
         try {
             establish(MODE_TEXT);
             AttributesImpl atts = new AttributesImpl();

Modified: xmlgraphics/fop/branches/Temp_Accessibility/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/status.xml?rev=745949&r1=745948&r2=745949&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Accessibility/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_Accessibility/status.xml Thu Feb 19 18:04:18 2009
@@ -58,6 +58,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Renderers" dev="JM" type="add" fixes-bug="46705" due-to="Jost Klopfstein">
+        Added basic accessibility and Tagged PDF support. 
+      </action>
       <action context="Fonts" dev="JM" type="fix" fixes-bug="46686" due-to="Alok Singh">
         Use temporary directory for the font cache if the user home directory is not
         write-accessible.



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org