equal
deleted
inserted
replaced
59 #include <qfileinfo.h> |
59 #include <qfileinfo.h> |
60 #include <qdir.h> |
60 #include <qdir.h> |
61 #include <qapplication.h> |
61 #include <qapplication.h> |
62 #include "qtextcontrol_p.h" |
62 #include "qtextcontrol_p.h" |
63 #include "private/qtextedit_p.h" |
63 #include "private/qtextedit_p.h" |
|
64 #include "private/qdataurl_p.h" |
64 |
65 |
65 #include "qtextdocument_p.h" |
66 #include "qtextdocument_p.h" |
66 #include <private/qprinter_p.h> |
67 #include <private/qprinter_p.h> |
67 #include <private/qabstracttextdocumentlayout_p.h> |
68 #include <private/qabstracttextdocumentlayout_p.h> |
68 |
69 |
432 *cursor = QTextCursor(this); |
433 *cursor = QTextCursor(this); |
433 cursor->setPosition(pos); |
434 cursor->setPosition(pos); |
434 } |
435 } |
435 } |
436 } |
436 |
437 |
|
438 /*! \enum QTextDocument::Stacks |
|
439 |
|
440 \value UndoStack The undo stack. |
|
441 \value RedoStack The redo stack. |
|
442 \value UndoAndRedoStacks Both the undo and redo stacks. |
|
443 */ |
|
444 |
|
445 /*! |
|
446 \since 4.7 |
|
447 Clears the stacks specified by \a stacksToClear. |
|
448 |
|
449 This method clears any commands on the undo stack, the redo stack, |
|
450 or both (the default). If commands are cleared, the appropriate |
|
451 signals are emitted, QTextDocument::undoAvailable() or |
|
452 QTextDocument::redoAvailable(). |
|
453 |
|
454 \sa QTextDocument::undoAvailable() QTextDocument::redoAvailable() |
|
455 */ |
|
456 void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear) |
|
457 { |
|
458 Q_D(QTextDocument); |
|
459 d->clearUndoRedoStacks(stacksToClear, true); |
|
460 } |
|
461 |
437 /*! |
462 /*! |
438 \overload |
463 \overload |
439 |
464 |
440 */ |
465 */ |
441 void QTextDocument::undo() |
466 void QTextDocument::undo() |
1677 // Check that there is a valid device to print to. |
1702 // Check that there is a valid device to print to. |
1678 if (!p.isActive()) |
1703 if (!p.isActive()) |
1679 return; |
1704 return; |
1680 |
1705 |
1681 const QTextDocument *doc = this; |
1706 const QTextDocument *doc = this; |
1682 QTextDocument *clonedDoc = 0; |
1707 QScopedPointer<QTextDocument> clonedDoc; |
1683 (void)doc->documentLayout(); // make sure that there is a layout |
1708 (void)doc->documentLayout(); // make sure that there is a layout |
1684 |
1709 |
1685 QRectF body = QRectF(QPointF(0, 0), d->pageSize); |
1710 QRectF body = QRectF(QPointF(0, 0), d->pageSize); |
1686 QPointF pageNumberPos; |
1711 QPointF pageNumberPos; |
1687 |
1712 |
1710 // scale to page |
1735 // scale to page |
1711 p.scale(printerPageSize.width() / scaledPageSize.width(), |
1736 p.scale(printerPageSize.width() / scaledPageSize.width(), |
1712 printerPageSize.height() / scaledPageSize.height()); |
1737 printerPageSize.height() / scaledPageSize.height()); |
1713 } else { |
1738 } else { |
1714 doc = clone(const_cast<QTextDocument *>(this)); |
1739 doc = clone(const_cast<QTextDocument *>(this)); |
1715 clonedDoc = const_cast<QTextDocument *>(doc); |
1740 clonedDoc.reset(const_cast<QTextDocument *>(doc)); |
1716 |
1741 |
1717 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); |
1742 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); |
1718 srcBlock.isValid() && dstBlock.isValid(); |
1743 srcBlock.isValid() && dstBlock.isValid(); |
1719 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { |
1744 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { |
1720 dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats()); |
1745 dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats()); |
1747 |
1772 |
1748 int docCopies; |
1773 int docCopies; |
1749 int pageCopies; |
1774 int pageCopies; |
1750 if (printer->collateCopies() == true){ |
1775 if (printer->collateCopies() == true){ |
1751 docCopies = 1; |
1776 docCopies = 1; |
1752 pageCopies = printer->numCopies(); |
1777 pageCopies = printer->supportsMultipleCopies() ? 1 : printer->copyCount(); |
1753 } else { |
1778 } else { |
1754 docCopies = printer->numCopies(); |
1779 docCopies = printer->supportsMultipleCopies() ? 1 : printer->copyCount(); |
1755 pageCopies = 1; |
1780 pageCopies = 1; |
1756 } |
1781 } |
1757 |
1782 |
1758 int fromPage = printer->fromPage(); |
1783 int fromPage = printer->fromPage(); |
1759 int toPage = printer->toPage(); |
1784 int toPage = printer->toPage(); |
1785 int page = fromPage; |
1810 int page = fromPage; |
1786 while (true) { |
1811 while (true) { |
1787 for (int j = 0; j < pageCopies; ++j) { |
1812 for (int j = 0; j < pageCopies; ++j) { |
1788 if (printer->printerState() == QPrinter::Aborted |
1813 if (printer->printerState() == QPrinter::Aborted |
1789 || printer->printerState() == QPrinter::Error) |
1814 || printer->printerState() == QPrinter::Error) |
1790 goto UserCanceled; |
1815 return; |
1791 printPage(page, &p, doc, body, pageNumberPos); |
1816 printPage(page, &p, doc, body, pageNumberPos); |
1792 if (j < pageCopies - 1) |
1817 if (j < pageCopies - 1) |
1793 printer->newPage(); |
1818 printer->newPage(); |
1794 } |
1819 } |
1795 |
1820 |
1805 } |
1830 } |
1806 |
1831 |
1807 if ( i < docCopies - 1) |
1832 if ( i < docCopies - 1) |
1808 printer->newPage(); |
1833 printer->newPage(); |
1809 } |
1834 } |
1810 |
|
1811 UserCanceled: |
|
1812 delete clonedDoc; |
|
1813 } |
1835 } |
1814 #endif |
1836 #endif |
1815 |
1837 |
1816 /*! |
1838 /*! |
1817 \enum QTextDocument::ResourceType |
1839 \enum QTextDocument::ResourceType |
1921 #ifndef QT_NO_TEXTCONTROL |
1943 #ifndef QT_NO_TEXTCONTROL |
1922 else if (QTextControl *control = qobject_cast<QTextControl *>(parent())) { |
1944 else if (QTextControl *control = qobject_cast<QTextControl *>(parent())) { |
1923 r = control->loadResource(type, name); |
1945 r = control->loadResource(type, name); |
1924 } |
1946 } |
1925 #endif |
1947 #endif |
|
1948 |
|
1949 // handle data: URLs |
|
1950 if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) |
|
1951 r = qDecodeDataUrl(name).second; |
1926 |
1952 |
1927 // if resource was not loaded try to load it here |
1953 // if resource was not loaded try to load it here |
1928 if (!doc && r.isNull() && name.isRelative()) { |
1954 if (!doc && r.isNull() && name.isRelative()) { |
1929 QUrl currentURL = d->url; |
1955 QUrl currentURL = d->url; |
1930 QUrl resourceUrl = name; |
1956 QUrl resourceUrl = name; |