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 vh...@apache.org on 2009/09/28 17:35:04 UTC

svn commit: r819591 - /xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java

Author: vhennebert
Date: Mon Sep 28 15:35:03 2009
New Revision: 819591

URL: http://svn.apache.org/viewvc?rev=819591&view=rev
Log:
Extracted code into new processStructureTree method

Modified:
    xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java

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=819591&r1=819590&r2=819591&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 Mon Sep 28 15:35:03 2009
@@ -252,45 +252,50 @@
         }
 
         if (getUserAgent().isAccessibilityEnabled()) {
-            if (this.pdfDoc.getRoot().getLanguage() == null) {
-                String fallbackLanguage;
-                if (this.pdfDoc.getProfile().getPDFAMode().isPDFA1LevelA()) {
-                    //According to Annex B of ISO-19005-1:2005(E), section B.2
-                    fallbackLanguage = "x-unknown";
-                } else {
-                    //No language has been set on the first page-sequence, so fall back to "en".
-                    fallbackLanguage = "en";
-                }
-                this.pdfDoc.getRoot().setLanguage(fallbackLanguage);
-            }
+            processStructureTree();
+        }
+    }
 
-            StructureTree structureTree = getUserAgent().getStructureTree();
-            PDFStructElem parent = (PDFStructElem)getStructTreeRoot().getFirstChild();
-            PDFStructElem structElemPart = new PDFStructElem(parent,
-                    FOToPDFRoleMap.mapFormattingObject("page-sequence", parent));
-            if (getContext().getLanguage() != null) {
-                structElemPart.setLanguage(getContext().getLanguage());
+    private void processStructureTree() {
+        if (this.pdfDoc.getRoot().getLanguage() == null) {
+            String fallbackLanguage;
+            if (this.pdfDoc.getProfile().getPDFAMode().isPDFA1LevelA()) {
+                //According to Annex B of ISO-19005-1:2005(E), section B.2
+                fallbackLanguage = "x-unknown";
+            } else {
+                //No language has been set on the first page-sequence, so fall back to "en".
+                fallbackLanguage = "en";
             }
-            this.pdfDoc.assignObjectNumber(structElemPart);
-            this.pdfDoc.addTrailerObject(structElemPart);
-            parent.addKid(structElemPart);
-
-            NodeList nodes = structureTree.getPageSequence(++pageSequenceCounter);
-
-            for (int i = 0, n = nodes.getLength(); i < n; i++) {
-                Node node = nodes.item(i);
-                if (node.getNodeName().equals("fo:flow")
-                        || node.getNodeName().equals("fo:static-content")) {
-                    PDFStructElem structElemSect = new PDFStructElem(structElemPart,
-                            FOToPDFRoleMap.mapFormattingObject(node.getLocalName(),
-                                    structElemPart));
-                    this.pdfDoc.assignObjectNumber(structElemSect);
-                    this.pdfDoc.addTrailerObject(structElemSect);
-                    structElemPart.addKid(structElemSect);
-                    NodeList iNodes = node.getChildNodes();
-                    for (int j = 0, m = iNodes.getLength(); j < m; j++) {
-                        processContent(iNodes.item(j), structElemSect, 1);
-                    }
+            this.pdfDoc.getRoot().setLanguage(fallbackLanguage);
+        }
+
+        /* Retrieve the structure element of type "Document" */
+        PDFStructElem parent = (PDFStructElem)getStructTreeRoot().getFirstChild();
+        PDFStructElem structElemPart = new PDFStructElem(parent,
+                FOToPDFRoleMap.mapFormattingObject("page-sequence", parent));
+        if (getContext().getLanguage() != null) {
+            structElemPart.setLanguage(getContext().getLanguage());
+        }
+        this.pdfDoc.assignObjectNumber(structElemPart);
+        this.pdfDoc.addTrailerObject(structElemPart);
+        parent.addKid(structElemPart);
+
+        StructureTree structureTree = getUserAgent().getStructureTree();
+        NodeList nodes = structureTree.getPageSequence(++pageSequenceCounter);
+
+        for (int i = 0, n = nodes.getLength(); i < n; i++) {
+            Node node = nodes.item(i);
+            if (node.getNodeName().equals("fo:flow")
+                    || node.getNodeName().equals("fo:static-content")) {
+                PDFStructElem structElemSect = new PDFStructElem(structElemPart,
+                        FOToPDFRoleMap.mapFormattingObject(node.getLocalName(),
+                                structElemPart));
+                this.pdfDoc.assignObjectNumber(structElemSect);
+                this.pdfDoc.addTrailerObject(structElemSect);
+                structElemPart.addKid(structElemSect);
+                NodeList iNodes = node.getChildNodes();
+                for (int j = 0, m = iNodes.getLength(); j < m; j++) {
+                    processContent(iNodes.item(j), structElemSect, 1);
                 }
             }
         }



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