160 rich += QLatin1String("<"); |
161 rich += QLatin1String("<"); |
161 else if (plain.at(i) == QLatin1Char('>')) |
162 else if (plain.at(i) == QLatin1Char('>')) |
162 rich += QLatin1String(">"); |
163 rich += QLatin1String(">"); |
163 else if (plain.at(i) == QLatin1Char('&')) |
164 else if (plain.at(i) == QLatin1Char('&')) |
164 rich += QLatin1String("&"); |
165 rich += QLatin1String("&"); |
|
166 else if (plain.at(i) == QLatin1Char('"')) |
|
167 rich += QLatin1String("""); |
165 else |
168 else |
166 rich += plain.at(i); |
169 rich += plain.at(i); |
167 } |
170 } |
168 return rich; |
171 return rich; |
169 } |
172 } |
954 */ |
957 */ |
955 |
958 |
956 |
959 |
957 /*! |
960 /*! |
958 Returns true if undo is available; otherwise returns false. |
961 Returns true if undo is available; otherwise returns false. |
|
962 |
|
963 \sa isRedoAvailable(), availableUndoSteps() |
959 */ |
964 */ |
960 bool QTextDocument::isUndoAvailable() const |
965 bool QTextDocument::isUndoAvailable() const |
961 { |
966 { |
962 Q_D(const QTextDocument); |
967 Q_D(const QTextDocument); |
963 return d->isUndoAvailable(); |
968 return d->isUndoAvailable(); |
964 } |
969 } |
965 |
970 |
966 /*! |
971 /*! |
967 Returns true if redo is available; otherwise returns false. |
972 Returns true if redo is available; otherwise returns false. |
|
973 |
|
974 \sa isUndoAvailable(), availableRedoSteps() |
968 */ |
975 */ |
969 bool QTextDocument::isRedoAvailable() const |
976 bool QTextDocument::isRedoAvailable() const |
970 { |
977 { |
971 Q_D(const QTextDocument); |
978 Q_D(const QTextDocument); |
972 return d->isRedoAvailable(); |
979 return d->isRedoAvailable(); |
973 } |
980 } |
974 |
981 |
|
982 /*! \since 4.6 |
|
983 |
|
984 Returns the number of available undo steps. |
|
985 |
|
986 \sa isUndoAvailable() |
|
987 */ |
|
988 int QTextDocument::availableUndoSteps() const |
|
989 { |
|
990 Q_D(const QTextDocument); |
|
991 return d->availableUndoSteps(); |
|
992 } |
|
993 |
|
994 /*! \since 4.6 |
|
995 |
|
996 Returns the number of available redo steps. |
|
997 |
|
998 \sa isRedoAvailable() |
|
999 */ |
|
1000 int QTextDocument::availableRedoSteps() const |
|
1001 { |
|
1002 Q_D(const QTextDocument); |
|
1003 return d->availableRedoSteps(); |
|
1004 } |
975 |
1005 |
976 /*! \since 4.4 |
1006 /*! \since 4.4 |
977 |
1007 |
978 Returns the document's revision (if undo is enabled). |
1008 Returns the document's revision (if undo is enabled). |
979 |
1009 |
1691 } |
1721 } |
1692 |
1722 |
1693 QAbstractTextDocumentLayout *layout = doc->documentLayout(); |
1723 QAbstractTextDocumentLayout *layout = doc->documentLayout(); |
1694 layout->setPaintDevice(p.device()); |
1724 layout->setPaintDevice(p.device()); |
1695 |
1725 |
|
1726 // copy the custom object handlers |
|
1727 layout->d_func()->handlers = documentLayout()->d_func()->handlers; |
|
1728 |
1696 int dpiy = p.device()->logicalDpiY(); |
1729 int dpiy = p.device()->logicalDpiY(); |
1697 int margin = 0; |
1730 int margin = 0; |
1698 if (printer->fullPage() && !printer->d_func()->hasCustomPageMargins) { |
1731 if (printer->fullPage() && !printer->d_func()->hasCustomPageMargins) { |
1699 // for compatibility |
1732 // for compatibility |
1700 margin = (int) ((2/2.54)*dpiy); // 2 cm margins |
1733 margin = (int) ((2/2.54)*dpiy); // 2 cm margins |
1731 toPage = doc->pageCount(); |
1764 toPage = doc->pageCount(); |
1732 } |
1765 } |
1733 // paranoia check |
1766 // paranoia check |
1734 fromPage = qMax(1, fromPage); |
1767 fromPage = qMax(1, fromPage); |
1735 toPage = qMin(doc->pageCount(), toPage); |
1768 toPage = qMin(doc->pageCount(), toPage); |
|
1769 |
|
1770 if (toPage < fromPage) { |
|
1771 // if the user entered a page range outside the actual number |
|
1772 // of printable pages, just return |
|
1773 return; |
|
1774 } |
1736 |
1775 |
1737 if (printer->pageOrder() == QPrinter::LastPageFirst) { |
1776 if (printer->pageOrder() == QPrinter::LastPageFirst) { |
1738 int tmp = fromPage; |
1777 int tmp = fromPage; |
1739 fromPage = toPage; |
1778 fromPage = toPage; |
1740 toPage = tmp; |
1779 toPage = tmp; |
2036 void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value) |
2075 void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value) |
2037 { |
2076 { |
2038 html += QLatin1Char(' '); |
2077 html += QLatin1Char(' '); |
2039 html += QLatin1String(attribute); |
2078 html += QLatin1String(attribute); |
2040 html += QLatin1String("=\""); |
2079 html += QLatin1String("=\""); |
2041 html += value; |
2080 html += Qt::escape(value); |
2042 html += QLatin1Char('"'); |
2081 html += QLatin1Char('"'); |
2043 } |
2082 } |
2044 |
2083 |
2045 bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) |
2084 bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) |
2046 { |
2085 { |
2300 |
2339 |
2301 void QTextHtmlExporter::emitFontFamily(const QString &family) |
2340 void QTextHtmlExporter::emitFontFamily(const QString &family) |
2302 { |
2341 { |
2303 html += QLatin1String(" font-family:"); |
2342 html += QLatin1String(" font-family:"); |
2304 |
2343 |
2305 QLatin1Char quote('\''); |
2344 QLatin1String quote("\'"); |
2306 if (family.contains(quote)) |
2345 if (family.contains(QLatin1Char('\''))) |
2307 quote = QLatin1Char('\"'); |
2346 quote = QLatin1String("""); |
2308 |
2347 |
2309 html += quote; |
2348 html += quote; |
2310 html += family; |
2349 html += Qt::escape(family); |
2311 html += quote; |
2350 html += quote; |
2312 html += QLatin1Char(';'); |
2351 html += QLatin1Char(';'); |
2313 } |
2352 } |
2314 |
2353 |
2315 void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right) |
2354 void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right) |
2339 |
2378 |
2340 if (format.isAnchor()) { |
2379 if (format.isAnchor()) { |
2341 const QString name = format.anchorName(); |
2380 const QString name = format.anchorName(); |
2342 if (!name.isEmpty()) { |
2381 if (!name.isEmpty()) { |
2343 html += QLatin1String("<a name=\""); |
2382 html += QLatin1String("<a name=\""); |
2344 html += name; |
2383 html += Qt::escape(name); |
2345 html += QLatin1String("\"></a>"); |
2384 html += QLatin1String("\"></a>"); |
2346 } |
2385 } |
2347 const QString href = format.anchorHref(); |
2386 const QString href = format.anchorHref(); |
2348 if (!href.isEmpty()) { |
2387 if (!href.isEmpty()) { |
2349 html += QLatin1String("<a href=\""); |
2388 html += QLatin1String("<a href=\""); |
2350 html += href; |
2389 html += Qt::escape(href); |
2351 html += QLatin1String("\">"); |
2390 html += QLatin1String("\">"); |
2352 closeAnchor = true; |
2391 closeAnchor = true; |
2353 } |
2392 } |
2354 } |
2393 } |
2355 |
2394 |