aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowPainter.java32
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,