From 4680aede4413ce5b1b50bc84daaa3b5b8ecd816a Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 29 Jan 2013 20:15:21 +0000 Subject: [PATCH] JIRA-1719 Fix IIOBE thrown when the final footnote-only page starts on a new footnote git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1440094 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/PageBreakingAlgorithm.java | 18 ++-- ...ote_footnote-only-final-page_multiple.xml} | 0 ...ootnote-only-final-page_multiple_whole.xml | 82 +++++++++++++++++++ ...ootnote-only-final-page_several-pages.xml} | 0 ...tnote_footnote-only-final-page_simple.xml} | 0 5 files changed, 87 insertions(+), 13 deletions(-) rename test/layoutengine/standard-testcases/{footnote-create_new_page.xml => footnote_footnote-only-final-page_multiple.xml} (100%) create mode 100644 test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple_whole.xml rename test/layoutengine/standard-testcases/{footnote_overflow-to-multiple-pages.xml => footnote_footnote-only-final-page_several-pages.xml} (100%) rename test/layoutengine/standard-testcases/{footnote_overflow-to-empty-page.xml => footnote_footnote-only-final-page_simple.xml} (100%) diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 4fa138da5..dce290b50 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -885,19 +885,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // create pages containing the remaining footnote bodies while (insertedFootnotesLength < totalFootnotesLength) { - final int tmpLength = lengthList.get(footnoteListIndex); - // check if last footnote has already been added completely - if (insertedFootnotesLength == tmpLength) { - footnoteListIndex++; - footnoteElementIndex - = getFootnoteList(footnoteListIndex).size() - 1; - } else if ((tmpLength - insertedFootnotesLength) <= availableBPD) { - // try adding some more content - // add a whole footnote - availableBPD -= tmpLength - insertedFootnotesLength; - insertedFootnotesLength = tmpLength; - footnoteElementIndex - = getFootnoteList(footnoteListIndex).size() - 1; + if (totalFootnotesLength - insertedFootnotesLength <= availableBPD) { + // All the remaining footnotes fit + insertedFootnotesLength = totalFootnotesLength; + footnoteListIndex = lengthList.size() - 1; + footnoteElementIndex = getFootnoteList(footnoteListIndex).size() - 1; } else if ((split = getFootnoteSplit // CSOK: InnerAssignment (footnoteListIndex, footnoteElementIndex, insertedFootnotesLength, availableBPD, true)) > 0) { diff --git a/test/layoutengine/standard-testcases/footnote-create_new_page.xml b/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple.xml similarity index 100% rename from test/layoutengine/standard-testcases/footnote-create_new_page.xml rename to test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple.xml diff --git a/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple_whole.xml b/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple_whole.xml new file mode 100644 index 000000000..bbddde998 --- /dev/null +++ b/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_multiple_whole.xml @@ -0,0 +1,82 @@ + + + + + +

When a footnote-only final page must be created, check the case where the final page starts on + a footnote that must be split over several pages.

+
+ + + + + + + + + + + + + + + + + + + Foonote call + 1 + + + Footnote 1 + + + , + 2 + + + Footnote 2.1 + Footnote 2.2 + Footnote 2.3 + + + , and + 3 + + + Footnote 3.1 + Footnote 3.2 + Footnote 3.3 + + + . + + + + + + + + + + + + + + + + + + +
diff --git a/test/layoutengine/standard-testcases/footnote_overflow-to-multiple-pages.xml b/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_several-pages.xml similarity index 100% rename from test/layoutengine/standard-testcases/footnote_overflow-to-multiple-pages.xml rename to test/layoutengine/standard-testcases/footnote_footnote-only-final-page_several-pages.xml diff --git a/test/layoutengine/standard-testcases/footnote_overflow-to-empty-page.xml b/test/layoutengine/standard-testcases/footnote_footnote-only-final-page_simple.xml similarity index 100% rename from test/layoutengine/standard-testcases/footnote_overflow-to-empty-page.xml rename to test/layoutengine/standard-testcases/footnote_footnote-only-final-page_simple.xml -- 2.39.5