Findbugs report generated with version 1.3.9. Checkstyle report generated with version 5.5. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImproveAccessibility@1240963 13f79535-47bb-0310-9956-ffa450edef68pull/24/head
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
<FindBugsFilter> | <FindBugsFilter> | ||||
<!-- The names of public methods will not be modified --> | |||||
<Match> | |||||
<Class name="org.apache.fop.render.intermediate.IFStructureTreeBuilder"/> | |||||
<Field name="delegate"/> | |||||
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="org.apache.fop.render.pdf.PDFLogicalStructureHandler"/> | |||||
<Field name="currentPage"/> | |||||
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="org.apache.fop.render.pdf.PDFLogicalStructureHandler"/> | |||||
<Field name="pageParentTreeArray"/> | |||||
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="org.apache.fop.render.pdf.PDFStructureTreeBuilder"/> | |||||
<Field name="logicalStructureHandler"/> | |||||
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="org.apache.fop.render.pdf.PDFStructureTreeBuilder"/> | |||||
<Field name="pdfFactory"/> | |||||
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="org.apache.fop.accessibility.fo.FO2StructureTreeConverter$1"/> | |||||
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/> | |||||
</Match> | |||||
<Match> | |||||
<Class name="~org.apache.fop.accessibility.fo.FOEventRecorder.*"/> | |||||
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/> | |||||
</Match> | |||||
<Match> | <Match> | ||||
<Class name="org.apache.fop.afp.AFPDataObjectInfo"/> | <Class name="org.apache.fop.afp.AFPDataObjectInfo"/> | ||||
<Method name="getUri"/> | <Method name="getUri"/> | ||||
<Bug pattern="REC_CATCH_EXCEPTION"/> | <Bug pattern="REC_CATCH_EXCEPTION"/> | ||||
</Match> | </Match> | ||||
<!-- /Automatically generated list of exclusions on 18 February 2011 --> | <!-- /Automatically generated list of exclusions on 18 February 2011 --> | ||||
</FindBugsFilter> | |||||
</FindBugsFilter> |
private DummyStructureTreeEventHandler() { } | private DummyStructureTreeEventHandler() { } | ||||
/** {@inheritDoc} */ | |||||
public void startPageSequence(Locale locale) { | public void startPageSequence(Locale locale) { | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void endPageSequence() { | public void endPageSequence() { | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startNode(String name, Attributes attributes) { | public StructureTreeElement startNode(String name, Attributes attributes) { | ||||
return null; | return null; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void endNode(String name) { | public void endNode(String name) { | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startImageNode(String name, Attributes attributes) { | public StructureTreeElement startImageNode(String name, Attributes attributes) { | ||||
return null; | return null; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startReferencedNode(String name, Attributes attributes) { | public StructureTreeElement startReferencedNode(String name, Attributes attributes) { | ||||
return null; | return null; | ||||
} | } |
/** | /** | ||||
* Factory method that creates a new instance. | * Factory method that creates a new instance. | ||||
* @param contentHandler The handler that receives SAX events | * @param contentHandler The handler that receives SAX events | ||||
* @return - | |||||
*/ | */ | ||||
public static StructureTreeEventHandler newInstance(ContentHandler contentHandler) { | public static StructureTreeEventHandler newInstance(ContentHandler contentHandler) { | ||||
return new StructureTree2SAXEventAdapter(contentHandler); | return new StructureTree2SAXEventAdapter(contentHandler); | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void startPageSequence(Locale locale) { | public void startPageSequence(Locale locale) { | ||||
try { | try { | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void endPageSequence() { | public void endPageSequence() { | ||||
try { | try { | ||||
contentHandler.endElement(IFConstants.NAMESPACE, IFConstants.EL_STRUCTURE_TREE, | contentHandler.endElement(IFConstants.NAMESPACE, IFConstants.EL_STRUCTURE_TREE, | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startNode(String name, Attributes attributes) { | public StructureTreeElement startNode(String name, Attributes attributes) { | ||||
try { | try { | ||||
if (name.equals("#PCDATA")) { | if (name.equals("#PCDATA")) { | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void endNode(String name) { | public void endNode(String name) { | ||||
try { | try { | ||||
contentHandler.endElement(FOElementMapping.URI, name, | contentHandler.endElement(FOElementMapping.URI, name, | ||||
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startImageNode(String name, Attributes attributes) { | public StructureTreeElement startImageNode(String name, Attributes attributes) { | ||||
return startNode(name, attributes); | return startNode(name, attributes); | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public StructureTreeElement startReferencedNode(String name, Attributes attributes) { | public StructureTreeElement startReferencedNode(String name, Attributes attributes) { | ||||
return startNode(name, attributes); | return startNode(name, attributes); | ||||
} | } |
/* $Id$ */ | /* $Id$ */ | ||||
/** | |||||
* | |||||
*/ | |||||
package org.apache.fop.accessibility; | package org.apache.fop.accessibility; | ||||
/** | /** |
if (node instanceof CommonAccessibilityHolder) { | if (node instanceof CommonAccessibilityHolder) { | ||||
addRole((CommonAccessibilityHolder) node, attributes); | addRole((CommonAccessibilityHolder) node, attributes); | ||||
} | } | ||||
node.setStructureTreeElement(structureTreeEventHandler.startReferencedNode(localName, attributes)); | |||||
node.setStructureTreeElement( | |||||
structureTreeEventHandler.startReferencedNode(localName, attributes)); | |||||
} | } | ||||
private void startElementWithIDAndAltText(AbstractGraphics node) { | private void startElementWithIDAndAltText(AbstractGraphics node) { | ||||
addRole(node, attributes); | addRole(node, attributes); | ||||
addAttribute(attributes, ExtensionElementMapping.URI, "alt-text", | addAttribute(attributes, ExtensionElementMapping.URI, "alt-text", | ||||
ExtensionElementMapping.STANDARD_PREFIX, node.getAltText()); | ExtensionElementMapping.STANDARD_PREFIX, node.getAltText()); | ||||
node.setStructureTreeElement(structureTreeEventHandler.startImageNode(localName, attributes)); | |||||
node.setStructureTreeElement( | |||||
structureTreeEventHandler.startImageNode(localName, attributes)); | |||||
} | } | ||||
private StructureTreeElement startElement(FONode node, AttributesImpl attributes) { | private StructureTreeElement startElement(FONode node, AttributesImpl attributes) { |
private boolean locatorEnabled = true; // true by default (for error messages). | private boolean locatorEnabled = true; // true by default (for error messages). | ||||
private boolean conserveMemoryPolicy = false; | private boolean conserveMemoryPolicy = false; | ||||
private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster(); | private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster(); | ||||
private StructureTreeEventHandler structureTreeEventHandler = DummyStructureTreeEventHandler.INSTANCE; | |||||
private StructureTreeEventHandler structureTreeEventHandler | |||||
= DummyStructureTreeEventHandler.INSTANCE; | |||||
/** Producer: Metadata element for the system/software that produces | /** Producer: Metadata element for the system/software that produces | ||||
* the document. (Some renderers can store this in the document.) | * the document. (Some renderers can store this in the document.) |
private DOMImplementation domImplementation; | private DOMImplementation domImplementation; | ||||
private Locator locator; | private Locator locator; | ||||
private Attributes pageSequenceAttributes; | |||||
public Handler(AreaTreeModel treeModel, FOUserAgent userAgent, | public Handler(AreaTreeModel treeModel, FOUserAgent userAgent, | ||||
ElementMappingRegistry elementMappingRegistry) { | ElementMappingRegistry elementMappingRegistry) { | ||||
this.treeModel = treeModel; | this.treeModel = treeModel; |
public void endDocument() throws SAXException { | public void endDocument() throws SAXException { | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void startRoot(Root root) { | public void startRoot(Root root) { | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public void endRoot(Root root) { | public void endRoot(Root root) { | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Sets the structure tree element. | |||||
* | |||||
* @param structureTreeElement set. | |||||
*/ | |||||
public void setStructureTreeElement(StructureTreeElement structureTreeElement) { | public void setStructureTreeElement(StructureTreeElement structureTreeElement) { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } |
this.structureTreeElement = structureTreeElement; | this.structureTreeElement = structureTreeElement; | ||||
} | } | ||||
/** @return the structure tree element. */ | |||||
public StructureTreeElement getStructureTreeElement() { | public StructureTreeElement getStructureTreeElement() { | ||||
return structureTreeElement; | return structureTreeElement; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } | ||||
return structureTreeElement; | return structureTreeElement; | ||||
} | } | ||||
/** @return the alternative text property. */ | |||||
public String getAltText() { | public String getAltText() { | ||||
return altText; | return altText; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
getFOEventHandler().endBlock(this); | getFOEventHandler().endBlock(this); | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
*/ | */ | ||||
public class FootnoteBody extends FObj implements CommonAccessibilityHolder { | public class FootnoteBody extends FObj implements CommonAccessibilityHolder { | ||||
/** {@inheritDoc} */ | |||||
private CommonAccessibility commonAccessibility; | private CommonAccessibility commonAccessibility; | ||||
/** | /** | ||||
return FO_FOOTNOTE_BODY; | return FO_FOOTNOTE_BODY; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
return FO_INITIAL_PROPERTY_SET; | return FO_INITIAL_PROPERTY_SET; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
return FO_TABLE_AND_CAPTION; | return FO_TABLE_AND_CAPTION; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
return FO_TABLE_CAPTION; | return FO_TABLE_CAPTION; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
return true; | return true; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
return columnNumberManager; | return columnNumberManager; | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } | ||||
} | } | ||||
/** @return locale proprty. */ | |||||
public Locale getLocale() { | public Locale getLocale() { | ||||
return locale; | return locale; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
} | } | ||||
} | } | ||||
/** {@inheritDoc} */ | |||||
public CommonAccessibility getCommonAccessibility() { | public CommonAccessibility getCommonAccessibility() { | ||||
return commonAccessibility; | return commonAccessibility; | ||||
} | } |
* @param area the area to set the traits on | * @param area the area to set the traits on | ||||
* @param structureTreeElement the element the area is associated to in the document structure | * @param structureTreeElement the element the area is associated to in the document structure | ||||
*/ | */ | ||||
public static void addStructureTreeElement(Area area, StructureTreeElement structureTreeElement) { | |||||
public static void addStructureTreeElement(Area area, | |||||
StructureTreeElement structureTreeElement) { | |||||
if (structureTreeElement != null) { | if (structureTreeElement != null) { | ||||
area.addTrait(Trait.STRUCTURE_TREE_ELEMENT, structureTreeElement); | area.addTrait(Trait.STRUCTURE_TREE_ELEMENT, structureTreeElement); | ||||
} | } |
} | } | ||||
/** | /** | ||||
* Sets the language identifier of the document. | |||||
* @param lang the language identifier of the document. | |||||
* Sets the locale of the document. | |||||
* @param locale the locale of the document. | |||||
*/ | */ | ||||
public void setLanguage(Locale locale) { | public void setLanguage(Locale locale) { | ||||
if (locale == null) { | if (locale == null) { |
return kidsAttached; | return kidsAttached; | ||||
} | } | ||||
/** | |||||
* Class representing a placeholder for a PDF Structure Element. | |||||
*/ | |||||
public static class Placeholder extends PDFStructElem { | public static class Placeholder extends PDFStructElem { | ||||
@Override | @Override | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Constructor | |||||
* @param parent - | |||||
* @param name - | |||||
*/ | |||||
public Placeholder(PDFObject parent, String name) { | public Placeholder(PDFObject parent, String name) { | ||||
super(parent, new PDFName(name)); | super(parent, new PDFName(name)); | ||||
} | } |
String EL_HEADER = "header"; | String EL_HEADER = "header"; | ||||
/** element name trailer */ | /** element name trailer */ | ||||
String EL_TRAILER = "trailer"; | String EL_TRAILER = "trailer"; | ||||
/** element name locale */ | |||||
String EL_LOCALE = "locale"; | String EL_LOCALE = "locale"; | ||||
/** element name page-sequence */ | /** element name page-sequence */ | ||||
String EL_PAGE_SEQUENCE = "page-sequence"; | String EL_PAGE_SEQUENCE = "page-sequence"; |
private Attributes pageSequenceAttributes; | private Attributes pageSequenceAttributes; | ||||
private Map<String, StructureTreeElement> structureTreeElements = | |||||
new HashMap<String, StructureTreeElement>(); | |||||
private Map<String, StructureTreeElement> structureTreeElements | |||||
= new HashMap<String, StructureTreeElement>(); | |||||
private final class StructureTreeHandler extends DefaultHandler { | private final class StructureTreeHandler extends DefaultHandler { | ||||
structureTreeEventHandler.startNode(localName, attributes); | structureTreeEventHandler.startNode(localName, attributes); | ||||
} else if (localName.equals("external-graphic") | } else if (localName.equals("external-graphic") | ||||
|| localName.equals("instream-foreign-object")) { | || localName.equals("instream-foreign-object")) { | ||||
StructureTreeElement structureTreeElement = | |||||
structureTreeEventHandler.startImageNode(localName, attributes); | |||||
StructureTreeElement structureTreeElement | |||||
= structureTreeEventHandler.startImageNode(localName, attributes); | |||||
structureTreeElements.put(structID, structureTreeElement); | structureTreeElements.put(structID, structureTreeElement); | ||||
} else { | } else { | ||||
StructureTreeElement structureTreeElement = | |||||
structureTreeEventHandler.startReferencedNode(localName, attributes); | |||||
StructureTreeElement structureTreeElement = structureTreeEventHandler | |||||
.startReferencedNode(localName, attributes); | |||||
structureTreeElements.put(structID, structureTreeElement); | structureTreeElements.put(structID, structureTreeElement); | ||||
} | } | ||||
} | } | ||||
} else if (DocumentNavigationExtensionConstants.NAMESPACE.equals(uri)) { | } else if (DocumentNavigationExtensionConstants.NAMESPACE.equals(uri)) { | ||||
if (this.navParser == null) { | if (this.navParser == null) { | ||||
this.navParser = new DocumentNavigationHandler( | this.navParser = new DocumentNavigationHandler( | ||||
this.documentHandler.getDocumentNavigationHandler(), structureTreeElements); | |||||
this.documentHandler.getDocumentNavigationHandler(), | |||||
structureTreeElements); | |||||
} | } | ||||
delegate = this.navParser; | delegate = this.navParser; | ||||
delegateDepth++; | delegateDepth++; |
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public void renderInlineViewport(InlineViewport viewport) { | public void renderInlineViewport(InlineViewport viewport) { | ||||
StructureTreeElement structElem = | |||||
(StructureTreeElement) viewport.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
StructureTreeElement structElem | |||||
= (StructureTreeElement) viewport.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
establishStructureTreeElement(structElem); | establishStructureTreeElement(structElem); | ||||
pushdID(viewport); | pushdID(viewport); | ||||
Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); | Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); | ||||
// warn if link trait found but not allowed, else create link | // warn if link trait found but not allowed, else create link | ||||
if (linkTraitFound) { | if (linkTraitFound) { | ||||
StructureTreeElement structElem = | |||||
(StructureTreeElement) ip.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
StructureTreeElement structElem | |||||
= (StructureTreeElement) ip.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
action.setStructureTreeElement(structElem); | action.setStructureTreeElement(structElem); | ||||
Link link = new Link(action, ipRect); | Link link = new Link(action, ipRect); | ||||
this.deferredLinks.add(link); | this.deferredLinks.add(link); | ||||
String fontName = getInternalFontNameForArea(text); | String fontName = getInternalFontNameForArea(text); | ||||
int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); | int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); | ||||
StructureTreeElement structElem = (StructureTreeElement) text.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
StructureTreeElement structElem | |||||
= (StructureTreeElement) text.getTrait(Trait.STRUCTURE_TREE_ELEMENT); | |||||
establishStructureTreeElement(structElem); | establishStructureTreeElement(structElem); | ||||
// This assumes that *all* CIDFonts use a /ToUnicode mapping | // This assumes that *all* CIDFonts use a /ToUnicode mapping |
handler.startPrefixMapping(XLINK_PREFIX, XLINK_NAMESPACE); | handler.startPrefixMapping(XLINK_PREFIX, XLINK_NAMESPACE); | ||||
handler.startPrefixMapping(DocumentNavigationExtensionConstants.PREFIX, | handler.startPrefixMapping(DocumentNavigationExtensionConstants.PREFIX, | ||||
DocumentNavigationExtensionConstants.NAMESPACE); | DocumentNavigationExtensionConstants.NAMESPACE); | ||||
handler.startPrefixMapping(InternalElementMapping.STANDARD_PREFIX, InternalElementMapping.URI); | |||||
handler.startPrefixMapping(InternalElementMapping.STANDARD_PREFIX, | |||||
InternalElementMapping.URI); | |||||
handler.startElement(EL_DOCUMENT); | handler.startElement(EL_DOCUMENT); | ||||
} catch (SAXException e) { | } catch (SAXException e) { | ||||
throw new IFException("SAX error in startDocument()", e); | throw new IFException("SAX error in startDocument()", e); | ||||
} | } | ||||
private void addStructureReference(AttributesImpl atts) { | private void addStructureReference(AttributesImpl atts) { | ||||
IFStructureTreeElement structureTreeElement = | |||||
(IFStructureTreeElement) getContext().getStructureTreeElement(); | |||||
IFStructureTreeElement structureTreeElement | |||||
= (IFStructureTreeElement) getContext().getStructureTreeElement(); | |||||
if (structureTreeElement != null) { | if (structureTreeElement != null) { | ||||
addStructRefAttribute(atts, structureTreeElement.id); | |||||
addStructRefAttribute(atts, structureTreeElement.getId()); | |||||
} | } | ||||
} | } | ||||
XMLConstants.CDATA, IFUtil.toString(link.getTargetRect())); | XMLConstants.CDATA, IFUtil.toString(link.getTargetRect())); | ||||
if (getUserAgent().isAccessibilityEnabled()) { | if (getUserAgent().isAccessibilityEnabled()) { | ||||
addStructRefAttribute(atts, | addStructRefAttribute(atts, | ||||
((IFStructureTreeElement) link.getAction().getStructureTreeElement()).id); | |||||
((IFStructureTreeElement) link.getAction().getStructureTreeElement()).getId()); | |||||
} | } | ||||
try { | try { | ||||
handler.startElement(DocumentNavigationExtensionConstants.LINK, atts); | handler.startElement(DocumentNavigationExtensionConstants.LINK, atts); |
static final class IFStructureTreeElement implements StructureTreeElement { | static final class IFStructureTreeElement implements StructureTreeElement { | ||||
final String id; | |||||
private final String id; | |||||
IFStructureTreeElement() { | IFStructureTreeElement() { | ||||
this.id = null; | this.id = null; | ||||
IFStructureTreeElement(String id) { | IFStructureTreeElement(String id) { | ||||
this.id = id; | this.id = id; | ||||
} | } | ||||
public String getId() { | |||||
return id; | |||||
} | |||||
} | } | ||||
/** A SAX handler that records events to replay them later. */ | /** A SAX handler that records events to replay them later. */ | ||||
private static final class StartPrefixMapping extends SAXEventRecorder.Event { | private static final class StartPrefixMapping extends SAXEventRecorder.Event { | ||||
protected final String prefix; | |||||
protected final String uri; | |||||
private final String prefix; | |||||
private final String uri; | |||||
private StartPrefixMapping(String prefix, String uri) { | private StartPrefixMapping(String prefix, String uri) { | ||||
this.prefix = prefix; | this.prefix = prefix; | ||||
private static final class EndPrefixMapping extends SAXEventRecorder.Event { | private static final class EndPrefixMapping extends SAXEventRecorder.Event { | ||||
protected final String prefix; | |||||
private final String prefix; | |||||
private EndPrefixMapping(String prefix) { | private EndPrefixMapping(String prefix) { | ||||
this.prefix = prefix; | this.prefix = prefix; | ||||
private StructureTreeEventHandler delegate; | private StructureTreeEventHandler delegate; | ||||
private final List<SAXEventRecorder> pageSequenceEventRecorders = new ArrayList<SAXEventRecorder>(); | |||||
private final List<SAXEventRecorder> pageSequenceEventRecorders | |||||
= new ArrayList<SAXEventRecorder>(); | |||||
private int idCounter; | private int idCounter; | ||||
throw new SAXException(localName + " must be the root element!"); | throw new SAXException(localName + " must be the root element!"); | ||||
} | } | ||||
Rectangle targetRect = XMLUtil.getAttributeAsRectangle(attributes, "rect"); | Rectangle targetRect = XMLUtil.getAttributeAsRectangle(attributes, "rect"); | ||||
structureTreeElement = structureTreeElements.get( | |||||
attributes.getValue(InternalElementMapping.URI, InternalElementMapping.STRUCT_REF)); | |||||
structureTreeElement = structureTreeElements.get(attributes.getValue( | |||||
InternalElementMapping.URI, InternalElementMapping.STRUCT_REF)); | |||||
Link link = new Link(null, targetRect); | Link link = new Link(null, targetRect); | ||||
objectStack.push(link); | objectStack.push(link); | ||||
} else if (GOTO_XY.getLocalName().equals(localName)) { | } else if (GOTO_XY.getLocalName().equals(localName)) { |
/** | /** | ||||
* Standard structure types defined by the PDF Reference, Fourth Edition (PDF 1.5). | * Standard structure types defined by the PDF Reference, Fourth Edition (PDF 1.5). | ||||
*/ | */ | ||||
private static final Map<String, PDFName> STANDARD_STRUCTURE_TYPES = new HashMap<String, PDFName>(); | |||||
private static final Map<String, PDFName> STANDARD_STRUCTURE_TYPES | |||||
= new HashMap<String, PDFName>(); | |||||
private static final Map<String, Mapper> DEFAULT_MAPPINGS = new java.util.HashMap<String, Mapper>(); | |||||
private static final Map<String, Mapper> DEFAULT_MAPPINGS | |||||
= new java.util.HashMap<String, Mapper>(); | |||||
private static final PDFName THEAD; | private static final PDFName THEAD; | ||||
private static final PDFName NON_STRUCT; | private static final PDFName NON_STRUCT; |
RtfTextrun textrun = container.getTextrun(); | RtfTextrun textrun = container.getTextrun(); | ||||
textrun.addLeader(rtfAttr); | textrun.addLeader(rtfAttr); | ||||
} catch (Exception e) { | |||||
} catch (IOException e) { | |||||
log.error("startLeader: " + e.getMessage()); | |||||
throw new RuntimeException(e.getMessage()); | |||||
} catch (FOPException e) { | |||||
log.error("startLeader: " + e.getMessage()); | log.error("startLeader: " + e.getMessage()); | ||||
throw new RuntimeException(e.getMessage()); | throw new RuntimeException(e.getMessage()); | ||||
} | } |
/** If not null, the XMLRenderer will mimic another renderer by using its font setup. */ | /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */ | ||||
protected Renderer mimic; | protected Renderer mimic; | ||||
private int pageSequenceIndex; | |||||
/** | /** | ||||
* Creates a new XML renderer. | * Creates a new XML renderer. | ||||
*/ | */ |
* | * | ||||
* @param locale a locale | * @param locale a locale | ||||
* @return the corresponding language tag | * @return the corresponding language tag | ||||
* @throws NullPointerException if the specified locale is null | |||||
*/ | */ | ||||
public static String toLanguageTag(Locale locale) { | public static String toLanguageTag(Locale locale) { | ||||
StringBuffer sb = new StringBuffer(5); | StringBuffer sb = new StringBuffer(5); | ||||
/** | /** | ||||
* Converts an RFC 3066 compliant language tag to a locale. | * Converts an RFC 3066 compliant language tag to a locale. | ||||
* | * | ||||
* @throws NullPointerException if the specified language tag is null | |||||
* @param languageTag language tag to convert | |||||
* @return the corresponding locale | |||||
*/ | */ | ||||
public static Locale toLocale(String languageTag) { | public static Locale toLocale(String languageTag) { | ||||
String[] parts = languageTag.split("-"); | String[] parts = languageTag.split("-"); |