equal
deleted
inserted
replaced
1677 // Check that there is a valid device to print to. |
1677 // Check that there is a valid device to print to. |
1678 if (!p.isActive()) |
1678 if (!p.isActive()) |
1679 return; |
1679 return; |
1680 |
1680 |
1681 const QTextDocument *doc = this; |
1681 const QTextDocument *doc = this; |
1682 QTextDocument *clonedDoc = 0; |
1682 QScopedPointer<QTextDocument> clonedDoc; |
1683 (void)doc->documentLayout(); // make sure that there is a layout |
1683 (void)doc->documentLayout(); // make sure that there is a layout |
1684 |
1684 |
1685 QRectF body = QRectF(QPointF(0, 0), d->pageSize); |
1685 QRectF body = QRectF(QPointF(0, 0), d->pageSize); |
1686 QPointF pageNumberPos; |
1686 QPointF pageNumberPos; |
1687 |
1687 |
1710 // scale to page |
1710 // scale to page |
1711 p.scale(printerPageSize.width() / scaledPageSize.width(), |
1711 p.scale(printerPageSize.width() / scaledPageSize.width(), |
1712 printerPageSize.height() / scaledPageSize.height()); |
1712 printerPageSize.height() / scaledPageSize.height()); |
1713 } else { |
1713 } else { |
1714 doc = clone(const_cast<QTextDocument *>(this)); |
1714 doc = clone(const_cast<QTextDocument *>(this)); |
1715 clonedDoc = const_cast<QTextDocument *>(doc); |
1715 clonedDoc.reset(const_cast<QTextDocument *>(doc)); |
1716 |
1716 |
1717 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); |
1717 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); |
1718 srcBlock.isValid() && dstBlock.isValid(); |
1718 srcBlock.isValid() && dstBlock.isValid(); |
1719 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { |
1719 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { |
1720 dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats()); |
1720 dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats()); |
1785 int page = fromPage; |
1785 int page = fromPage; |
1786 while (true) { |
1786 while (true) { |
1787 for (int j = 0; j < pageCopies; ++j) { |
1787 for (int j = 0; j < pageCopies; ++j) { |
1788 if (printer->printerState() == QPrinter::Aborted |
1788 if (printer->printerState() == QPrinter::Aborted |
1789 || printer->printerState() == QPrinter::Error) |
1789 || printer->printerState() == QPrinter::Error) |
1790 goto UserCanceled; |
1790 return; |
1791 printPage(page, &p, doc, body, pageNumberPos); |
1791 printPage(page, &p, doc, body, pageNumberPos); |
1792 if (j < pageCopies - 1) |
1792 if (j < pageCopies - 1) |
1793 printer->newPage(); |
1793 printer->newPage(); |
1794 } |
1794 } |
1795 |
1795 |
1805 } |
1805 } |
1806 |
1806 |
1807 if ( i < docCopies - 1) |
1807 if ( i < docCopies - 1) |
1808 printer->newPage(); |
1808 printer->newPage(); |
1809 } |
1809 } |
1810 |
|
1811 UserCanceled: |
|
1812 delete clonedDoc; |
|
1813 } |
1810 } |
1814 #endif |
1811 #endif |
1815 |
1812 |
1816 /*! |
1813 /*! |
1817 \enum QTextDocument::ResourceType |
1814 \enum QTextDocument::ResourceType |