diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2008-01-25 15:52:53 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2008-01-25 15:52:53 +0000 |
commit | 1902be605c9712faa705c54180c8b2b079437720 (patch) | |
tree | c6de38c8c50c00187fa21559c5f51eda8139182b /src | |
parent | ab66977cddab31240ab6f132996939bddd243245 (diff) | |
download | xmlgraphics-fop-1902be605c9712faa705c54180c8b2b079437720.tar.gz xmlgraphics-fop-1902be605c9712faa705c54180c8b2b079437720.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/table/RowPainter.java | 32 |
1 files changed, 19 insertions, 13 deletions
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, |