aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2009-09-28 15:35:03 +0000
committerVincent Hennebert <vhennebert@apache.org>2009-09-28 15:35:03 +0000
commit834d6b586229731a5a81c8d8e21a8c40c5d809b5 (patch)
treecf7897d65f67c3f63c18fc6cd7684198e39b0ef8 /src
parent3ec57c684b6564fa7f2c920c32e94572c3543692 (diff)
downloadxmlgraphics-fop-834d6b586229731a5a81c8d8e21a8c40c5d809b5.tar.gz
xmlgraphics-fop-834d6b586229731a5a81c8d8e21a8c40c5d809b5.zip
Extracted code into new processStructureTree method
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@819591 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java79
1 files changed, 42 insertions, 37 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
index 064682a3c..12c796c5a 100644
--- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
@@ -252,45 +252,50 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
}
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);
}
}
}