From: Simon Steiner Date: Fri, 5 Jun 2015 14:13:45 +0000 (+0000) Subject: FOP-2475: Tagged PDF footnote separator incorrect order X-Git-Tag: fop-2_1~64 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=399d10251b199159a1c109902b1eefec5f0fd976;p=xmlgraphics-fop.git FOP-2475: Tagged PDF footnote separator incorrect order git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1683760 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java index f89d574e3..b00c60a9b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java +++ b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java @@ -47,7 +47,7 @@ import org.apache.fop.pdf.StructureType; import org.apache.fop.util.LanguageTags; import org.apache.fop.util.XMLUtil; -class PDFStructureTreeBuilder implements StructureTreeEventHandler { +public class PDFStructureTreeBuilder implements StructureTreeEventHandler { private static final String ROLE = "role"; @@ -347,7 +347,7 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler { new AttributesImpl(), pdfFactory, eventBroadcaster); } - private static PDFStructElem createStructureElement(String name, StructureHierarchyMember parent, + public static PDFStructElem createStructureElement(String name, StructureHierarchyMember parent, Attributes attributes, PDFFactory pdfFactory, EventBroadcaster eventBroadcaster) { StructureElementBuilder builder = BUILDERS.get(name); if (builder == null) { diff --git a/src/java/org/apache/fop/render/pdf/PageSequenceStructElem.java b/src/java/org/apache/fop/render/pdf/PageSequenceStructElem.java index 09d5b81a2..c660d2496 100644 --- a/src/java/org/apache/fop/render/pdf/PageSequenceStructElem.java +++ b/src/java/org/apache/fop/render/pdf/PageSequenceStructElem.java @@ -27,7 +27,7 @@ import org.apache.fop.pdf.PDFObject; import org.apache.fop.pdf.PDFStructElem; import org.apache.fop.pdf.StructureType; -class PageSequenceStructElem extends PDFStructElem { +public class PageSequenceStructElem extends PDFStructElem { private List regionBefores = new ArrayList(); @@ -37,6 +37,8 @@ class PageSequenceStructElem extends PDFStructElem { private List regionEnds = new ArrayList(); + private List footnoteSeparator = new ArrayList(); + PageSequenceStructElem(PDFObject parent, StructureType structureType) { super(parent, structureType); } @@ -50,6 +52,8 @@ class PageSequenceStructElem extends PDFStructElem { regionStarts.add(content); } else if (flowName.equals("xsl-region-end")) { regionEnds.add(content); + } else if (flowName.equals("xsl-footnote-separator")) { + footnoteSeparator.add(content); } else { addKid(content); } @@ -63,6 +67,7 @@ class PageSequenceStructElem extends PDFStructElem { addRegions(k, regionStarts); addRegions(k, kids); addRegions(k, regionEnds); + addRegions(k, footnoteSeparator); addRegions(k, regionAfters); put("K", k); return true; diff --git a/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java b/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java new file mode 100644 index 000000000..1da88b2eb --- /dev/null +++ b/test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java @@ -0,0 +1,68 @@ +/* + * 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.pdf; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import org.junit.Test; + +import org.xml.sax.helpers.AttributesImpl; +import static org.junit.Assert.assertEquals; + +import org.apache.fop.pdf.PDFArray; +import org.apache.fop.pdf.PDFDocument; +import org.apache.fop.pdf.PDFFactory; +import org.apache.fop.pdf.PDFParentTree; +import org.apache.fop.pdf.PDFStructElem; +import org.apache.fop.pdf.PDFStructTreeRoot; +import org.apache.fop.render.pdf.PDFStructureTreeBuilder; + +public class FootnoteSeparatorTestCase { + + @Test + public void testFootNoteSeparatorText() throws IOException { + PDFParentTree tree = new PDFParentTree(); + AttributesImpl attributes = new AttributesImpl(); + attributes.addAttribute("", "role", "role", "CDATA", null); + PDFDocument doc = new PDFDocument(""); + PDFStructTreeRoot strucRoot = doc.makeStructTreeRoot(tree); + PDFFactory factory = new PDFFactory(doc); + PDFStructElem part = PDFStructureTreeBuilder.createStructureElement("page-sequence", strucRoot, attributes, + factory, null); + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "flow-name", "flow-name", "CDATA", "xsl-footnote-separator"); + PDFStructElem staticSection = PDFStructureTreeBuilder.createStructureElement("static-content", part, att, + factory, null); + PDFStructElem block = PDFStructureTreeBuilder.createStructureElement("block", part, new AttributesImpl(), + factory, null); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + part.output(bos); + PDFArray array = (PDFArray)part.get("K"); + PDFStructElem elem1 = (PDFStructElem)array.get(0); + String test = elem1.getStructureType().getName().getName(); + String expected = "P"; + assertEquals(test, expected); + PDFStructElem elem2 = (PDFStructElem)array.get(1); + test = elem2.getStructureType().getName().getName(); + expected = "Sect"; + assertEquals(test, expected); + } +}