]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2475: Tagged PDF footnote separator incorrect order
authorSimon Steiner <ssteiner@apache.org>
Fri, 5 Jun 2015 14:13:45 +0000 (14:13 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 5 Jun 2015 14:13:45 +0000 (14:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1683760 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
src/java/org/apache/fop/render/pdf/PageSequenceStructElem.java
test/java/org/apache/fop/accessibility/pdf/FootnoteSeparatorTestCase.java [new file with mode: 0644]

index f89d574e38c9185cb5a742eda119b122fa83b40d..b00c60a9ba3197ac124510063b2ecf66c6573ad0 100644 (file)
@@ -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) {
index 09d5b81a2636323c89d8e04f7599ea40af812969..c660d249609ea59bbe0ba53afe4f883033c6b973 100644 (file)
@@ -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<PDFStructElem> regionBefores = new ArrayList<PDFStructElem>();
 
@@ -37,6 +37,8 @@ class PageSequenceStructElem extends PDFStructElem {
 
     private List<PDFStructElem> regionEnds = new ArrayList<PDFStructElem>();
 
+    private List<PDFStructElem> footnoteSeparator = new ArrayList<PDFStructElem>();
+
     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 (file)
index 0000000..1da88b2
--- /dev/null
@@ -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);
+    }
+}