* Removed addPtr.xsl and reduceFOTree.xsl * Implemented Common Accessibility properties on objects that support them * Added a special implementation of FOEventHandler to build the structure tree * Added mockito library and its dependencies * Added mocks for some FO nodes and properties * Removed FOTreeUnitTester and converted it into a re-usable FODocumentParser class * Re-worked table FO test cases accordingly git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImproveAccessibility@1188205 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
<include name="**/*.xml"/> | <include name="**/*.xml"/> | ||||
<include name="**/*.fo"/> | <include name="**/*.fo"/> | ||||
<include name="**/*.afp"/> | <include name="**/*.afp"/> | ||||
<include name="**/*.xsl"/> | |||||
</fileset> | </fileset> | ||||
<fileset dir="${build.dir}/test-gensrc"> | <fileset dir="${build.dir}/test-gensrc"> | ||||
<include name="**/*.xml"/> | <include name="**/*.xml"/> |
BSD License | |||||
Copyright (c) 2000-2006, www.hamcrest.org | |||||
All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without | |||||
modification, are permitted provided that the following conditions are met: | |||||
Redistributions of source code must retain the above copyright notice, this list of | |||||
conditions and the following disclaimer. Redistributions in binary form must reproduce | |||||
the above copyright notice, this list of conditions and the following disclaimer in | |||||
the documentation and/or other materials provided with the distribution. | |||||
Neither the name of Hamcrest nor the names of its contributors may be used to endorse | |||||
or promote products derived from this software without specific prior written | |||||
permission. | |||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | |||||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY | |||||
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |||||
DAMAGE. |
The MIT License | |||||
Copyright (c) 2007 Mockito contributors | |||||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
of this software and associated documentation files (the "Software"), to deal | |||||
in the Software without restriction, including without limitation the rights | |||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||||
copies of the Software, and to permit persons to whom the Software is | |||||
furnished to do so, subject to the following conditions: | |||||
The above copyright notice and this permission notice shall be included in | |||||
all copies or substantial portions of the Software. | |||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||
THE SOFTWARE. |
Mockito license - MIT. | |||||
Libraries used: | |||||
Cglib - Apache License 2.0 | |||||
ASM - BSD license | |||||
Mockito all distribution: | |||||
Objenesis - MIT license | |||||
Hamcrest - BSD license |
Copyright (c) 2003-2008, Objenesis Team and all contributors | |||||
Permission is hereby granted, free of charge, to any person obtaining a copy of | |||||
this software and associated documentation files (the "Software"), to deal in | |||||
the Software without restriction, including without limitation the rights to | |||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |||||
the Software, and to permit persons to whom the Software is furnished to do so, | |||||
subject to the following conditions: | |||||
The above copyright notice and this permission notice shall be included in all | |||||
copies or substantial portions of the Software. | |||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
package org.apache.fop.accessibility; | 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. | * Helper class for FOP's accessibility features. | ||||
/** Constant string for the rendering options key to enable accessibility features. */ | /** Constant string for the rendering options key to enable accessibility features. */ | ||||
public static final String ACCESSIBILITY = "accessibility"; | 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() { } | 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); | |||||
} | |||||
} | } |
/* | |||||
* 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$ */ | |||||
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); | |||||
} | |||||
} | |||||
} |
/** | /** | ||||
* Package-private default constructor. | * Package-private default constructor. | ||||
*/ | */ | ||||
StructureTree() { } | |||||
public StructureTree() { } | |||||
private static boolean flowOrStaticContentNodes(NodeList nodes) { | private static boolean flowOrStaticContentNodes(NodeList nodes) { | ||||
for (int i = 0; i < nodes.getLength(); i++) { | for (int i = 0; i < nodes.getLength(); i++) { |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.accessibility; | |||||
import javax.xml.transform.TransformerConfigurationException; | |||||
import javax.xml.transform.TransformerFactory; | |||||
import javax.xml.transform.dom.DOMResult; | |||||
import javax.xml.transform.sax.SAXTransformerFactory; | |||||
import javax.xml.transform.sax.TransformerHandler; | |||||
import org.xml.sax.SAXException; | |||||
import org.xml.sax.helpers.AttributesImpl; | |||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.fo.DelegatingFOEventHandler; | |||||
import org.apache.fop.fo.FOEventHandler; | |||||
import org.apache.fop.fo.FONode; | |||||
import org.apache.fop.fo.extensions.ExtensionElementMapping; | |||||
import org.apache.fop.fo.extensions.ExternalDocument; | |||||
import org.apache.fop.fo.extensions.InternalElementMapping; | |||||
import org.apache.fop.fo.flow.AbstractGraphics; | |||||
import org.apache.fop.fo.flow.BasicLink; | |||||
import org.apache.fop.fo.flow.Block; | |||||
import org.apache.fop.fo.flow.BlockContainer; | |||||
import org.apache.fop.fo.flow.Character; | |||||
import org.apache.fop.fo.flow.ExternalGraphic; | |||||
import org.apache.fop.fo.flow.Footnote; | |||||
import org.apache.fop.fo.flow.FootnoteBody; | |||||
import org.apache.fop.fo.flow.Inline; | |||||
import org.apache.fop.fo.flow.InstreamForeignObject; | |||||
import org.apache.fop.fo.flow.Leader; | |||||
import org.apache.fop.fo.flow.ListBlock; | |||||
import org.apache.fop.fo.flow.ListItem; | |||||
import org.apache.fop.fo.flow.ListItemBody; | |||||
import org.apache.fop.fo.flow.ListItemLabel; | |||||
import org.apache.fop.fo.flow.PageNumber; | |||||
import org.apache.fop.fo.flow.PageNumberCitation; | |||||
import org.apache.fop.fo.flow.PageNumberCitationLast; | |||||
import org.apache.fop.fo.flow.Wrapper; | |||||
import org.apache.fop.fo.flow.table.Table; | |||||
import org.apache.fop.fo.flow.table.TableBody; | |||||
import org.apache.fop.fo.flow.table.TableCell; | |||||
import org.apache.fop.fo.flow.table.TableColumn; | |||||
import org.apache.fop.fo.flow.table.TableFooter; | |||||
import org.apache.fop.fo.flow.table.TableHeader; | |||||
import org.apache.fop.fo.flow.table.TableRow; | |||||
import org.apache.fop.fo.pagination.Flow; | |||||
import org.apache.fop.fo.pagination.PageSequence; | |||||
import org.apache.fop.fo.pagination.StaticContent; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.util.XMLUtil; | |||||
/** | |||||
* A class that builds the document's structure tree. | |||||
*/ | |||||
public class StructureTreeBuildingFOEventHandler extends DelegatingFOEventHandler { | |||||
private int idCounter; | |||||
private final StructureTree structureTree; | |||||
private TransformerHandler structureTreeDOMBuilder; | |||||
private DOMResult result; | |||||
/** Delegates to either {@link #actualStructureTreeBuilder} or {@link #eventSwallower}. */ | |||||
private FOEventHandler structureTreeBuilder; | |||||
private FOEventHandler actualStructureTreeBuilder; | |||||
/** The descendants of some elements like fo:leader must be ignored. */ | |||||
private final FOEventHandler eventSwallower; | |||||
private final class StructureTreeBuilder extends FOEventHandler { | |||||
public StructureTreeBuilder(FOUserAgent foUserAgent) { | |||||
super(foUserAgent); | |||||
} | |||||
@Override | |||||
public void startDocument() throws SAXException { | |||||
} | |||||
@Override | |||||
public void endDocument() throws SAXException { | |||||
} | |||||
@Override | |||||
public void startPageSequence(PageSequence pageSeq) { | |||||
SAXTransformerFactory transformerFactory = | |||||
(SAXTransformerFactory) TransformerFactory.newInstance(); | |||||
try { | |||||
structureTreeDOMBuilder = transformerFactory.newTransformerHandler(); | |||||
} catch (TransformerConfigurationException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
result = new DOMResult(); | |||||
structureTreeDOMBuilder.setResult(result); | |||||
try { | |||||
structureTreeDOMBuilder.startDocument(); | |||||
} catch (SAXException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
startElement(pageSeq); | |||||
} | |||||
@Override | |||||
public void endPageSequence(PageSequence pageSeq) { | |||||
endElement(pageSeq); | |||||
try { | |||||
structureTreeDOMBuilder.endDocument(); | |||||
} catch (SAXException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
structureTree.addPageSequenceStructure( | |||||
result.getNode().getFirstChild().getChildNodes()); | |||||
} | |||||
@Override | |||||
public void startPageNumber(PageNumber pagenum) { | |||||
startElementWithID(pagenum); | |||||
} | |||||
@Override | |||||
public void endPageNumber(PageNumber pagenum) { | |||||
endElement(pagenum); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitation(PageNumberCitation pageCite) { | |||||
startElementWithID(pageCite); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitation(PageNumberCitation pageCite) { | |||||
endElement(pageCite); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
startElementWithID(pageLast); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
endElement(pageLast); | |||||
} | |||||
@Override | |||||
public void startFlow(Flow fl) { | |||||
startElement(fl); | |||||
} | |||||
@Override | |||||
public void endFlow(Flow fl) { | |||||
endElement(fl); | |||||
} | |||||
@Override | |||||
public void startBlock(Block bl) { | |||||
startElementWithID(bl); | |||||
} | |||||
@Override | |||||
public void endBlock(Block bl) { | |||||
endElement(bl); | |||||
} | |||||
@Override | |||||
public void startBlockContainer(BlockContainer blc) { | |||||
startElement(blc); | |||||
} | |||||
@Override | |||||
public void endBlockContainer(BlockContainer blc) { | |||||
endElement(blc); | |||||
} | |||||
@Override | |||||
public void startInline(Inline inl) { | |||||
startElementWithID(inl); | |||||
} | |||||
@Override | |||||
public void endInline(Inline inl) { | |||||
endElement(inl); | |||||
} | |||||
@Override | |||||
public void startTable(Table tbl) { | |||||
startElementWithID(tbl); | |||||
} | |||||
@Override | |||||
public void endTable(Table tbl) { | |||||
endElement(tbl); | |||||
} | |||||
@Override | |||||
public void startHeader(TableHeader header) { | |||||
startElementWithID(header); | |||||
} | |||||
@Override | |||||
public void endHeader(TableHeader header) { | |||||
endElement(header); | |||||
} | |||||
@Override | |||||
public void startFooter(TableFooter footer) { | |||||
startElementWithID(footer); | |||||
} | |||||
@Override | |||||
public void endFooter(TableFooter footer) { | |||||
endElement(footer); | |||||
} | |||||
@Override | |||||
public void startBody(TableBody body) { | |||||
startElementWithID(body); | |||||
} | |||||
@Override | |||||
public void endBody(TableBody body) { | |||||
endElement(body); | |||||
} | |||||
@Override | |||||
public void startRow(TableRow tr) { | |||||
startElementWithID(tr); | |||||
} | |||||
@Override | |||||
public void endRow(TableRow tr) { | |||||
endElement(tr); | |||||
} | |||||
@Override | |||||
public void startCell(TableCell tc) { | |||||
AttributesImpl attributes = new AttributesImpl(); | |||||
int colSpan = tc.getNumberColumnsSpanned(); | |||||
if (colSpan > 1) { | |||||
addNoNamespaceAttribute(attributes, "number-columns-spanned", | |||||
Integer.toString(colSpan)); | |||||
} | |||||
startElementWithID(tc, attributes); | |||||
} | |||||
@Override | |||||
public void endCell(TableCell tc) { | |||||
endElement(tc); | |||||
} | |||||
@Override | |||||
public void startList(ListBlock lb) { | |||||
startElement(lb); | |||||
} | |||||
@Override | |||||
public void endList(ListBlock lb) { | |||||
endElement(lb); | |||||
} | |||||
@Override | |||||
public void startListItem(ListItem li) { | |||||
startElement(li); | |||||
} | |||||
@Override | |||||
public void endListItem(ListItem li) { | |||||
endElement(li); | |||||
} | |||||
@Override | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
startElement(listItemLabel); | |||||
} | |||||
@Override | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
endElement(listItemLabel); | |||||
} | |||||
@Override | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
startElement(listItemBody); | |||||
} | |||||
@Override | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
endElement(listItemBody); | |||||
} | |||||
@Override | |||||
public void startStatic(StaticContent staticContent) { | |||||
startElement(staticContent); | |||||
} | |||||
@Override | |||||
public void endStatic(StaticContent statisContent) { | |||||
endElement(statisContent); | |||||
} | |||||
@Override | |||||
public void startLink(BasicLink basicLink) { | |||||
startElementWithID(basicLink); | |||||
} | |||||
@Override | |||||
public void endLink(BasicLink basicLink) { | |||||
endElement(basicLink); | |||||
} | |||||
@Override | |||||
public void image(ExternalGraphic eg) { | |||||
startElementWithIDAndAltText(eg); | |||||
endElement(eg); | |||||
} | |||||
@Override | |||||
public void startInstreamForeignObject(InstreamForeignObject ifo) { | |||||
startElementWithIDAndAltText(ifo); | |||||
} | |||||
@Override | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
endElement(ifo); | |||||
} | |||||
@Override | |||||
public void startFootnote(Footnote footnote) { | |||||
startElement(footnote); | |||||
} | |||||
@Override | |||||
public void endFootnote(Footnote footnote) { | |||||
endElement(footnote); | |||||
} | |||||
@Override | |||||
public void startFootnoteBody(FootnoteBody body) { | |||||
startElement(body); | |||||
} | |||||
@Override | |||||
public void endFootnoteBody(FootnoteBody body) { | |||||
endElement(body); | |||||
} | |||||
@Override | |||||
public void startWrapper(Wrapper wrapper) { | |||||
startElement(wrapper); | |||||
} | |||||
@Override | |||||
public void endWrapper(Wrapper wrapper) { | |||||
endElement(wrapper); | |||||
} | |||||
@Override | |||||
public void character(Character c) { | |||||
startElementWithID(c); | |||||
endElement(c); | |||||
} | |||||
private void startElement(FONode node) { | |||||
startElement(node, new AttributesImpl()); | |||||
} | |||||
private void startElementWithID(FONode node) { | |||||
startElementWithID(node, new AttributesImpl()); | |||||
} | |||||
private void startElementWithIDAndAltText(AbstractGraphics node) { | |||||
AttributesImpl attributes = new AttributesImpl(); | |||||
addAttribute(attributes, ExtensionElementMapping.URI, "alt-text", | |||||
ExtensionElementMapping.STANDARD_PREFIX, node.getAltText()); | |||||
startElementWithID(node, attributes); | |||||
} | |||||
private void startElementWithID(FONode node, AttributesImpl attributes) { | |||||
String id = Integer.toHexString(idCounter++); | |||||
node.setPtr(id); | |||||
addAttribute(attributes, | |||||
InternalElementMapping.URI, "ptr", InternalElementMapping.STANDARD_PREFIX, id); | |||||
startElement(node, attributes); | |||||
} | |||||
private void startElement(FONode node, AttributesImpl attributes) { | |||||
String localName = node.getLocalName(); | |||||
if (node instanceof CommonAccessibilityHolder) { | |||||
addRole((CommonAccessibilityHolder) node, attributes); | |||||
} | |||||
try { | |||||
structureTreeDOMBuilder.startElement(node.getNamespaceURI(), localName, | |||||
node.getNormalNamespacePrefix() + ":" + localName, | |||||
attributes); | |||||
} catch (SAXException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
private void addNoNamespaceAttribute(AttributesImpl attributes, String name, String value) { | |||||
attributes.addAttribute("", name, name, XMLUtil.CDATA, value); | |||||
} | |||||
private void addAttribute(AttributesImpl attributes, | |||||
String namespace, String localName, String prefix, String value) { | |||||
assert namespace.length() > 0 && prefix.length() > 0; | |||||
String qualifiedName = prefix + ":" + localName; | |||||
attributes.addAttribute(namespace, localName, qualifiedName, XMLUtil.CDATA, value); | |||||
} | |||||
private void addRole(CommonAccessibilityHolder node, AttributesImpl attributes) { | |||||
String role = node.getCommonAccessibility().getRole(); | |||||
if (role != null) { | |||||
addNoNamespaceAttribute(attributes, "role", role); | |||||
} | |||||
} | |||||
private void endElement(FONode node) { | |||||
String localName = node.getLocalName(); | |||||
try { | |||||
structureTreeDOMBuilder.endElement(node.getNamespaceURI(), localName, | |||||
node.getNormalNamespacePrefix() + ":" + localName); | |||||
} catch (SAXException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Creates a new instance. | |||||
* | |||||
* @param structureTree the object that will hold the structure tree | |||||
* @param delegate the FO event handler that must be wrapped by this instance | |||||
*/ | |||||
public StructureTreeBuildingFOEventHandler(StructureTree structureTree, | |||||
FOEventHandler delegate) { | |||||
super(delegate); | |||||
this.structureTree = structureTree; | |||||
this.actualStructureTreeBuilder = new StructureTreeBuilder(foUserAgent); | |||||
this.structureTreeBuilder = actualStructureTreeBuilder; | |||||
this.eventSwallower = new FOEventHandler(foUserAgent) { }; | |||||
} | |||||
@Override | |||||
public void startDocument() throws SAXException { | |||||
structureTreeBuilder.startDocument(); | |||||
super.startDocument(); | |||||
} | |||||
@Override | |||||
public void endDocument() throws SAXException { | |||||
structureTreeBuilder.endDocument(); | |||||
super.endDocument(); | |||||
} | |||||
@Override | |||||
public void startPageSequence(PageSequence pageSeq) { | |||||
structureTreeBuilder.startPageSequence(pageSeq); | |||||
super.startPageSequence(pageSeq); | |||||
} | |||||
@Override | |||||
public void endPageSequence(PageSequence pageSeq) { | |||||
structureTreeBuilder.endPageSequence(pageSeq); | |||||
super.endPageSequence(pageSeq); | |||||
} | |||||
@Override | |||||
public void startPageNumber(PageNumber pagenum) { | |||||
structureTreeBuilder.startPageNumber(pagenum); | |||||
super.startPageNumber(pagenum); | |||||
} | |||||
@Override | |||||
public void endPageNumber(PageNumber pagenum) { | |||||
structureTreeBuilder.endPageNumber(pagenum); | |||||
super.endPageNumber(pagenum); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitation(PageNumberCitation pageCite) { | |||||
structureTreeBuilder.startPageNumberCitation(pageCite); | |||||
super.startPageNumberCitation(pageCite); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitation(PageNumberCitation pageCite) { | |||||
structureTreeBuilder.endPageNumberCitation(pageCite); | |||||
super.endPageNumberCitation(pageCite); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
structureTreeBuilder.startPageNumberCitationLast(pageLast); | |||||
super.startPageNumberCitationLast(pageLast); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
structureTreeBuilder.endPageNumberCitationLast(pageLast); | |||||
super.endPageNumberCitationLast(pageLast); | |||||
} | |||||
@Override | |||||
public void startFlow(Flow fl) { | |||||
structureTreeBuilder.startFlow(fl); | |||||
super.startFlow(fl); | |||||
} | |||||
@Override | |||||
public void endFlow(Flow fl) { | |||||
structureTreeBuilder.endFlow(fl); | |||||
super.endFlow(fl); | |||||
} | |||||
@Override | |||||
public void startBlock(Block bl) { | |||||
structureTreeBuilder.startBlock(bl); | |||||
super.startBlock(bl); | |||||
} | |||||
@Override | |||||
public void endBlock(Block bl) { | |||||
structureTreeBuilder.endBlock(bl); | |||||
super.endBlock(bl); | |||||
} | |||||
@Override | |||||
public void startBlockContainer(BlockContainer blc) { | |||||
structureTreeBuilder.startBlockContainer(blc); | |||||
super.startBlockContainer(blc); | |||||
} | |||||
@Override | |||||
public void endBlockContainer(BlockContainer blc) { | |||||
structureTreeBuilder.endBlockContainer(blc); | |||||
super.endBlockContainer(blc); | |||||
} | |||||
@Override | |||||
public void startInline(Inline inl) { | |||||
structureTreeBuilder.startInline(inl); | |||||
super.startInline(inl); | |||||
} | |||||
@Override | |||||
public void endInline(Inline inl) { | |||||
structureTreeBuilder.endInline(inl); | |||||
super.endInline(inl); | |||||
} | |||||
@Override | |||||
public void startTable(Table tbl) { | |||||
structureTreeBuilder.startTable(tbl); | |||||
super.startTable(tbl); | |||||
} | |||||
@Override | |||||
public void endTable(Table tbl) { | |||||
structureTreeBuilder.endTable(tbl); | |||||
super.endTable(tbl); | |||||
} | |||||
@Override | |||||
public void startColumn(TableColumn tc) { | |||||
structureTreeBuilder.startColumn(tc); | |||||
super.startColumn(tc); | |||||
} | |||||
@Override | |||||
public void endColumn(TableColumn tc) { | |||||
structureTreeBuilder.endColumn(tc); | |||||
super.endColumn(tc); | |||||
} | |||||
@Override | |||||
public void startHeader(TableHeader header) { | |||||
structureTreeBuilder.startHeader(header); | |||||
super.startHeader(header); | |||||
} | |||||
@Override | |||||
public void endHeader(TableHeader header) { | |||||
structureTreeBuilder.endHeader(header); | |||||
super.endHeader(header); | |||||
} | |||||
@Override | |||||
public void startFooter(TableFooter footer) { | |||||
structureTreeBuilder.startFooter(footer); | |||||
super.startFooter(footer); | |||||
} | |||||
@Override | |||||
public void endFooter(TableFooter footer) { | |||||
structureTreeBuilder.endFooter(footer); | |||||
super.endFooter(footer); | |||||
} | |||||
@Override | |||||
public void startBody(TableBody body) { | |||||
structureTreeBuilder.startBody(body); | |||||
super.startBody(body); | |||||
} | |||||
@Override | |||||
public void endBody(TableBody body) { | |||||
structureTreeBuilder.endBody(body); | |||||
super.endBody(body); | |||||
} | |||||
@Override | |||||
public void startRow(TableRow tr) { | |||||
structureTreeBuilder.startRow(tr); | |||||
super.startRow(tr); | |||||
} | |||||
@Override | |||||
public void endRow(TableRow tr) { | |||||
structureTreeBuilder.endRow(tr); | |||||
super.endRow(tr); | |||||
} | |||||
@Override | |||||
public void startCell(TableCell tc) { | |||||
structureTreeBuilder.startCell(tc); | |||||
super.startCell(tc); | |||||
} | |||||
@Override | |||||
public void endCell(TableCell tc) { | |||||
structureTreeBuilder.endCell(tc); | |||||
super.endCell(tc); | |||||
} | |||||
@Override | |||||
public void startList(ListBlock lb) { | |||||
structureTreeBuilder.startList(lb); | |||||
super.startList(lb); | |||||
} | |||||
@Override | |||||
public void endList(ListBlock lb) { | |||||
structureTreeBuilder.endList(lb); | |||||
super.endList(lb); | |||||
} | |||||
@Override | |||||
public void startListItem(ListItem li) { | |||||
structureTreeBuilder.startListItem(li); | |||||
super.startListItem(li); | |||||
} | |||||
@Override | |||||
public void endListItem(ListItem li) { | |||||
structureTreeBuilder.endListItem(li); | |||||
super.endListItem(li); | |||||
} | |||||
@Override | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
structureTreeBuilder.startListLabel(listItemLabel); | |||||
super.startListLabel(listItemLabel); | |||||
} | |||||
@Override | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
structureTreeBuilder.endListLabel(listItemLabel); | |||||
super.endListLabel(listItemLabel); | |||||
} | |||||
@Override | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
structureTreeBuilder.startListBody(listItemBody); | |||||
super.startListBody(listItemBody); | |||||
} | |||||
@Override | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
structureTreeBuilder.endListBody(listItemBody); | |||||
super.endListBody(listItemBody); | |||||
} | |||||
@Override | |||||
public void startStatic(StaticContent staticContent) { | |||||
structureTreeBuilder.startStatic(staticContent); | |||||
super.startStatic(staticContent); | |||||
} | |||||
@Override | |||||
public void endStatic(StaticContent statisContent) { | |||||
structureTreeBuilder.endStatic(statisContent); | |||||
super.endStatic(statisContent); | |||||
} | |||||
@Override | |||||
public void startMarkup() { | |||||
structureTreeBuilder.startMarkup(); | |||||
super.startMarkup(); | |||||
} | |||||
@Override | |||||
public void endMarkup() { | |||||
structureTreeBuilder.endMarkup(); | |||||
super.endMarkup(); | |||||
} | |||||
@Override | |||||
public void startLink(BasicLink basicLink) { | |||||
structureTreeBuilder.startLink(basicLink); | |||||
super.startLink(basicLink); | |||||
} | |||||
@Override | |||||
public void endLink(BasicLink basicLink) { | |||||
structureTreeBuilder.endLink(basicLink); | |||||
super.endLink(basicLink); | |||||
} | |||||
@Override | |||||
public void image(ExternalGraphic eg) { | |||||
structureTreeBuilder.image(eg); | |||||
super.image(eg); | |||||
} | |||||
@Override | |||||
public void pageRef() { | |||||
structureTreeBuilder.pageRef(); | |||||
super.pageRef(); | |||||
} | |||||
@Override | |||||
public void startInstreamForeignObject(InstreamForeignObject ifo) { | |||||
structureTreeBuilder.startInstreamForeignObject(ifo); | |||||
super.startInstreamForeignObject(ifo); | |||||
} | |||||
@Override | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
structureTreeBuilder.endInstreamForeignObject(ifo); | |||||
super.endInstreamForeignObject(ifo); | |||||
} | |||||
@Override | |||||
public void startFootnote(Footnote footnote) { | |||||
structureTreeBuilder.startFootnote(footnote); | |||||
super.startFootnote(footnote); | |||||
} | |||||
@Override | |||||
public void endFootnote(Footnote footnote) { | |||||
structureTreeBuilder.endFootnote(footnote); | |||||
super.endFootnote(footnote); | |||||
} | |||||
@Override | |||||
public void startFootnoteBody(FootnoteBody body) { | |||||
structureTreeBuilder.startFootnoteBody(body); | |||||
super.startFootnoteBody(body); | |||||
} | |||||
@Override | |||||
public void endFootnoteBody(FootnoteBody body) { | |||||
structureTreeBuilder.endFootnoteBody(body); | |||||
super.endFootnoteBody(body); | |||||
} | |||||
@Override | |||||
public void startLeader(Leader l) { | |||||
structureTreeBuilder = eventSwallower; | |||||
structureTreeBuilder.startLeader(l); | |||||
super.startLeader(l); | |||||
} | |||||
@Override | |||||
public void endLeader(Leader l) { | |||||
structureTreeBuilder.endLeader(l); | |||||
structureTreeBuilder = actualStructureTreeBuilder; | |||||
super.endLeader(l); | |||||
} | |||||
@Override | |||||
public void startWrapper(Wrapper wrapper) { | |||||
structureTreeBuilder.startWrapper(wrapper); | |||||
super.startWrapper(wrapper); | |||||
} | |||||
@Override | |||||
public void endWrapper(Wrapper wrapper) { | |||||
structureTreeBuilder.endWrapper(wrapper); | |||||
super.endWrapper(wrapper); | |||||
} | |||||
@Override | |||||
public void character(Character c) { | |||||
structureTreeBuilder.character(c); | |||||
super.character(c); | |||||
} | |||||
@Override | |||||
public void characters(char[] data, int start, int length) { | |||||
structureTreeBuilder.characters(data, start, length); | |||||
super.characters(data, start, length); | |||||
} | |||||
@Override | |||||
public void startExternalDocument(ExternalDocument document) { | |||||
structureTreeBuilder.startExternalDocument(document); | |||||
super.startExternalDocument(document); | |||||
} | |||||
@Override | |||||
public void endExternalDocument(ExternalDocument document) { | |||||
structureTreeBuilder.endExternalDocument(document); | |||||
super.endExternalDocument(document); | |||||
} | |||||
} |
<?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$ --> | |||||
<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> |
<?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$ --> | |||||
<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> |
import org.xml.sax.helpers.DefaultHandler; | import org.xml.sax.helpers.DefaultHandler; | ||||
import org.apache.fop.accessibility.Accessibility; | |||||
import org.apache.fop.fo.FOTreeBuilder; | import org.apache.fop.fo.FOTreeBuilder; | ||||
/** | /** | ||||
if (foTreeBuilder == null) { | if (foTreeBuilder == null) { | ||||
createDefaultHandler(); | createDefaultHandler(); | ||||
} | } | ||||
if (this.foUserAgent.isAccessibilityEnabled()) { | |||||
return Accessibility.decorateDefaultHandler(this.foTreeBuilder, foUserAgent); | |||||
} else { | |||||
return this.foTreeBuilder; | |||||
} | |||||
return this.foTreeBuilder; | |||||
} | } | ||||
/** | /** |
* multi-column layouts. | * multi-column layouts. | ||||
*/ | */ | ||||
int PR_X_DISABLE_COLUMN_BALANCING = 273; | int PR_X_DISABLE_COLUMN_BALANCING = 273; | ||||
/** Property constant - FOP proprietary: FOP internal use for accessibility */ | |||||
int PR_X_PTR = 274; | |||||
/** | /** | ||||
* Property constant - FOP proprietary: alternative text for e-g and i-f-o. | * Property constant - FOP proprietary: alternative text for e-g and i-f-o. | ||||
* Used for accessibility. | * Used for accessibility. | ||||
*/ | */ | ||||
int PR_X_ALT_TEXT = 275; | |||||
int PR_X_ALT_TEXT = 274; | |||||
/** Property constant - FOP proprietary prototype (in XSL-FO 2.0 Requirements) */ | /** Property constant - FOP proprietary prototype (in XSL-FO 2.0 Requirements) */ | ||||
int PR_X_XML_BASE = 276; | |||||
int PR_X_XML_BASE = 275; | |||||
/** Number of property constants defined */ | /** Number of property constants defined */ | ||||
int PROPERTY_COUNT = 276; | |||||
int PROPERTY_COUNT = 275; | |||||
// compound property constants | // compound property constants | ||||
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo; | |||||
import org.xml.sax.SAXException; | |||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.fo.extensions.ExternalDocument; | |||||
import org.apache.fop.fo.flow.BasicLink; | |||||
import org.apache.fop.fo.flow.Block; | |||||
import org.apache.fop.fo.flow.BlockContainer; | |||||
import org.apache.fop.fo.flow.Character; | |||||
import org.apache.fop.fo.flow.ExternalGraphic; | |||||
import org.apache.fop.fo.flow.Footnote; | |||||
import org.apache.fop.fo.flow.FootnoteBody; | |||||
import org.apache.fop.fo.flow.Inline; | |||||
import org.apache.fop.fo.flow.InstreamForeignObject; | |||||
import org.apache.fop.fo.flow.Leader; | |||||
import org.apache.fop.fo.flow.ListBlock; | |||||
import org.apache.fop.fo.flow.ListItem; | |||||
import org.apache.fop.fo.flow.ListItemBody; | |||||
import org.apache.fop.fo.flow.ListItemLabel; | |||||
import org.apache.fop.fo.flow.PageNumber; | |||||
import org.apache.fop.fo.flow.PageNumberCitation; | |||||
import org.apache.fop.fo.flow.PageNumberCitationLast; | |||||
import org.apache.fop.fo.flow.Wrapper; | |||||
import org.apache.fop.fo.flow.table.Table; | |||||
import org.apache.fop.fo.flow.table.TableBody; | |||||
import org.apache.fop.fo.flow.table.TableCell; | |||||
import org.apache.fop.fo.flow.table.TableColumn; | |||||
import org.apache.fop.fo.flow.table.TableFooter; | |||||
import org.apache.fop.fo.flow.table.TableHeader; | |||||
import org.apache.fop.fo.flow.table.TableRow; | |||||
import org.apache.fop.fo.pagination.Flow; | |||||
import org.apache.fop.fo.pagination.PageSequence; | |||||
import org.apache.fop.fo.pagination.StaticContent; | |||||
import org.apache.fop.fonts.FontInfo; | |||||
/** | |||||
* This class delegates all FO events to another FOEventHandler instance. | |||||
*/ | |||||
public abstract class DelegatingFOEventHandler extends FOEventHandler { | |||||
private final FOEventHandler delegate; | |||||
/** | |||||
* Creates a new instance that delegates events to the given object. | |||||
* | |||||
* @param delegate the object to which all FO events will be forwarded | |||||
*/ | |||||
public DelegatingFOEventHandler(FOEventHandler delegate) { | |||||
super(delegate.getUserAgent()); | |||||
this.delegate = delegate; | |||||
} | |||||
@Override | |||||
public FOUserAgent getUserAgent() { | |||||
return delegate.getUserAgent(); | |||||
} | |||||
@Override | |||||
public FontInfo getFontInfo() { | |||||
return delegate.getFontInfo(); | |||||
} | |||||
@Override | |||||
public void startDocument() throws SAXException { | |||||
delegate.startDocument(); | |||||
} | |||||
@Override | |||||
public void endDocument() throws SAXException { | |||||
delegate.endDocument(); | |||||
} | |||||
@Override | |||||
public void startPageSequence(PageSequence pageSeq) { | |||||
delegate.startPageSequence(pageSeq); | |||||
} | |||||
@Override | |||||
public void endPageSequence(PageSequence pageSeq) { | |||||
delegate.endPageSequence(pageSeq); | |||||
} | |||||
@Override | |||||
public void startPageNumber(PageNumber pagenum) { | |||||
delegate.startPageNumber(pagenum); | |||||
} | |||||
@Override | |||||
public void endPageNumber(PageNumber pagenum) { | |||||
delegate.endPageNumber(pagenum); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitation(PageNumberCitation pageCite) { | |||||
delegate.startPageNumberCitation(pageCite); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitation(PageNumberCitation pageCite) { | |||||
delegate.endPageNumberCitation(pageCite); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
delegate.startPageNumberCitationLast(pageLast); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
delegate.endPageNumberCitationLast(pageLast); | |||||
} | |||||
@Override | |||||
public void startFlow(Flow fl) { | |||||
delegate.startFlow(fl); | |||||
} | |||||
@Override | |||||
public void endFlow(Flow fl) { | |||||
delegate.endFlow(fl); | |||||
} | |||||
@Override | |||||
public void startBlock(Block bl) { | |||||
delegate.startBlock(bl); | |||||
} | |||||
@Override | |||||
public void endBlock(Block bl) { | |||||
delegate.endBlock(bl); | |||||
} | |||||
@Override | |||||
public void startBlockContainer(BlockContainer blc) { | |||||
delegate.startBlockContainer(blc); | |||||
} | |||||
@Override | |||||
public void endBlockContainer(BlockContainer blc) { | |||||
delegate.endBlockContainer(blc); | |||||
} | |||||
@Override | |||||
public void startInline(Inline inl) { | |||||
delegate.startInline(inl); | |||||
} | |||||
@Override | |||||
public void endInline(Inline inl) { | |||||
delegate.endInline(inl); | |||||
} | |||||
@Override | |||||
public void startTable(Table tbl) { | |||||
delegate.startTable(tbl); | |||||
} | |||||
@Override | |||||
public void endTable(Table tbl) { | |||||
delegate.endTable(tbl); | |||||
} | |||||
@Override | |||||
public void startColumn(TableColumn tc) { | |||||
delegate.startColumn(tc); | |||||
} | |||||
@Override | |||||
public void endColumn(TableColumn tc) { | |||||
delegate.endColumn(tc); | |||||
} | |||||
@Override | |||||
public void startHeader(TableHeader header) { | |||||
delegate.startHeader(header); | |||||
} | |||||
@Override | |||||
public void endHeader(TableHeader header) { | |||||
delegate.endHeader(header); | |||||
} | |||||
@Override | |||||
public void startFooter(TableFooter footer) { | |||||
delegate.startFooter(footer); | |||||
} | |||||
@Override | |||||
public void endFooter(TableFooter footer) { | |||||
delegate.endFooter(footer); | |||||
} | |||||
@Override | |||||
public void startBody(TableBody body) { | |||||
delegate.startBody(body); | |||||
} | |||||
@Override | |||||
public void endBody(TableBody body) { | |||||
delegate.endBody(body); | |||||
} | |||||
@Override | |||||
public void startRow(TableRow tr) { | |||||
delegate.startRow(tr); | |||||
} | |||||
@Override | |||||
public void endRow(TableRow tr) { | |||||
delegate.endRow(tr); | |||||
} | |||||
@Override | |||||
public void startCell(TableCell tc) { | |||||
delegate.startCell(tc); | |||||
} | |||||
@Override | |||||
public void endCell(TableCell tc) { | |||||
delegate.endCell(tc); | |||||
} | |||||
@Override | |||||
public void startList(ListBlock lb) { | |||||
delegate.startList(lb); | |||||
} | |||||
@Override | |||||
public void endList(ListBlock lb) { | |||||
delegate.endList(lb); | |||||
} | |||||
@Override | |||||
public void startListItem(ListItem li) { | |||||
delegate.startListItem(li); | |||||
} | |||||
@Override | |||||
public void endListItem(ListItem li) { | |||||
delegate.endListItem(li); | |||||
} | |||||
@Override | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
delegate.startListLabel(listItemLabel); | |||||
} | |||||
@Override | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
delegate.endListLabel(listItemLabel); | |||||
} | |||||
@Override | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
delegate.startListBody(listItemBody); | |||||
} | |||||
@Override | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
delegate.endListBody(listItemBody); | |||||
} | |||||
@Override | |||||
public void startStatic(StaticContent staticContent) { | |||||
delegate.startStatic(staticContent); | |||||
} | |||||
@Override | |||||
public void endStatic(StaticContent statisContent) { | |||||
delegate.endStatic(statisContent); | |||||
} | |||||
@Override | |||||
public void startMarkup() { | |||||
delegate.startMarkup(); | |||||
} | |||||
@Override | |||||
public void endMarkup() { | |||||
delegate.endMarkup(); | |||||
} | |||||
@Override | |||||
public void startLink(BasicLink basicLink) { | |||||
delegate.startLink(basicLink); | |||||
} | |||||
@Override | |||||
public void endLink(BasicLink basicLink) { | |||||
delegate.endLink(basicLink); | |||||
} | |||||
@Override | |||||
public void image(ExternalGraphic eg) { | |||||
delegate.image(eg); | |||||
} | |||||
@Override | |||||
public void pageRef() { | |||||
delegate.pageRef(); | |||||
} | |||||
@Override | |||||
public void startInstreamForeignObject(InstreamForeignObject ifo) { | |||||
delegate.startInstreamForeignObject(ifo); | |||||
} | |||||
@Override | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
delegate.endInstreamForeignObject(ifo); | |||||
} | |||||
@Override | |||||
public void startFootnote(Footnote footnote) { | |||||
delegate.startFootnote(footnote); | |||||
} | |||||
@Override | |||||
public void endFootnote(Footnote footnote) { | |||||
delegate.endFootnote(footnote); | |||||
} | |||||
@Override | |||||
public void startFootnoteBody(FootnoteBody body) { | |||||
delegate.startFootnoteBody(body); | |||||
} | |||||
@Override | |||||
public void endFootnoteBody(FootnoteBody body) { | |||||
delegate.endFootnoteBody(body); | |||||
} | |||||
@Override | |||||
public void startLeader(Leader l) { | |||||
delegate.startLeader(l); | |||||
} | |||||
@Override | |||||
public void endLeader(Leader l) { | |||||
delegate.endLeader(l); | |||||
} | |||||
@Override | |||||
public void startWrapper(Wrapper wrapper) { | |||||
delegate.startWrapper(wrapper); | |||||
} | |||||
@Override | |||||
public void endWrapper(Wrapper wrapper) { | |||||
delegate.endWrapper(wrapper); | |||||
} | |||||
@Override | |||||
public void character(Character c) { | |||||
delegate.character(c); | |||||
} | |||||
@Override | |||||
public void characters(char[] data, int start, int length) { | |||||
delegate.characters(data, start, length); | |||||
} | |||||
@Override | |||||
public void startExternalDocument(ExternalDocument document) { | |||||
delegate.startExternalDocument(document); | |||||
} | |||||
@Override | |||||
public void endExternalDocument(ExternalDocument document) { | |||||
delegate.endExternalDocument(document); | |||||
} | |||||
} |
import org.apache.fop.fo.flow.Leader; | import org.apache.fop.fo.flow.Leader; | ||||
import org.apache.fop.fo.flow.ListBlock; | import org.apache.fop.fo.flow.ListBlock; | ||||
import org.apache.fop.fo.flow.ListItem; | import org.apache.fop.fo.flow.ListItem; | ||||
import org.apache.fop.fo.flow.ListItemBody; | |||||
import org.apache.fop.fo.flow.ListItemLabel; | |||||
import org.apache.fop.fo.flow.PageNumber; | import org.apache.fop.fo.flow.PageNumber; | ||||
import org.apache.fop.fo.flow.PageNumberCitation; | import org.apache.fop.fo.flow.PageNumberCitation; | ||||
import org.apache.fop.fo.flow.PageNumberCitationLast; | import org.apache.fop.fo.flow.PageNumberCitationLast; | ||||
import org.apache.fop.fo.flow.Wrapper; | |||||
import org.apache.fop.fo.flow.table.Table; | import org.apache.fop.fo.flow.table.Table; | ||||
import org.apache.fop.fo.flow.table.TableBody; | import org.apache.fop.fo.flow.table.TableBody; | ||||
import org.apache.fop.fo.flow.table.TableCell; | import org.apache.fop.fo.flow.table.TableCell; | ||||
import org.apache.fop.fo.flow.table.TableRow; | import org.apache.fop.fo.flow.table.TableRow; | ||||
import org.apache.fop.fo.pagination.Flow; | import org.apache.fop.fo.pagination.Flow; | ||||
import org.apache.fop.fo.pagination.PageSequence; | import org.apache.fop.fo.pagination.PageSequence; | ||||
import org.apache.fop.fo.pagination.StaticContent; | |||||
import org.apache.fop.fonts.FontEventAdapter; | import org.apache.fop.fonts.FontEventAdapter; | ||||
import org.apache.fop.fonts.FontInfo; | import org.apache.fop.fonts.FontInfo; | ||||
/** | /** | ||||
* Process start of a ListLabel. | * Process start of a ListLabel. | ||||
* @param listItemLabel ListItemLabel that is starting | |||||
*/ | */ | ||||
public void startListLabel() { | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
} | } | ||||
/** | /** | ||||
* Process end of a ListLabel. | * Process end of a ListLabel. | ||||
* @param listItemLabel ListItemLabel that is ending | |||||
*/ | */ | ||||
public void endListLabel() { | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
} | } | ||||
/** | /** | ||||
* Process start of a ListBody. | * Process start of a ListBody. | ||||
* @param listItemBody ListItemBody that is starting | |||||
*/ | */ | ||||
public void startListBody() { | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
} | } | ||||
/** | /** | ||||
* Process end of a ListBody. | * Process end of a ListBody. | ||||
* @param listItemBody ListItemBody that is ending | |||||
*/ | */ | ||||
public void endListBody() { | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
} | } | ||||
// Static Regions | // Static Regions | ||||
/** | /** | ||||
* Process start of a Static. | * Process start of a Static. | ||||
* @param staticContent StaticContent that is starting | |||||
*/ | */ | ||||
public void startStatic() { | |||||
public void startStatic(StaticContent staticContent) { | |||||
} | } | ||||
/** | /** | ||||
* Process end of a Static. | * Process end of a Static. | ||||
* @param statisContent StaticContent that is ending | |||||
*/ | */ | ||||
public void endStatic() { | |||||
public void endStatic(StaticContent statisContent) { | |||||
} | } | ||||
/** | /** | ||||
* Process start of a Link. | * Process start of a Link. | ||||
* @param basicLink BasicLink that is ending | |||||
* @param basicLink BasicLink that is starting | |||||
*/ | */ | ||||
public void startLink(BasicLink basicLink) { | public void startLink(BasicLink basicLink) { | ||||
} | } | ||||
/** | /** | ||||
* Process end of a Link. | * Process end of a Link. | ||||
* @param basicLink BasicLink that is ending | |||||
*/ | */ | ||||
public void endLink() { | |||||
public void endLink(BasicLink basicLink) { | |||||
} | } | ||||
/** | /** | ||||
} | } | ||||
/** | /** | ||||
* Process an InstreamForeignObject. | |||||
* @param ifo InstreamForeignObject to process. | |||||
* Process the start of an InstreamForeignObject. | |||||
* @param ifo InstreamForeignObject that is starting | |||||
*/ | |||||
public void startInstreamForeignObject(InstreamForeignObject ifo) { | |||||
} | |||||
/** | |||||
* Process the end of an InstreamForeignObject. | |||||
* @param ifo InstreamForeignObject that is ending | |||||
*/ | */ | ||||
public void foreignObject(InstreamForeignObject ifo) { | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
} | } | ||||
/** | /** | ||||
} | } | ||||
/** | /** | ||||
* Process a Leader. | |||||
* @param l Leader to process. | |||||
* Process the start of a Leader. | |||||
* @param l Leader that is starting | |||||
*/ | |||||
public void startLeader(Leader l) { | |||||
} | |||||
/** | |||||
* Process the end of a Leader. | |||||
* @param l Leader that is ending | |||||
*/ | |||||
public void endLeader(Leader l) { | |||||
} | |||||
/** | |||||
* Process the start of a wrapper. | |||||
* | |||||
* @param wrapper wrapper that is starting | |||||
*/ | |||||
public void startWrapper(Wrapper wrapper) { | |||||
} | |||||
/** | |||||
* Process the ending of a wrapper. | |||||
* | |||||
* @param wrapper wrapper that is ending | |||||
*/ | */ | ||||
public void leader(Leader l) { | |||||
public void endWrapper(Wrapper wrapper) { | |||||
} | } | ||||
/** | /** |
} | } | ||||
public void setPtr(String ptr) { | |||||
throw new UnsupportedOperationException(); | |||||
} | |||||
} | } |
m.setDefault(""); | m.setDefault(""); | ||||
addPropertyMaker("id", m); | 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 | // fox:alt-text, used for accessibility | ||||
m = new StringProperty.Maker(PR_X_ALT_TEXT); | m = new StringProperty.Maker(PR_X_ALT_TEXT); | ||||
m.setInherited(false); | m.setInherited(false); |
import org.apache.xmlgraphics.util.QName; | import org.apache.xmlgraphics.util.QName; | ||||
import org.apache.fop.accessibility.StructureTree; | |||||
import org.apache.fop.accessibility.StructureTreeBuildingFOEventHandler; | |||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.apps.FOUserAgent; | import org.apache.fop.apps.FOUserAgent; | ||||
import org.apache.fop.apps.FormattingResults; | import org.apache.fop.apps.FormattingResults; | ||||
//one of the RTF-, MIF- etc. Handlers. | //one of the RTF-, MIF- etc. Handlers. | ||||
foEventHandler = foUserAgent.getRendererFactory().createFOEventHandler( | foEventHandler = foUserAgent.getRendererFactory().createFOEventHandler( | ||||
foUserAgent, outputFormat, stream); | foUserAgent, outputFormat, stream); | ||||
if (userAgent.isAccessibilityEnabled()) { | |||||
StructureTree structureTree = new StructureTree(); | |||||
foEventHandler = new StructureTreeBuildingFOEventHandler(structureTree, foEventHandler); | |||||
userAgent.setStructureTree(structureTree); | |||||
} | |||||
builderContext = new FOTreeBuilderContext(); | builderContext = new FOTreeBuilderContext(); | ||||
builderContext.setPropertyListMaker(new PropertyListMaker() { | builderContext.setPropertyListMaker(new PropertyListMaker() { | ||||
public PropertyList make(FObj fobj, PropertyList parentPropertyList) { | public PropertyList make(FObj fobj, PropertyList parentPropertyList) { |
import org.apache.fop.apps.FopFactory; | import org.apache.fop.apps.FopFactory; | ||||
import org.apache.fop.fo.expr.PropertyException; | import org.apache.fop.fo.expr.PropertyException; | ||||
import org.apache.fop.fo.properties.CommonAbsolutePosition; | import org.apache.fop.fo.properties.CommonAbsolutePosition; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAural; | import org.apache.fop.fo.properties.CommonAural; | ||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonFont; | import org.apache.fop.fo.properties.CommonFont; | ||||
return new CommonMarginInline(this); | return new CommonMarginInline(this); | ||||
} | } | ||||
/** | |||||
* Constructs a CommonAccessibility object. | |||||
* @return the CommonAccessibility object | |||||
* @throws PropertyException if there's a problem while processing the properties | |||||
*/ | |||||
public CommonAccessibility getAccessibilityProps() throws PropertyException { | |||||
return new CommonAccessibility(this); | |||||
} | |||||
/** | /** | ||||
* Constructs a CommonAural object. | * Constructs a CommonAural object. | ||||
* @return the CommonAural object | * @return the CommonAural object |
/** The FOP extension namespace URI */ | /** The FOP extension namespace URI */ | ||||
public static final String URI = "http://xmlgraphics.apache.org/fop/extensions"; | public static final String URI = "http://xmlgraphics.apache.org/fop/extensions"; | ||||
/** The standard XML prefix for elements and attributes in this namespace. */ | |||||
public static final String STANDARD_PREFIX = "fox"; | |||||
private static final Set<String> PROPERTY_ATTRIBUTES | private static final Set<String> PROPERTY_ATTRIBUTES | ||||
= new java.util.HashSet<String>(); | = new java.util.HashSet<String>(); | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getStandardPrefix() { | public String getStandardPrefix() { | ||||
return "fox"; | |||||
return STANDARD_PREFIX; | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ |
/** The FOP extension namespace URI */ | /** The FOP extension namespace URI */ | ||||
public static final String URI = "http://xmlgraphics.apache.org/fop/internal"; | public static final String URI = "http://xmlgraphics.apache.org/fop/internal"; | ||||
/** The standard XML prefix for elements and attributes in this namespace. */ | |||||
public static final String STANDARD_PREFIX = "foi"; | |||||
private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>(); | private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>(); | ||||
static { | static { | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getStandardPrefix() { | public String getStandardPrefix() { | ||||
return "foi"; | |||||
return STANDARD_PREFIX; | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.GraphicsProperties; | import org.apache.fop.fo.GraphicsProperties; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.KeepProperty; | import org.apache.fop.fo.properties.KeepProperty; | ||||
import org.apache.fop.fo.properties.LengthRangeProperty; | import org.apache.fop.fo.properties.LengthRangeProperty; | ||||
* <code>fo:external-graphic</code></a> flow formatting objects. | * <code>fo:external-graphic</code></a> flow formatting objects. | ||||
*/ | */ | ||||
public abstract class AbstractGraphics extends FObj | public abstract class AbstractGraphics extends FObj | ||||
implements GraphicsProperties, StructurePointerPropertySet { | |||||
implements GraphicsProperties, StructurePointerPropertySet, CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:instream-foreign-object | // The value of properties relevant for fo:instream-foreign-object | ||||
// and external-graphics. | // and external-graphics. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private Length alignmentAdjust; | private Length alignmentAdjust; | ||||
private int alignmentBaseline; | private int alignmentBaseline; | ||||
private int scaling; | private int scaling; | ||||
private int textAlign; | private int textAlign; | ||||
private Length width; | private Length width; | ||||
private String altText; | |||||
private String ptr; // used for accessibility | private String ptr; // used for accessibility | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | // private CommonAccessibility commonAccessibility; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | ||||
alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | ||||
dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | ||||
height = pList.get(PR_HEIGHT).getLength(); | height = pList.get(PR_HEIGHT).getLength(); | ||||
id = pList.get(PR_ID).getString(); | id = pList.get(PR_ID).getString(); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange(); | inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange(); | ||||
keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); | keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); | ||||
keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); | keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); | ||||
textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); | textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); | ||||
width = pList.get(PR_WIDTH).getLength(); | width = pList.get(PR_WIDTH).getLength(); | ||||
if (getUserAgent().isAccessibilityEnabled()) { | if (getUserAgent().isAccessibilityEnabled()) { | ||||
String altText = pList.get(PR_X_ALT_TEXT).getString(); | |||||
altText = pList.get(PR_X_ALT_TEXT).getString(); | |||||
if (altText.equals("")) { | if (altText.equals("")) { | ||||
getFOValidationEventProducer().altTextMissing(this, getLocalName(), getLocator()); | getFOValidationEventProducer().altTextMissing(this, getLocalName(), getLocator()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* @return the "id" property. | * @return the "id" property. | ||||
*/ | */ | ||||
return keepWithPrevious; | return keepWithPrevious; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; | ||||
} | } | ||||
public String getAltText() { | |||||
return altText; | |||||
} | |||||
/** @return the graphic's intrinsic width in millipoints */ | /** @return the graphic's intrinsic width in millipoints */ | ||||
public abstract int getIntrinsicWidth(); | public abstract int getIntrinsicWidth(); | ||||
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.KeepProperty; | import org.apache.fop.fo.properties.KeepProperty; | ||||
/** | /** | ||||
* <code>fo:list-item-label</code></a> and <a href="http://www.w3.org/TR/xsl/#fo_list-item-body"> | * <code>fo:list-item-label</code></a> and <a href="http://www.w3.org/TR/xsl/#fo_list-item-body"> | ||||
* <code>fo:list-item-body</code></a>. | * <code>fo:list-item-body</code></a>. | ||||
*/ | */ | ||||
public abstract class AbstractListItemPart extends FObj { | |||||
// The value of properties relevant for fo:list-item-label and fo:list-item-body. | |||||
public abstract class AbstractListItemPart extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
private KeepProperty keepTogether; | private KeepProperty keepTogether; | ||||
// Valid properties, commented out for performance: | // Valid properties, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | // private CommonAccessibility commonAccessibility; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); | keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the "keep-together" property. */ | /** @return the "keep-together" property. */ | ||||
public KeepProperty getKeepTogether() { | public KeepProperty getKeepTogether() { | ||||
return keepTogether; | return keepTogether; |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonFont; | import org.apache.fop.fo.properties.CommonFont; | ||||
import org.apache.fop.fo.properties.CommonTextDecoration; | import org.apache.fop.fo.properties.CommonTextDecoration; | ||||
* <code>fo:page-number-citation-last</code></a> objects. | * <code>fo:page-number-citation-last</code></a> objects. | ||||
*/ | */ | ||||
public abstract class AbstractPageNumberCitation extends FObj | public abstract class AbstractPageNumberCitation extends FObj | ||||
implements StructurePointerPropertySet { | |||||
implements StructurePointerPropertySet, CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:page-number-citation(-last). | // The value of properties relevant for fo:page-number-citation(-last). | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonFont commonFont; | private CommonFont commonFont; | ||||
private Length alignmentAdjust; | private Length alignmentAdjust; | ||||
private CommonTextDecoration textDecoration; | private CommonTextDecoration textDecoration; | ||||
// private ToBeImplementedProperty textShadow; | // private ToBeImplementedProperty textShadow; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonMarginInline commonMarginInline; | // private CommonMarginInline commonMarginInline; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonFont = pList.getFontProps(); | commonFont = pList.getFontProps(); | ||||
alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | ||||
dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | ||||
// letterSpacing = pList.get(PR_LETTER_SPACING); | // letterSpacing = pList.get(PR_LETTER_SPACING); | ||||
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
refId = pList.get(PR_REF_ID).getString(); | refId = pList.get(PR_REF_ID).getString(); | ||||
textDecoration = pList.getTextDecorationProps(); | textDecoration = pList.getTextDecorationProps(); | ||||
// textShadow = pList.get(PR_TEXT_SHADOW); | // textShadow = pList.get(PR_TEXT_SHADOW); | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the {@link CommonFont} */ | /** @return the {@link CommonFont} */ | ||||
public CommonFont getCommonFont() { | public CommonFont getCommonFont() { | ||||
return commonFont; | return commonFont; | ||||
return textDecoration; | return textDecoration; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | ||||
baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); | baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); | ||||
dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
// destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET); | // destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET); | ||||
externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); | externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); | ||||
// indicateDestination = pList.get(PR_INDICATE_DESTINATION); | // indicateDestination = pList.get(PR_INDICATE_DESTINATION); | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void endOfNode() throws FOPException { | protected void endOfNode() throws FOPException { | ||||
super.endOfNode(); | super.endOfNode(); | ||||
getFOEventHandler().endLink(); | |||||
getFOEventHandler().endLink(this); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
return dominantBaseline; | return dominantBaseline; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.BreakPropertySet; | import org.apache.fop.fo.properties.BreakPropertySet; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonFont; | import org.apache.fop.fo.properties.CommonFont; | ||||
import org.apache.fop.fo.properties.CommonHyphenation; | import org.apache.fop.fo.properties.CommonHyphenation; | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block"> | ||||
* <code>fo:block object</code></a>. | * <code>fo:block object</code></a>. | ||||
*/ | */ | ||||
public class Block extends FObjMixed implements BreakPropertySet, StructurePointerPropertySet { | |||||
public class Block extends FObjMixed implements BreakPropertySet, StructurePointerPropertySet, | |||||
CommonAccessibilityHolder { | |||||
// used for FO validation | // used for FO validation | ||||
private boolean blockOrInlineItemFound = false; | private boolean blockOrInlineItemFound = false; | ||||
private boolean initialPropertySetFound = false; | private boolean initialPropertySetFound = false; | ||||
// The value of properties relevant for fo:block. | // The value of properties relevant for fo:block. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonFont commonFont; | private CommonFont commonFont; | ||||
private CommonHyphenation commonHyphenation; | private CommonHyphenation commonHyphenation; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonFont = pList.getFontProps(); | commonFont = pList.getFontProps(); | ||||
commonHyphenation = pList.getHyphenationProps(); | commonHyphenation = pList.getHyphenationProps(); | ||||
lineHeightShiftAdjustment = pList.get(PR_LINE_HEIGHT_SHIFT_ADJUSTMENT).getEnum(); | lineHeightShiftAdjustment = pList.get(PR_LINE_HEIGHT_SHIFT_ADJUSTMENT).getEnum(); | ||||
lineStackingStrategy = pList.get(PR_LINE_STACKING_STRATEGY).getEnum(); | lineStackingStrategy = pList.get(PR_LINE_STACKING_STRATEGY).getEnum(); | ||||
orphans = pList.get(PR_ORPHANS).getNumeric(); | orphans = pList.get(PR_ORPHANS).getNumeric(); | ||||
ptr = pList.get(PR_X_PTR).getString(); //used for accessibility | |||||
whiteSpaceTreatment = pList.get(PR_WHITE_SPACE_TREATMENT).getEnum(); | whiteSpaceTreatment = pList.get(PR_WHITE_SPACE_TREATMENT).getEnum(); | ||||
span = pList.get(PR_SPAN).getEnum(); | span = pList.get(PR_SPAN).getEnum(); | ||||
textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); | textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); | ||||
getFOEventHandler().endBlock(this); | getFOEventHandler().endBlock(this); | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the {@link CommonMarginBlock} */ | /** @return the {@link CommonMarginBlock} */ | ||||
public CommonMarginBlock getCommonMarginBlock() { | public CommonMarginBlock getCommonMarginBlock() { | ||||
return commonMarginBlock; | return commonMarginBlock; | ||||
return breakAfter; | return breakAfter; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
textDecoration = pList.getTextDecorationProps(); | textDecoration = pList.getTextDecorationProps(); | ||||
wordSpacing = pList.get(PR_WORD_SPACING); | wordSpacing = pList.get(PR_WORD_SPACING); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
return keepWithPrevious; | return keepWithPrevious; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_footnote"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_footnote"> | ||||
* <code>fo:footnote</code></a> object. | * <code>fo:footnote</code></a> object. | ||||
*/ | */ | ||||
public class Footnote extends FObj { | |||||
// The value of properties relevant for fo:footnote (commented out for performance). | |||||
// private CommonAccessibility commonAccessibility; | |||||
// End of property values | |||||
public class Footnote extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
private Inline footnoteCitation = null; | private Inline footnoteCitation = null; | ||||
private FootnoteBody footnoteBody; | private FootnoteBody footnoteBody; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
// No active properties -> do nothing. | |||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* Public accessor for inline FO | * Public accessor for inline FO | ||||
* | * |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_footnote-body"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_footnote-body"> | ||||
* <code>fo:footnote-body</code></a> object. | * <code>fo:footnote-body</code></a> object. | ||||
*/ | */ | ||||
public class FootnoteBody extends FObj { | |||||
// The value of properties relevant for fo:footnote-body (commented out for perforance). | |||||
// private CommonAccessibility commonAccessibility; | |||||
// End of property values | |||||
public class FootnoteBody extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
/** | /** | ||||
* Base constructor | * Base constructor | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public int getNameId() { | public int getNameId() { | ||||
return FO_FOOTNOTE_BODY; | return FO_FOOTNOTE_BODY; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
} | } |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.SpaceProperty; | import org.apache.fop.fo.properties.SpaceProperty; | ||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_initial-property-set"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_initial-property-set"> | ||||
* <code>fo:initial-property-set</code></a> object. | * <code>fo:initial-property-set</code></a> object. | ||||
*/ | */ | ||||
public class InitialPropertySet extends FObj { | |||||
// The value of properties relevant for fo:initial-property-set. | |||||
public class InitialPropertySet extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
// private ToBeImplementedProperty letterSpacing; | // private ToBeImplementedProperty letterSpacing; | ||||
private SpaceProperty lineHeight; | private SpaceProperty lineHeight; | ||||
// private ToBeImplementedProperty textShadow; | // private ToBeImplementedProperty textShadow; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonBorderPaddingBackground commonBorderPaddingBackground; | // private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
// private CommonFont commonFont; | // private CommonFont commonFont; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
// letterSpacing = pList.get(PR_LETTER_SPACING); | // letterSpacing = pList.get(PR_LETTER_SPACING); | ||||
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
// textShadow = pList.get(PR_TEXT_SHADOW); | // textShadow = pList.get(PR_TEXT_SHADOW); | ||||
public int getNameId() { | public int getNameId() { | ||||
return FO_INITIAL_PROPERTY_SET; | return FO_INITIAL_PROPERTY_SET; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
} | } |
alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); | ||||
baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); | baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); | ||||
dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
return dominantBaseline; | return dominantBaseline; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.FObjMixed; | import org.apache.fop.fo.FObjMixed; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonFont; | import org.apache.fop.fo.properties.CommonFont; | ||||
import org.apache.fop.fo.properties.CommonMarginInline; | import org.apache.fop.fo.properties.CommonMarginInline; | ||||
* Class modelling the commonalities of several inline-level | * Class modelling the commonalities of several inline-level | ||||
* formatting objects. | * formatting objects. | ||||
*/ | */ | ||||
public abstract class InlineLevel extends FObjMixed { | |||||
public abstract class InlineLevel extends FObjMixed implements CommonAccessibilityHolder { | |||||
// The value of properties relevant for inline-level FOs. | // The value of properties relevant for inline-level FOs. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonMarginInline commonMarginInline; | private CommonMarginInline commonMarginInline; | ||||
private CommonFont commonFont; | private CommonFont commonFont; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonMarginInline = pList.getMarginInlineProps(); | commonMarginInline = pList.getMarginInlineProps(); | ||||
commonFont = pList.getFontProps(); | commonFont = pList.getFontProps(); | ||||
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the {@link CommonMarginInline} */ | /** @return the {@link CommonMarginInline} */ | ||||
public CommonMarginInline getCommonMarginInline() { | public CommonMarginInline getCommonMarginInline() { | ||||
return commonMarginInline; | return commonMarginInline; |
super(parent); | super(parent); | ||||
} | } | ||||
@Override | |||||
protected void startOfNode() throws FOPException { | |||||
super.startOfNode(); | |||||
getFOEventHandler().startInstreamForeignObject(this); | |||||
} | |||||
/** | /** | ||||
* Make sure content model satisfied, if so then tell the | * Make sure content model satisfied, if so then tell the | ||||
* {@link org.apache.fop.fo.FOEventHandler} that we are at | * {@link org.apache.fop.fo.FOEventHandler} that we are at | ||||
if (firstChild == null) { | if (firstChild == null) { | ||||
missingChildElementError("one (1) non-XSL namespace child"); | missingChildElementError("one (1) non-XSL namespace child"); | ||||
} | } | ||||
getFOEventHandler().foreignObject(this); | |||||
getFOEventHandler().endInstreamForeignObject(this); | |||||
} | } | ||||
/** | /** |
public int getNameId() { | public int getNameId() { | ||||
return FO_LEADER; | return FO_LEADER; | ||||
} | } | ||||
@Override | |||||
protected void startOfNode() throws FOPException { | |||||
super.startOfNode(); | |||||
getFOEventHandler().startLeader(this); | |||||
} | |||||
@Override | |||||
protected void endOfNode() throws FOPException { | |||||
super.endOfNode(); | |||||
getFOEventHandler().endLeader(this); | |||||
} | |||||
} | } |
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.BreakPropertySet; | import org.apache.fop.fo.properties.BreakPropertySet; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonMarginBlock; | import org.apache.fop.fo.properties.CommonMarginBlock; | ||||
import org.apache.fop.fo.properties.KeepProperty; | import org.apache.fop.fo.properties.KeepProperty; | ||||
* Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-block"> | * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-block"> | ||||
* <code>fo:list-block</code></a> object. | * <code>fo:list-block</code></a> object. | ||||
*/ | */ | ||||
public class ListBlock extends FObj implements BreakPropertySet { | |||||
public class ListBlock extends FObj implements BreakPropertySet, CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:list-block. | // The value of properties relevant for fo:list-block. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonMarginBlock commonMarginBlock; | private CommonMarginBlock commonMarginBlock; | ||||
private int breakAfter; | private int breakAfter; | ||||
private KeepProperty keepWithNext; | private KeepProperty keepWithNext; | ||||
private KeepProperty keepWithPrevious; | private KeepProperty keepWithPrevious; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
// private int intrusionDisplace; | // private int intrusionDisplace; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonMarginBlock = pList.getMarginBlockProps(); | commonMarginBlock = pList.getMarginBlockProps(); | ||||
breakAfter = pList.get(PR_BREAK_AFTER).getEnum(); | breakAfter = pList.get(PR_BREAK_AFTER).getEnum(); | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the {@link CommonMarginBlock} */ | /** @return the {@link CommonMarginBlock} */ | ||||
public CommonMarginBlock getCommonMarginBlock() { | public CommonMarginBlock getCommonMarginBlock() { | ||||
return commonMarginBlock; | return commonMarginBlock; |
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.BreakPropertySet; | import org.apache.fop.fo.properties.BreakPropertySet; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonMarginBlock; | import org.apache.fop.fo.properties.CommonMarginBlock; | ||||
import org.apache.fop.fo.properties.KeepProperty; | import org.apache.fop.fo.properties.KeepProperty; | ||||
* Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-item"> | * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-item"> | ||||
* <code>fo:list-item</code></a> object. | * <code>fo:list-item</code></a> object. | ||||
*/ | */ | ||||
public class ListItem extends FObj implements BreakPropertySet { | |||||
public class ListItem extends FObj implements BreakPropertySet, CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:list-item. | // The value of properties relevant for fo:list-item. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonMarginBlock commonMarginBlock; | private CommonMarginBlock commonMarginBlock; | ||||
private int breakAfter; | private int breakAfter; | ||||
private KeepProperty keepWithNext; | private KeepProperty keepWithNext; | ||||
private KeepProperty keepWithPrevious; | private KeepProperty keepWithPrevious; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
// private int intrusionDisplace; | // private int intrusionDisplace; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonMarginBlock = pList.getMarginBlockProps(); | commonMarginBlock = pList.getMarginBlockProps(); | ||||
breakAfter = pList.get(PR_BREAK_AFTER).getEnum(); | breakAfter = pList.get(PR_BREAK_AFTER).getEnum(); | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the {@link CommonMarginBlock} */ | /** @return the {@link CommonMarginBlock} */ | ||||
public CommonMarginBlock getCommonMarginBlock() { | public CommonMarginBlock getCommonMarginBlock() { | ||||
return commonMarginBlock; | return commonMarginBlock; |
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void startOfNode() throws FOPException { | protected void startOfNode() throws FOPException { | ||||
super.startOfNode(); | super.startOfNode(); | ||||
getFOEventHandler().startListBody(); | |||||
getFOEventHandler().startListBody(this); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void endOfNode() throws FOPException { | protected void endOfNode() throws FOPException { | ||||
super.endOfNode(); | super.endOfNode(); | ||||
getFOEventHandler().endListBody(); | |||||
getFOEventHandler().endListBody(this); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ |
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void startOfNode() throws FOPException { | protected void startOfNode() throws FOPException { | ||||
super.startOfNode(); | super.startOfNode(); | ||||
getFOEventHandler().startListLabel(); | |||||
getFOEventHandler().startListLabel(this); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected void endOfNode() throws FOPException { | protected void endOfNode() throws FOPException { | ||||
super.endOfNode(); | super.endOfNode(); | ||||
getFOEventHandler().endListLabel(); | |||||
getFOEventHandler().endListLabel(this); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ |
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonFont; | import org.apache.fop.fo.properties.CommonFont; | ||||
import org.apache.fop.fo.properties.CommonTextDecoration; | import org.apache.fop.fo.properties.CommonTextDecoration; | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-number"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-number"> | ||||
* <code>fo:page-number</code></a> object. | * <code>fo:page-number</code></a> object. | ||||
*/ | */ | ||||
public class PageNumber extends FObj implements StructurePointerPropertySet { | |||||
public class PageNumber extends FObj | |||||
implements StructurePointerPropertySet, CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:page-number. | // The value of properties relevant for fo:page-number. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonFont commonFont; | private CommonFont commonFont; | ||||
private Length alignmentAdjust; | private Length alignmentAdjust; | ||||
private CommonTextDecoration textDecoration; | private CommonTextDecoration textDecoration; | ||||
// private ToBeImplementedProperty textShadow; | // private ToBeImplementedProperty textShadow; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonMarginInline commonMarginInline; | // private CommonMarginInline commonMarginInline; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonFont = pList.getFontProps(); | commonFont = pList.getFontProps(); | ||||
alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); | ||||
// letterSpacing = pList.get(PR_LETTER_SPACING); | // letterSpacing = pList.get(PR_LETTER_SPACING); | ||||
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
textDecoration = pList.getTextDecorationProps(); | textDecoration = pList.getTextDecorationProps(); | ||||
ptr = pList.get(PR_X_PTR).getString(); // used for accessibility | |||||
// textShadow = pList.get(PR_TEXT_SHADOW); | // textShadow = pList.get(PR_TEXT_SHADOW); | ||||
// implicit properties | // implicit properties | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** @return the Common Font Properties. */ | /** @return the Common Font Properties. */ | ||||
public CommonFont getCommonFont() { | public CommonFont getCommonFont() { | ||||
return commonFont; | return commonFont; | ||||
return lineHeight; | return lineHeight; | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
super(parent); | super(parent); | ||||
} | } | ||||
@Override | |||||
protected void startOfNode() throws FOPException { | |||||
super.startOfNode(); | |||||
getFOEventHandler().startWrapper(this); | |||||
} | |||||
@Override | |||||
protected void endOfNode() throws FOPException { | |||||
super.endOfNode(); | |||||
getFOEventHandler().endWrapper(this); | |||||
} | |||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
* <br>XSL Content Model: marker* (#PCDATA|%inline;|%block;)* | * <br>XSL Content Model: marker* (#PCDATA|%inline;|%block;)* |
import org.apache.fop.fo.StaticPropertyList; | import org.apache.fop.fo.StaticPropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.BreakPropertySet; | import org.apache.fop.fo.properties.BreakPropertySet; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.CommonMarginBlock; | import org.apache.fop.fo.properties.CommonMarginBlock; | ||||
import org.apache.fop.fo.properties.KeepProperty; | import org.apache.fop.fo.properties.KeepProperty; | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table"> | ||||
* <code>fo:table</code></a> object. | * <code>fo:table</code></a> object. | ||||
*/ | */ | ||||
public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet { | |||||
public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet, | |||||
CommonAccessibilityHolder { | |||||
/** properties */ | /** properties */ | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private CommonMarginBlock commonMarginBlock; | private CommonMarginBlock commonMarginBlock; | ||||
private LengthRangeProperty blockProgressionDimension; | private LengthRangeProperty blockProgressionDimension; | ||||
private int tableOmitFooterAtBreak; | private int tableOmitFooterAtBreak; | ||||
private int tableOmitHeaderAtBreak; | private int tableOmitHeaderAtBreak; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
// private int intrusionDisplace; | // private int intrusionDisplace; | ||||
*/ | */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
commonMarginBlock = pList.getMarginBlockProps(); | commonMarginBlock = pList.getMarginBlockProps(); | ||||
blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); | blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public Table getTable() { | public Table getTable() { | ||||
return this; | return this; |
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | |||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-and-caption"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-and-caption"> | ||||
* <code>fo:table-and-caption</code></a> property. | * <code>fo:table-and-caption</code></a> property. | ||||
* TODO needs implementation | * TODO needs implementation | ||||
*/ | */ | ||||
public class TableAndCaption extends FObj /*implements BreakPropertySet*/ { | |||||
public class TableAndCaption extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
// The value of properties relevant for fo:table-and-caption. | // The value of properties relevant for fo:table-and-caption. | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonBorderPaddingBackground commonBorderPaddingBackground; | // private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
// private CommonMarginBlock commonMarginBlock; | // private CommonMarginBlock commonMarginBlock; | ||||
// private int textAlign; | // private int textAlign; | ||||
// End of property values | // End of property values | ||||
private static boolean notImplementedWarningGiven = false; | |||||
static boolean notImplementedWarningGiven = false; // CSOK: VisibilityModifier | |||||
/** used for FO validation */ | /** used for FO validation */ | ||||
private boolean tableCaptionFound = false; | private boolean tableCaptionFound = false; | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void bind(PropertyList pList) throws FOPException { | |||||
super.bind(pList); | |||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | |||||
/** | /** | ||||
* Make sure content model satisfied, if so then tell the | * Make sure content model satisfied, if so then tell the | ||||
* FOEventHandler that we are at the end of the flow. | * FOEventHandler that we are at the end of the flow. | ||||
public int getNameId() { | public int getNameId() { | ||||
return FO_TABLE_AND_CAPTION; | return FO_TABLE_AND_CAPTION; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
} | } | ||||
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-caption"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-caption"> | ||||
* <code>fo:table-caption</code></a> object. | * <code>fo:table-caption</code></a> object. | ||||
*/ | */ | ||||
public class TableCaption extends FObj { | |||||
public class TableCaption extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
// The value of properties relevant for fo:table-caption. | // The value of properties relevant for fo:table-caption. | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
/** used for FO validation */ | /** used for FO validation */ | ||||
private boolean blockItemFound = false; | private boolean blockItemFound = false; | ||||
private static boolean notImplementedWarningGiven = false; | |||||
static boolean notImplementedWarningGiven = false; // CSOK: VisibilityModifier | |||||
/** | /** | ||||
* Create a TableCaption instance with the given {@link FONode} | * Create a TableCaption instance with the given {@link FONode} | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public int getNameId() { | public int getNameId() { | ||||
return FO_TABLE_CAPTION; | return FO_TABLE_CAPTION; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
} | } | ||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | import org.apache.fop.fo.properties.CommonBorderPaddingBackground; | ||||
import org.apache.fop.fo.properties.LengthRangeProperty; | import org.apache.fop.fo.properties.LengthRangeProperty; | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-cell"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-cell"> | ||||
* <code>fo:table-cell</code></a> object. | * <code>fo:table-cell</code></a> object. | ||||
*/ | */ | ||||
public class TableCell extends TableFObj { | |||||
public class TableCell extends TableFObj implements CommonAccessibilityHolder { | |||||
// The value of properties relevant for fo:table-cell. | // The value of properties relevant for fo:table-cell. | ||||
private CommonAccessibility commonAccessibility; | |||||
private CommonBorderPaddingBackground commonBorderPaddingBackground; | private CommonBorderPaddingBackground commonBorderPaddingBackground; | ||||
private LengthRangeProperty blockProgressionDimension; | private LengthRangeProperty blockProgressionDimension; | ||||
private int columnNumber; | private int columnNumber; | ||||
private int startsRow; | private int startsRow; | ||||
private Length width; | private Length width; | ||||
// Unused but valid items, commented out for performance: | // Unused but valid items, commented out for performance: | ||||
// private CommonAccessibility commonAccessibility; | |||||
// private CommonAural commonAural; | // private CommonAural commonAural; | ||||
// private CommonRelativePosition commonRelativePosition; | // private CommonRelativePosition commonRelativePosition; | ||||
// private int relativeAlign; | // private int relativeAlign; | ||||
*/ | */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); | ||||
blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); | blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); | ||||
displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum(); | displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum(); | ||||
return true; | return true; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* Get the {@link CommonBorderPaddingBackground} instance | * Get the {@link CommonBorderPaddingBackground} instance | ||||
* attached to this TableCell. | * attached to this TableCell. |
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.datatypes.Length; | import org.apache.fop.datatypes.Length; | ||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.PropertyList; | |||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* A common class for fo:table-body and fo:table-row which both can contain fo:table-cell. | * A common class for fo:table-body and fo:table-row which both can contain fo:table-cell. | ||||
*/ | */ | ||||
public abstract class TableCellContainer extends TableFObj implements ColumnNumberManagerHolder { | |||||
public abstract class TableCellContainer extends TableFObj | |||||
implements ColumnNumberManagerHolder, CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
/** list of pending spans */ | /** list of pending spans */ | ||||
protected List pendingSpans; | protected List pendingSpans; | ||||
super(parent); | super(parent); | ||||
} | } | ||||
@Override | |||||
public void bind(PropertyList pList) throws FOPException { | |||||
super.bind(pList); | |||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | |||||
/** | /** | ||||
* Add cell to current row. | * Add cell to current row. | ||||
* @param cell a table cell to add | * @param cell a table cell to add | ||||
return columnNumberManager; | return columnNumberManager; | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
} | } |
borderBeforePrecedence = pList.get(PR_BORDER_BEFORE_PRECEDENCE).getNumeric(); | borderBeforePrecedence = pList.get(PR_BORDER_BEFORE_PRECEDENCE).getNumeric(); | ||||
borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE).getNumeric(); | borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE).getNumeric(); | ||||
borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE).getNumeric(); | borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE).getNumeric(); | ||||
ptr = pList.get(PR_X_PTR).getString(); | |||||
if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java | if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java | ||||
&& getNameId() != FO_TABLE_CELL | && getNameId() != FO_TABLE_CELL | ||||
&& getCommonBorderPaddingBackground().hasPadding( | && getCommonBorderPaddingBackground().hasPadding( | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void setPtr(String ptr) { | |||||
this.ptr = ptr; | |||||
} | |||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public String getPtr() { | public String getPtr() { | ||||
return ptr; | return ptr; |
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.extensions.destination.Destination; | import org.apache.fop.fo.extensions.destination.Destination; | ||||
import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; | import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modeling the <a href="http://www.w3.org/TR/xsl/#fo_root"> | * Class modeling the <a href="http://www.w3.org/TR/xsl/#fo_root"> | ||||
* <code>fo:root</code></a> formatting object. | * <code>fo:root</code></a> formatting object. | ||||
* Contains page masters, page-sequences. | * Contains page masters, page-sequences. | ||||
*/ | */ | ||||
public class Root extends FObj { | |||||
// The value of properties relevant for fo:root. | |||||
public class Root extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
private int mediaUsage; | private int mediaUsage; | ||||
// End of property values | |||||
private LayoutMasterSet layoutMasterSet; | private LayoutMasterSet layoutMasterSet; | ||||
private Declarations declarations; | private Declarations declarations; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
super.bind(pList); | super.bind(pList); | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum(); | mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* Sets the FOEventHandler object that this Root is attached to | * Sets the FOEventHandler object that this Root is attached to | ||||
* @param foEventHandler the FOEventHandler object | * @param foEventHandler the FOEventHandler object |
if (getFlowName() == null || getFlowName().equals("")) { | if (getFlowName() == null || getFlowName().equals("")) { | ||||
missingPropertyError("flow-name"); | missingPropertyError("flow-name"); | ||||
} | } | ||||
getFOEventHandler().startFlow(this); | |||||
getFOEventHandler().startStatic(this); | |||||
} | } | ||||
/** | /** | ||||
if (firstChild == null && getUserAgent().validateStrictly()) { | if (firstChild == null && getUserAgent().validateStrictly()) { | ||||
missingChildElementError("(%block;)+"); | missingChildElementError("(%block;)+"); | ||||
} | } | ||||
getFOEventHandler().endFlow(this); | |||||
getFOEventHandler().endStatic(this); | |||||
} | } | ||||
/** | /** |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import org.xml.sax.Locator; | import org.xml.sax.Locator; | ||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.fo.FObj; | |||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.FObj; | |||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* <code>fo:bookmark</code></a> object, first introduced in the | * <code>fo:bookmark</code></a> object, first introduced in the | ||||
* XSL 1.1 WD. | * XSL 1.1 WD. | ||||
*/ | */ | ||||
public class Bookmark extends FObj { | |||||
public class Bookmark extends FObj implements CommonAccessibilityHolder { | |||||
private BookmarkTitle bookmarkTitle; | private BookmarkTitle bookmarkTitle; | ||||
private ArrayList childBookmarks = new ArrayList(); | private ArrayList childBookmarks = new ArrayList(); | ||||
// The value of properties relevant for this FO | // The value of properties relevant for this FO | ||||
private CommonAccessibility commonAccessibility; | |||||
private String internalDestination; | private String internalDestination; | ||||
private String externalDestination; | private String externalDestination; | ||||
private boolean bShow = true; // from starting-state property | private boolean bShow = true; // from starting-state property | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void bind(PropertyList pList) throws FOPException { | public void bind(PropertyList pList) throws FOPException { | ||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); | externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); | ||||
internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); | internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); | ||||
bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW); | bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW); | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* Get the bookmark title for this bookmark | * Get the bookmark title for this bookmark | ||||
* | * |
import org.xml.sax.Locator; | import org.xml.sax.Locator; | ||||
import org.apache.fop.apps.FOPException; | |||||
import org.apache.fop.fo.FONode; | import org.apache.fop.fo.FONode; | ||||
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.fo.PropertyList; | import org.apache.fop.fo.PropertyList; | ||||
import org.apache.fop.fo.ValidationException; | import org.apache.fop.fo.ValidationException; | ||||
import org.apache.fop.fo.properties.CommonAccessibility; | |||||
import org.apache.fop.fo.properties.CommonAccessibilityHolder; | |||||
/** | /** | ||||
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_bookmark-title"> | * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_bookmark-title"> | ||||
* <code>fo:bookmark-title</code></a> object, first introduced in the | * <code>fo:bookmark-title</code></a> object, first introduced in the | ||||
* XSL 1.1 WD. | * XSL 1.1 WD. | ||||
*/ | */ | ||||
public class BookmarkTitle extends FObj { | |||||
public class BookmarkTitle extends FObj implements CommonAccessibilityHolder { | |||||
private CommonAccessibility commonAccessibility; | |||||
private String title = ""; | private String title = ""; | ||||
/** | /** | ||||
super(parent); | super(parent); | ||||
} | } | ||||
@Override | |||||
public void bind(PropertyList pList) throws FOPException { | |||||
super.bind(pList); | |||||
commonAccessibility = CommonAccessibility.getInstance(pList); | |||||
} | |||||
/** | /** | ||||
* Add the characters to this BookmarkTitle. | * Add the characters to this BookmarkTitle. | ||||
* The text data inside the BookmarkTitle xml element | * The text data inside the BookmarkTitle xml element | ||||
} | } | ||||
} | } | ||||
public CommonAccessibility getCommonAccessibility() { | |||||
return commonAccessibility; | |||||
} | |||||
/** | /** | ||||
* Get the title for this BookmarkTitle. | * Get the title for this BookmarkTitle. | ||||
* | * |
import org.apache.fop.fo.expr.PropertyException; | import org.apache.fop.fo.expr.PropertyException; | ||||
/** | /** | ||||
* Store all common accessibility properties. | |||||
* See Sec 7.4 of the XSL-FO Standard. | |||||
* Public "structure" allows direct member access. | |||||
* The "role" and "source-document" properties, see Section 7.5 of the XSL-FO 1.1 | |||||
* Recommendation. | |||||
*/ | */ | ||||
public class CommonAccessibility { | |||||
/** | |||||
* The "source-doc" property. | |||||
*/ | |||||
public String sourceDoc = null; // CSOK: VisibilityModifier | |||||
public final class CommonAccessibility { | |||||
/** | |||||
* The "role" property. | |||||
*/ | |||||
public String role = null; // CSOK: VisibilityModifier | |||||
private static final CommonAccessibility DEFAULT_INSTANCE = new CommonAccessibility(null, null); | |||||
private final String sourceDocument; | |||||
private final String role; | |||||
private CommonAccessibility(String sourceDocument, String role) { | |||||
this.sourceDocument = sourceDocument; | |||||
this.role = role; | |||||
} | |||||
/** | /** | ||||
* Create a <code>CommonAccessibility</code> object. | |||||
* @param pList The PropertyList with propery values. | |||||
* @throws PropertyException if a property exception is raised | |||||
* Returns an instance that matches the values (if any) in the given property list. | |||||
* | |||||
* @param propertyList a list from which to retrieve the accessibility properties | |||||
* @return the corresponding instance | |||||
* @throws PropertyException if a problem occurs while retrieving the properties | |||||
*/ | */ | ||||
public CommonAccessibility(PropertyList pList) throws PropertyException { | |||||
sourceDoc = pList.get(Constants.PR_SOURCE_DOCUMENT).getString(); | |||||
if ("none".equals(sourceDoc)) { | |||||
sourceDoc = null; | |||||
public static CommonAccessibility getInstance(PropertyList propertyList) | |||||
throws PropertyException { | |||||
String sourceDocument = propertyList.get(Constants.PR_SOURCE_DOCUMENT).getString(); | |||||
if ("none".equals(sourceDocument)) { | |||||
sourceDocument = null; | |||||
} | } | ||||
role = pList.get(Constants.PR_ROLE).getString(); | |||||
String role = propertyList.get(Constants.PR_ROLE).getString(); | |||||
if ("none".equals(role)) { | if ("none".equals(role)) { | ||||
role = null; | role = null; | ||||
} | } | ||||
if (sourceDocument == null && role == null) { | |||||
return DEFAULT_INSTANCE; | |||||
} else { | |||||
return new CommonAccessibility(sourceDocument, role); | |||||
} | |||||
} | |||||
/** | |||||
* Returns the value of the source-document property. | |||||
* | |||||
* @return the source document, or null if the property was set to "none" | |||||
*/ | |||||
public String getSourceDocument() { | |||||
return sourceDocument; | |||||
} | } | ||||
/** | |||||
* Returns the value of the role property. | |||||
* | |||||
* @return the role, or null if the property was set to "none" | |||||
*/ | |||||
public String getRole() { | |||||
return role; | |||||
} | |||||
} | } |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo.properties; | |||||
/** | |||||
* Classes that implement this interface support the common accessibility properties. | |||||
* | |||||
* @see CommonAccessibility | |||||
*/ | |||||
public interface CommonAccessibilityHolder { | |||||
/** | |||||
* Returns the accessibility properties. | |||||
* | |||||
* @return the accessibility properties | |||||
*/ | |||||
CommonAccessibility getCommonAccessibility(); | |||||
} |
} | } | ||||
private void processNode(Node node, PDFStructElem parent, boolean addKid) { | private void processNode(Node node, PDFStructElem parent, boolean addKid) { | ||||
Node attr = node.getAttributes().getNamedItemNS(InternalElementMapping.URI, "ptr"); | |||||
assert attr != null; | |||||
String ptr = attr.getNodeValue(); | |||||
PDFStructElem structElem = pdfDoc.getFactory().makeStructureElement( | PDFStructElem structElem = pdfDoc.getFactory().makeStructureElement( | ||||
FOToPDFRoleMap.mapFormattingObject(node, parent, eventBroadcaster), parent); | FOToPDFRoleMap.mapFormattingObject(node, parent, eventBroadcaster), parent); | ||||
// TODO necessary? If a page-sequence is empty (e.g., contains a single | // TODO necessary? If a page-sequence is empty (e.g., contains a single | ||||
structElem.put("Alt", "No alternate text specified"); | structElem.put("Alt", "No alternate text specified"); | ||||
} | } | ||||
} | } | ||||
structTreeMap.put(ptr, structElem); | |||||
Node attr = node.getAttributes().getNamedItemNS(InternalElementMapping.URI, "ptr"); | |||||
if (attr != null) { | |||||
String ptr = attr.getNodeValue(); | |||||
structTreeMap.put(ptr, structElem); | |||||
} | |||||
NodeList nodes = node.getChildNodes(); | NodeList nodes = node.getChildNodes(); | ||||
for (int i = 0, n = nodes.getLength(); i < n; i++) { | for (int i = 0, n = nodes.getLength(); i < n; i++) { | ||||
processNode(nodes.item(i), structElem, false); | processNode(nodes.item(i), structElem, false); |
import java.util.Map; | import java.util.Map; | ||||
import org.w3c.dom.Document; | import org.w3c.dom.Document; | ||||
import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
*/ | */ | ||||
//TODO: do this only, if the labels content <> previous labels content | //TODO: do this only, if the labels content <> previous labels content | ||||
if (list.getChildCount() > 0) { | if (list.getChildCount() > 0) { | ||||
this.endListBody(); | |||||
this.endListBody(null); | |||||
this.endList((ListBlock) li.getParent()); | this.endList((ListBlock) li.getParent()); | ||||
this.startList((ListBlock) li.getParent()); | this.startList((ListBlock) li.getParent()); | ||||
this.startListBody(); | |||||
this.startListBody(null); | |||||
list = (RtfList)builderContext.getContainer( | list = (RtfList)builderContext.getContainer( | ||||
RtfList.class, true, this); | RtfList.class, true, this); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void startListLabel() { | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
if (bDefer) { | if (bDefer) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void endListLabel() { | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
if (bDefer) { | if (bDefer) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void startListBody() { | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void endListBody() { | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
} | } | ||||
// Static Regions | // Static Regions | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void startStatic() { | |||||
public void startStatic(StaticContent staticContent) { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void endStatic() { | |||||
public void endStatic(StaticContent statisContent) { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void endLink() { | |||||
public void endLink(BasicLink basicLink) { | |||||
if (bDefer) { | if (bDefer) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void foreignObject(InstreamForeignObject ifo) { | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
if (bDefer) { | if (bDefer) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void leader(Leader l) { | |||||
public void startLeader(Leader l) { | |||||
if (bDefer) { | if (bDefer) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} else if (foNode instanceof StaticContent) { | } else if (foNode instanceof StaticContent) { | ||||
if (bStart) { | if (bStart) { | ||||
startStatic(); | |||||
startStatic(null); | |||||
} else { | } else { | ||||
endStatic(); | |||||
endStatic(null); | |||||
} | } | ||||
} else if (foNode instanceof ExternalGraphic) { | } else if (foNode instanceof ExternalGraphic) { | ||||
if (bStart) { | if (bStart) { | ||||
} | } | ||||
} else if (foNode instanceof InstreamForeignObject) { | } else if (foNode instanceof InstreamForeignObject) { | ||||
if (bStart) { | if (bStart) { | ||||
foreignObject( (InstreamForeignObject) foNode ); | |||||
endInstreamForeignObject( (InstreamForeignObject) foNode ); | |||||
} | } | ||||
} else if (foNode instanceof Block) { | } else if (foNode instanceof Block) { | ||||
if (bStart) { | if (bStart) { | ||||
if (bStart) { | if (bStart) { | ||||
startLink( (BasicLink) foNode); | startLink( (BasicLink) foNode); | ||||
} else { | } else { | ||||
endLink(); | |||||
endLink(null); | |||||
} | } | ||||
} else if (foNode instanceof Inline) { | } else if (foNode instanceof Inline) { | ||||
if (bStart) { | if (bStart) { | ||||
} | } | ||||
} else if (foNode instanceof ListItemBody) { | } else if (foNode instanceof ListItemBody) { | ||||
if (bStart) { | if (bStart) { | ||||
startListBody(); | |||||
startListBody(null); | |||||
} else { | } else { | ||||
endListBody(); | |||||
endListBody(null); | |||||
} | } | ||||
} else if (foNode instanceof ListItem) { | } else if (foNode instanceof ListItem) { | ||||
if (bStart) { | if (bStart) { | ||||
} | } | ||||
} else if (foNode instanceof ListItemLabel) { | } else if (foNode instanceof ListItemLabel) { | ||||
if (bStart) { | if (bStart) { | ||||
startListLabel(); | |||||
startListLabel(null); | |||||
} else { | } else { | ||||
endListLabel(); | |||||
endListLabel(null); | |||||
} | } | ||||
} else if (foNode instanceof Table) { | } else if (foNode instanceof Table) { | ||||
if (bStart) { | if (bStart) { | ||||
} | } | ||||
} else if (foNode instanceof Leader) { | } else if (foNode instanceof Leader) { | ||||
if (bStart) { | if (bStart) { | ||||
leader((Leader) foNode); | |||||
startLeader((Leader) foNode); | |||||
} | } | ||||
} else if (foNode instanceof PageNumberCitation) { | } else if (foNode instanceof PageNumberCitation) { | ||||
if (bStart) { | if (bStart) { |
This directory contains sample FO files for testing the accessibility features | This directory contains sample FO files for testing the accessibility features | ||||
of FOP. | of FOP. | ||||
To every FO file in this directory correspond two PDF files in the pdf/ | |||||
sub-directory: one generated by the painter, one by the renderer. For example, | |||||
the text_1.fo file has been rendered into pdf/text_1_painter_orig.pdf and | |||||
pdf/text_1_renderer_orig.pdf. The configuration file config-painter.xconf (resp. | |||||
config-renderer.xconf) was used. | |||||
Every FO file in this directory has a corresponding PDF file in the pdf/ | |||||
sub-directory. The fop.xconf configuration file was used. | |||||
The PDF files have been checked with Adobe Acrobat Professional 9, using both | The PDF files have been checked with Adobe Acrobat Professional 9, using both | ||||
the full accessibility checker and the read-aloud feature. The checker reports | the full accessibility checker and the read-aloud feature. The checker reports | ||||
The purpose of this infrastructure is to be able to quickly re-test the | The purpose of this infrastructure is to be able to quickly re-test the | ||||
accessibility processing chain when any change has been made to it. The | accessibility processing chain when any change has been made to it. The | ||||
configuration files disable the compression of the PDF streams, so it is | |||||
configuration file disables the compression of the PDF streams, so it is | |||||
possible to compare a re-generated PDF with the original one by using a simple | possible to compare a re-generated PDF with the original one by using a simple | ||||
diff tool. The files will not be identical because of the different creation | diff tool. The files will not be identical because of the different creation | ||||
dates (and the ID key in the trailer), but apart from that there should be no | dates (and the ID key in the trailer), but apart from that there should be no | ||||
running Acrobat's accessibility checker and read-aloud feature every time. | running Acrobat's accessibility checker and read-aloud feature every time. | ||||
To re-generate the PDF files using the painter: | |||||
../../fop -c config-painter.xconf text_1.fo pdf/text_1_painter.pdf | |||||
diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf | |||||
To re-generate the PDF files: | |||||
../../fop -c fop.xconf text_1.fo pdf/text_1.new.pdf | |||||
diff pdf/text_1_painter.pdf pdf/text_1.new.pdf | |||||
Or, going through the intermediate format: | Or, going through the intermediate format: | ||||
../../fop -c config-painter.xconf text_1.fo -if application/pdf text_1_if.xml | |||||
../../fop -c config-painter.xconf -ifin text_1_if.xml pdf/text_1_painter.pdf | |||||
diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf | |||||
To re-generate the PDF files using the legacy renderer: | |||||
../../fop -c config-renderer.xconf text_1.fo pdf/text_1_renderer.pdf | |||||
diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf | |||||
Or, going through the intermediate format: | |||||
../../fop -c config-renderer.xconf text_1.fo -at application/pdf text_1_at.xml | |||||
../../fop -c config-renderer.xconf -atin text_1_at.xml pdf/text_1_renderer.pdf | |||||
diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf | |||||
../../fop -c fop.xconf text_1.fo -if application/pdf text_1_if.xml | |||||
../../fop -c fop.xconf -ifin text_1_if.xml pdf/text_1.new.pdf | |||||
diff pdf/text_1.pdf pdf/text_1.new.pdf | |||||
$Id$ | $Id$ |
<?xml version="1.0" standalone="no"?> | |||||
<!-- | |||||
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$ --> | |||||
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" | |||||
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> | |||||
<fo:layout-master-set> | |||||
<fo:simple-page-master master-name="page" | |||||
page-height="400pt" page-width="300pt" margin="20pt" margin-top="10pt"> | |||||
<fo:region-body margin-top="20pt"/> | |||||
<fo:region-before extent="15pt"/> | |||||
</fo:simple-page-master> | |||||
</fo:layout-master-set> | |||||
<fo:page-sequence master-reference="page"> | |||||
<fo:static-content flow-name="xsl-region-before"> | |||||
<fo:block id="1" font-size="7pt" text-align-last="justify" padding-bottom="2pt" | |||||
border-bottom="0.25pt solid black">This is the page header<fo:leader/>Page <fo:page-number | |||||
id="2"/></fo:block> | |||||
</fo:static-content> | |||||
<fo:static-content flow-name="xsl-footnote-separator"> | |||||
<fo:block id="3"><fo:leader leader-length="100pt" leader-pattern="rule"/></fo:block> | |||||
</fo:static-content> | |||||
<fo:flow flow-name="xsl-region-body"> | |||||
<fo:block id="4">This is a link to the <fo:wrapper id="5" color="blue"><fo:basic-link id="6" | |||||
internal-destination="second-start">next page-sequence</fo:basic-link></fo:wrapper> | |||||
(which starts on page <fo:page-number-citation id="7" ref-id="second-start"/> and ends on | |||||
page <fo:page-number-citation-last id="8" ref-id="second-end"/>).</fo:block> | |||||
<fo:block id="9" font-family="sans-serif" font-weight="bold" space-before="1em" | |||||
space-after="0.2em" role="H1"><fo:block id="10">A Title Block</fo:block></fo:block> | |||||
<fo:block id="11">This block of text contains a footnote<fo:footnote id="12"><fo:inline id="13" | |||||
baseline-shift="super" font-size="70%">1</fo:inline><fo:footnote-body id="14"><fo:block | |||||
id="15">A footnote with a link to the <fo:wrapper id="16" color="blue"><fo:basic-link | |||||
id="17" external-destination="http://xmlgraphics.apache.org/fop/">FOP | |||||
website</fo:basic-link></fo:wrapper></fo:block></fo:footnote-body></fo:footnote> | |||||
call.</fo:block> | |||||
<fo:table id="18" space-before="1em" width="100%" table-layout="fixed"> | |||||
<fo:table-column id="19" column-width="proportional-column-width(1)"/> | |||||
<fo:table-column id="20" column-width="proportional-column-width(2)"/> | |||||
<fo:table-header id="21"> | |||||
<fo:table-row id="22"> | |||||
<fo:table-cell id="23" border="2pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="24">Header 1.1</fo:block> | |||||
</fo:table-cell> | |||||
<fo:table-cell id="25" border="2pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="26">Header 1.2</fo:block> | |||||
</fo:table-cell> | |||||
</fo:table-row> | |||||
</fo:table-header> | |||||
<fo:table-footer id="27"> | |||||
<fo:table-row id="28"> | |||||
<fo:table-cell id="29" border="2pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="30">Footer 1.1</fo:block> | |||||
</fo:table-cell> | |||||
<fo:table-cell id="31" border="2pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="32">Footer 1.2</fo:block> | |||||
</fo:table-cell> | |||||
</fo:table-row> | |||||
</fo:table-footer> | |||||
<fo:table-body id="33"> | |||||
<fo:table-row id="34"> | |||||
<fo:table-cell id="35" border="1pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="36">Cell 1.1</fo:block> | |||||
</fo:table-cell> | |||||
<fo:table-cell id="37" border="1pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="38">Cell 1.2</fo:block> | |||||
</fo:table-cell> | |||||
</fo:table-row> | |||||
<fo:table-row id="39"> | |||||
<fo:table-cell id="40" border="1pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="41">Cell 2.1</fo:block> | |||||
</fo:table-cell> | |||||
<fo:table-cell id="42" border="1pt solid black" padding="2pt 2pt 0"> | |||||
<fo:block id="43">Cell 2.2</fo:block> | |||||
</fo:table-cell> | |||||
</fo:table-row> | |||||
</fo:table-body> | |||||
</fo:table> | |||||
<fo:block-container id="44" space-before="1.2em"> | |||||
<fo:block-container id="45" absolute-position="absolute" top="6pt" right="2.5pt" | |||||
inline-progression-dimension="37%" padding="3pt 1pt 2pt 3pt" border="1.5pt solid | |||||
darkblue"> | |||||
<fo:block id="46" color="darkblue" font-size="80%">This is an absolutely positioned | |||||
block-container. Nullam interdum mattis ipsum sit amet molestie.</fo:block> | |||||
</fo:block-container> | |||||
<fo:block id="47" end-indent="37% + 15pt">Lorem ipsum dolor sit amet, consectetur adipiscing | |||||
elit. Integer vel lacinia diam. Etiam venenatis magna vel libero imperdiet | |||||
rhoncus.</fo:block> | |||||
</fo:block-container> | |||||
</fo:flow> | |||||
</fo:page-sequence> | |||||
<fo:page-sequence master-reference="page"> | |||||
<fo:static-content id="48" flow-name="xsl-region-before"> | |||||
<fo:block id="49" font-size="7pt" text-align-last="justify" padding-bottom="2pt" | |||||
border-bottom="0.25pt solid black">This is the page header<fo:leader id="50"/>Page | |||||
<fo:page-number id="51"/></fo:block> | |||||
</fo:static-content> | |||||
<fo:flow flow-name="xsl-region-body" text-align="justify" space-before.minimum="8pt" | |||||
space-before.optimum="10pt" space-before.maximum="12pt"> | |||||
<fo:block id="second-start">Starting a new page-sequence.</fo:block> | |||||
<fo:block id="52" text-align="center">The <fo:external-graphic id="53" | |||||
src="test/resources/images/fop-logo-color-24bit.png" | |||||
inline-progression-dimension.maximum="50%" content-width="scale-to-fit" | |||||
alignment-adjust="-46%" alignment-baseline="middle" fox:alt-text="FOP Logo"/> | |||||
logo.</fo:block> | |||||
<fo:list-block id="54" provisional-distance-between-starts="15pt" | |||||
provisional-label-separation="0" space-before="inherit"> | |||||
<fo:list-item id="55"> | |||||
<fo:list-item-label id="56" end-indent="label-end()"> | |||||
<fo:block id="57">1.</fo:block> | |||||
</fo:list-item-label> | |||||
<fo:list-item-body id="58" start-indent="body-start()"> | |||||
<fo:block id="59">First item of a list</fo:block> | |||||
</fo:list-item-body> | |||||
</fo:list-item> | |||||
<fo:list-item id="60"> | |||||
<fo:list-item-label id="61" end-indent="label-end()"> | |||||
<fo:block id="62">2.</fo:block> | |||||
</fo:list-item-label> | |||||
<fo:list-item-body id="63" start-indent="body-start()"> | |||||
<fo:block id="64">Second item of a list</fo:block> | |||||
</fo:list-item-body> | |||||
</fo:list-item> | |||||
<fo:list-item id="65"> | |||||
<fo:list-item-label id="66" end-indent="label-end()"> | |||||
<fo:block id="67">3.</fo:block> | |||||
</fo:list-item-label> | |||||
<fo:list-item-body id="68" start-indent="body-start()"> | |||||
<fo:block id="69">Third item of a list</fo:block> | |||||
</fo:list-item-body> | |||||
</fo:list-item> | |||||
</fo:list-block> | |||||
<fo:block id="70" text-align="center"><fo:instream-foreign-object id="71" | |||||
inline-progression-dimension.maximum="50%" content-width="scale-to-fit"> | |||||
<svg xmlns="http://www.w3.org/2000/svg" width="319" height="286.6"> | |||||
<g style="fill-opacity:0.7; stroke:black; stroke-width:3" | |||||
transform="translate(0, 286.6) scale(1, -1) translate(100, 100)"> | |||||
<circle cx="50" cy="86.6" r="80" style="fill:red;"/> | |||||
<circle cx="0" cy="0" r="80" style="fill:green;"/> | |||||
<circle cx="100" cy="0" r="80" style="fill:blue;"/> | |||||
</g> | |||||
</svg> | |||||
</fo:instream-foreign-object></fo:block> | |||||
<fo:block id="72" space-before="inherit">A block containing an <fo:inline id="73" | |||||
border="0.5pt solid black" padding="2pt" padding-bottom="0">inline</fo:inline> | |||||
element.</fo:block> | |||||
<fo:block id="74" space-before="inherit">A block containing a fancy <fo:character id="75" | |||||
border="1pt solid black" padding="0 2pt 1pt 2pt" font-family="Symbol" character="♦"/> | |||||
character.</fo:block> | |||||
<fo:block id="76" space-before="inherit" text-align-last="justify">A leader with special | |||||
content: <fo:leader id="77" leader-pattern="use-content"><fo:inline id="78"><fo:character | |||||
id="79" character=" "/><fo:inline id="80" border="0.5pt solid black" | |||||
padding-left="2pt" padding-right="2pt"><fo:character id="81" baseline-shift="-10%" | |||||
character="•"/></fo:inline></fo:inline></fo:leader>.</fo:block> | |||||
<fo:block id="second-end" space-before="inherit">Ending the page-sequence.</fo:block> | |||||
</fo:flow> | |||||
</fo:page-sequence> | |||||
</fo:root> |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo; | |||||
import static org.junit.Assert.assertArrayEquals; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import javax.xml.transform.Result; | |||||
import javax.xml.transform.Source; | |||||
import javax.xml.transform.Transformer; | |||||
import javax.xml.transform.TransformerConfigurationException; | |||||
import javax.xml.transform.TransformerException; | |||||
import javax.xml.transform.TransformerFactory; | |||||
import javax.xml.transform.sax.SAXResult; | |||||
import javax.xml.transform.stream.StreamSource; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.xml.sax.Attributes; | |||||
import org.xml.sax.SAXException; | |||||
import org.xml.sax.helpers.DefaultHandler; | |||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory; | |||||
import org.apache.fop.fo.flow.BasicLink; | |||||
import org.apache.fop.fo.flow.Block; | |||||
import org.apache.fop.fo.flow.BlockContainer; | |||||
import org.apache.fop.fo.flow.Character; | |||||
import org.apache.fop.fo.flow.ExternalGraphic; | |||||
import org.apache.fop.fo.flow.Footnote; | |||||
import org.apache.fop.fo.flow.FootnoteBody; | |||||
import org.apache.fop.fo.flow.Inline; | |||||
import org.apache.fop.fo.flow.InstreamForeignObject; | |||||
import org.apache.fop.fo.flow.Leader; | |||||
import org.apache.fop.fo.flow.ListBlock; | |||||
import org.apache.fop.fo.flow.ListItem; | |||||
import org.apache.fop.fo.flow.ListItemBody; | |||||
import org.apache.fop.fo.flow.ListItemLabel; | |||||
import org.apache.fop.fo.flow.PageNumber; | |||||
import org.apache.fop.fo.flow.PageNumberCitation; | |||||
import org.apache.fop.fo.flow.PageNumberCitationLast; | |||||
import org.apache.fop.fo.flow.Wrapper; | |||||
import org.apache.fop.fo.flow.table.Table; | |||||
import org.apache.fop.fo.flow.table.TableBody; | |||||
import org.apache.fop.fo.flow.table.TableCell; | |||||
import org.apache.fop.fo.flow.table.TableColumn; | |||||
import org.apache.fop.fo.flow.table.TableFooter; | |||||
import org.apache.fop.fo.flow.table.TableHeader; | |||||
import org.apache.fop.fo.flow.table.TableRow; | |||||
import org.apache.fop.fo.pagination.Flow; | |||||
import org.apache.fop.fo.pagination.PageSequence; | |||||
import org.apache.fop.fo.pagination.StaticContent; | |||||
/** | |||||
* Tests that {@link DelegatingFOEventHandler} does forward every event to its delegate | |||||
* event handler. | |||||
*/ | |||||
public class DelegatingFOEventHandlerTestCase { | |||||
private InputStream document; | |||||
private List<String> expectedEvents; | |||||
private List<String> actualEvents; | |||||
private FODocumentParser documentParser; | |||||
private class DelegatingFOEventHandlerTester extends FOEventHandler { | |||||
DelegatingFOEventHandlerTester(FOUserAgent foUserAgent) { | |||||
super(foUserAgent); | |||||
} | |||||
private final StringBuilder eventBuilder = new StringBuilder(); | |||||
@Override | |||||
public void startDocument() throws SAXException { | |||||
actualEvents.add("start root"); | |||||
} | |||||
@Override | |||||
public void endDocument() throws SAXException { | |||||
actualEvents.add("end root"); | |||||
} | |||||
@Override | |||||
public void startPageSequence(PageSequence pageSeq) { | |||||
startElement(pageSeq); | |||||
} | |||||
@Override | |||||
public void endPageSequence(PageSequence pageSeq) { | |||||
endElement(pageSeq); | |||||
} | |||||
@Override | |||||
public void startPageNumber(PageNumber pagenum) { | |||||
startElement(pagenum); | |||||
} | |||||
@Override | |||||
public void endPageNumber(PageNumber pagenum) { | |||||
endElement(pagenum); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitation(PageNumberCitation pageCite) { | |||||
startElement(pageCite); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitation(PageNumberCitation pageCite) { | |||||
endElement(pageCite); | |||||
} | |||||
@Override | |||||
public void startPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
startElement(pageLast); | |||||
} | |||||
@Override | |||||
public void endPageNumberCitationLast(PageNumberCitationLast pageLast) { | |||||
endElement(pageLast); | |||||
} | |||||
@Override | |||||
public void startFlow(Flow fl) { | |||||
startElement(fl); | |||||
} | |||||
@Override | |||||
public void endFlow(Flow fl) { | |||||
endElement(fl); | |||||
} | |||||
@Override | |||||
public void startBlock(Block bl) { | |||||
startElement(bl); | |||||
} | |||||
@Override | |||||
public void endBlock(Block bl) { | |||||
endElement(bl); | |||||
} | |||||
@Override | |||||
public void startBlockContainer(BlockContainer blc) { | |||||
startElement(blc); | |||||
} | |||||
@Override | |||||
public void endBlockContainer(BlockContainer blc) { | |||||
endElement(blc); | |||||
} | |||||
@Override | |||||
public void startInline(Inline inl) { | |||||
startElement(inl); | |||||
} | |||||
@Override | |||||
public void endInline(Inline inl) { | |||||
endElement(inl); | |||||
} | |||||
@Override | |||||
public void startTable(Table tbl) { | |||||
startElement(tbl); | |||||
} | |||||
@Override | |||||
public void endTable(Table tbl) { | |||||
endElement(tbl); | |||||
} | |||||
@Override | |||||
public void startColumn(TableColumn tc) { | |||||
startElement(tc); | |||||
} | |||||
@Override | |||||
public void endColumn(TableColumn tc) { | |||||
endElement(tc); | |||||
} | |||||
@Override | |||||
public void startHeader(TableHeader header) { | |||||
startElement(header); | |||||
} | |||||
@Override | |||||
public void endHeader(TableHeader header) { | |||||
endElement(header); | |||||
} | |||||
@Override | |||||
public void startFooter(TableFooter footer) { | |||||
startElement(footer); | |||||
} | |||||
@Override | |||||
public void endFooter(TableFooter footer) { | |||||
endElement(footer); | |||||
} | |||||
@Override | |||||
public void startBody(TableBody body) { | |||||
startElement(body); | |||||
} | |||||
@Override | |||||
public void endBody(TableBody body) { | |||||
endElement(body); | |||||
} | |||||
@Override | |||||
public void startRow(TableRow tr) { | |||||
startElement(tr); | |||||
} | |||||
@Override | |||||
public void endRow(TableRow tr) { | |||||
endElement(tr); | |||||
} | |||||
@Override | |||||
public void startCell(TableCell tc) { | |||||
startElement(tc); | |||||
} | |||||
@Override | |||||
public void endCell(TableCell tc) { | |||||
endElement(tc); | |||||
} | |||||
@Override | |||||
public void startList(ListBlock lb) { | |||||
startElement(lb); | |||||
} | |||||
@Override | |||||
public void endList(ListBlock lb) { | |||||
endElement(lb); | |||||
} | |||||
@Override | |||||
public void startListItem(ListItem li) { | |||||
startElement(li); | |||||
} | |||||
@Override | |||||
public void endListItem(ListItem li) { | |||||
endElement(li); | |||||
} | |||||
@Override | |||||
public void startListLabel(ListItemLabel listItemLabel) { | |||||
startElement(listItemLabel); | |||||
} | |||||
@Override | |||||
public void endListLabel(ListItemLabel listItemLabel) { | |||||
endElement(listItemLabel); | |||||
} | |||||
@Override | |||||
public void startListBody(ListItemBody listItemBody) { | |||||
startElement(listItemBody); | |||||
} | |||||
@Override | |||||
public void endListBody(ListItemBody listItemBody) { | |||||
endElement(listItemBody); | |||||
} | |||||
@Override | |||||
public void startStatic(StaticContent staticContent) { | |||||
startElement(staticContent); | |||||
} | |||||
@Override | |||||
public void endStatic(StaticContent statisContent) { | |||||
endElement(statisContent); | |||||
} | |||||
@Override | |||||
public void startLink(BasicLink basicLink) { | |||||
startElement(basicLink); | |||||
} | |||||
@Override | |||||
public void endLink(BasicLink basicLink) { | |||||
endElement(basicLink); | |||||
} | |||||
@Override | |||||
public void image(ExternalGraphic eg) { | |||||
startElement(eg); | |||||
endElement(eg); | |||||
} | |||||
@Override | |||||
public void startInstreamForeignObject(InstreamForeignObject ifo) { | |||||
startElement(ifo); | |||||
} | |||||
@Override | |||||
public void endInstreamForeignObject(InstreamForeignObject ifo) { | |||||
endElement(ifo); | |||||
} | |||||
@Override | |||||
public void startFootnote(Footnote footnote) { | |||||
startElement(footnote); | |||||
} | |||||
@Override | |||||
public void endFootnote(Footnote footnote) { | |||||
endElement(footnote); | |||||
} | |||||
@Override | |||||
public void startFootnoteBody(FootnoteBody body) { | |||||
startElement(body); | |||||
} | |||||
@Override | |||||
public void endFootnoteBody(FootnoteBody body) { | |||||
endElement(body); | |||||
} | |||||
@Override | |||||
public void startLeader(Leader l) { | |||||
startElement(l); | |||||
} | |||||
@Override | |||||
public void endLeader(Leader l) { | |||||
endElement(l); | |||||
} | |||||
@Override | |||||
public void startWrapper(Wrapper wrapper) { | |||||
startElement(wrapper); | |||||
} | |||||
@Override | |||||
public void endWrapper(Wrapper wrapper) { | |||||
endElement(wrapper); | |||||
} | |||||
@Override | |||||
public void character(Character c) { | |||||
startElement(c); | |||||
endElement(c); | |||||
} | |||||
private void startElement(FObj node) { | |||||
addEvent("start ", node); | |||||
} | |||||
private void endElement(FObj node) { | |||||
addEvent("end ", node); | |||||
} | |||||
private void addEvent(String event, FObj node) { | |||||
eventBuilder.append(event); | |||||
eventBuilder.append(node.getLocalName()); | |||||
addID(node); | |||||
actualEvents.add(eventBuilder.toString()); | |||||
eventBuilder.setLength(0); | |||||
} | |||||
private void addID(FObj node) { | |||||
String id = node.getId(); | |||||
if (id != null && id.length() > 0) { | |||||
eventBuilder.append(" id=\""); | |||||
eventBuilder.append(id); | |||||
eventBuilder.append("\""); | |||||
} | |||||
} | |||||
} | |||||
@Before | |||||
public void setUp() throws IOException { | |||||
setUpEvents(); | |||||
loadDocument(); | |||||
createDocumentParser(); | |||||
} | |||||
private void setUpEvents() throws IOException { | |||||
loadDocument(); | |||||
loadExpectedEvents(); | |||||
actualEvents = new ArrayList<String>(expectedEvents.size()); | |||||
} | |||||
private void loadDocument() { | |||||
Class<?> clazz = getClass(); | |||||
String documentName = clazz.getSimpleName() + ".fo"; | |||||
document = clazz.getResourceAsStream(documentName); | |||||
} | |||||
private void loadExpectedEvents() throws IOException { | |||||
expectedEvents = new ArrayList<String>(); | |||||
InputStream xslt = getClass().getResourceAsStream("extract-events.xsl"); | |||||
try { | |||||
runXSLT(xslt); | |||||
} finally { | |||||
closeStream(xslt); | |||||
closeStream(document); | |||||
} | |||||
} | |||||
private void runXSLT(InputStream xslt) { | |||||
Transformer transformer = createTransformer(xslt); | |||||
Source fo = new StreamSource(document); | |||||
Result result = createTransformOutputHandler(); | |||||
try { | |||||
transformer.transform(fo, result); | |||||
} catch (TransformerException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
private Transformer createTransformer(InputStream xslt) { | |||||
TransformerFactory transformerFactory = TransformerFactory.newInstance(); | |||||
try { | |||||
return transformerFactory.newTransformer(new StreamSource(xslt)); | |||||
} catch (TransformerConfigurationException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
private Result createTransformOutputHandler() { | |||||
return new SAXResult(new DefaultHandler() { | |||||
private final StringBuilder event = new StringBuilder(); | |||||
@Override | |||||
public void startElement(String uri, String localName, String qName, | |||||
Attributes attributes) throws SAXException { | |||||
event.setLength(0); | |||||
} | |||||
@Override | |||||
public void characters(char[] ch, int start, int length) throws SAXException { | |||||
event.append(ch, start, length); | |||||
} | |||||
@Override | |||||
public void endElement(String uri, String localName, String qName) throws SAXException { | |||||
expectedEvents.add(event.toString()); | |||||
} | |||||
}); | |||||
} | |||||
private void closeStream(InputStream stream) { | |||||
try { | |||||
stream.close(); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
private void createDocumentParser() { | |||||
documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() { | |||||
public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) { | |||||
return new DelegatingFOEventHandler( | |||||
new DelegatingFOEventHandlerTester(foUserAgent)) { | |||||
}; | |||||
} | |||||
}); | |||||
} | |||||
@Test | |||||
public void testFOEventHandler() throws Exception { | |||||
documentParser.parse(document); | |||||
assertArrayEquals(expectedEvents.toArray(), actualEvents.toArray()); | |||||
} | |||||
@After | |||||
public void unloadDocument() throws IOException { | |||||
document.close(); | |||||
} | |||||
/** | |||||
* Prints the given list to {@code System.out}, each element on a new line. For | |||||
* debugging purpose. | |||||
* | |||||
* @param list a list | |||||
*/ | |||||
public void printList(List<?> list) { | |||||
for (Object element : list) { | |||||
System.out.println(element); | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo; | |||||
import java.io.InputStream; | |||||
import javax.xml.transform.Result; | |||||
import javax.xml.transform.Source; | |||||
import javax.xml.transform.Transformer; | |||||
import javax.xml.transform.TransformerConfigurationException; | |||||
import javax.xml.transform.TransformerException; | |||||
import javax.xml.transform.TransformerFactory; | |||||
import javax.xml.transform.sax.SAXResult; | |||||
import javax.xml.transform.stream.StreamSource; | |||||
import org.apache.fop.apps.FOPException; | |||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.apps.Fop; | |||||
import org.apache.fop.apps.FopFactory; | |||||
import org.apache.fop.events.EventListener; | |||||
/** | |||||
* Parse an FO document and run the corresponding FO events through a given | |||||
* {@link FOEventHandler} instance. That instance is created using the helper | |||||
* {@link FOEventHandlerFactory}. | |||||
* | |||||
* <p>An instance of this class may not be used in multiple threads concurrently.<p> | |||||
* | |||||
* <p>An instance of this class may be used multiple times if the given | |||||
* {@link FOEventHandler} implementation can be used multiple times. | |||||
*/ | |||||
public final class FODocumentParser { | |||||
private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance(); | |||||
private static final FopFactory FOP_FACTORY = FopFactory.newInstance(); | |||||
private final FOEventHandlerFactory foEventHandlerFactory; | |||||
private Fop fop; | |||||
private Transformer transformer; | |||||
private EventListener eventListener; | |||||
/** | |||||
* A factory to create custom instances of {@link FOEventHandler}. | |||||
*/ | |||||
public static interface FOEventHandlerFactory { | |||||
/** | |||||
* Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent. | |||||
* | |||||
* @param foUserAgent an FO user agent | |||||
* @return a new {@code FOEventHandler} instance | |||||
*/ | |||||
FOEventHandler newFOEventHandler(FOUserAgent foUserAgent); | |||||
} | |||||
private FODocumentParser(FOEventHandlerFactory foeEventHandlerFactory) { | |||||
this.foEventHandlerFactory = foeEventHandlerFactory; | |||||
} | |||||
/** | |||||
* Creates and returns a new FO document parser. The given factory will be used to | |||||
* customize the handler that will receive FO events, using the | |||||
* {@link FOUserAgent#setFOEventHandlerOverride(FOEventHandler)} method. | |||||
* | |||||
* @param foEventHandlerFactory the factory to be used to create {@code | |||||
* FOEventHandler} instances | |||||
* @return a new parser | |||||
*/ | |||||
public static FODocumentParser newInstance(FOEventHandlerFactory foEventHandlerFactory) { | |||||
return new FODocumentParser(foEventHandlerFactory); | |||||
} | |||||
/** | |||||
* Sets the event listener to be used if events occurs when parsing the document. | |||||
* | |||||
* @param eventListener an event listener | |||||
*/ | |||||
public void setEventListener(EventListener eventListener) { | |||||
this.eventListener = eventListener; | |||||
} | |||||
/** | |||||
* Runs FOP on the given document. | |||||
* | |||||
* @param document XSL-FO document to parse | |||||
* @throws FOPException if an error occurs when initializing FOP | |||||
* @throws LoadingException if an error occurs when parsing the document | |||||
*/ | |||||
public void parse(InputStream document) throws FOPException, LoadingException { | |||||
FOUserAgent foUserAgent = createFOUserAgent(); | |||||
fop = FOP_FACTORY.newFop(foUserAgent); | |||||
createTransformer(); | |||||
runTransformer(document); | |||||
} | |||||
private FOUserAgent createFOUserAgent() { | |||||
FOUserAgent userAgent = FOP_FACTORY.newFOUserAgent(); | |||||
FOEventHandler foEventHandler = foEventHandlerFactory.newFOEventHandler(userAgent); | |||||
userAgent.setFOEventHandlerOverride(foEventHandler); | |||||
if (eventListener != null) { | |||||
userAgent.getEventBroadcaster().addEventListener(eventListener); | |||||
} | |||||
return userAgent; | |||||
} | |||||
private void createTransformer() { | |||||
try { | |||||
transformer = TRANSFORMER_FACTORY.newTransformer(); | |||||
} catch (TransformerConfigurationException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
private void runTransformer(InputStream input) throws LoadingException, FOPException { | |||||
Source source = new StreamSource(input); | |||||
Result result = new SAXResult(fop.getDefaultHandler()); | |||||
try { | |||||
transformer.transform(source, result); | |||||
} catch (TransformerException e) { | |||||
Throwable cause = e.getCause(); | |||||
throw new LoadingException(cause == null ? e : cause); | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo; | |||||
import static org.mockito.Matchers.any; | |||||
import static org.mockito.Matchers.anyString; | |||||
import static org.mockito.Mockito.mock; | |||||
import static org.mockito.Mockito.when; | |||||
import java.io.IOException; | |||||
import org.apache.xmlgraphics.image.loader.ImageException; | |||||
import org.apache.xmlgraphics.image.loader.ImageManager; | |||||
import org.apache.xmlgraphics.image.loader.ImageSessionContext; | |||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.apps.FopFactory; | |||||
/** | |||||
* A helper class for creating mocks of {@link FONode} and its descendants. | |||||
*/ | |||||
public final class FONodeMocks { | |||||
private FONodeMocks() { } | |||||
/** | |||||
* Creates and returns a mock {@link FONode} configured with a mock | |||||
* {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent}, | |||||
* which in turn returns a mock {@link FopFactory}, which returns a mock | |||||
* {@link ImageManager}. | |||||
* | |||||
* @return a mock FO node | |||||
*/ | |||||
public static FONode mockFONode() { | |||||
FONode mockFONode = mock(FONode.class); | |||||
mockGetFOEventHandler(mockFONode); | |||||
return mockFONode; | |||||
} | |||||
private static void mockGetFOEventHandler(FONode mockFONode) { | |||||
FOEventHandler mockFOEventHandler = mock(FOEventHandler.class); | |||||
mockGetUserAgent(mockFOEventHandler); | |||||
when(mockFONode.getFOEventHandler()).thenReturn(mockFOEventHandler); | |||||
} | |||||
private static void mockGetUserAgent(FOEventHandler mockFOEventHandler) { | |||||
FOUserAgent mockFOUserAgent = mock(FOUserAgent.class); | |||||
mockGetFactory(mockFOUserAgent); | |||||
when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent); | |||||
} | |||||
private static void mockGetFactory(FOUserAgent mockFOUserAgent) { | |||||
FopFactory mockFopFactory = mock(FopFactory.class); | |||||
mockGetImageManager(mockFopFactory); | |||||
when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory); | |||||
} | |||||
private static void mockGetImageManager(FopFactory mockFopFactory) { | |||||
try { | |||||
ImageManager mockImageManager = mock(ImageManager.class); | |||||
when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class))) | |||||
.thenReturn(null); | |||||
when(mockFopFactory.getImageManager()).thenReturn(mockImageManager); | |||||
} catch (ImageException e) { | |||||
throw new RuntimeException(e); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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$ */ | |||||
package org.apache.fop.fo; | |||||
/** | |||||
* This class specifies an exceptional condition that occurred while an XSL-FO document | |||||
* was being parsed. | |||||
*/ | |||||
public class LoadingException extends Exception { | |||||
private static final long serialVersionUID = 7529029475875542916L; | |||||
LoadingException(Throwable cause) { | |||||
super(cause); | |||||
} | |||||
} |