From fcfcda477575b669e9fd544f44c7a8b1458197e1 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Tue, 14 Jan 2020 12:07:58 +0000 Subject: [PATCH] FOP-2901: NoSuchElementException on empty table footer git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1872773 13f79535-47bb-0310-9956-ffa450edef68 --- .../table/TableContentLayoutManager.java | 18 ++--- .../standard-testcases/table_empty_footer.xml | 67 +++++++++++++++++++ 2 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 fop/test/layoutengine/standard-testcases/table_empty_footer.xml diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 16eba41fa..ad51ba579 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -328,13 +328,15 @@ public class TableContentLayoutManager implements PercentBaseContext { * represent the content. In such a case the break is simply disabled by setting * its penalty to infinite. */ - ListIterator elemIter = returnList.listIterator(returnList.size()); - ListElement elem = (ListElement) elemIter.previous(); - if (elem instanceof KnuthGlue) { - BreakElement breakElement = (BreakElement) elemIter.previous(); - breakElement.setPenaltyValue(KnuthElement.INFINITE); - } else { - elemIter.remove(); + if (!returnList.isEmpty()) { + ListIterator elemIter = returnList.listIterator(returnList.size()); + ListElement elem = (ListElement) elemIter.previous(); + if (elem instanceof KnuthGlue) { + BreakElement breakElement = (BreakElement) elemIter.previous(); + breakElement.setPenaltyValue(KnuthElement.INFINITE); + } else { + elemIter.remove(); + } } context.updateKeepWithPreviousPending(keepWithPrevious); context.setBreakBefore(breakBefore); @@ -483,7 +485,7 @@ public class TableContentLayoutManager implements PercentBaseContext { tableLM.repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); atLeastOnce = true; - if (footerElements != null) { + if (footerElements != null && !footerElements.isEmpty()) { boolean ancestorTreatAsArtifact = layoutContext.treatAsArtifact(); layoutContext.setTreatAsArtifact(treatFooterAsArtifact); //Positions for footers are simply added at the end diff --git a/fop/test/layoutengine/standard-testcases/table_empty_footer.xml b/fop/test/layoutengine/standard-testcases/table_empty_footer.xml new file mode 100644 index 000000000..0c2d101cc --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/table_empty_footer.xml @@ -0,0 +1,67 @@ + + + + + +

+ This test checks basic tables. +

+
+ + false + + + + + + + + + + + + + + + + + + a + + + + + + + b + + + + + + + + + + + + + + + +
-- 2.39.5