From: Vincent Hennebert Date: Fri, 25 Jan 2008 15:52:53 +0000 (+0000) Subject: Fixed a bug in computeContentLength when there are empty cells X-Git-Tag: fop-0_95beta~133 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1902be605c9712faa705c54180c8b2b079437720;p=xmlgraphics-fop.git Fixed a bug in computeContentLength when there are empty cells git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@615251 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index e5b90aa5f..9004e9c17 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -234,20 +234,26 @@ class RowPainter { // be used as padding. // This should be handled automatically by a proper use of Knuth elements private int computeContentLength(PrimaryGridUnit pgu, int startIndex, int endIndex) { - int actualStart = startIndex; - // Skip from the content length calculation glues and penalties occurring at the - // beginning of the page - while (actualStart <= endIndex - && !((KnuthElement) pgu.getElements().get(actualStart)).isBox()) { - actualStart++; - } - int len = ElementListUtils.calcContentLength( - pgu.getElements(), actualStart, endIndex); - KnuthElement el = (KnuthElement)pgu.getElements().get(endIndex); - if (el.isPenalty()) { - len += el.getW(); + if (startIndex >= endIndex) { + // May happen if the cell contributes no content on the current page (empty + // cell, in most cases) + return 0; + } else { + int actualStart = startIndex; + // Skip from the content length calculation glues and penalties occurring at the + // beginning of the page + while (actualStart <= endIndex + && !((KnuthElement) pgu.getElements().get(actualStart)).isBox()) { + actualStart++; + } + int len = ElementListUtils.calcContentLength( + pgu.getElements(), actualStart, endIndex); + KnuthElement el = (KnuthElement)pgu.getElements().get(endIndex); + if (el.isPenalty()) { + len += el.getW(); + } + return len; } - return len; } private void addAreasForCell(PrimaryGridUnit pgu, int startPos, int endPos,