You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ss...@apache.org on 2025/07/15 06:52:38 UTC

(xmlgraphics-fop) branch main updated: FOP-3264: Footnote accessibility should use reference type

This is an automated email from the ASF dual-hosted git repository.

ssteiner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git


The following commit(s) were added to refs/heads/main by this push:
     new b077abbad FOP-3264: Footnote accessibility should use reference type
b077abbad is described below

commit b077abbad95b14b8880b4ca34f8e49690a890416
Author: Simon Steiner <ss...@apache.org>
AuthorDate: Tue Jul 15 07:52:26 2025 +0100

    FOP-3264: Footnote accessibility should use reference type
---
 .../java/org/apache/fop/pdf/PDFStructElem.java     |  3 +++
 .../fop/render/pdf/PDFStructureTreeBuilder.java    |  4 ++--
 .../apache/fop/pdf/PDFStructureTreeTestCase.java   | 27 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
index cc299fa1d..838703a77 100644
--- a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
+++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java
@@ -267,6 +267,9 @@ public class PDFStructElem extends StructureHierarchyMember implements Structure
     }
 
     public int output(OutputStream stream) throws IOException {
+        if (structureType == StandardStructureTypes.InlineLevelStructure.NOTE) {
+            put("ID", "Note ID " + getObjectNumber().getNumber());
+        }
         if (getDocument() != null && getDocument().getProfile().getPDFUAMode().isEnabled()) {
             if (entries.containsKey("Alt") && "".equals(get("Alt"))) {
                 put("Alt", "No alternate text specified");
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
index 949fdb22d..4080b5bb1 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java
@@ -94,8 +94,8 @@ public class PDFStructureTreeBuilder implements StructureTreeEventHandler {
         addBuilder("basic-link",                new LinkBuilder());
         // Out-of-Line Formatting Objects
         addBuilder("float",                     StandardStructureTypes.Grouping.DIV);
-        addBuilder("footnote",                  StandardStructureTypes.InlineLevelStructure.NOTE);
-        addBuilder("footnote-body",             StandardStructureTypes.Grouping.SECT);
+        addBuilder("footnote",                  StandardStructureTypes.InlineLevelStructure.REFERENCE);
+        addBuilder("footnote-body",             StandardStructureTypes.InlineLevelStructure.NOTE);
         // Other Formatting Objects
         addBuilder("wrapper",                   StandardStructureTypes.InlineLevelStructure.SPAN);
         addBuilder("marker",                    StandardStructureTypes.Grouping.PRIVATE);
diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java
index 27b0bea12..eb36357cf 100644
--- a/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java
@@ -91,4 +91,31 @@ public class PDFStructureTreeTestCase {
         transformer.transform(src, res);
         return bos;
     }
+
+    @Test
+    public void testFootnote() throws Exception {
+        String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n"
+                + "  <fo:layout-master-set>\n"
+                + "    <fo:simple-page-master master-name=\"simple\" page-height=\"27.9cm\" page-width=\"21.6cm\">\n"
+                + "      <fo:region-body />\n"
+                + "    </fo:simple-page-master>\n"
+                + "  </fo:layout-master-set>\n"
+                + "  <fo:page-sequence master-reference=\"simple\">\n"
+                + "    <fo:flow flow-name=\"xsl-region-body\">\n"
+                + "      <fo:block>Text<fo:footnote>\n"
+                + "      <fo:inline>1</fo:inline>\n"
+                + "      <fo:footnote-body>\n"
+                + "         <fo:block>footnote</fo:block>\n"
+                + "          </fo:footnote-body>\n"
+                + "        </fo:footnote>\n"
+                + "      </fo:block>\n"
+                + "    </fo:flow>\n"
+                + "  </fo:page-sequence>\n"
+                + "</fo:root>\n";
+        ByteArrayOutputStream bos = foToOutput(fo);
+        String pdf = bos.toString();
+        Assert.assertTrue(pdf.contains("/ID (Note ID "));
+        Assert.assertTrue(pdf.contains("/S /Note"));
+        Assert.assertTrue(pdf.contains("/S /Reference"));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org