diff options
author | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-08-24 13:55:51 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-08-24 14:01:50 (GMT) |
commit | bda6a5e7a8a233dc4b4395aa20b41f74f2c0857a (patch) | |
tree | b6a440b2e50d4bc878305859a3bf6534f669e59d /tests/auto/qtextdocumentlayout | |
parent | 9e8b3f2e789e24c561d2f583927ee15b38808941 (diff) | |
download | Qt-bda6a5e7a8a233dc4b4395aa20b41f74f2c0857a.zip Qt-bda6a5e7a8a233dc4b4395aa20b41f74f2c0857a.tar.gz Qt-bda6a5e7a8a233dc4b4395aa20b41f74f2c0857a.tar.bz2 |
Don't float objects into next page unless they can fit in it
If you had a floating table which spanned over several pages, this would
always float down to the next page, even when it was the only element
in the document. The main reason why this mechanism was added to
positionFloat() was to handle floating images, since they can't be
broken down into more than one page. Tables, however, have logic to
ensure they are broken into several pages if they are too large for the
current page. There is however no reason to float an object into the
next page if it is larger than that page.
Since the size of tables are altered by their position as long as they
span more than one page, we need to set the sizeDirty flag for
floating tables when positioning and then relayout the frame to make
sure the page breaks are set correctly.
Task-number: 240086
Reviewed-by: Simon Hausmann
Diffstat (limited to 'tests/auto/qtextdocumentlayout')
-rw-r--r-- | tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp index d8c4f51..dbba9ef 100644 --- a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +++ b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp @@ -71,6 +71,7 @@ private slots: void wrapAtWordBoundaryOrAnywhere(); void inlineImage(); void clippedTableCell(); + void floatingTablePageBreak(); private: QTextDocument *doc; @@ -250,5 +251,25 @@ void tst_QTextDocumentLayout::clippedTableCell() QCOMPARE(img, expected); } +void tst_QTextDocumentLayout::floatingTablePageBreak() +{ + doc->clear(); + + QTextCursor cursor(doc); + + QTextTableFormat tableFormat; + tableFormat.setPosition(QTextFrameFormat::FloatLeft); + QTextTable *table = cursor.insertTable(50, 1, tableFormat); + + // Make height of document 2/3 of the table, fitting the table into two pages + QSizeF documentSize = doc->size(); + documentSize.rheight() *= 2.0 / 3.0; + + doc->setPageSize(documentSize); + + QCOMPARE(doc->pageCount(), 2); +} + + QTEST_MAIN(tst_QTextDocumentLayout) #include "tst_qtextdocumentlayout.moc" |