Author: vhennebert
Date: Tue Jul 24 16:39:04 2012
New Revision: 1365162
URL: http://svn.apache.org/viewvc?rev=1365162&view=rev
Log:
Bugzilla #53596: When PDF accessibility is enabled, the structure tree must
contain information about the number of columns or rows spanned by a table cell.
Added:
xmlgraphics/fop/trunk/test/pdf/accessibility/pdf/table_row-col-span.pdf
(with props)
xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo (with
props)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFArray.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFStructElem.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
xmlgraphics/fop/trunk/status.xml
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java?rev=1365162&r1=1365161&r2=1365162&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java
Tue Jul 24 16:39:04 2012
@@ -221,14 +221,17 @@ class StructureTreeEventTrigger extends
@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));
- }
+ addSpanAttribute(attributes, "number-columns-spanned",
tc.getNumberColumnsSpanned());
+ addSpanAttribute(attributes, "number-rows-spanned",
tc.getNumberRowsSpanned());
startElement(tc, attributes);
}
+ private void addSpanAttribute(AttributesImpl attributes, String
attributeName, int span) {
+ if (span > 1) {
+ addNoNamespaceAttribute(attributes, attributeName,
Integer.toString(span));
+ }
+ }
+
@Override
public void endCell(TableCell tc) {
endElement(tc);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFArray.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFArray.java?rev=1365162&r1=1365161&r2=1365162&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFArray.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFArray.java Tue Jul 24
16:39:04 2012
@@ -100,6 +100,15 @@ public class PDFArray extends PDFObject
}
/**
+ * Creates an array object made of the given elements.
+ *
+ * @param elements the array content
+ */
+ public PDFArray(List<?> elements) {
+ this(null, elements);
+ }
+
+ /**
* Create the array object
* @param parent the array's parent if any
* @param values the actual array wrapped by this object
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFStructElem.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFStructElem.java?rev=1365162&r1=1365161&r2=1365162&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFStructElem.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFStructElem.java Tue
Jul 24 16:39:04 2012
@@ -33,6 +33,8 @@ import org.apache.fop.util.LanguageTags;
*/
public class PDFStructElem extends PDFDictionary implements
StructureTreeElement, CompressedObject {
+ private static final PDFName TABLE = new PDFName("Table");
+
private PDFStructElem parentElement;
/**
@@ -40,6 +42,8 @@ public class PDFStructElem extends PDFDi
*/
protected List<PDFObject> kids;
+ private List<PDFDictionary> attributes;
+
/**
* Creates a new structure element.
*
@@ -143,9 +147,21 @@ public class PDFStructElem extends PDFDi
@Override
protected void writeDictionary(OutputStream out, StringBuilder textBuffer)
throws IOException {
attachKids();
+ attachAttributes();
super.writeDictionary(out, textBuffer);
}
+ private void attachAttributes() {
+ if (attributes != null) {
+ if (attributes.size() == 1) {
+ put("A", attributes.get(0));
+ } else {
+ PDFArray array = new PDFArray(attributes);
+ put("A", array);
+ }
+ }
+ }
+
/**
* Attaches all valid kids to the kids array.
*
@@ -175,6 +191,24 @@ public class PDFStructElem extends PDFDi
return kidsAttached;
}
+ public void setTableAttributeColSpan(int colSpan) {
+ setTableAttributeRowColumnSpan("ColSpan", colSpan);
+ }
+
+ public void setTableAttributeRowSpan(int rowSpan) {
+ setTableAttributeRowColumnSpan("RowSpan", rowSpan);
+ }
+
+ private void setTableAttributeRowColumnSpan(String typeSpan, int span) {
+ PDFDictionary attribute = new PDFDictionary();
+ attribute.put("O", TABLE);
+ attribute.put(typeSpan, span);
+ if (attributes == null) {
+ attributes = new ArrayList<PDFDictionary>(2);
+ }
+ attributes.add(attribute);
+ }
+
/**
* Class representing a placeholder for a PDF Structure Element.
*/
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java?rev=1365162&r1=1365161&r2=1365162&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
Tue Jul 24 16:39:04 2012
@@ -90,11 +90,23 @@ class PDFStructureTreeBuilder implements
PDFStructElem parent = ancestors.getFirst();
String role = attributes.getValue("role");
PDFStructElem structElem = createStructureElement(name, parent, role);
+ setSpanAttributes(structElem, attributes);
parent.addKid(structElem);
ancestors.addFirst(structElem);
return structElem;
}
+ private void setSpanAttributes(PDFStructElem structElem, Attributes
attributes) {
+ String columnSpan = attributes.getValue("number-columns-spanned");
+ if (columnSpan != null) {
+ structElem.setTableAttributeColSpan(Integer.parseInt(columnSpan));
+ }
+ String rowSpan = attributes.getValue("number-rows-spanned");
+ if (rowSpan != null) {
+ structElem.setTableAttributeRowSpan(Integer.parseInt(rowSpan));
+ }
+ }
+
public void endNode(String name) {
removeFirstAncestor();
}
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1365162&r1=1365161&r2=1365162&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Jul 24 16:39:04 2012
@@ -62,6 +62,10 @@
documents. Example: the fix of marks layering will be such a case when
it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="VH" type="add" fixes-bug="53596">
+ When PDF accessibility is enabled, the structure tree must contain
information about the
+ number of columns or rows spanned by a table cell.
+ </action>
<action context="Renderers" dev="MH" type="add" fixes-bug="53563"
importance="low">
Removed a method call to the
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
that could (in a headless environment) throw a
java.awt.HeadlessException
Added: xmlgraphics/fop/trunk/test/pdf/accessibility/pdf/table_row-col-span.pdf
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/pdf/accessibility/pdf/table_row-col-span.pdf?rev=1365162&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
xmlgraphics/fop/trunk/test/pdf/accessibility/pdf/table_row-col-span.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo?rev=1365162&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo (added)
+++ xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo Tue Jul
24 16:39:04 2012
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="utf-8"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page" page-height="320pt"
page-width="420pt" margin="10pt">
+ <fo:region-body display-align="center"/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:table table-layout="fixed" width="100%" border-collapse="separate"
+ border-separation="4pt">
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell number-columns-spanned="2"
background-color="orange" padding-left="1pt">
+ <fo:block>Cells 1.1 and 1.2.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 1.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 1.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 2.1.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell number-columns-spanned="2"
background-color="orange" padding-left="1pt">
+ <fo:block>Cells 2.2 and 2.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 2.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 3.1.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 3.2.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell number-columns-spanned="2"
background-color="orange" padding-left="1pt">
+ <fo:block>Cells 3.3 and 3.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell number-columns-spanned="3"
background-color="orange" padding-left="1pt">
+ <fo:block>Cells 4.1, 4.2 and 4.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 4.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell number-columns-spanned="4"
background-color="orange" padding-left="1pt">
+ <fo:block>Cells 5.1, 5.2, 5.3 and 5.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+
+ <fo:table table-layout="fixed" width="100%" space-before="40pt"
border-collapse="separate"
+ border-separation="4pt">
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell number-rows-spanned="2" background-color="orange"
padding-left="1pt">
+ <fo:block>Cells 1.1</fo:block>
+ <fo:block>and 2.1.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 1.2.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 1.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell number-rows-spanned="4" background-color="orange"
padding-left="1pt">
+ <fo:block>Cells 1.4,</fo:block>
+ <fo:block>2.4,</fo:block>
+ <fo:block>3.4</fo:block>
+ <fo:block>and 4.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell number-rows-spanned="2" background-color="orange"
padding-left="1pt">
+ <fo:block>Cells 2.2</fo:block>
+ <fo:block>and 3.2.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell number-rows-spanned="3" background-color="orange"
padding-left="1pt">
+ <fo:block>Cells 2.3,</fo:block>
+ <fo:block>3.3</fo:block>
+ <fo:block>and 4.3.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 3.1.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 4.1.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 4.2.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+
+ <fo:table table-layout="fixed" width="100%" space-before="40pt"
border-collapse="separate"
+ border-separation="4pt">
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell number-rows-spanned="2" number-columns-spanned="3"
+ background-color="orange" padding-left="1pt">
+ <fo:block>Cells 1.1, 1.2, 1.3</fo:block>
+ <fo:block>and 2.1, 2.2, 2.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 1.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 2.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>Cell 3.1.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 3.2.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 3.3.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <fo:block>Cell 3.4.</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
Propchange: xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/pdf/accessibility/table_row-col-span.fo
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]