summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocumentlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index a795c1f..7b36b9d 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1994,9 +1994,12 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur
}
}
- if (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom) {
+ bool frameSpansIntoNextPage = (y + layoutStruct->frameY + fd->size.height > layoutStruct->pageBottom);
+ if (frameSpansIntoNextPage && fd->size.height <= layoutStruct->pageHeight) {
layoutStruct->newPage();
y = layoutStruct->y;
+
+ frameSpansIntoNextPage = false;
}
y = findY(y, layoutStruct, fd->size.width);
@@ -2017,6 +2020,11 @@ void QTextDocumentLayoutPrivate::positionFloat(QTextFrame *frame, QTextLine *cur
// qDebug()<< "float positioned at " << fd->position.x << fd->position.y;
fd->layoutDirty = false;
+
+ // If the frame is a table, then positioning it will affect the size if it covers more than
+ // one page, because of page breaks and repeating the header.
+ if (qobject_cast<QTextTable *>(frame) != 0)
+ fd->sizeDirty = frameSpansIntoNextPage;
}
QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY)
@@ -2349,6 +2357,10 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QLayoutStru
positionFloat(c);
+ // If the size was made dirty when the position was set, layout again
+ if (cd->sizeDirty)
+ updateRect = layoutFrame(c, layoutFrom, layoutTo);
+
QRectF frameRect(cd->position.toPointF(), cd->size.toSizeF());
if (frameRect == oldFrameRect && updateRect.isValid())