]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #37880:
authorJeremias Maerki <jeremias@apache.org>
Tue, 13 Dec 2005 19:50:59 +0000 (19:50 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 13 Dec 2005 19:50:59 +0000 (19:50 +0000)
Bugfix for lost footnotes in centered text.
Skip elements with no Position in TextLayoutManager.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@356594 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
status.xml
test/layoutengine/standard-testcases/footnote_bug37880.xml [new file with mode: 0644]

index 29087b0297e013b42260cbf89f2e00f2b78e76b8..48a91989646bb8a02e82845c50c800ffe9e70d3a 100644 (file)
@@ -79,7 +79,7 @@ public class FootnoteLayoutManager extends AbstractLayoutManager
             //Inline part of the footnote is empty. Need to send back an auxiliary
             //zero-width, zero-height inline box so the footnote gets painted.
             KnuthSequence seq = new KnuthSequence(true);
-            seq.add(new KnuthInlineBox(0, null, null, true));
+            seq.add(new KnuthInlineBox(0, null, null, false));
             returnedList.add(seq);
         }
         setFinished(true);
@@ -106,7 +106,7 @@ public class FootnoteLayoutManager extends AbstractLayoutManager
                 ListIterator nestedIterator = seq.listIterator(seq.size());
                 while (nestedIterator.hasPrevious() && lastBox == null) {
                     KnuthElement element = (KnuthElement)nestedIterator.previous();
-                    if (element instanceof KnuthInlineBox) {
+                    if (element instanceof KnuthInlineBox && !element.isAuxiliary()) {
                         lastBox = (KnuthInlineBox) element;
                     }
                 }
@@ -114,6 +114,8 @@ public class FootnoteLayoutManager extends AbstractLayoutManager
         }
         if (lastBox != null) {
             lastBox.setFootnoteBodyLM(bodyLM);
+        } else {
+            throw new IllegalStateException("No anchor box was found for a footnote.");
         }
     }
 
index cbf798b03351e016526ff7a70025e65aa96e9746..f6de2e9399fde067c59a64730d6f88b7dae090f6 100644 (file)
@@ -271,7 +271,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
          */
         while (posIter.hasNext()) {
             LeafPosition tbpNext = (LeafPosition) posIter.next();
-            //
+            if (tbpNext == null) {
+                continue; //Ignore elements without Positions
+            }
             if (tbpNext.getLeafPos() != -1) {
                 ai = (AreaInfo) vecAreaInfo.get(tbpNext.getLeafPos());
                 if (firstAreaInfoIndex == -1) {
index 10d2df52850523556c7d4572690b746c65a4c9ce..a67405174550cad515835d63bf017716a9a89093 100644 (file)
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="fix" fixes-bug="37880">
+        Bugfix: Footnotes were lost if the footnote appeared in centered text.
+      </action>
+      <action context="Code" dev="JM" type="update">
+        Improved log and error messages in a number of places by adding additional
+        context information that should make it easier to find the location in the
+        source files.
+      </action>
+      <action context="Code" dev="JM" type="fix">
+        Fix to correct image sizes in RTF output.
+      </action>
+      <action context="Code" dev="JM" type="add">
+        First attempt at SVG support in RTF output. SVG images are converted to 300dpi JPEG
+        images internally.
+      </action>
+      <action context="Code" dev="JM" type="update">
+        Additional checks to detect text overflows. The overflow property is now properly
+        handled where applicable.
+      </action>
+      <action context="Code" dev="JM" type="update">
+        Source location information improved. If location information is not available,
+        the context information is provided based on text content.
+      </action>
       <action context="Code" dev="JM" type="add">
         The command-line now automatically sets two parameters for any XSLT transformation:
         "fop-output-format" contains the MIME type of the currently selected output format,
diff --git a/test/layoutengine/standard-testcases/footnote_bug37880.xml b/test/layoutengine/standard-testcases/footnote_bug37880.xml
new file mode 100644 (file)
index 0000000..d293973
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 2005 The Apache Software Foundation
+
+  Licensed 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 footnotes, particularly bug #37880. A footnote in centered text was ignored.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="3in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block text-align="center">
+            Blah
+            <fo:footnote id="fn1">
+              <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>
+              <fo:footnote-body>
+                <fo:block text-align="left">
+                  <fo:inline font-size="6.95pt" vertical-align="super">1) </fo:inline>http://xmlgrapics.apache.org/fop/</fo:block>
+              </fo:footnote-body>
+            </fo:footnote>
+          </fo:block>
+          <!-- This second block uses an empty inline which will produce an auxiliary box w=0. I wanted to check if maybe this
+               box would be ignored as anchor due to the additional check on auxiliary boxes that was necessary to fix the 
+               above bug. -->
+          <fo:block text-align="center">
+            Blah2
+            <fo:footnote id="fn2">
+              <fo:inline/>
+              <fo:footnote-body>
+                <fo:block text-align="left">
+                  <fo:inline font-size="6.95pt" vertical-align="super">2) </fo:inline>http://www.apache.org</fo:block>
+              </fo:footnote-body>
+            </fo:footnote>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <true xpath="//footnote/block[1]/@bpd &gt; 0"/>
+    <true xpath="//footnote/block[2]/@bpd &gt; 0"/>
+  </checks>
+</testcase>