Commit 71d01aaf authored by Pierre Ducroquet's avatar Pierre Ducroquet 🛩

Check cell size constraints against rerow height

If the requested row height for the cell is not enough to old borders
and padding, we force the layouting to happen nevertheless in order
to prevent infinite looking for space.

Testing done on the test case for bug 293337 containing both 'real'
cells and small cells : no more infinite loop.

REVIEW: 120468
BUG: 293337
parent 7000a6bb
......@@ -638,10 +638,14 @@ bool KoTextLayoutTableArea::layoutRow(TableIterator *cursor, qreal topBorderWidt
* This cell ends vertically in this row, and hence should
* contribute to the row height.
*/
bool ignoreMisFittingCell = false;
KoTableCellStyle cellStyle = d->effectiveCellStyle(cell);
anyCellTried = true;
qreal maxBottom = maximumAllowedBottom();
qreal requiredRowHeight = cellStyle.bottomPadding() + cellStyle.bottomPadding();
if (rowHasExactHeight) {
maxBottom = qMin(d->rowPositions[row] + rowHeight, maxBottom);
}
......@@ -652,12 +656,19 @@ bool KoTextLayoutTableArea::layoutRow(TableIterator *cursor, qreal topBorderWidt
if (d->collapsing) {
areaTop += topBorderWidth;
maxBottom -= bottomBorderWidth;
requiredRowHeight += bottomBorderWidth + topBorderWidth;
} else {
areaTop += cellStyle.topBorderWidth();
maxBottom -= cellStyle.bottomBorderWidth();
requiredRowHeight += cellStyle.bottomBorderWidth() + cellStyle.topBorderWidth();
}
if (rowHasExactHeight && (rowHeight < requiredRowHeight))
{
ignoreMisFittingCell = true;
}
if (maxBottom < areaTop) {
if (maxBottom < areaTop && !ignoreMisFittingCell) {
d->rowPositions[row+1] = d->rowPositions[row];
nukeRow(cursor);
if (cursor->row > d->startOfArea->row) {
......@@ -688,7 +699,7 @@ bool KoTextLayoutTableArea::layoutRow(TableIterator *cursor, qreal topBorderWidt
bool cellFully = cellArea->layout(cellCursor);
allCellsFullyDone = allCellsFullyDone && (cellFully || rowHasExactHeight);
noCellsFitted = noCellsFitted && (cellArea->top() >= cellArea->bottom());
noCellsFitted = noCellsFitted && (cellArea->top() >= cellArea->bottom()) && !ignoreMisFittingCell;
if (!rowHasExactHeight) {
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment