From 5079afc86b092f3113f4490ec390a39ff4941444 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 8 Jan 2002 08:18:42 +0000 Subject: [PATCH] fix for infinite loops with table keeps Submitted by: Christian Geisert git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@194616 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/RowSpanMgr.java | 20 ++++++++++++++++++++ src/org/apache/fop/fo/flow/TableBody.java | 13 +++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java index 363963b62..c98b054cc 100644 --- a/src/org/apache/fop/fo/flow/RowSpanMgr.java +++ b/src/org/apache/fop/fo/flow/RowSpanMgr.java @@ -52,6 +52,8 @@ public class RowSpanMgr { private SpanInfo spanInfo[]; + private boolean ignoreKeeps = false; + public RowSpanMgr(int numCols) { this.spanInfo = new SpanInfo[numCols]; } @@ -125,4 +127,22 @@ public class RowSpanMgr { return false; } + /** + * helper method to prevent infinite loops if + * keeps or spans are not fitting on a page + * @param true if keeps and spans should be ignored + */ + public void setIgnoreKeeps(boolean ignoreKeeps) { + this.ignoreKeeps = ignoreKeeps; + } + + /** + * helper method (i.e. hack ;-) to prevent infinite loops if + * keeps or spans are not fitting on a page + * @return true if keeps or spans should be ignored + */ + public boolean ignoreKeeps() { + return ignoreKeeps; + } + } diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 7ca06d172..b69e59feb 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -186,8 +186,9 @@ public class TableBody extends FObj { } return status; } - if (keepWith.size() - > 0) { // && status.getCode() == Status.AREA_FULL_NONE + if ((keepWith.size() > 0) + && (!rowSpanMgr.ignoreKeeps())) { + // && status.getCode() == Status.AREA_FULL_NONE // FIXME!!! Handle rows spans!!! row.removeLayout(areaContainer); for (Enumeration e = keepWith.elements(); @@ -198,6 +199,10 @@ public class TableBody extends FObj { } if (i == 0) { resetMarker(); + + // Fix for infinite loop bug if keeps are too big for page + rowSpanMgr.setIgnoreKeeps(true); + return new Status(Status.AREA_FULL_NONE); } } @@ -212,6 +217,10 @@ public class TableBody extends FObj { area.increaseHeight(areaContainer.getHeight()); area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); } + + // Fix for infinite loop bug if spanned rows are too big for page + rowSpanMgr.setIgnoreKeeps(true); + return status; } else if (status.getCode() == Status.KEEP_WITH_NEXT || rowSpanMgr.hasUnfinishedSpans()) { -- 2.39.5