From 5395717c60984c11f069d68405ca1c489748b071 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 17 Mar 2008 17:48:44 +0000 Subject: [PATCH] Bugzilla #44621: when the after border of a cell, in the trailing case, is bigger than in the normal case, the generated sequence of Knuth elements was wrong, leading to content being swallowed This is a partial fix only: the content is no longer swallowed, but the penalty is wrong (shorter than it should be). This will lead to the table overflowing the region-body without warning. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95@637993 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/table/ActiveCell.java | 18 ++- .../standard-testcases/table_bug44621.xml | 105 ++++++++++++++++++ .../table_row-delay_fixed-row-height.xml | 2 +- 3 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 test/layoutengine/standard-testcases/table_bug44621.xml diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java index 4e41e909f..ab65a1d28 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java +++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java @@ -337,14 +337,22 @@ class ActiveCell { } /** - * Returns the last step for this cell. + * Returns the last step for this cell. This includes the normal border- and + * padding-before, the whole content, the normal padding-after, and the + * trailing after border. Indeed, if the normal border is taken instead, + * and appears to be smaller than the trailing one, the last step may be smaller than + * the current step (see TableStepper#considerRowLastStep). This will produce a wrong + * infinite penalty, plus the cell's content won't be taken into account since the + * final step will be smaller than the current one (see {@link #signalNextStep(int)}). + * This actually means that the content will be swallowed. * - * @return the step including all of the cell's content plus the normal borders and paddings + * @return the length of last step */ int getLastStep() { assert nextStep.end == elementList.size() - 1; assert nextStep.contentLength == totalLength && nextStep.penaltyLength == 0; - int lastStep = bpBeforeNormal + totalLength + bpAfterNormal; + int lastStep = bpBeforeNormal + totalLength + paddingAfterNormal + + pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING); log.debug(this + ": last step = " + lastStep); return lastStep; } @@ -466,8 +474,12 @@ class ActiveCell { */ void endRow(int rowIndex) { if (endsOnRow(rowIndex)) { + // Subtract the old value of bpAfterTrailing... + nextStep.totalLength -= bpAfterTrailing; bpAfterTrailing = paddingAfterNormal + pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING); + // ... and add the new one + nextStep.totalLength += bpAfterTrailing; lastCellPart = true; } else { bpBeforeLeading = paddingBeforeLeading diff --git a/test/layoutengine/standard-testcases/table_bug44621.xml b/test/layoutengine/standard-testcases/table_bug44621.xml new file mode 100644 index 000000000..b4b9edbd0 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_bug44621.xml @@ -0,0 +1,105 @@ + + + + + +

+ This is a testcase for bug #44621: when the width of the after border of a cell, in the + trailing case, is bigger than in the normal case, a wrong sequence of Knuth elements was + generated, leading to some content being swallowed. +

+
+ + + + + + + + + + The after borders of the body’s cells, in the trailing case, + are thicker than in the normal case. + + + + + Footer 1.1 + + + Footer 1.2 + + + + + + Cell 1.1 + + + Cell 1.2 + + + + + Cell 2.1 + + + Cell 2.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + 3 + + +
diff --git a/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml b/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml index 7b50996cc..0c6ed10eb 100644 --- a/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml +++ b/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml @@ -145,7 +145,7 @@ 3 - + -- 2.39.5