mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:13:25 +00:00
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 <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4583cd8e09
commit
81125d190a
1 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue