From 83dccf00ccf75da27551b68652d5c3c1b4f7ebff Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 11 Apr 2019 15:29:44 +0200 Subject: Fix printing of table headers in multi-frame QTextDocuments The calculation of page position of table headers would only work correctly for tables in the root frame of a QTextDocument. Fix by including the relative positions of subframes. Fixes: QTBUG-59000 Change-Id: I2cc7e21bddf806f7f5f9b0675ac014c339ba2453 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextdocumentlayout.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gui/text/qtextdocumentlayout.cpp') diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index bed0a2c450..cf02e2f9c8 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -970,8 +970,14 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain if (pageHeight <= 0) pageHeight = QFIXED_MAX; - const int tableStartPage = (td->position.y / pageHeight).truncate(); - const int tableEndPage = ((td->position.y + td->size.height) / pageHeight).truncate(); + QFixed absYPos = td->position.y; + QTextFrame *parentFrame = table->parentFrame(); + while (parentFrame) { + absYPos += data(parentFrame)->position.y; + parentFrame = parentFrame->parentFrame(); + } + const int tableStartPage = (absYPos / pageHeight).truncate(); + const int tableEndPage = ((absYPos + td->size.height) / pageHeight).truncate(); qreal border = td->border.toReal(); drawFrameDecoration(painter, frame, fd, context.clip, frameRect); -- cgit v1.2.3