aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2022-06-15 08:10:12 +0000
committerSimon Steiner <ssteiner@apache.org>2022-06-15 08:10:12 +0000
commit8ac86aa2513dc26a0691ce228dbba17c6c9cd080 (patch)
tree03c282e6f25632686b10d61d1654228ad3492b75
parent1d958041958ea7d506560e77baf1afb20ba600c7 (diff)
downloadxmlgraphics-fop-8ac86aa2513dc26a0691ce228dbba17c6c9cd080.tar.gz
xmlgraphics-fop-8ac86aa2513dc26a0691ce228dbba17c6c9cd080.zip
FOP-3080: Allow removing empty table elements from structure tree
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1901930 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java12
-rw-r--r--fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java37
-rw-r--r--fop-core/src/test/resources/org/apache/fop/accessibility/fo/fo2StructureTree.xsl2
-rw-r--r--fop-core/src/test/resources/org/apache/fop/accessibility/fo/table-artifact.fo46
4 files changed, 93 insertions, 4 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java b/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
index 92c7cf7d9..060316bce 100644
--- a/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
+++ b/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
@@ -380,11 +380,12 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
@Override
public void startHeader(final TableHeader header) {
+ handleStartArtifact(header);
startContent(new Event(this) {
public void run() {
eventHandler.startHeader(header);
}
- }, true);
+ }, false);
super.startHeader(header);
}
@@ -395,16 +396,18 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
eventHandler.endHeader(header);
}
});
+ handleEndArtifact(header);
super.endHeader(header);
}
@Override
public void startFooter(final TableFooter footer) {
+ handleStartArtifact(footer);
startContent(new Event(this) {
public void run() {
eventHandler.startFooter(footer);
}
- }, true);
+ }, false);
super.startFooter(footer);
}
@@ -415,6 +418,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
eventHandler.endFooter(footer);
}
});
+ handleEndArtifact(footer);
super.endFooter(footer);
}
@@ -444,7 +448,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
public void run() {
eventHandler.startRow(tr);
}
- }, true);
+ }, false);
super.startRow(tr);
}
@@ -464,7 +468,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
public void run() {
eventHandler.startCell(tc);
}
- }, true);
+ }, false);
super.startCell(tc);
}
diff --git a/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
index 5d353a886..d00526b10 100644
--- a/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
@@ -51,6 +51,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.apache.commons.io.IOUtils;
+
import org.apache.fop.accessibility.StructureTree2SAXEventAdapter;
import org.apache.fop.accessibility.StructureTreeEventHandler;
import org.apache.fop.apps.FOPException;
@@ -115,6 +117,11 @@ public class FO2StructureTreeConverterTestCase {
}
@Test
+ public void testTableArtifact() throws Exception {
+ testConverter("table-artifact.fo");
+ }
+
+ @Test
public void testLanguage() throws Exception {
testConverter("language.fo");
}
@@ -173,6 +180,36 @@ public class FO2StructureTreeConverterTestCase {
+ "</structure-tree-sequence>\n");
}
+ @Test
+ public void testRemoveTableHeader() throws Exception {
+ keepEmptyTags = false;
+ String fo = IOUtils.toString(getResource("table-artifact.fo")).replace("role=\"artifact\"", "");
+ compare(fo, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<structure-tree-sequence>\n"
+ + "<structure-tree xmlns=\"http://xmlgraphics.apache.org/fop/intermediate\" "
+ + "xmlns:foi=\"http://xmlgraphics.apache.org/fop/internal\" "
+ + "xmlns:fox=\"http://xmlgraphics.apache.org/fop/extensions\">\n"
+ + "<fo:flow xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" flow-name=\"xsl-region-body\">\n"
+ + "<fo:table>\n"
+ + "<fo:table-body>\n"
+ + "<fo:table-row>\n"
+ + "<fo:table-cell>\n"
+ + "<fo:block>\n"
+ + "<marked-content/>\n"
+ + "<fo:block>\n"
+ + "<marked-content/>\n"
+ + "</fo:block>\n"
+ + "<marked-content/>\n"
+ + "</fo:block>\n"
+ + "</fo:table-cell>\n"
+ + "</fo:table-row>\n"
+ + "</fo:table-body>\n"
+ + "</fo:table>\n"
+ + "</fo:flow>\n"
+ + "</structure-tree>\n"
+ + "</structure-tree-sequence>");
+ }
+
private void compare(final String fo, String tree) throws Exception {
foLoader = new FOLoader("") {
public InputStream getFoInputStream() {
diff --git a/fop-core/src/test/resources/org/apache/fop/accessibility/fo/fo2StructureTree.xsl b/fop-core/src/test/resources/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
index f21b079a4..7f058d4a3 100644
--- a/fop-core/src/test/resources/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
+++ b/fop-core/src/test/resources/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
@@ -145,6 +145,8 @@
<xsl:template match="fo:wrapper[translate(normalize-space(@role), 'ARTIFCT', 'artifct') = 'artifact']"/>
+ <xsl:template match="fo:table-header[@role = 'artifact']"/>
+ <xsl:template match="fo:table-footer[@role = 'artifact']"/>
<!-- Discard descendants of fo:leader -->
<xsl:template match="fo:leader"/>
diff --git a/fop-core/src/test/resources/org/apache/fop/accessibility/fo/table-artifact.fo b/fop-core/src/test/resources/org/apache/fop/accessibility/fo/table-artifact.fo
new file mode 100644
index 000000000..98c5bccde
--- /dev/null
+++ b/fop-core/src/test/resources/org/apache/fop/accessibility/fo/table-artifact.fo
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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="simple" page-height="27.9cm" page-width="21.6cm">
+ <fo:region-body />
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="simple">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:table border-collapse="separate" table-layout="fixed">
+ <fo:table-column column-width="2in" column-number="1"/>
+ <fo:table-header role="artifact">
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>
+ <fo:block>
+ <fo:leader/>
+ </fo:block>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-header>
+ <fo:table-footer role="artifact">
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>
+ <fo:block>
+ <fo:leader/>
+ </fo:block>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-footer>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell>
+ <fo:block>
+ <fo:block>a</fo:block>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>