ASF Bugzilla – Attachment 26708 Details for
Bug 50852
[PATCH] Improve generation of PDFs with accessibility information
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch 08/20
0008-Remove-unused-code.patch (text/plain), 21.07 KB, created by
Martin K
on 2011-03-02 07:01:59 UTC
(
hide
)
Description:
Patch 08/20
Filename:
MIME Type:
Creator:
Martin K
Created:
2011-03-02 07:01:59 UTC
Size:
21.07 KB
patch
obsolete
>Subject: [PATCH 08/20] Remove unused code > >--- > .../apache/fop/accessibility/Accessibility.java | 54 ---------- > .../accessibility/AccessibilityPreprocessor.java | 95 ------------------ > .../apache/fop/accessibility/StructureTree.java | 102 -------------------- > src/java/org/apache/fop/accessibility/addPtr.xsl | 88 ----------------- > .../org/apache/fop/accessibility/reduceFOTree.xsl | 100 ------------------- > src/java/org/apache/fop/apps/FOUserAgent.java | 24 ----- > src/java/org/apache/fop/fo/FOPropertyMapping.java | 6 - > 7 files changed, 0 insertions(+), 469 deletions(-) > delete mode 100644 src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java > delete mode 100644 src/java/org/apache/fop/accessibility/StructureTree.java > delete mode 100644 src/java/org/apache/fop/accessibility/addPtr.xsl > delete mode 100644 src/java/org/apache/fop/accessibility/reduceFOTree.xsl > >diff --git a/src/java/org/apache/fop/accessibility/Accessibility.java b/src/java/org/apache/fop/accessibility/Accessibility.java >index 73bffe5..c1e4cf3 100644 >--- a/src/java/org/apache/fop/accessibility/Accessibility.java >+++ b/src/java/org/apache/fop/accessibility/Accessibility.java >@@ -19,19 +19,6 @@ > > package org.apache.fop.accessibility; > >-import javax.xml.transform.Source; >-import javax.xml.transform.Templates; >-import javax.xml.transform.Transformer; >-import javax.xml.transform.TransformerConfigurationException; >-import javax.xml.transform.sax.SAXTransformerFactory; >-import javax.xml.transform.sax.TransformerHandler; >-import javax.xml.transform.stream.StreamSource; >- >-import org.xml.sax.helpers.DefaultHandler; >- >-import org.apache.fop.apps.FOPException; >-import org.apache.fop.apps.FOUserAgent; >- > /** > * Helper class for FOP's accessibility features. > */ >@@ -40,48 +27,7 @@ public final class Accessibility { > /** Constant string for the rendering options key to enable accessibility features. */ > public static final String ACCESSIBILITY = "accessibility"; > >- // TODO what if the default factory is not a SAXTransformerFactory? >- private static SAXTransformerFactory tfactory >- = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); >- >- private static Templates addPtrTemplates; >- >- private static Templates reduceFOTreeTemplates; > > private Accessibility() { } > >- /** >- * Decorates the given handler so the structure tree used for accessibility >- * features can be branched off the main content stream. >- * @param handler the handler to decorate >- * @param userAgent the user agent >- * @return the decorated handler >- * @throws FOPException if an error occurs setting up the decoration >- */ >- public static DefaultHandler decorateDefaultHandler(DefaultHandler handler, >- FOUserAgent userAgent) throws FOPException { >- try { >- setupTemplates(); >- TransformerHandler addPtr = tfactory.newTransformerHandler(addPtrTemplates); >- Transformer reduceFOTree = reduceFOTreeTemplates.newTransformer(); >- return new AccessibilityPreprocessor(addPtr, reduceFOTree, userAgent, handler); >- } catch (TransformerConfigurationException e) { >- throw new FOPException(e); >- } >- } >- >- private static synchronized void setupTemplates() throws TransformerConfigurationException { >- if (addPtrTemplates == null) { >- addPtrTemplates = loadTemplates("addPtr.xsl"); >- } >- if (reduceFOTreeTemplates == null) { >- reduceFOTreeTemplates = loadTemplates("reduceFOTree.xsl"); >- } >- } >- >- private static Templates loadTemplates(String source) throws TransformerConfigurationException { >- Source src = new StreamSource(Accessibility.class.getResource(source).toExternalForm()); >- return tfactory.newTemplates(src); >- } >- > } >diff --git a/src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java b/src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java >deleted file mode 100644 >index 0ecd9ed..0000000 >--- a/src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java >+++ /dev/null >@@ -1,95 +0,0 @@ >-/* >- * Licensed to the Apache Software Foundation (ASF) under one or more >- * contributor license agreements. See the NOTICE file distributed with >- * this work for additional information regarding copyright ownership. >- * The ASF licenses this file to You under the Apache License, Version 2.0 >- * (the "License"); you may not use this file except in compliance with >- * the License. You may obtain a copy of the License at >- * >- * http://www.apache.org/licenses/LICENSE-2.0 >- * >- * Unless required by applicable law or agreed to in writing, software >- * distributed under the License is distributed on an "AS IS" BASIS, >- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >- * See the License for the specific language governing permissions and >- * limitations under the License. >- */ >- >-/* $Id: AccessibilityPreprocessor.java 830293 2009-10-27 19:07:52Z vhennebert $ */ >- >-package org.apache.fop.accessibility; >- >-import java.io.ByteArrayInputStream; >-import java.io.InputStream; >- >-import javax.xml.parsers.SAXParser; >-import javax.xml.parsers.SAXParserFactory; >-import javax.xml.transform.Source; >-import javax.xml.transform.Transformer; >-import javax.xml.transform.dom.DOMResult; >-import javax.xml.transform.sax.TransformerHandler; >-import javax.xml.transform.stream.StreamResult; >-import javax.xml.transform.stream.StreamSource; >- >-import org.w3c.dom.NodeList; >-import org.xml.sax.SAXException; >-import org.xml.sax.helpers.DefaultHandler; >- >-import org.apache.commons.io.output.ByteArrayOutputStream; >- >-import org.apache.fop.apps.FOUserAgent; >-import org.apache.fop.util.TransformerDefaultHandler; >- >-/** >- * This class prepares an XSL-FO document for accessibility. It adds a unique >- * identifier to every applicable FO, then creates the structure tree, before >- * handing the document over to the regular handler. >- */ >-class AccessibilityPreprocessor extends TransformerDefaultHandler { >- >- private final ByteArrayOutputStream enrichedFOBuffer = new ByteArrayOutputStream(); >- >- private final Transformer reduceFOTree; >- >- private final FOUserAgent userAgent; >- >- private final DefaultHandler fopHandler; >- >- public AccessibilityPreprocessor(TransformerHandler addPtr, Transformer reduceFOTree, >- FOUserAgent userAgent, DefaultHandler fopHandler) { >- super(addPtr); >- this.reduceFOTree = reduceFOTree; >- this.userAgent = userAgent; >- this.fopHandler = fopHandler; >- getTransformerHandler().setResult(new StreamResult(enrichedFOBuffer)); >- } >- >- /** {@inheritDoc} */ >- public void endDocument() throws SAXException { >- super.endDocument(); >- // do the second transform to struct >- try { >- //TODO this must be optimized, no buffering (ex. SAX-based tee-proxy) >- byte[] enrichedFO = enrichedFOBuffer.toByteArray(); >- Source src = new StreamSource(new ByteArrayInputStream(enrichedFO)); >- DOMResult res = new DOMResult(); >- reduceFOTree.transform(src, res); >- StructureTree structureTree = new StructureTree(); >- NodeList pageSequences = res.getNode().getFirstChild().getChildNodes(); >- for (int i = 0; i < pageSequences.getLength(); i++) { >- structureTree.addPageSequenceStructure(pageSequences.item(i).getChildNodes()); >- } >- userAgent.setStructureTree(structureTree); >- >- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); >- saxParserFactory.setNamespaceAware(true); >- saxParserFactory.setValidating(false); >- SAXParser saxParser = saxParserFactory.newSAXParser(); >- InputStream in = new ByteArrayInputStream(enrichedFO); >- saxParser.parse(in, fopHandler); >- } catch (Exception e) { >- throw new SAXException(e); >- } >- } >- >-} >diff --git a/src/java/org/apache/fop/accessibility/StructureTree.java b/src/java/org/apache/fop/accessibility/StructureTree.java >deleted file mode 100644 >index 94e8b36..0000000 >--- a/src/java/org/apache/fop/accessibility/StructureTree.java >+++ /dev/null >@@ -1,102 +0,0 @@ >-/* >- * Licensed to the Apache Software Foundation (ASF) under one or more >- * contributor license agreements. See the NOTICE file distributed with >- * this work for additional information regarding copyright ownership. >- * The ASF licenses this file to You under the Apache License, Version 2.0 >- * (the "License"); you may not use this file except in compliance with >- * the License. You may obtain a copy of the License at >- * >- * http://www.apache.org/licenses/LICENSE-2.0 >- * >- * Unless required by applicable law or agreed to in writing, software >- * distributed under the License is distributed on an "AS IS" BASIS, >- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >- * See the License for the specific language governing permissions and >- * limitations under the License. >- */ >- >-/* $Id: StructureTree.java 830293 2009-10-27 19:07:52Z vhennebert $ */ >- >-package org.apache.fop.accessibility; >- >-import java.io.StringWriter; >-import java.io.Writer; >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.xml.transform.Transformer; >-import javax.xml.transform.TransformerFactory; >-import javax.xml.transform.dom.DOMSource; >-import javax.xml.transform.stream.StreamResult; >- >-import org.w3c.dom.Node; >-import org.w3c.dom.NodeList; >- >-/** >- * A reduced version of the document's FO tree, containing only its logical >- * structure. Used by accessible output formats. >- */ >-public final class StructureTree { >- >- private final List pageSequenceStructures = new ArrayList(); >- >- /** >- * Package-private default constructor. >- */ >- StructureTree() { } >- >- private static boolean flowOrStaticContentNodes(NodeList nodes) { >- for (int i = 0; i < nodes.getLength(); i++) { >- Node node = nodes.item(i); >- if (node.getNodeType() != Node.ELEMENT_NODE) { >- return false; >- } >- String name = node.getLocalName(); >- if (!(name.equals("flow") || name.equals("static-content"))) { >- return false; >- } >- } >- return true; >- } >- >- void addPageSequenceStructure(NodeList structureTree) { >- assert flowOrStaticContentNodes(structureTree); >- pageSequenceStructures.add(structureTree); >- } >- >- /** >- * Returns the list of nodes that are the children of the given page sequence. >- * >- * @param index index of the page sequence, 0-based >- * @return its children nodes >- */ >- public NodeList getPageSequence(int index) { >- return (NodeList) pageSequenceStructures.get(index); >- } >- >- /** >- * Returns an XML-like representation of the structure trees. >- * <p> >- * <strong>Note:</strong> use only for debugging purpose, as this method >- * performs non-trivial operations. >- * </p> >- * @return a string representation of this object >- */ >- public String toString() { >- try { >- Transformer t = TransformerFactory.newInstance().newTransformer(); >- Writer str = new StringWriter(); >- for (Iterator iter = pageSequenceStructures.iterator(); iter.hasNext();) { >- NodeList nodes = (NodeList) iter.next(); >- for (int i = 0, c = nodes.getLength(); i < c; i++) { >- t.transform(new DOMSource(nodes.item(i)), new StreamResult(str)); >- } >- } >- return str.toString(); >- } catch (Exception e) { >- return e.toString(); >- } >- } >- >-} >diff --git a/src/java/org/apache/fop/accessibility/addPtr.xsl b/src/java/org/apache/fop/accessibility/addPtr.xsl >deleted file mode 100644 >index a236561..0000000 >--- a/src/java/org/apache/fop/accessibility/addPtr.xsl >+++ /dev/null >@@ -1,88 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<!-- >- Licensed to the Apache Software Foundation (ASF) under one or more >- contributor license agreements. See the NOTICE file distributed with >- this work for additional information regarding copyright ownership. >- The ASF licenses this file to You under the Apache License, Version 2.0 >- (the "License"); you may not use this file except in compliance with >- the License. You may obtain a copy of the License at >- >- http://www.apache.org/licenses/LICENSE-2.0 >- >- Unless required by applicable law or agreed to in writing, software >- distributed under the License is distributed on an "AS IS" BASIS, >- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >- See the License for the specific language governing permissions and >- limitations under the License. >---> >-<!-- $Id: addPtr.xsl 830293 2009-10-27 19:07:52Z vhennebert $ --> >-<xsl:stylesheet version="1.0" >- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >- xmlns:fo="http://www.w3.org/1999/XSL/Format" >- xmlns:foi="http://xmlgraphics.apache.org/fop/internal"> >- >- <xsl:template name="addPtr"> >- <xsl:copy> >- <xsl:apply-templates select="@*"/> >- <xsl:attribute name="foi:ptr"> >- <xsl:value-of select="generate-id()"/> >- </xsl:attribute> >- <xsl:apply-templates/> >- </xsl:copy> >- </xsl:template> >- >- <!-- Block-level Formatting Objects --> >- <xsl:template match="fo:block|fo:block-container"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Inline-level Formatting Objects --> >- <xsl:template match="fo:character|fo:inline|fo:inline-container"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <xsl:template match="fo:external-graphic|fo:instream-foreign-object"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <xsl:template match="fo:page-number|fo:page-number-citation|fo:page-number-citation-last"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Formatting Objects for Tables --> >- <xsl:template match="fo:table-and-caption|fo:table-caption|fo:table"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <xsl:template match="fo:table-header|fo:table-footer|fo:table-body|fo:table-row|fo:table-cell"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Formatting Objects for Lists --> >- <xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Dynamic Effects: Link and Multi Formatting Objects --> >- <xsl:template match="fo:basic-link"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Out-of-Line Formatting Objects --> >- <xsl:template match="fo:float|fo:footnote|fo:footnote-body"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- <!-- Other Formatting Objects --> >- <xsl:template match="fo:wrapper|fo:marker"> >- <xsl:call-template name="addPtr"/> >- </xsl:template> >- >- >- <xsl:template match="@*|node()"> >- <xsl:copy> >- <xsl:apply-templates select="@*|node()"/> >- </xsl:copy> >- </xsl:template> >- >-</xsl:stylesheet> >diff --git a/src/java/org/apache/fop/accessibility/reduceFOTree.xsl b/src/java/org/apache/fop/accessibility/reduceFOTree.xsl >deleted file mode 100644 >index 7786842..0000000 >--- a/src/java/org/apache/fop/accessibility/reduceFOTree.xsl >+++ /dev/null >@@ -1,100 +0,0 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<!-- >- Licensed to the Apache Software Foundation (ASF) under one or more >- contributor license agreements. See the NOTICE file distributed with >- this work for additional information regarding copyright ownership. >- The ASF licenses this file to You under the Apache License, Version 2.0 >- (the "License"); you may not use this file except in compliance with >- the License. You may obtain a copy of the License at >- >- http://www.apache.org/licenses/LICENSE-2.0 >- >- Unless required by applicable law or agreed to in writing, software >- distributed under the License is distributed on an "AS IS" BASIS, >- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >- See the License for the specific language governing permissions and >- limitations under the License. >---> >-<!-- $Id: reduceFOTree.xsl 898840 2010-01-13 17:05:59Z vhennebert $ --> >-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >- xmlns:fo="http://www.w3.org/1999/XSL/Format" >- xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" >- xmlns:foi="http://xmlgraphics.apache.org/fop/internal"> >- >- <xsl:output method="xml" indent="no"/> >- >- <xsl:template name="copy"> >- <xsl:copy> >- <xsl:apply-templates select="@*|node()"/> >- </xsl:copy> >- </xsl:template> >- >- <!-- Declarations and Pagination and Layout Formatting Objects --> >- <xsl:template match="fo:root|fo:page-sequence|fo:static-content|fo:flow"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Block-level Formatting Objects --> >- <xsl:template match="fo:block|fo:block-container"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Inline-level Formatting Objects --> >- <xsl:template match="fo:character|fo:inline|fo:inline-container"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <xsl:template match="fo:external-graphic|fo:instream-foreign-object"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <xsl:template match="fo:page-number|fo:page-number-citation|fo:page-number-citation-last"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Formatting Objects for Tables --> >- <xsl:template match="fo:table-and-caption|fo:table-caption|fo:table"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <xsl:template match="fo:table-header|fo:table-footer|fo:table-body|fo:table-row|fo:table-cell"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Formatting Objects for Lists --> >- <xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Dynamic Effects: Link and Multi Formatting Objects --> >- <xsl:template match="fo:basic-link"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Out-of-Line Formatting Objects --> >- <xsl:template match="fo:float|fo:footnote|fo:footnote-body"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- <!-- Other Formatting Objects --> >- <xsl:template match="fo:wrapper|fo:marker"> >- <xsl:call-template name="copy"/> >- </xsl:template> >- >- >- <!-- Discard descendants of fo:leader --> >- <xsl:template match="fo:leader"/> >- >- >- <!-- Keep foi:ptr, fox:alt-text and role attributes, discard everything else --> >- <xsl:template match="@foi:ptr|@fox:alt-text|@role"> >- <xsl:copy-of select="."/> >- </xsl:template> >- >- <xsl:template match="@*"/> >- >- >- <!-- Discard text --> >- <xsl:template match="text()"/> >- >-</xsl:stylesheet> >diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java >index 3f1edab..c23ace7 100644 >--- a/src/java/org/apache/fop/apps/FOUserAgent.java >+++ b/src/java/org/apache/fop/apps/FOUserAgent.java >@@ -39,7 +39,6 @@ import org.apache.xmlgraphics.util.UnitConv; > > import org.apache.fop.Version; > import org.apache.fop.accessibility.Accessibility; >-import org.apache.fop.accessibility.StructureTree; > import org.apache.fop.events.DefaultEventBroadcaster; > import org.apache.fop.events.Event; > import org.apache.fop.events.EventBroadcaster; >@@ -102,8 +101,6 @@ public class FOUserAgent { > private boolean conserveMemoryPolicy = false; > private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster(); > >- private StructureTree structureTree; >- > /** Producer: Metadata element for the system/software that produces > * the document. (Some renderers can store this in the document.) > */ >@@ -672,26 +669,5 @@ public class FOUserAgent { > return false; > } > } >- >- /** >- * Sets the document's structure tree, for use by accessible output formats. >- * >- * @param structureTree a simplified version of the FO tree, retaining only >- * its logical structure >- */ >- public void setStructureTree(StructureTree structureTree) { >- this.structureTree = structureTree; >- } >- >- /** >- * Returns the document's structure tree, for use by accessible output >- * formats. >- * >- * @return a simplified version of the FO tree, retaining only its logical >- * structure >- */ >- public StructureTree getStructureTree() { >- return this.structureTree; >- } > } > >diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java >index b87e293..62ddbbd 100644 >--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java >+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java >@@ -2533,12 +2533,6 @@ public final class FOPropertyMapping implements Constants { > m.setDefault(""); > addPropertyMaker("id", m); > >- // foi:ptr, used for accessibility >- m = new StringProperty.Maker(PR_X_PTR); >- m.setInherited(false); >- m.setDefault(""); >- addPropertyMaker("foi:ptr", m); >- > // fox:alt-text, used for accessibility > m = new StringProperty.Maker(PR_X_ALT_TEXT); > m.setInherited(false); >-- >1.6.4.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 50852
:
26701
|
26702
|
26703
|
26704
|
26705
|
26706
|
26707
|
26708
|
26709
|
26710
|
26711
|
26712
|
26713
|
26714
|
26715
|
26716
|
26717
|
26718
|
26719
|
26720
|
27171
|
28824
|
28825
|
28826