diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2015-03-02 09:23:07 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2015-03-02 09:23:07 +0100 |
commit | 2b5982aac8ad103443e33379fe5654f5bd419c87 (patch) | |
tree | 8cc1d4e00029a6c0f5a23d87e9c97cdfc4619538 /src/gui/text/qtextdocumentlayout.cpp | |
parent | efe3f631f232e6cc3966de59b9237653bf7fa96e (diff) | |
parent | fc3733cba4652f2b8930c66665103fcb20874735 (diff) |
Merge remote-tracking branch 'origin/5.4' into 5.5
Change-Id: I95b3a87c5068c6b8068b30a35655b4c2419e7f9e
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index a00dac61fb..3a86a454ac 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -1115,6 +1115,13 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter const QFixed leftPadding = td->leftPadding(fmt); const QFixed topPadding = td->topPadding(fmt); + qreal topMargin = (td->effectiveTopMargin + td->cellSpacing + td->border).toReal(); + qreal bottomMargin = (td->effectiveBottomMargin + td->cellSpacing + td->border).toReal(); + + const int headerRowCount = qMin(table->format().headerRowCount(), table->rows() - 1); + if (r >= headerRowCount) + topMargin += td->headerHeight.toReal(); + if (td->border != 0) { const QBrush oldBrush = painter->brush(); const QPen oldPen = painter->pen(); @@ -1142,13 +1149,6 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter break; } - qreal topMargin = (td->effectiveTopMargin + td->cellSpacing + td->border).toReal(); - qreal bottomMargin = (td->effectiveBottomMargin + td->cellSpacing + td->border).toReal(); - - const int headerRowCount = qMin(table->format().headerRowCount(), table->rows() - 1); - if (r >= headerRowCount) - topMargin += td->headerHeight.toReal(); - drawBorder(painter, borderRect, topMargin, bottomMargin, border, table->format().borderBrush(), cellBorder); @@ -1159,7 +1159,30 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter const QBrush bg = cell.format().background(); const QPointF brushOrigin = painter->brushOrigin(); if (bg.style() != Qt::NoBrush) { - fillBackground(painter, cellRect, bg, cellRect.topLeft()); + const qreal pageHeight = document->pageSize().height(); + const int topPage = pageHeight > 0 ? static_cast<int>(cellRect.top() / pageHeight) : 0; + const int bottomPage = pageHeight > 0 ? static_cast<int>((cellRect.bottom()) / pageHeight) : 0; + + if (topPage == bottomPage) + fillBackground(painter, cellRect, bg, cellRect.topLeft()); + else { + for (int i = topPage; i <= bottomPage; ++i) { + QRectF clipped = cellRect.toRect(); + + if (topPage != bottomPage) { + const qreal top = qMax(i * pageHeight + topMargin, cell_context.clip.top()); + const qreal bottom = qMin((i + 1) * pageHeight - bottomMargin, cell_context.clip.bottom()); + + clipped.setTop(qMax(clipped.top(), top)); + clipped.setBottom(qMin(clipped.bottom(), bottom)); + + if (clipped.bottom() <= clipped.top()) + continue; + + fillBackground(painter, clipped, bg, cellRect.topLeft()); + } + } + } if (bg.style() > Qt::SolidPattern) painter->setBrushOrigin(cellRect.topLeft()); |