]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2764: footnote-body ignores rl-tb writing mode by João André Gonçalves
authorSimon Steiner <ssteiner@apache.org>
Fri, 15 Dec 2023 14:45:37 +0000 (14:45 +0000)
committerSimon Steiner <ssteiner@apache.org>
Fri, 15 Dec 2023 14:45:37 +0000 (14:45 +0000)
fop-core/src/main/java/org/apache/fop/fo/flow/Footnote.java
fop/test/layoutengine/standard-testcases/footnote_writing-mode_rl.xml [new file with mode: 0644]

index 521e8b081c03676149bc3f49e85494a8aa81068b..aec57cf860dce0fc25a60810e0ee704d3f0c4709 100644 (file)
 
 package org.apache.fop.fo.flow;
 
+import java.util.Iterator;
+import java.util.Stack;
+
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
@@ -148,5 +152,24 @@ public class Footnote extends FObj implements CommonAccessibilityHolder {
     public int getNameId() {
         return FO_FOOTNOTE;
     }
+
+    @Override
+    protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges,
+                                                                   DelimitedTextRange currentRange) {
+        FootnoteBody body = getFootnoteBody();
+        if (body != null) {
+            ranges = body.collectDelimitedTextRanges(ranges);
+        }
+
+        Inline inline = getFootnoteCitation();
+        if (inline != null) {
+            ranges = inline.collectDelimitedTextRanges(ranges);
+        }
+
+        for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) {
+            ranges = ((FONode) it.next()).collectDelimitedTextRanges(ranges);
+        }
+        return ranges;
+    }
 }
 
diff --git a/fop/test/layoutengine/standard-testcases/footnote_writing-mode_rl.xml b/fop/test/layoutengine/standard-testcases/footnote_writing-mode_rl.xml
new file mode 100644 (file)
index 0000000..893c9ca
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks that the footnote respects writing-mode="rl" specified on block-container.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="first" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="first">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block-container writing-mode="rl-tb">
+            <fo:block>
+              rightLeft
+              <fo:footnote>
+                <fo:inline>1</fo:inline>
+                <fo:footnote-body>
+                  <fo:block>
+                    <fo:inline>1</fo:inline>
+                    footnoteRL
+                  </fo:block>
+                </fo:footnote-body>
+              </fo:footnote>
+            </fo:block>
+          </fo:block-container>
+          <fo:block-container writing-mode="lr-tb">
+            <fo:block>
+              leftRight
+              <fo:footnote>
+                <fo:inline>2</fo:inline>
+                <fo:footnote-body>
+                  <fo:block>
+                    <fo:inline>2</fo:inline>
+                    footnoteLR
+                  </fo:block>
+                </fo:footnote-body>
+              </fo:footnote>
+            </fo:block>
+          </fo:block-container>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="1 rightLeft" xpath="//block[1]"/>
+    <eval expected="footnoteRL 1" xpath="//footnote/block[1]"/>
+    <eval expected="leftRight 2" xpath="//block[2]"/>
+    <eval expected="2 footnoteLR" xpath="//footnote/block[2]"/>
+  </checks>
+</testcase>