From 81125d190a216d5718e44a984aef62fc3d7d07fe Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 5 Aug 2014 20:45:53 +0300 Subject: Print: add a safe guard for row heights in the table print If a row height is more than the available height on a page (minus the height of a heading row) we have to skip this row (dive). The current profile print simply does not support that and it does not make much sense. For that to happen either the page will have to be tiny or the user must have entered a very long text for "buddy", "dive master", "location" or there must be some sort of a very-large-font-while-printing type of a problem. Technically, rows spanning on multiple pages is doable, but probably not worth the effort. Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/printlayout.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index e7fba9bfb..8fdee858f 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -384,7 +384,7 @@ void PrintLayout::printTable() * use 10% each, then the sum of passes[] here should be 80%. * two should be enough! */ const int passes[] = { 70, 10 }; - int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings, headingRowHeightD2; + int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings, headingRowHeightD2, headingRowHeight; bool isHeading = false; for (unsigned int pass = 0; pass < sizeof(passes) / sizeof(passes[0]); pass++) { @@ -392,9 +392,14 @@ void PrintLayout::printTable() total = model.rows - lastAccIndex; for (i = lastAccIndex; i < model.rows; i++) { rowH = table.rowHeight(i); + if (i == 0) { // first row is always a heading. it's height is constant. + headingRowHeight = rowH; + headingRowHeightD2 = rowH / 2; + } + if (rowH > pageH - headingRowHeight) // skip huge rows. we don't support row spanning on multiple pages. + continue; accH += rowH; if (isHeading) { - headingRowHeightD2 = rowH >> 1; headings += rowH; isHeading = false; } -- cgit v1.2.3-70-g09d2