diff --git a/libs/textlayout/KoTextLayoutNoteArea.cpp b/libs/textlayout/KoTextLayoutNoteArea.cpp --- a/libs/textlayout/KoTextLayoutNoteArea.cpp +++ b/libs/textlayout/KoTextLayoutNoteArea.cpp @@ -138,7 +138,11 @@ bool contNotNeeded = KoTextLayoutArea::layout(cursor); - d->labelYOffset += block.layout()->lineAt(0).ascent(); + QTextLine blockLayoutLine = block.layout()->lineAt(0); + + if (blockLayoutLine.isValid()) { + d->labelYOffset += blockLayoutLine.ascent(); + } if (!contNotNeeded) { QString contNote = notesConfig->footnoteContinuationForward(); diff --git a/libs/textlayout/KoTextLayoutTableArea.cpp b/libs/textlayout/KoTextLayoutTableArea.cpp --- a/libs/textlayout/KoTextLayoutTableArea.cpp +++ b/libs/textlayout/KoTextLayoutTableArea.cpp @@ -435,7 +435,9 @@ if (complete) { - setVirginPage(false); + if (cursor->row >= d->headerRows) { + setVirginPage(false); + } cursor->row++; } } while (complete && cursor->row < d->table->rows()); @@ -785,10 +787,6 @@ } } - if (noCellsFitted && row <= d->headerRows) { - d->totalMisFit = true; - } - if (anyCellTried && noCellsFitted && !rowHasExactHeight && !allCellsFullyDone) { d->rowPositions[row+1] = d->rowPositions[row]; nukeRow(cursor); @@ -800,6 +798,10 @@ return false; // we can't honour the anything inside so give up doing row } + if (noCellsFitted && d->headerRows && row <= d->headerRows) { + d->totalMisFit = true; + } + if (!allCellsFullyDone) { layoutMergedCellsNotEnding(cursor, topBorderWidth, bottomBorderWidth, rowBottom); } else {