diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-02 21:39:34 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-08 11:49:54 +0100 |
commit | b14b1c99f8d122c7988cd6e59b0f3fef15923da4 (patch) | |
tree | c876d2428f7be32a73a1d066fa2d703b59708a1e /src/gui/text/qtextdocument.cpp | |
parent | 8bf36025f5602e3067448941ee4d0ccca3928a40 (diff) |
Rename QRangeCollection to QPageRanges, make it a proper value type
The type is specific about printing, so give it a name in line with
QPageLayout and QPageSize.
As per API review comment, it's not clear why this type should not be a
regular, copyable and movable value type. It stores a list of intervals.
Give it value-type semantics, as an implicitly shared class.
Convert the parse method into a static factory function.
Add a Range type and use it instead of the semantic-free QPair.
Move QPrinter getter into QPagedPainteDevice, make it return a copy
rather than a pointer, and add a setter.
Extend test case to cover all members and more merge cases. Fix bugs
found that way.
Fixes: QTBUG-88113
Change-Id: If17ea4d410d49f16b097e88b7979db5d72add820
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 0c5872a2f2..50f56b9a99 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1916,8 +1916,6 @@ void QTextDocument::print(QPagedPaintDevice *printer) const bool documentPaginated = d->pageSize.isValid() && !d->pageSize.isNull() && d->pageSize.height() != INT_MAX; - QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer); - // ### set page size to paginated size? QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter); if (!documentPaginated && m.left() == 0. && m.right() == 0. && m.top() == 0. && m.bottom() == 0.) { @@ -2003,9 +2001,9 @@ void QTextDocument::print(QPagedPaintDevice *printer) const clonedDoc->setPageSize(body.size()); } - QRangeCollection *rangeCollection = pd->rangeCollection; - int fromPage = rangeCollection->firstPage(); - int toPage = rangeCollection->lastPage(); + const QPageRanges pageRanges = printer->pageRanges(); + int fromPage = pageRanges.firstPage(); + int toPage = pageRanges.lastPage(); if (fromPage == 0 && toPage == 0) { fromPage = 1; @@ -2031,7 +2029,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const int page = fromPage; while (true) { - if (rangeCollection->isEmpty() || rangeCollection->contains(page)) + if (pageRanges.isEmpty() || pageRanges.contains(page)) printPage(page, &p, doc, body, pageNumberPos); if (page == toPage) |