Hi all,

I hope this list is still alive... as there has not been any reaction to my 
previous posts.

Attached is a patch that resolves the issue for the .fo attached to FOP-2106 
issue, as well as with the document where I had the issue. With that patch, 
all ~60 footnotes in my document have been placed where they should've been, 
without any of them going to the previous page or overlapping with the body.

The issue is that when the PageBreakingAlgorithm class backtracks to handle a 
page break (via its parent, BreakingAlgorithm), it does not reset the 
footnoteListIndex/footnoteElementIndex fields. As a result, in the second pass 
the footnote position is not calculated properly - then first/last 
element/list indexes on pagebreaks are not correct, and footnote is placed on 
the page before one where it has been successfully fitted. This happens when 
two conditions are met: (a) there is at least one page break inserted before 
the problematic footnote, and (b) if not for the footnote, the containing 
block would fit at the bottom of the previous page.

I am not sure about s/insertedFootnoteLength/totalFootnoteLength/ change in 
createNode(). I haven't seen any immediate effect from this, but it looks like 
the total length of all the footnotes should also reset when BreakingAlgorithm 
backtracks to a previous active node. Feedback welcome.

If the patch is deemed acceptable, I could probably add a test case for that 
issue.

Regards,
Alexey.
Index: src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java	(revision 1523182)
+++ src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java	(working copy)
@@ -287,7 +287,7 @@
                                    int difference, double totalDemerits, KnuthNode previous) {
         return new KnuthPageNode(position, line, fitness,
                                  totalWidth, totalStretch, totalShrink,
-                                 insertedFootnotesLength, footnoteListIndex, footnoteElementIndex,
+                                 totalFootnotesLength, footnoteListIndex, footnoteElementIndex,
                                  adjustRatio, availableShrink, availableStretch,
                                  difference, totalDemerits, previous);
     }
@@ -405,6 +405,8 @@
                     resetFootnotes(((KnuthBlockBox) resetElement).getElementLists());
                 }
             }
+	    footnoteElementIndex = ((KnuthPageNode) restartingNode).footnoteElementIndex;
+	    footnoteListIndex = ((KnuthPageNode) restartingNode).footnoteListIndex;
         }
         return returnValue;
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to