qtextdocument.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextdocument.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qtextdocument.h"-
35#include <qtextformat.h>-
36#include "qtextcursor_p.h"-
37#include "qtextdocumentlayout_p.h"-
38#include "qtextdocumentfragment.h"-
39#include "qtextdocumentfragment_p.h"-
40#include "qtexttable.h"-
41#include "qtextlist.h"-
42#include <qdebug.h>-
43#include <qregexp.h>-
44#include <qregularexpression.h>-
45#include <qvarlengtharray.h>-
46#include <qtextcodec.h>-
47#include <qthread.h>-
48#include <qcoreapplication.h>-
49#include <qmetaobject.h>-
50-
51#include "qtexthtmlparser_p.h"-
52#include "qpainter.h"-
53#include <qfile.h>-
54#include <qfileinfo.h>-
55#include <qdir.h>-
56#include "qfont_p.h"-
57#include "private/qdataurl_p.h"-
58-
59#include "qtextdocument_p.h"-
60#include <private/qabstracttextdocumentlayout_p.h>-
61#include "qpagedpaintdevice.h"-
62#include "private/qpagedpaintdevice_p.h"-
63-
64#include <limits.h>-
65-
66QT_BEGIN_NAMESPACE-
67-
68Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n);-
69-
70/*!-
71 Returns \c true if the string \a text is likely to be rich text;-
72 otherwise returns \c false.-
73-
74 This function uses a fast and therefore simple heuristic. It-
75 mainly checks whether there is something that looks like a tag-
76 before the first line break. Although the result may be correct-
77 for common cases, there is no guarantee.-
78-
79 This function is defined in the \c <QTextDocument> header file.-
80*/-
81bool Qt::mightBeRichText(const QString& text)-
82{-
83 if (text.isEmpty())
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 return false;
never executed: return false;
0
85 int start = 0;-
86-
87 while (start < text.length() && text.at(start).isSpace())
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(start).isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
0
88 ++start;
never executed: ++start;
0
89-
90 // skip a leading <?xml ... ?> as for example with xhtml-
91 if (text.mid(start, 5) == QLatin1String("<?xml")) {
text.mid(start...tring("<?xml")Description
TRUEnever evaluated
FALSEnever evaluated
0
92 while (start < text.length()) {
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
93 if (text.at(start) == QLatin1Char('?')
text.at(start)...atin1Char('?')Description
TRUEnever evaluated
FALSEnever evaluated
0
94 && start + 2 < text.length()
start + 2 < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
95 && text.at(start + 1) == QLatin1Char('>')) {
text.at(start ...atin1Char('>')Description
TRUEnever evaluated
FALSEnever evaluated
0
96 start += 2;-
97 break;
never executed: break;
0
98 }-
99 ++start;-
100 }
never executed: end of block
0
101-
102 while (start < text.length() && text.at(start).isSpace())
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(start).isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
0
103 ++start;
never executed: ++start;
0
104 }
never executed: end of block
0
105-
106 if (text.mid(start, 5).toLower() == QLatin1String("<!doc"))
text.mid(start...tring("<!doc")Description
TRUEnever evaluated
FALSEnever evaluated
0
107 return true;
never executed: return true;
0
108 int open = start;-
109 while (open < text.length() && text.at(open) != QLatin1Char('<')
open < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(open) ...atin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
0
110 && text.at(open) != QLatin1Char('\n')) {
text.at(open) ...tin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
0
111 if (text.at(open) == QLatin1Char('&') && text.mid(open+1,3) == QLatin1String("lt;"))
text.at(open) ...atin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
text.mid(open+...1String("lt;")Description
TRUEnever evaluated
FALSEnever evaluated
0
112 return true; // support desperate attempt of user to see <...>
never executed: return true;
0
113 ++open;-
114 }
never executed: end of block
0
115 if (open < text.length() && text.at(open) == QLatin1Char('<')) {
open < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(open) ...atin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
0
116 const int close = text.indexOf(QLatin1Char('>'), open);-
117 if (close > -1) {
close > -1Description
TRUEnever evaluated
FALSEnever evaluated
0
118 QString tag;-
119 for (int i = open+1; i < close; ++i) {
i < closeDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 if (text[i].isDigit() || text[i].isLetter())
text[i].isDigit()Description
TRUEnever evaluated
FALSEnever evaluated
text[i].isLetter()Description
TRUEnever evaluated
FALSEnever evaluated
0
121 tag += text[i];
never executed: tag += text[i];
0
122 else if (!tag.isEmpty() && text[i].isSpace())
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
text[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
0
123 break;
never executed: break;
0
124 else if (!tag.isEmpty() && text[i] == QLatin1Char('/') && i + 1 == close)
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
text[i] == QLatin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
i + 1 == closeDescription
TRUEnever evaluated
FALSEnever evaluated
0
125 break;
never executed: break;
0
126 else if (!text[i].isSpace() && (!tag.isEmpty() || text[i] != QLatin1Char('!')))
!text[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
text[i] != QLatin1Char('!')Description
TRUEnever evaluated
FALSEnever evaluated
0
127 return false; // that's not a tag
never executed: return false;
0
128 }
never executed: end of block
0
129#ifndef QT_NO_TEXTHTMLPARSER-
130 return QTextHtmlParser::lookupElement(tag.toLower()) != -1;
never executed: return QTextHtmlParser::lookupElement(tag.toLower()) != -1;
0
131#else-
132 return false;-
133#endif // QT_NO_TEXTHTMLPARSER-
134 }-
135 }
never executed: end of block
0
136 return false;
never executed: return false;
0
137}-
138-
139-
140/*!-
141 Converts the plain text string \a plain to an HTML-formatted-
142 paragraph while preserving most of its look.-
143-
144 \a mode defines how whitespace is handled.-
145-
146 This function is defined in the \c <QTextDocument> header file.-
147-
148 \sa escape(), mightBeRichText()-
149*/-
150QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode)-
151{-
152 int col = 0;-
153 QString rich;-
154 rich += QLatin1String("<p>");-
155 for (int i = 0; i < plain.length(); ++i) {
i < plain.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
156 if (plain[i] == QLatin1Char('\n')){
plain[i] == QLatin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
0
157 int c = 1;-
158 while (i+1 < plain.length() && plain[i+1] == QLatin1Char('\n')) {
i+1 < plain.length()Description
TRUEnever evaluated
FALSEnever evaluated
plain[i+1] == ...tin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
0
159 i++;-
160 c++;-
161 }
never executed: end of block
0
162 if (c == 1)
c == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
163 rich += QLatin1String("<br>\n");
never executed: rich += QLatin1String("<br>\n");
0
164 else {-
165 rich += QLatin1String("</p>\n");-
166 while (--c > 1)
--c > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
167 rich += QLatin1String("<br>\n");
never executed: rich += QLatin1String("<br>\n");
0
168 rich += QLatin1String("<p>");-
169 }
never executed: end of block
0
170 col = 0;-
171 } else {
never executed: end of block
0
172 if (mode == Qt::WhiteSpacePre && plain[i] == QLatin1Char('\t')){
mode == Qt::WhiteSpacePreDescription
TRUEnever evaluated
FALSEnever evaluated
plain[i] == QLatin1Char('\t')Description
TRUEnever evaluated
FALSEnever evaluated
0
173 rich += QChar(0x00a0U);-
174 ++col;-
175 while (col % 8) {
col % 8Description
TRUEnever evaluated
FALSEnever evaluated
0
176 rich += QChar(0x00a0U);-
177 ++col;-
178 }
never executed: end of block
0
179 }
never executed: end of block
0
180 else if (mode == Qt::WhiteSpacePre && plain[i].isSpace())
mode == Qt::WhiteSpacePreDescription
TRUEnever evaluated
FALSEnever evaluated
plain[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
0
181 rich += QChar(0x00a0U);
never executed: rich += QChar(0x00a0U);
0
182 else if (plain[i] == QLatin1Char('<'))
plain[i] == QLatin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
0
183 rich += QLatin1String("&lt;");
never executed: rich += QLatin1String("&lt;");
0
184 else if (plain[i] == QLatin1Char('>'))
plain[i] == QLatin1Char('>')Description
TRUEnever evaluated
FALSEnever evaluated
0
185 rich += QLatin1String("&gt;");
never executed: rich += QLatin1String("&gt;");
0
186 else if (plain[i] == QLatin1Char('&'))
plain[i] == QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
187 rich += QLatin1String("&amp;");
never executed: rich += QLatin1String("&amp;");
0
188 else-
189 rich += plain[i];
never executed: rich += plain[i];
0
190 ++col;-
191 }
never executed: end of block
0
192 }-
193 if (col != 0)
col != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
194 rich += QLatin1String("</p>");
never executed: rich += QLatin1String("</p>");
0
195 return rich;
never executed: return rich;
0
196}-
197-
198#ifndef QT_NO_TEXTCODEC-
199/*!-
200 \internal-
201-
202 This function is defined in the \c <QTextDocument> header file.-
203*/-
204QTextCodec *Qt::codecForHtml(const QByteArray &ba)-
205{-
206 return QTextCodec::codecForHtml(ba);
never executed: return QTextCodec::codecForHtml(ba);
0
207}-
208#endif-
209-
210/*!-
211 \class QTextDocument-
212 \reentrant-
213 \inmodule QtGui-
214-
215 \brief The QTextDocument class holds formatted text.-
216-
217 \ingroup richtext-processing-
218-
219-
220 QTextDocument is a container for structured rich text documents, providing-
221 support for styled text and various types of document elements, such as-
222 lists, tables, frames, and images.-
223 They can be created for use in a QTextEdit, or used independently.-
224-
225 Each document element is described by an associated format object. Each-
226 format object is treated as a unique object by QTextDocuments, and can be-
227 passed to objectForFormat() to obtain the document element that it is-
228 applied to.-
229-
230 A QTextDocument can be edited programmatically using a QTextCursor, and-
231 its contents can be examined by traversing the document structure. The-
232 entire document structure is stored as a hierarchy of document elements-
233 beneath the root frame, found with the rootFrame() function. Alternatively,-
234 if you just want to iterate over the textual contents of the document you-
235 can use begin(), end(), and findBlock() to retrieve text blocks that you-
236 can examine and iterate over.-
237-
238 The layout of a document is determined by the documentLayout();-
239 you can create your own QAbstractTextDocumentLayout subclass and-
240 set it using setDocumentLayout() if you want to use your own-
241 layout logic. The document's title and other meta-information can be-
242 obtained by calling the metaInformation() function. For documents that-
243 are exposed to users through the QTextEdit class, the document title-
244 is also available via the QTextEdit::documentTitle() function.-
245-
246 The toPlainText() and toHtml() convenience functions allow you to retrieve the-
247 contents of the document as plain text and HTML.-
248 The document's text can be searched using the find() functions.-
249-
250 Undo/redo of operations performed on the document can be controlled using-
251 the setUndoRedoEnabled() function. The undo/redo system can be controlled-
252 by an editor widget through the undo() and redo() slots; the document also-
253 provides contentsChanged(), undoAvailable(), and redoAvailable() signals-
254 that inform connected editor widgets about the state of the undo/redo-
255 system. The following are the undo/redo operations of a QTextDocument:-
256-
257 \list-
258 \li Insertion or removal of characters. A sequence of insertions or removals-
259 within the same text block are regarded as a single undo/redo operation.-
260 \li Insertion or removal of text blocks. Sequences of insertion or removals-
261 in a single operation (e.g., by selecting and then deleting text) are-
262 regarded as a single undo/redo operation.-
263 \li Text character format changes.-
264 \li Text block format changes.-
265 \li Text block group format changes.-
266 \endlist-
267-
268 \sa QTextCursor, QTextEdit, {Rich Text Processing}, {Text Object Example}-
269*/-
270-
271/*!-
272 \property QTextDocument::defaultFont-
273 \brief the default font used to display the document's text-
274*/-
275-
276/*!-
277 \property QTextDocument::defaultTextOption-
278 \brief the default text option will be set on all \l{QTextLayout}s in the document.-
279-
280 When \l{QTextBlock}s are created, the defaultTextOption is set on their-
281 QTextLayout. This allows setting global properties for the document such as the-
282 default word wrap mode.-
283 */-
284-
285/*!-
286 Constructs an empty QTextDocument with the given \a parent.-
287*/-
288QTextDocument::QTextDocument(QObject *parent)-
289 : QObject(*new QTextDocumentPrivate, parent)-
290{-
291 Q_D(QTextDocument);-
292 d->init();-
293}
never executed: end of block
0
294-
295/*!-
296 Constructs a QTextDocument containing the plain (unformatted) \a text-
297 specified, and with the given \a parent.-
298*/-
299QTextDocument::QTextDocument(const QString &text, QObject *parent)-
300 : QObject(*new QTextDocumentPrivate, parent)-
301{-
302 Q_D(QTextDocument);-
303 d->init();-
304 QTextCursor(this).insertText(text);-
305}
never executed: end of block
0
306-
307/*!-
308 \internal-
309*/-
310QTextDocument::QTextDocument(QTextDocumentPrivate &dd, QObject *parent)-
311 : QObject(dd, parent)-
312{-
313 Q_D(QTextDocument);-
314 d->init();-
315}
never executed: end of block
0
316-
317/*!-
318 Destroys the document.-
319*/-
320QTextDocument::~QTextDocument()-
321{-
322}-
323-
324-
325/*!-
326 Creates a new QTextDocument that is a copy of this text document. \a-
327 parent is the parent of the returned text document.-
328*/-
329QTextDocument *QTextDocument::clone(QObject *parent) const-
330{-
331 Q_D(const QTextDocument);-
332 QTextDocument *doc = new QTextDocument(parent);-
333 QTextCursor(doc).insertFragment(QTextDocumentFragment(this));-
334 doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat());-
335 QTextDocumentPrivate *priv = doc->d_func();-
336 priv->title = d->title;-
337 priv->url = d->url;-
338 priv->pageSize = d->pageSize;-
339 priv->indentWidth = d->indentWidth;-
340 priv->defaultTextOption = d->defaultTextOption;-
341 priv->setDefaultFont(d->defaultFont());-
342 priv->resources = d->resources;-
343 priv->cachedResources.clear();-
344#ifndef QT_NO_CSSPARSER-
345 priv->defaultStyleSheet = d->defaultStyleSheet;-
346 priv->parsedDefaultStyleSheet = d->parsedDefaultStyleSheet;-
347#endif-
348 return doc;
never executed: return doc;
0
349}-
350-
351/*!-
352 Returns \c true if the document is empty; otherwise returns \c false.-
353*/-
354bool QTextDocument::isEmpty() const-
355{-
356 Q_D(const QTextDocument);-
357 /* because if we're empty we still have one single paragraph as-
358 * one single fragment */-
359 return d->length() <= 1;
never executed: return d->length() <= 1;
0
360}-
361-
362/*!-
363 Clears the document.-
364*/-
365void QTextDocument::clear()-
366{-
367 Q_D(QTextDocument);-
368 d->clear();-
369 d->resources.clear();-
370}
never executed: end of block
0
371-
372/*!-
373 \since 4.2-
374-
375 Undoes the last editing operation on the document if undo is-
376 available. The provided \a cursor is positioned at the end of the-
377 location where the edition operation was undone.-
378-
379 See the \l {Overview of Qt's Undo Framework}{Qt Undo Framework}-
380 documentation for details.-
381-
382 \sa undoAvailable(), isUndoRedoEnabled()-
383*/-
384void QTextDocument::undo(QTextCursor *cursor)-
385{-
386 Q_D(QTextDocument);-
387 const int pos = d->undoRedo(true);-
388 if (cursor && pos >= 0) {
cursorDescription
TRUEnever evaluated
FALSEnever evaluated
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
389 *cursor = QTextCursor(this);-
390 cursor->setPosition(pos);-
391 }
never executed: end of block
0
392}
never executed: end of block
0
393-
394/*!-
395 \since 4.2-
396 Redoes the last editing operation on the document if \l{QTextDocument::isRedoAvailable()}{redo is available}.-
397-
398 The provided \a cursor is positioned at the end of the location where-
399 the edition operation was redone.-
400*/-
401void QTextDocument::redo(QTextCursor *cursor)-
402{-
403 Q_D(QTextDocument);-
404 const int pos = d->undoRedo(false);-
405 if (cursor && pos >= 0) {
cursorDescription
TRUEnever evaluated
FALSEnever evaluated
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
406 *cursor = QTextCursor(this);-
407 cursor->setPosition(pos);-
408 }
never executed: end of block
0
409}
never executed: end of block
0
410-
411/*! \enum QTextDocument::Stacks-
412-
413 \value UndoStack The undo stack.-
414 \value RedoStack The redo stack.-
415 \value UndoAndRedoStacks Both the undo and redo stacks.-
416*/-
417-
418/*!-
419 \since 4.7-
420 Clears the stacks specified by \a stacksToClear.-
421-
422 This method clears any commands on the undo stack, the redo stack,-
423 or both (the default). If commands are cleared, the appropriate-
424 signals are emitted, QTextDocument::undoAvailable() or-
425 QTextDocument::redoAvailable().-
426-
427 \sa QTextDocument::undoAvailable(), QTextDocument::redoAvailable()-
428*/-
429void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear)-
430{-
431 Q_D(QTextDocument);-
432 d->clearUndoRedoStacks(stacksToClear, true);-
433}
never executed: end of block
0
434-
435/*!-
436 \overload-
437-
438*/-
439void QTextDocument::undo()-
440{-
441 Q_D(QTextDocument);-
442 d->undoRedo(true);-
443}
never executed: end of block
0
444-
445/*!-
446 \overload-
447 Redoes the last editing operation on the document if \l{QTextDocument::isRedoAvailable()}{redo is available}.-
448*/-
449void QTextDocument::redo()-
450{-
451 Q_D(QTextDocument);-
452 d->undoRedo(false);-
453}
never executed: end of block
0
454-
455/*!-
456 \internal-
457-
458 Appends a custom undo \a item to the undo stack.-
459*/-
460void QTextDocument::appendUndoItem(QAbstractUndoItem *item)-
461{-
462 Q_D(QTextDocument);-
463 d->appendUndoItem(item);-
464}
never executed: end of block
0
465-
466/*!-
467 \property QTextDocument::undoRedoEnabled-
468 \brief whether undo/redo are enabled for this document-
469-
470 This defaults to true. If disabled, the undo stack is cleared and-
471 no items will be added to it.-
472*/-
473void QTextDocument::setUndoRedoEnabled(bool enable)-
474{-
475 Q_D(QTextDocument);-
476 d->enableUndoRedo(enable);-
477}
never executed: end of block
0
478-
479bool QTextDocument::isUndoRedoEnabled() const-
480{-
481 Q_D(const QTextDocument);-
482 return d->isUndoRedoEnabled();
never executed: return d->isUndoRedoEnabled();
0
483}-
484-
485/*!-
486 \property QTextDocument::maximumBlockCount-
487 \since 4.2-
488 \brief Specifies the limit for blocks in the document.-
489-
490 Specifies the maximum number of blocks the document may have. If there are-
491 more blocks in the document that specified with this property blocks are removed-
492 from the beginning of the document.-
493-
494 A negative or zero value specifies that the document may contain an unlimited-
495 amount of blocks.-
496-
497 The default value is 0.-
498-
499 Note that setting this property will apply the limit immediately to the document-
500 contents.-
501-
502 Setting this property also disables the undo redo history.-
503-
504 This property is undefined in documents with tables or frames.-
505*/-
506int QTextDocument::maximumBlockCount() const-
507{-
508 Q_D(const QTextDocument);-
509 return d->maximumBlockCount;
never executed: return d->maximumBlockCount;
0
510}-
511-
512void QTextDocument::setMaximumBlockCount(int maximum)-
513{-
514 Q_D(QTextDocument);-
515 d->maximumBlockCount = maximum;-
516 d->ensureMaximumBlockCount();-
517 setUndoRedoEnabled(false);-
518}
never executed: end of block
0
519-
520/*!-
521 \since 4.3-
522-
523 The default text option is used on all QTextLayout objects in the document.-
524 This allows setting global properties for the document such as the default-
525 word wrap mode.-
526*/-
527QTextOption QTextDocument::defaultTextOption() const-
528{-
529 Q_D(const QTextDocument);-
530 return d->defaultTextOption;
never executed: return d->defaultTextOption;
0
531}-
532-
533/*!-
534 \since 4.3-
535-
536 Sets the default text option to \a option.-
537*/-
538void QTextDocument::setDefaultTextOption(const QTextOption &option)-
539{-
540 Q_D(QTextDocument);-
541 d->defaultTextOption = option;-
542 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
543 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
544}
never executed: end of block
0
545-
546/*!-
547 \property QTextDocument::baseUrl-
548 \since 5.3-
549 \brief the base URL used to resolve relative resource URLs within the document.-
550-
551 Resource URLs are resolved to be within the same directory as the target of the base-
552 URL meaning any portion of the path after the last '/' will be ignored.-
553-
554 \table-
555 \header \li Base URL \li Relative URL \li Resolved URL-
556 \row \li file:///path/to/content \li images/logo.png \li file:///path/to/images/logo.png-
557 \row \li file:///path/to/content/ \li images/logo.png \li file:///path/to/content/images/logo.png-
558 \row \li file:///path/to/content/index.html \li images/logo.png \li file:///path/to/content/images/logo.png-
559 \row \li file:///path/to/content/images/ \li ../images/logo.png \li file:///path/to/content/images/logo.png-
560 \endtable-
561*/-
562QUrl QTextDocument::baseUrl() const-
563{-
564 Q_D(const QTextDocument);-
565 return d->baseUrl;
never executed: return d->baseUrl;
0
566}-
567-
568void QTextDocument::setBaseUrl(const QUrl &url)-
569{-
570 Q_D(QTextDocument);-
571 if (d->baseUrl != url) {
d->baseUrl != urlDescription
TRUEnever evaluated
FALSEnever evaluated
0
572 d->baseUrl = url;-
573 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
574 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
575 emit baseUrlChanged(url);-
576 }
never executed: end of block
0
577}
never executed: end of block
0
578-
579/*!-
580 \since 4.8-
581-
582 The default cursor movement style is used by all QTextCursor objects-
583 created from the document. The default is Qt::LogicalMoveStyle.-
584*/-
585Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const-
586{-
587 Q_D(const QTextDocument);-
588 return d->defaultCursorMoveStyle;
never executed: return d->defaultCursorMoveStyle;
0
589}-
590-
591/*!-
592 \since 4.8-
593-
594 Sets the default cursor movement style to the given \a style.-
595*/-
596void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)-
597{-
598 Q_D(QTextDocument);-
599 d->defaultCursorMoveStyle = style;-
600}
never executed: end of block
0
601-
602/*!-
603 \fn void QTextDocument::markContentsDirty(int position, int length)-
604-
605 Marks the contents specified by the given \a position and \a length-
606 as "dirty", informing the document that it needs to be laid out-
607 again.-
608*/-
609void QTextDocument::markContentsDirty(int from, int length)-
610{-
611 Q_D(QTextDocument);-
612 d->documentChange(from, length);-
613 if (!d->inContentsChange) {
!d->inContentsChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
614 if (d->lout) {
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
615 d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength);-
616 d->docChangeFrom = -1;-
617 }
never executed: end of block
0
618 }
never executed: end of block
0
619}
never executed: end of block
0
620-
621/*!-
622 \property QTextDocument::useDesignMetrics-
623 \since 4.1-
624 \brief whether the document uses design metrics of fonts to improve the accuracy of text layout-
625-
626 If this property is set to true, the layout will use design metrics.-
627 Otherwise, the metrics of the paint device as set on-
628 QAbstractTextDocumentLayout::setPaintDevice() will be used.-
629-
630 Using design metrics makes a layout have a width that is no longer dependent on hinting-
631 and pixel-rounding. This means that WYSIWYG text layout becomes possible because the width-
632 scales much more linearly based on paintdevice metrics than it would otherwise.-
633-
634 By default, this property is \c false.-
635*/-
636-
637void QTextDocument::setUseDesignMetrics(bool b)-
638{-
639 Q_D(QTextDocument);-
640 if (b == d->defaultTextOption.useDesignMetrics())
b == d->defaul...esignMetrics()Description
TRUEnever evaluated
FALSEnever evaluated
0
641 return;
never executed: return;
0
642 d->defaultTextOption.setUseDesignMetrics(b);-
643 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
644 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
645}
never executed: end of block
0
646-
647bool QTextDocument::useDesignMetrics() const-
648{-
649 Q_D(const QTextDocument);-
650 return d->defaultTextOption.useDesignMetrics();
never executed: return d->defaultTextOption.useDesignMetrics();
0
651}-
652-
653/*!-
654 \since 4.2-
655-
656 Draws the content of the document with painter \a p, clipped to \a rect.-
657 If \a rect is a null rectangle (default) then the document is painted unclipped.-
658*/-
659void QTextDocument::drawContents(QPainter *p, const QRectF &rect)-
660{-
661 p->save();-
662 QAbstractTextDocumentLayout::PaintContext ctx;-
663 if (rect.isValid()) {
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
664 p->setClipRect(rect);-
665 ctx.clip = rect;-
666 }
never executed: end of block
0
667 documentLayout()->draw(p, ctx);-
668 p->restore();-
669}
never executed: end of block
0
670-
671/*!-
672 \property QTextDocument::textWidth-
673 \since 4.2-
674-
675 The text width specifies the preferred width for text in the document. If-
676 the text (or content in general) is wider than the specified with it is broken-
677 into multiple lines and grows vertically. If the text cannot be broken into multiple-
678 lines to fit into the specified text width it will be larger and the size() and the-
679 idealWidth() property will reflect that.-
680-
681 If the text width is set to -1 then the text will not be broken into multiple lines-
682 unless it is enforced through an explicit line break or a new paragraph.-
683-
684 The default value is -1.-
685-
686 Setting the text width will also set the page height to -1, causing the document to-
687 grow or shrink vertically in a continuous way. If you want the document layout to break-
688 the text into multiple pages then you have to set the pageSize property instead.-
689-
690 \sa size(), idealWidth(), pageSize()-
691*/-
692void QTextDocument::setTextWidth(qreal width)-
693{-
694 Q_D(QTextDocument);-
695 QSizeF sz = d->pageSize;-
696 sz.setWidth(width);-
697 sz.setHeight(-1);-
698 setPageSize(sz);-
699}
never executed: end of block
0
700-
701qreal QTextDocument::textWidth() const-
702{-
703 Q_D(const QTextDocument);-
704 return d->pageSize.width();
never executed: return d->pageSize.width();
0
705}-
706-
707/*!-
708 \since 4.2-
709-
710 Returns the ideal width of the text document. The ideal width is the actually used width-
711 of the document without optional alignments taken into account. It is always <= size().width().-
712-
713 \sa adjustSize(), textWidth-
714*/-
715qreal QTextDocument::idealWidth() const-
716{-
717 if (QTextDocumentLayout *lout = qobject_cast<QTextDocumentLayout *>(documentLayout()))
QTextDocumentL...umentLayout())Description
TRUEnever evaluated
FALSEnever evaluated
0
718 return lout->idealWidth();
never executed: return lout->idealWidth();
0
719 return textWidth();
never executed: return textWidth();
0
720}-
721-
722/*!-
723 \property QTextDocument::documentMargin-
724 \since 4.5-
725-
726 The margin around the document. The default is 4.-
727*/-
728qreal QTextDocument::documentMargin() const-
729{-
730 Q_D(const QTextDocument);-
731 return d->documentMargin;
never executed: return d->documentMargin;
0
732}-
733-
734void QTextDocument::setDocumentMargin(qreal margin)-
735{-
736 Q_D(QTextDocument);-
737 if (d->documentMargin != margin) {
d->documentMargin != marginDescription
TRUEnever evaluated
FALSEnever evaluated
0
738 d->documentMargin = margin;-
739-
740 QTextFrame* root = rootFrame();-
741 QTextFrameFormat format = root->frameFormat();-
742 format.setMargin(margin);-
743 root->setFrameFormat(format);-
744-
745 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
746 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
747 }
never executed: end of block
0
748}
never executed: end of block
0
749-
750-
751/*!-
752 \property QTextDocument::indentWidth-
753 \since 4.4-
754-
755 Returns the width used for text list and text block indenting.-
756-
757 The indent properties of QTextListFormat and QTextBlockFormat specify-
758 multiples of this value. The default indent width is 40.-
759*/-
760qreal QTextDocument::indentWidth() const-
761{-
762 Q_D(const QTextDocument);-
763 return d->indentWidth;
never executed: return d->indentWidth;
0
764}-
765-
766-
767/*!-
768 \since 4.4-
769-
770 Sets the \a width used for text list and text block indenting.-
771-
772 The indent properties of QTextListFormat and QTextBlockFormat specify-
773 multiples of this value. The default indent width is 40 .-
774-
775 \sa indentWidth()-
776*/-
777void QTextDocument::setIndentWidth(qreal width)-
778{-
779 Q_D(QTextDocument);-
780 if (d->indentWidth != width) {
d->indentWidth != widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
781 d->indentWidth = width;-
782 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
783 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
784 }
never executed: end of block
0
785}
never executed: end of block
0
786-
787-
788-
789-
790/*!-
791 \since 4.2-
792-
793 Adjusts the document to a reasonable size.-
794-
795 \sa idealWidth(), textWidth, size-
796*/-
797void QTextDocument::adjustSize()-
798{-
799 // Pull this private function in from qglobal.cpp-
800 QFont f = defaultFont();-
801 QFontMetrics fm(f);-
802 int mw = fm.width(QLatin1Char('x')) * 80;-
803 int w = mw;-
804 setTextWidth(w);-
805 QSizeF size = documentLayout()->documentSize();-
806 if (size.width() != 0) {
size.width() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
807 w = qt_int_sqrt((uint)(5 * size.height() * size.width() / 3));-
808 setTextWidth(qMin(w, mw));-
809-
810 size = documentLayout()->documentSize();-
811 if (w*3 < 5*size.height()) {
w*3 < 5*size.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
812 w = qt_int_sqrt((uint)(2 * size.height() * size.width()));-
813 setTextWidth(qMin(w, mw));-
814 }
never executed: end of block
0
815 }
never executed: end of block
0
816 setTextWidth(idealWidth());-
817}
never executed: end of block
0
818-
819/*!-
820 \property QTextDocument::size-
821 \since 4.2-
822-
823 Returns the actual size of the document.-
824 This is equivalent to documentLayout()->documentSize();-
825-
826 The size of the document can be changed either by setting-
827 a text width or setting an entire page size.-
828-
829 Note that the width is always >= pageSize().width().-
830-
831 By default, for a newly-created, empty document, this property contains-
832 a configuration-dependent size.-
833-
834 \sa setTextWidth(), setPageSize(), idealWidth()-
835*/-
836QSizeF QTextDocument::size() const-
837{-
838 return documentLayout()->documentSize();
never executed: return documentLayout()->documentSize();
0
839}-
840-
841/*!-
842 \property QTextDocument::blockCount-
843 \since 4.2-
844-
845 Returns the number of text blocks in the document.-
846-
847 The value of this property is undefined in documents with tables or frames.-
848-
849 By default, if defined, this property contains a value of 1.-
850 \sa lineCount(), characterCount()-
851*/-
852int QTextDocument::blockCount() const-
853{-
854 Q_D(const QTextDocument);-
855 return d->blockMap().numNodes();
never executed: return d->blockMap().numNodes();
0
856}-
857-
858-
859/*!-
860 \since 4.5-
861-
862 Returns the number of lines of this document (if the layout supports-
863 this). Otherwise, this is identical to the number of blocks.-
864-
865 \sa blockCount(), characterCount()-
866 */-
867int QTextDocument::lineCount() const-
868{-
869 Q_D(const QTextDocument);-
870 return d->blockMap().length(2);
never executed: return d->blockMap().length(2);
0
871}-
872-
873/*!-
874 \since 4.5-
875-
876 Returns the number of characters of this document.-
877-
878 \sa blockCount(), characterAt()-
879 */-
880int QTextDocument::characterCount() const-
881{-
882 Q_D(const QTextDocument);-
883 return d->length();
never executed: return d->length();
0
884}-
885-
886/*!-
887 \since 4.5-
888-
889 Returns the character at position \a pos, or a null character if the-
890 position is out of range.-
891-
892 \sa characterCount()-
893 */-
894QChar QTextDocument::characterAt(int pos) const-
895{-
896 Q_D(const QTextDocument);-
897 if (pos < 0 || pos >= d->length())
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
pos >= d->length()Description
TRUEnever evaluated
FALSEnever evaluated
0
898 return QChar();
never executed: return QChar();
0
899 QTextDocumentPrivate::FragmentIterator fragIt = d->find(pos);-
900 const QTextFragmentData * const frag = fragIt.value();-
901 const int offsetInFragment = qMax(0, pos - fragIt.position());-
902 return d->text.at(frag->stringPosition + offsetInFragment);
never executed: return d->text.at(frag->stringPosition + offsetInFragment);
0
903}-
904-
905-
906/*!-
907 \property QTextDocument::defaultStyleSheet-
908 \since 4.2-
909-
910 The default style sheet is applied to all newly HTML formatted text that is-
911 inserted into the document, for example using setHtml() or QTextCursor::insertHtml().-
912-
913 The style sheet needs to be compliant to CSS 2.1 syntax.-
914-
915 \b{Note:} Changing the default style sheet does not have any effect to the existing content-
916 of the document.-
917-
918 \sa {Supported HTML Subset}-
919*/-
920-
921#ifndef QT_NO_CSSPARSER-
922void QTextDocument::setDefaultStyleSheet(const QString &sheet)-
923{-
924 Q_D(QTextDocument);-
925 d->defaultStyleSheet = sheet;-
926 QCss::Parser parser(sheet);-
927 d->parsedDefaultStyleSheet = QCss::StyleSheet();-
928 d->parsedDefaultStyleSheet.origin = QCss::StyleSheetOrigin_UserAgent;-
929 parser.parse(&d->parsedDefaultStyleSheet);-
930}
never executed: end of block
0
931-
932QString QTextDocument::defaultStyleSheet() const-
933{-
934 Q_D(const QTextDocument);-
935 return d->defaultStyleSheet;
never executed: return d->defaultStyleSheet;
0
936}-
937#endif // QT_NO_CSSPARSER-
938-
939/*!-
940 \fn void QTextDocument::contentsChanged()-
941-
942 This signal is emitted whenever the document's content changes; for-
943 example, when text is inserted or deleted, or when formatting is applied.-
944-
945 \sa contentsChange()-
946*/-
947-
948/*!-
949 \fn void QTextDocument::contentsChange(int position, int charsRemoved, int charsAdded)-
950-
951 This signal is emitted whenever the document's content changes; for-
952 example, when text is inserted or deleted, or when formatting is applied.-
953-
954 Information is provided about the \a position of the character in the-
955 document where the change occurred, the number of characters removed-
956 (\a charsRemoved), and the number of characters added (\a charsAdded).-
957-
958 The signal is emitted before the document's layout manager is notified-
959 about the change. This hook allows you to implement syntax highlighting-
960 for the document.-
961-
962 \sa QAbstractTextDocumentLayout::documentChanged(), contentsChanged()-
963*/-
964-
965-
966/*!-
967 \fn QTextDocument::undoAvailable(bool available);-
968-
969 This signal is emitted whenever undo operations become available-
970 (\a available is true) or unavailable (\a available is false).-
971-
972 See the \l {Overview of Qt's Undo Framework}{Qt Undo Framework}-
973 documentation for details.-
974-
975 \sa undo(), isUndoRedoEnabled()-
976*/-
977-
978/*!-
979 \fn QTextDocument::redoAvailable(bool available);-
980-
981 This signal is emitted whenever redo operations become available-
982 (\a available is true) or unavailable (\a available is false).-
983*/-
984-
985/*!-
986 \fn QTextDocument::cursorPositionChanged(const QTextCursor &cursor);-
987-
988 This signal is emitted whenever the position of a cursor changed-
989 due to an editing operation. The cursor that changed is passed in-
990 \a cursor. If the document is used with the QTextEdit class and you need a signal when the-
991 cursor is moved with the arrow keys you can use the \l{QTextEdit::}{cursorPositionChanged()}-
992 signal in QTextEdit.-
993*/-
994-
995/*!-
996 \fn QTextDocument::blockCountChanged(int newBlockCount);-
997 \since 4.3-
998-
999 This signal is emitted when the total number of text blocks in the-
1000 document changes. The value passed in \a newBlockCount is the new-
1001 total.-
1002*/-
1003-
1004/*!-
1005 \fn QTextDocument::documentLayoutChanged();-
1006 \since 4.4-
1007-
1008 This signal is emitted when a new document layout is set.-
1009-
1010 \sa setDocumentLayout()-
1011-
1012*/-
1013-
1014-
1015/*!-
1016 Returns \c true if undo is available; otherwise returns \c false.-
1017-
1018 \sa isRedoAvailable(), availableUndoSteps()-
1019*/-
1020bool QTextDocument::isUndoAvailable() const-
1021{-
1022 Q_D(const QTextDocument);-
1023 return d->isUndoAvailable();
never executed: return d->isUndoAvailable();
0
1024}-
1025-
1026/*!-
1027 Returns \c true if redo is available; otherwise returns \c false.-
1028-
1029 \sa isUndoAvailable(), availableRedoSteps()-
1030*/-
1031bool QTextDocument::isRedoAvailable() const-
1032{-
1033 Q_D(const QTextDocument);-
1034 return d->isRedoAvailable();
never executed: return d->isRedoAvailable();
0
1035}-
1036-
1037/*! \since 4.6-
1038-
1039 Returns the number of available undo steps.-
1040-
1041 \sa isUndoAvailable()-
1042*/-
1043int QTextDocument::availableUndoSteps() const-
1044{-
1045 Q_D(const QTextDocument);-
1046 return d->availableUndoSteps();
never executed: return d->availableUndoSteps();
0
1047}-
1048-
1049/*! \since 4.6-
1050-
1051 Returns the number of available redo steps.-
1052-
1053 \sa isRedoAvailable()-
1054*/-
1055int QTextDocument::availableRedoSteps() const-
1056{-
1057 Q_D(const QTextDocument);-
1058 return d->availableRedoSteps();
never executed: return d->availableRedoSteps();
0
1059}-
1060-
1061/*! \since 4.4-
1062-
1063 Returns the document's revision (if undo is enabled).-
1064-
1065 The revision is guaranteed to increase when a document that is not-
1066 modified is edited.-
1067-
1068 \sa QTextBlock::revision(), isModified()-
1069 */-
1070int QTextDocument::revision() const-
1071{-
1072 Q_D(const QTextDocument);-
1073 return d->revision;
never executed: return d->revision;
0
1074}-
1075-
1076-
1077-
1078/*!-
1079 Sets the document to use the given \a layout. The previous layout-
1080 is deleted.-
1081-
1082 \sa documentLayoutChanged()-
1083*/-
1084void QTextDocument::setDocumentLayout(QAbstractTextDocumentLayout *layout)-
1085{-
1086 Q_D(QTextDocument);-
1087 d->setLayout(layout);-
1088}
never executed: end of block
0
1089-
1090/*!-
1091 Returns the document layout for this document.-
1092*/-
1093QAbstractTextDocumentLayout *QTextDocument::documentLayout() const-
1094{-
1095 Q_D(const QTextDocument);-
1096 if (!d->lout) {
!d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1097 QTextDocument *that = const_cast<QTextDocument *>(this);-
1098 that->d_func()->setLayout(new QTextDocumentLayout(that));-
1099 }
never executed: end of block
0
1100 return d->lout;
never executed: return d->lout;
0
1101}-
1102-
1103-
1104/*!-
1105 Returns meta information about the document of the type specified by-
1106 \a info.-
1107-
1108 \sa setMetaInformation()-
1109*/-
1110QString QTextDocument::metaInformation(MetaInformation info) const-
1111{-
1112 Q_D(const QTextDocument);-
1113 switch (info) {-
1114 case DocumentTitle:
never executed: case DocumentTitle:
0
1115 return d->title;
never executed: return d->title;
0
1116 case DocumentUrl:
never executed: case DocumentUrl:
0
1117 return d->url;
never executed: return d->url;
0
1118 }-
1119 return QString();
never executed: return QString();
0
1120}-
1121-
1122/*!-
1123 Sets the document's meta information of the type specified by \a info-
1124 to the given \a string.-
1125-
1126 \sa metaInformation()-
1127*/-
1128void QTextDocument::setMetaInformation(MetaInformation info, const QString &string)-
1129{-
1130 Q_D(QTextDocument);-
1131 switch (info) {-
1132 case DocumentTitle:
never executed: case DocumentTitle:
0
1133 d->title = string;-
1134 break;
never executed: break;
0
1135 case DocumentUrl:
never executed: case DocumentUrl:
0
1136 d->url = string;-
1137 break;
never executed: break;
0
1138 }-
1139}
never executed: end of block
0
1140-
1141/*!-
1142 Returns the plain text contained in the document. If you want-
1143 formatting information use a QTextCursor instead.-
1144-
1145 \note Embedded objects, such as images, are represented by a-
1146 Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER).-
1147-
1148 \sa toHtml()-
1149*/-
1150QString QTextDocument::toPlainText() const-
1151{-
1152 Q_D(const QTextDocument);-
1153 QString txt = d->plainText();-
1154-
1155 QChar *uc = txt.data();-
1156 QChar *e = uc + txt.size();-
1157-
1158 for (; uc != e; ++uc) {
uc != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
1159 switch (uc->unicode()) {-
1160 case 0xfdd0: // QTextBeginningOfFrame
never executed: case 0xfdd0:
0
1161 case 0xfdd1: // QTextEndOfFrame
never executed: case 0xfdd1:
0
1162 case QChar::ParagraphSeparator:
never executed: case QChar::ParagraphSeparator:
0
1163 case QChar::LineSeparator:
never executed: case QChar::LineSeparator:
0
1164 *uc = QLatin1Char('\n');-
1165 break;
never executed: break;
0
1166 case QChar::Nbsp:
never executed: case QChar::Nbsp:
0
1167 *uc = QLatin1Char(' ');-
1168 break;
never executed: break;
0
1169 default:
never executed: default:
0
1170 ;-
1171 }
never executed: end of block
0
1172 }-
1173 return txt;
never executed: return txt;
0
1174}-
1175-
1176/*!-
1177 Replaces the entire contents of the document with the given plain-
1178 \a text. The undo/redo history is reset when this function is called.-
1179-
1180 \sa setHtml()-
1181*/-
1182void QTextDocument::setPlainText(const QString &text)-
1183{-
1184 Q_D(QTextDocument);-
1185 bool previousState = d->isUndoRedoEnabled();-
1186 d->enableUndoRedo(false);-
1187 d->beginEditBlock();-
1188 d->clear();-
1189 QTextCursor(this).insertText(text);-
1190 d->endEditBlock();-
1191 d->enableUndoRedo(previousState);-
1192}
never executed: end of block
0
1193-
1194/*!-
1195 Replaces the entire contents of the document with the given-
1196 HTML-formatted text in the \a html string. The undo/redo history-
1197 is reset when this function is called.-
1198-
1199 The HTML formatting is respected as much as possible; for example,-
1200 "<b>bold</b> text" will produce text where the first word has a font-
1201 weight that gives it a bold appearance: "\b{bold} text".-
1202-
1203 \note It is the responsibility of the caller to make sure that the-
1204 text is correctly decoded when a QString containing HTML is created-
1205 and passed to setHtml().-
1206-
1207 \sa setPlainText(), {Supported HTML Subset}-
1208*/-
1209-
1210#ifndef QT_NO_TEXTHTMLPARSER-
1211-
1212void QTextDocument::setHtml(const QString &html)-
1213{-
1214 Q_D(QTextDocument);-
1215 bool previousState = d->isUndoRedoEnabled();-
1216 d->enableUndoRedo(false);-
1217 d->beginEditBlock();-
1218 d->clear();-
1219 QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import();-
1220 d->endEditBlock();-
1221 d->enableUndoRedo(previousState);-
1222}
never executed: end of block
0
1223-
1224#endif // QT_NO_TEXTHTMLPARSER-
1225-
1226/*!-
1227 \enum QTextDocument::FindFlag-
1228-
1229 This enum describes the options available to QTextDocument's find function. The options-
1230 can be OR-ed together from the following list:-
1231-
1232 \value FindBackward Search backwards instead of forwards.-
1233 \value FindCaseSensitively By default find works case insensitive. Specifying this option-
1234 changes the behaviour to a case sensitive find operation.-
1235 \value FindWholeWords Makes find match only complete words.-
1236*/-
1237-
1238/*!-
1239 \enum QTextDocument::MetaInformation-
1240-
1241 This enum describes the different types of meta information that can be-
1242 added to a document.-
1243-
1244 \value DocumentTitle The title of the document.-
1245 \value DocumentUrl The url of the document. The loadResource() function uses-
1246 this url as the base when loading relative resources.-
1247-
1248 \sa metaInformation(), setMetaInformation()-
1249*/-
1250-
1251static bool findInBlock(const QTextBlock &block, const QString &expression, int offset,-
1252 QTextDocument::FindFlags options, QTextCursor *cursor)-
1253{-
1254 QString text = block.text();-
1255 text.replace(QChar::Nbsp, QLatin1Char(' '));-
1256 Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively ? Qt::CaseSensitive : Qt::CaseInsensitive;
options & QTex...aseSensitivelyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1257 int idx = -1;-
1258-
1259 while (offset >= 0 && offset <= text.length()) {
offset >= 0Description
TRUEnever evaluated
FALSEnever evaluated
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
1260 idx = (options & QTextDocument::FindBackward) ?
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1261 text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity);-
1262 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1263 return false;
never executed: return false;
0
1264-
1265 if (options & QTextDocument::FindWholeWords) {
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1266 const int start = idx;-
1267 const int end = start + expression.length();-
1268 if ((start != 0 && text.at(start - 1).isLetterOrNumber())
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1269 || (end != text.length() && text.at(end).isLetterOrNumber())) {
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1270 //if this is not a whole word, continue the search in the string-
1271 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1272 idx = -1;-
1273 continue;
never executed: continue;
0
1274 }-
1275 }
never executed: end of block
0
1276 //we have a hit, return the cursor for that.-
1277 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
1278 cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor);-
1279 return true;
never executed: return true;
0
1280 }-
1281 return false;
never executed: return false;
0
1282}-
1283-
1284/*!-
1285 \fn QTextCursor QTextDocument::find(const QString &subString, int position, FindFlags options) const-
1286-
1287 \overload-
1288-
1289 Finds the next occurrence of the string, \a subString, in the document.-
1290 The search starts at the given \a position, and proceeds forwards-
1291 through the document unless specified otherwise in the search options.-
1292 The \a options control the type of search performed.-
1293-
1294 Returns a cursor with the match selected if \a subString-
1295 was found; otherwise returns a null cursor.-
1296-
1297 If the \a position is 0 (the default) the search begins from the beginning-
1298 of the document; otherwise it begins at the specified position.-
1299*/-
1300QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags options) const-
1301{-
1302 Q_D(const QTextDocument);-
1303-
1304 if (subString.isEmpty())
subString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1305 return QTextCursor();
never executed: return QTextCursor();
0
1306-
1307 int pos = from;-
1308 //the cursor is positioned between characters, so for a backward search-
1309 //do not include the character given in the position.-
1310 if (options & FindBackward) {
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1311 --pos ;-
1312 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1313 return QTextCursor();
never executed: return QTextCursor();
0
1314 }
never executed: end of block
0
1315-
1316 QTextCursor cursor;-
1317 QTextBlock block = d->blocksFind(pos);-
1318 int blockOffset = pos - block.position();-
1319-
1320 if (!(options & FindBackward)) {
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1321 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1322 if (findInBlock(block, subString, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1323 return cursor;
never executed: return cursor;
0
1324 block = block.next();-
1325 blockOffset = 0;-
1326 }
never executed: end of block
0
1327 } else {
never executed: end of block
0
1328 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1329 if (findInBlock(block, subString, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1330 return cursor;
never executed: return cursor;
0
1331 block = block.previous();-
1332 blockOffset = block.length() - 2;-
1333 }
never executed: end of block
0
1334 }
never executed: end of block
0
1335-
1336 return QTextCursor();
never executed: return QTextCursor();
0
1337}-
1338-
1339/*!-
1340 Finds the next occurrence of the string, \a subString, in the document.-
1341 The search starts at the position of the given \a cursor, and proceeds-
1342 forwards through the document unless specified otherwise in the search-
1343 options. The \a options control the type of search performed.-
1344-
1345 Returns a cursor with the match selected if \a subString was found; otherwise-
1346 returns a null cursor.-
1347-
1348 If the given \a cursor has a selection, the search begins after the-
1349 selection; otherwise it begins at the cursor's position.-
1350-
1351 By default the search is case-sensitive, and can match text anywhere in the-
1352 document.-
1353*/-
1354QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const-
1355{-
1356 int pos = 0;-
1357 if (!cursor.isNull()) {
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1358 if (options & QTextDocument::FindBackward)
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1359 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
1360 else-
1361 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
1362 }-
1363-
1364 return find(subString, pos, options);
never executed: return find(subString, pos, options);
0
1365}-
1366-
1367-
1368#ifndef QT_NO_REGEXP-
1369static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset,-
1370 QTextDocument::FindFlags options, QTextCursor *cursor)-
1371{-
1372 QRegExp expr(expression);-
1373 QString text = block.text();-
1374 text.replace(QChar::Nbsp, QLatin1Char(' '));-
1375-
1376 int idx = -1;-
1377 while (offset >=0 && offset <= text.length()) {
offset >=0Description
TRUEnever evaluated
FALSEnever evaluated
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
1378 idx = (options & QTextDocument::FindBackward) ?
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1379 expr.lastIndexIn(text, offset) : expr.indexIn(text, offset);-
1380 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1381 return false;
never executed: return false;
0
1382-
1383 if (options & QTextDocument::FindWholeWords) {
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1384 const int start = idx;-
1385 const int end = start + expr.matchedLength();-
1386 if ((start != 0 && text.at(start - 1).isLetterOrNumber())
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1387 || (end != text.length() && text.at(end).isLetterOrNumber())) {
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1388 //if this is not a whole word, continue the search in the string-
1389 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1390 idx = -1;-
1391 continue;
never executed: continue;
0
1392 }-
1393 }
never executed: end of block
0
1394 //we have a hit, return the cursor for that.-
1395 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
1396 cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor);-
1397 return true;
never executed: return true;
0
1398 }-
1399 return false;
never executed: return false;
0
1400}-
1401-
1402/*!-
1403 \overload-
1404-
1405 Finds the next occurrence that matches the given regular expression,-
1406 \a expr, within the same paragraph in the document.-
1407-
1408 The search starts at the given \a from position, and proceeds forwards-
1409 through the document unless specified otherwise in the search options.-
1410 The \a options control the type of search performed. The FindCaseSensitively-
1411 option is ignored for this overload, use QRegExp::caseSensitivity instead.-
1412-
1413 Returns a cursor with the match selected if a match was found; otherwise-
1414 returns a null cursor.-
1415-
1416 If the \a from position is 0 (the default) the search begins from the beginning-
1417 of the document; otherwise it begins at the specified position.-
1418*/-
1419QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags options) const-
1420{-
1421 Q_D(const QTextDocument);-
1422-
1423 if (expr.isEmpty())
expr.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1424 return QTextCursor();
never executed: return QTextCursor();
0
1425-
1426 int pos = from;-
1427 //the cursor is positioned between characters, so for a backward search-
1428 //do not include the character given in the position.-
1429 if (options & FindBackward) {
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1430 --pos ;-
1431 if(pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1432 return QTextCursor();
never executed: return QTextCursor();
0
1433 }
never executed: end of block
0
1434-
1435 QTextCursor cursor;-
1436 QTextBlock block = d->blocksFind(pos);-
1437 int blockOffset = pos - block.position();-
1438 if (!(options & FindBackward)) {
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1439 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1440 if (findInBlock(block, expr, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1441 return cursor;
never executed: return cursor;
0
1442 block = block.next();-
1443 blockOffset = 0;-
1444 }
never executed: end of block
0
1445 } else {
never executed: end of block
0
1446 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1447 if (findInBlock(block, expr, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1448 return cursor;
never executed: return cursor;
0
1449 block = block.previous();-
1450 blockOffset = block.length() - 1;-
1451 }
never executed: end of block
0
1452 }
never executed: end of block
0
1453-
1454 return QTextCursor();
never executed: return QTextCursor();
0
1455}-
1456-
1457/*!-
1458 \overload-
1459-
1460 Finds the next occurrence that matches the given regular expression,-
1461 \a expr, within the same paragraph in the document.-
1462-
1463 The search starts at the position of the given from \a cursor, and proceeds-
1464 forwards through the document unless specified otherwise in the search-
1465 options. The \a options control the type of search performed. The FindCaseSensitively-
1466 option is ignored for this overload, use QRegExp::caseSensitivity instead.-
1467-
1468 Returns a cursor with the match selected if a match was found; otherwise-
1469 returns a null cursor.-
1470-
1471 If the given \a cursor has a selection, the search begins after the-
1472 selection; otherwise it begins at the cursor's position.-
1473-
1474 By default the search is case-sensitive, and can match text anywhere in the-
1475 document.-
1476*/-
1477QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const-
1478{-
1479 int pos = 0;-
1480 if (!cursor.isNull()) {
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1481 if (options & QTextDocument::FindBackward)
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1482 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
1483 else-
1484 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
1485 }-
1486 return find(expr, pos, options);
never executed: return find(expr, pos, options);
0
1487}-
1488#endif // QT_REGEXP-
1489-
1490#ifndef QT_NO_REGULAREXPRESSION-
1491static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset,-
1492 QTextDocument::FindFlags options, QTextCursor *cursor)-
1493{-
1494 QRegularExpression expr(expression);-
1495 if (!(options & QTextDocument::FindCaseSensitively))
!(options & QT...seSensitively)Description
TRUEnever evaluated
FALSEnever evaluated
0
1496 expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption);
never executed: expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption);
0
1497 else-
1498 expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
never executed: expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
0
1499-
1500 QString text = block.text();-
1501 text.replace(QChar::Nbsp, QLatin1Char(' '));-
1502 QRegularExpressionMatch match;-
1503 int idx = -1;-
1504-
1505 while (offset >= 0 && offset <= text.length()) {
offset >= 0Description
TRUEnever evaluated
FALSEnever evaluated
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
1506 idx = (options & QTextDocument::FindBackward) ?
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1507 text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match);-
1508 if (idx == -1)
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1509 return false;
never executed: return false;
0
1510-
1511 if (options & QTextDocument::FindWholeWords) {
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1512 const int start = idx;-
1513 const int end = start + match.capturedLength();-
1514 if ((start != 0 && text.at(start - 1).isLetterOrNumber())
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1515 || (end != text.length() && text.at(end).isLetterOrNumber())) {
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1516 //if this is not a whole word, continue the search in the string-
1517 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1;
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1518 idx = -1;-
1519 continue;
never executed: continue;
0
1520 }-
1521 }
never executed: end of block
0
1522 //we have a hit, return the cursor for that.-
1523 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
1524 cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor);-
1525 return true;
never executed: return true;
0
1526 }-
1527 return false;
never executed: return false;
0
1528}-
1529-
1530/*!-
1531 \since 5.5-
1532-
1533 Finds the next occurrence that matches the given regular expression,-
1534 \a expr, within the same paragraph in the document.-
1535-
1536 The search starts at the given \a from position, and proceeds forwards-
1537 through the document unless specified otherwise in the search options.-
1538 The \a options control the type of search performed.-
1539-
1540 Returns a cursor with the match selected if a match was found; otherwise-
1541 returns a null cursor.-
1542-
1543 If the \a from position is 0 (the default) the search begins from the beginning-
1544 of the document; otherwise it begins at the specified position.-
1545*/-
1546QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const-
1547{-
1548 Q_D(const QTextDocument);-
1549-
1550 if (!expr.isValid())
!expr.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1551 return QTextCursor();
never executed: return QTextCursor();
0
1552-
1553 int pos = from;-
1554 //the cursor is positioned between characters, so for a backward search-
1555 //do not include the character given in the position.-
1556 if (options & FindBackward) {
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1557 --pos ;-
1558 if (pos < 0)
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1559 return QTextCursor();
never executed: return QTextCursor();
0
1560 }
never executed: end of block
0
1561-
1562 QTextCursor cursor;-
1563 QTextBlock block = d->blocksFind(pos);-
1564 int blockOffset = pos - block.position();-
1565-
1566 if (!(options & FindBackward)) {
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
0
1567 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1568 if (findInBlock(block, expr, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1569 return cursor;
never executed: return cursor;
0
1570 block = block.next();-
1571 blockOffset = 0;-
1572 }
never executed: end of block
0
1573 } else {
never executed: end of block
0
1574 while (block.isValid()) {
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1575 if (findInBlock(block, expr, blockOffset, options, &cursor))
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
1576 return cursor;
never executed: return cursor;
0
1577 block = block.previous();-
1578 blockOffset = block.length() - 1;-
1579 }
never executed: end of block
0
1580 }
never executed: end of block
0
1581-
1582 return QTextCursor();
never executed: return QTextCursor();
0
1583}-
1584-
1585/*!-
1586 \since 5.5-
1587-
1588 Finds the next occurrence that matches the given regular expression,-
1589 \a expr, within the same paragraph in the document.-
1590-
1591 The search starts at the position of the given \a cursor, and proceeds-
1592 forwards through the document unless specified otherwise in the search-
1593 options. The \a options control the type of search performed.-
1594-
1595 Returns a cursor with the match selected if a match was found; otherwise-
1596 returns a null cursor.-
1597-
1598 If the given \a cursor has a selection, the search begins after the-
1599 selection; otherwise it begins at the cursor's position.-
1600-
1601 By default the search is case-sensitive, and can match text anywhere in the-
1602 document.-
1603*/-
1604QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options) const-
1605{-
1606 int pos = 0;-
1607 if (!cursor.isNull()) {
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1608 if (options & QTextDocument::FindBackward)
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1609 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
1610 else-
1611 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
1612 }-
1613 return find(expr, pos, options);
never executed: return find(expr, pos, options);
0
1614}-
1615#endif // QT_NO_REGULAREXPRESSION-
1616-
1617/*!-
1618 \fn QTextObject *QTextDocument::createObject(const QTextFormat &format)-
1619-
1620 Creates and returns a new document object (a QTextObject), based-
1621 on the given \a format.-
1622-
1623 QTextObjects will always get created through this method, so you-
1624 must reimplement it if you use custom text objects inside your document.-
1625*/-
1626QTextObject *QTextDocument::createObject(const QTextFormat &f)-
1627{-
1628 QTextObject *obj = 0;-
1629 if (f.isListFormat())
f.isListFormat()Description
TRUEnever evaluated
FALSEnever evaluated
0
1630 obj = new QTextList(this);
never executed: obj = new QTextList(this);
0
1631 else if (f.isTableFormat())
f.isTableFormat()Description
TRUEnever evaluated
FALSEnever evaluated
0
1632 obj = new QTextTable(this);
never executed: obj = new QTextTable(this);
0
1633 else if (f.isFrameFormat())
f.isFrameFormat()Description
TRUEnever evaluated
FALSEnever evaluated
0
1634 obj = new QTextFrame(this);
never executed: obj = new QTextFrame(this);
0
1635-
1636 return obj;
never executed: return obj;
0
1637}-
1638-
1639/*!-
1640 \internal-
1641-
1642 Returns the frame that contains the text cursor position \a pos.-
1643*/-
1644QTextFrame *QTextDocument::frameAt(int pos) const-
1645{-
1646 Q_D(const QTextDocument);-
1647 return d->frameAt(pos);
never executed: return d->frameAt(pos);
0
1648}-
1649-
1650/*!-
1651 Returns the document's root frame.-
1652*/-
1653QTextFrame *QTextDocument::rootFrame() const-
1654{-
1655 Q_D(const QTextDocument);-
1656 return d->rootFrame();
never executed: return d->rootFrame();
0
1657}-
1658-
1659/*!-
1660 Returns the text object associated with the given \a objectIndex.-
1661*/-
1662QTextObject *QTextDocument::object(int objectIndex) const-
1663{-
1664 Q_D(const QTextDocument);-
1665 return d->objectForIndex(objectIndex);
never executed: return d->objectForIndex(objectIndex);
0
1666}-
1667-
1668/*!-
1669 Returns the text object associated with the format \a f.-
1670*/-
1671QTextObject *QTextDocument::objectForFormat(const QTextFormat &f) const-
1672{-
1673 Q_D(const QTextDocument);-
1674 return d->objectForFormat(f);
never executed: return d->objectForFormat(f);
0
1675}-
1676-
1677-
1678/*!-
1679 Returns the text block that contains the \a{pos}-th character.-
1680*/-
1681QTextBlock QTextDocument::findBlock(int pos) const-
1682{-
1683 Q_D(const QTextDocument);-
1684 return QTextBlock(docHandle(), d->blockMap().findNode(pos));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(pos));
0
1685}-
1686-
1687/*!-
1688 \since 4.4-
1689 Returns the text block with the specified \a blockNumber.-
1690-
1691 \sa QTextBlock::blockNumber()-
1692*/-
1693QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const-
1694{-
1695 Q_D(const QTextDocument);-
1696 return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
0
1697}-
1698-
1699/*!-
1700 \since 4.5-
1701 Returns the text block that contains the specified \a lineNumber.-
1702-
1703 \sa QTextBlock::firstLineNumber()-
1704*/-
1705QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const-
1706{-
1707 Q_D(const QTextDocument);-
1708 return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
0
1709}-
1710-
1711/*!-
1712 Returns the document's first text block.-
1713-
1714 \sa firstBlock()-
1715*/-
1716QTextBlock QTextDocument::begin() const-
1717{-
1718 Q_D(const QTextDocument);-
1719 return QTextBlock(docHandle(), d->blockMap().begin().n);
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
0
1720}-
1721-
1722/*!-
1723 This function returns a block to test for the end of the document-
1724 while iterating over it.-
1725-
1726 \snippet textdocumentendsnippet.cpp 0-
1727-
1728 The block returned is invalid and represents the block after the-
1729 last block in the document. You can use lastBlock() to retrieve the-
1730 last valid block of the document.-
1731-
1732 \sa lastBlock()-
1733*/-
1734QTextBlock QTextDocument::end() const-
1735{-
1736 return QTextBlock(docHandle(), 0);
never executed: return QTextBlock(docHandle(), 0);
0
1737}-
1738-
1739/*!-
1740 \since 4.4-
1741 Returns the document's first text block.-
1742*/-
1743QTextBlock QTextDocument::firstBlock() const-
1744{-
1745 Q_D(const QTextDocument);-
1746 return QTextBlock(docHandle(), d->blockMap().begin().n);
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
0
1747}-
1748-
1749/*!-
1750 \since 4.4-
1751 Returns the document's last (valid) text block.-
1752*/-
1753QTextBlock QTextDocument::lastBlock() const-
1754{-
1755 Q_D(const QTextDocument);-
1756 return QTextBlock(docHandle(), d->blockMap().last().n);
never executed: return QTextBlock(docHandle(), d->blockMap().last().n);
0
1757}-
1758-
1759/*!-
1760 \property QTextDocument::pageSize-
1761 \brief the page size that should be used for laying out the document-
1762-
1763 The units are determined by the underlying paint device. The size is-
1764 measured in logical pixels when painting to the screen, and in points-
1765 (1/72 inch) when painting to a printer.-
1766-
1767 By default, for a newly-created, empty document, this property contains-
1768 an undefined size.-
1769-
1770 \sa modificationChanged()-
1771*/-
1772-
1773void QTextDocument::setPageSize(const QSizeF &size)-
1774{-
1775 Q_D(QTextDocument);-
1776 d->pageSize = size;-
1777 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1778 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
1779}
never executed: end of block
0
1780-
1781QSizeF QTextDocument::pageSize() const-
1782{-
1783 Q_D(const QTextDocument);-
1784 return d->pageSize;
never executed: return d->pageSize;
0
1785}-
1786-
1787/*!-
1788 returns the number of pages in this document.-
1789*/-
1790int QTextDocument::pageCount() const-
1791{-
1792 return documentLayout()->pageCount();
never executed: return documentLayout()->pageCount();
0
1793}-
1794-
1795/*!-
1796 Sets the default \a font to use in the document layout.-
1797*/-
1798void QTextDocument::setDefaultFont(const QFont &font)-
1799{-
1800 Q_D(QTextDocument);-
1801 d->setDefaultFont(font);-
1802 if (d->lout)
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1803 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
1804}
never executed: end of block
0
1805-
1806/*!-
1807 Returns the default font to be used in the document layout.-
1808*/-
1809QFont QTextDocument::defaultFont() const-
1810{-
1811 Q_D(const QTextDocument);-
1812 return d->defaultFont();
never executed: return d->defaultFont();
0
1813}-
1814-
1815/*!-
1816 \fn QTextDocument::modificationChanged(bool changed)-
1817-
1818 This signal is emitted whenever the content of the document-
1819 changes in a way that affects the modification state. If \a-
1820 changed is true, the document has been modified; otherwise it is-
1821 false.-
1822-
1823 For example, calling setModified(false) on a document and then-
1824 inserting text causes the signal to get emitted. If you undo that-
1825 operation, causing the document to return to its original-
1826 unmodified state, the signal will get emitted again.-
1827*/-
1828-
1829/*!-
1830 \property QTextDocument::modified-
1831 \brief whether the document has been modified by the user-
1832-
1833 By default, this property is \c false.-
1834-
1835 \sa modificationChanged()-
1836*/-
1837-
1838bool QTextDocument::isModified() const-
1839{-
1840 return docHandle()->isModified();
never executed: return docHandle()->isModified();
0
1841}-
1842-
1843void QTextDocument::setModified(bool m)-
1844{-
1845 docHandle()->setModified(m);-
1846}
never executed: end of block
0
1847-
1848#ifndef QT_NO_PRINTER-
1849static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos)-
1850{-
1851 painter->save();-
1852 painter->translate(body.left(), body.top() - (index - 1) * body.height());-
1853 QRectF view(0, (index - 1) * body.height(), body.width(), body.height());-
1854-
1855 QAbstractTextDocumentLayout *layout = doc->documentLayout();-
1856 QAbstractTextDocumentLayout::PaintContext ctx;-
1857-
1858 painter->setClipRect(view);-
1859 ctx.clip = view;-
1860-
1861 // don't use the system palette text as default text color, on HP/UX-
1862 // for example that's white, and white text on white paper doesn't-
1863 // look that nice-
1864 ctx.palette.setColor(QPalette::Text, Qt::black);-
1865-
1866 layout->draw(painter, ctx);-
1867-
1868 if (!pageNumberPos.isNull()) {
!pageNumberPos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1869 painter->setClipping(false);-
1870 painter->setFont(QFont(doc->defaultFont()));-
1871 const QString pageString = QString::number(index);-
1872-
1873 painter->drawText(qRound(pageNumberPos.x() - painter->fontMetrics().width(pageString)),-
1874 qRound(pageNumberPos.y() + view.top()),-
1875 pageString);-
1876 }
never executed: end of block
0
1877-
1878 painter->restore();-
1879}
never executed: end of block
0
1880-
1881/*!-
1882 Prints the document to the given \a printer. The QPageablePaintDevice must be-
1883 set up before being used with this function.-
1884-
1885 This is only a convenience method to print the whole document to the printer.-
1886-
1887 If the document is already paginated through a specified height in the pageSize()-
1888 property it is printed as-is.-
1889-
1890 If the document is not paginated, like for example a document used in a QTextEdit,-
1891 then a temporary copy of the document is created and the copy is broken into-
1892 multiple pages according to the size of the paint device's paperRect(). By default-
1893 a 2 cm margin is set around the document contents. In addition the current page-
1894 number is printed at the bottom of each page.-
1895-
1896 \sa QTextEdit::print()-
1897*/-
1898-
1899void QTextDocument::print(QPagedPaintDevice *printer) const-
1900{-
1901 Q_D(const QTextDocument);-
1902-
1903 if (!printer)
!printerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1904 return;
never executed: return;
0
1905-
1906 bool documentPaginated = d->pageSize.isValid() && !d->pageSize.isNull()
d->pageSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
!d->pageSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1907 && d->pageSize.height() != INT_MAX;
d->pageSize.he... != 2147483647Description
TRUEnever evaluated
FALSEnever evaluated
0
1908-
1909 QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer);-
1910-
1911 // ### set page size to paginated size?-
1912 QPagedPaintDevice::Margins m = printer->margins();-
1913 if (!documentPaginated && m.left == 0. && m.right == 0. && m.top == 0. && m.bottom == 0.) {
!documentPaginatedDescription
TRUEnever evaluated
FALSEnever evaluated
m.left == 0.Description
TRUEnever evaluated
FALSEnever evaluated
m.right == 0.Description
TRUEnever evaluated
FALSEnever evaluated
m.top == 0.Description
TRUEnever evaluated
FALSEnever evaluated
m.bottom == 0.Description
TRUEnever evaluated
FALSEnever evaluated
0
1914 m.left = m.right = m.top = m.bottom = 2.;-
1915 printer->setMargins(m);-
1916 }
never executed: end of block
0
1917 // ### use the margins correctly-
1918-
1919 QPainter p(printer);-
1920-
1921 // Check that there is a valid device to print to.-
1922 if (!p.isActive())
!p.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1923 return;
never executed: return;
0
1924-
1925 const QTextDocument *doc = this;-
1926 QScopedPointer<QTextDocument> clonedDoc;-
1927 (void)doc->documentLayout(); // make sure that there is a layout-
1928-
1929 QRectF body = QRectF(QPointF(0, 0), d->pageSize);-
1930 QPointF pageNumberPos;-
1931-
1932 if (documentPaginated) {
documentPaginatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1933 qreal sourceDpiX = qt_defaultDpi();-
1934 qreal sourceDpiY = sourceDpiX;-
1935-
1936 QPaintDevice *dev = doc->documentLayout()->paintDevice();-
1937 if (dev) {
devDescription
TRUEnever evaluated
FALSEnever evaluated
0
1938 sourceDpiX = dev->logicalDpiX();-
1939 sourceDpiY = dev->logicalDpiY();-
1940 }
never executed: end of block
0
1941-
1942 const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;-
1943 const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;-
1944-
1945 // scale to dpi-
1946 p.scale(dpiScaleX, dpiScaleY);-
1947-
1948 QSizeF scaledPageSize = d->pageSize;-
1949 scaledPageSize.rwidth() *= dpiScaleX;-
1950 scaledPageSize.rheight() *= dpiScaleY;-
1951-
1952 const QSizeF printerPageSize(printer->width(), printer->height());-
1953-
1954 // scale to page-
1955 p.scale(printerPageSize.width() / scaledPageSize.width(),-
1956 printerPageSize.height() / scaledPageSize.height());-
1957 } else {
never executed: end of block
0
1958 doc = clone(const_cast<QTextDocument *>(this));-
1959 clonedDoc.reset(const_cast<QTextDocument *>(doc));-
1960-
1961 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock();-
1962 srcBlock.isValid() && dstBlock.isValid();
srcBlock.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
dstBlock.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1963 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {-
1964 dstBlock.layout()->setFormats(srcBlock.layout()->formats());-
1965 }
never executed: end of block
0
1966-
1967 QAbstractTextDocumentLayout *layout = doc->documentLayout();-
1968 layout->setPaintDevice(p.device());-
1969-
1970 // copy the custom object handlers-
1971 layout->d_func()->handlers = documentLayout()->d_func()->handlers;-
1972-
1973 int dpiy = p.device()->logicalDpiY();-
1974 int margin = (int) ((2/2.54)*dpiy); // 2 cm margins-
1975 QTextFrameFormat fmt = doc->rootFrame()->frameFormat();-
1976 fmt.setMargin(margin);-
1977 doc->rootFrame()->setFrameFormat(fmt);-
1978-
1979 body = QRectF(0, 0, printer->width(), printer->height());-
1980 pageNumberPos = QPointF(body.width() - margin,-
1981 body.height() - margin-
1982 + QFontMetrics(doc->defaultFont(), p.device()).ascent()-
1983 + 5 * dpiy / 72.0);-
1984 clonedDoc->setPageSize(body.size());-
1985 }
never executed: end of block
0
1986-
1987 int fromPage = pd->fromPage;-
1988 int toPage = pd->toPage;-
1989 bool ascending = true;-
1990-
1991 if (fromPage == 0 && toPage == 0) {
fromPage == 0Description
TRUEnever evaluated
FALSEnever evaluated
toPage == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1992 fromPage = 1;-
1993 toPage = doc->pageCount();-
1994 }
never executed: end of block
0
1995 // paranoia check-
1996 fromPage = qMax(1, fromPage);-
1997 toPage = qMin(doc->pageCount(), toPage);-
1998-
1999 if (toPage < fromPage) {
toPage < fromPageDescription
TRUEnever evaluated
FALSEnever evaluated
0
2000 // if the user entered a page range outside the actual number-
2001 // of printable pages, just return-
2002 return;
never executed: return;
0
2003 }-
2004-
2005// if (printer->pageOrder() == QPrinter::LastPageFirst) {-
2006// int tmp = fromPage;-
2007// fromPage = toPage;-
2008// toPage = tmp;-
2009// ascending = false;-
2010// }-
2011-
2012 int page = fromPage;-
2013 while (true) {-
2014 printPage(page, &p, doc, body, pageNumberPos);-
2015-
2016 if (page == toPage)
page == toPageDescription
TRUEnever evaluated
FALSEnever evaluated
0
2017 break;
never executed: break;
0
2018-
2019 if (ascending)
ascendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2020 ++page;
never executed: ++page;
0
2021 else-
2022 --page;
never executed: --page;
0
2023-
2024 if (!printer->newPage())
!printer->newPage()Description
TRUEnever evaluated
FALSEnever evaluated
0
2025 return;
never executed: return;
0
2026 }
never executed: end of block
0
2027}
never executed: end of block
0
2028#endif-
2029-
2030/*!-
2031 \enum QTextDocument::ResourceType-
2032-
2033 This enum describes the types of resources that can be loaded by-
2034 QTextDocument's loadResource() function.-
2035-
2036 \value HtmlResource The resource contains HTML.-
2037 \value ImageResource The resource contains image data.-
2038 Currently supported data types are QVariant::Pixmap and-
2039 QVariant::Image. If the corresponding variant is of type-
2040 QVariant::ByteArray then Qt attempts to load the image using-
2041 QImage::loadFromData. QVariant::Icon is currently not supported.-
2042 The icon needs to be converted to one of the supported types first,-
2043 for example using QIcon::pixmap.-
2044 \value StyleSheetResource The resource contains CSS.-
2045 \value UserResource The first available value for user defined-
2046 resource types.-
2047-
2048 \sa loadResource()-
2049*/-
2050-
2051/*!-
2052 Returns data of the specified \a type from the resource with the-
2053 given \a name.-
2054-
2055 This function is called by the rich text engine to request data that isn't-
2056 directly stored by QTextDocument, but still associated with it. For example,-
2057 images are referenced indirectly by the name attribute of a QTextImageFormat-
2058 object.-
2059-
2060 Resources are cached internally in the document. If a resource can-
2061 not be found in the cache, loadResource is called to try to load-
2062 the resource. loadResource should then use addResource to add the-
2063 resource to the cache.-
2064-
2065 \sa QTextDocument::ResourceType-
2066*/-
2067QVariant QTextDocument::resource(int type, const QUrl &name) const-
2068{-
2069 Q_D(const QTextDocument);-
2070 const QUrl url = d->baseUrl.resolved(name);-
2071 QVariant r = d->resources.value(url);-
2072 if (!r.isValid()) {
!r.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2073 r = d->cachedResources.value(url);-
2074 if (!r.isValid())
!r.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2075 r = const_cast<QTextDocument *>(this)->loadResource(type, url);
never executed: r = const_cast<QTextDocument *>(this)->loadResource(type, url);
0
2076 }
never executed: end of block
0
2077 return r;
never executed: return r;
0
2078}-
2079-
2080/*!-
2081 Adds the resource \a resource to the resource cache, using \a-
2082 type and \a name as identifiers. \a type should be a value from-
2083 QTextDocument::ResourceType.-
2084-
2085 For example, you can add an image as a resource in order to reference it-
2086 from within the document:-
2087-
2088 \snippet textdocument-resources/main.cpp Adding a resource-
2089-
2090 The image can be inserted into the document using the QTextCursor API:-
2091-
2092 \snippet textdocument-resources/main.cpp Inserting an image with a cursor-
2093-
2094 Alternatively, you can insert images using the HTML \c img tag:-
2095-
2096 \snippet textdocument-resources/main.cpp Inserting an image using HTML-
2097*/-
2098void QTextDocument::addResource(int type, const QUrl &name, const QVariant &resource)-
2099{-
2100 Q_UNUSED(type);-
2101 Q_D(QTextDocument);-
2102 d->resources.insert(name, resource);-
2103}
never executed: end of block
0
2104-
2105/*!-
2106 Loads data of the specified \a type from the resource with the-
2107 given \a name.-
2108-
2109 This function is called by the rich text engine to request data that isn't-
2110 directly stored by QTextDocument, but still associated with it. For example,-
2111 images are referenced indirectly by the name attribute of a QTextImageFormat-
2112 object.-
2113-
2114 When called by Qt, \a type is one of the values of-
2115 QTextDocument::ResourceType.-
2116-
2117 If the QTextDocument is a child object of a QObject that has an invokable-
2118 loadResource method such as QTextEdit, QTextBrowser-
2119 or a QTextDocument itself then the default implementation tries-
2120 to retrieve the data from the parent.-
2121*/-
2122QVariant QTextDocument::loadResource(int type, const QUrl &name)-
2123{-
2124 Q_D(QTextDocument);-
2125 QVariant r;-
2126-
2127 QObject *p = parent();-
2128 if (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
2129 const QMetaObject *me = p->metaObject();-
2130 int index = me->indexOfMethod("loadResource(int,QUrl)");-
2131 if (index >= 0) {
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2132 QMetaMethod loader = me->method(index);-
2133 loader.invoke(p, Q_RETURN_ARG(QVariant, r), Q_ARG(int, type), Q_ARG(QUrl, name));-
2134 }
never executed: end of block
0
2135 }
never executed: end of block
0
2136-
2137 // handle data: URLs-
2138 if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) {
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
name.scheme()....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2139 QString mimetype;-
2140 QByteArray payload;-
2141 if (qDecodeDataUrl(name, mimetype, payload))
qDecodeDataUrl...type, payload)Description
TRUEnever evaluated
FALSEnever evaluated
0
2142 r = payload;
never executed: r = payload;
0
2143 }
never executed: end of block
0
2144-
2145 // if resource was not loaded try to load it here-
2146 if (!qobject_cast<QTextDocument *>(p) && r.isNull()) {
!qobject_cast<...Document *>(p)Description
TRUEnever evaluated
FALSEnever evaluated
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2147 QUrl resourceUrl = name;-
2148-
2149 if (name.isRelative()) {
name.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
0
2150 QUrl currentURL = d->url;-
2151 // For the second case QUrl can merge "#someanchor" with "foo.html"-
2152 // correctly to "foo.html#someanchor"-
2153 if (!(currentURL.isRelative()
currentURL.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
0
2154 || (currentURL.scheme() == QLatin1String("file")
currentURL.sch...String("file")Description
TRUEnever evaluated
FALSEnever evaluated
0
2155 && !QFileInfo(currentURL.toLocalFile()).isAbsolute()))
!QFileInfo(cur...).isAbsolute()Description
TRUEnever evaluated
FALSEnever evaluated
0
2156 || (name.hasFragment() && name.path().isEmpty())) {
name.hasFragment()Description
TRUEnever evaluated
FALSEnever evaluated
name.path().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2157 resourceUrl = currentURL.resolved(name);-
2158 } else {
never executed: end of block
0
2159 // this is our last resort when current url and new url are both relative-
2160 // we try to resolve against the current working directory in the local-
2161 // file system.-
2162 QFileInfo fi(currentURL.toLocalFile());-
2163 if (fi.exists()) {
fi.exists()Description
TRUEnever evaluated
FALSEnever evaluated
0
2164 resourceUrl =-
2165 QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name);-
2166 } else if (currentURL.isEmpty()) {
never executed: end of block
currentURL.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2167 resourceUrl.setScheme(QLatin1String("file"));-
2168 }
never executed: end of block
0
2169 }
never executed: end of block
0
2170 }-
2171-
2172 QString s = resourceUrl.toLocalFile();-
2173 QFile f(s);-
2174 if (!s.isEmpty() && f.open(QFile::ReadOnly)) {
!s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
f.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
0
2175 r = f.readAll();-
2176 f.close();-
2177 }
never executed: end of block
0
2178 }
never executed: end of block
0
2179-
2180 if (!r.isNull()) {
!r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2181 if (type == ImageResource && r.type() == QVariant::ByteArray) {
type == ImageResourceDescription
TRUEnever evaluated
FALSEnever evaluated
r.type() == QV...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
0
2182 if (qApp->thread() != QThread::currentThread()) {
QCoreApplicati...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
0
2183 // must use images in non-GUI threads-
2184 QImage image;-
2185 image.loadFromData(r.toByteArray());-
2186 if (!image.isNull())
!image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2187 r = image;
never executed: r = image;
0
2188 } else {
never executed: end of block
0
2189 QPixmap pm;-
2190 pm.loadFromData(r.toByteArray());-
2191 if (!pm.isNull())
!pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2192 r = pm;
never executed: r = pm;
0
2193 }
never executed: end of block
0
2194 }-
2195 d->cachedResources.insert(name, r);-
2196 }
never executed: end of block
0
2197 return r;
never executed: return r;
0
2198}-
2199-
2200static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to)-
2201{-
2202 QTextFormat diff = to;-
2203-
2204 const QMap<int, QVariant> props = to.properties();-
2205 for (QMap<int, QVariant>::ConstIterator it = props.begin(), end = props.end();-
2206 it != end; ++it)
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
2207 if (it.value() == from.property(it.key()))
it.value() == ...erty(it.key())Description
TRUEnever evaluated
FALSEnever evaluated
0
2208 diff.clearProperty(it.key());
never executed: diff.clearProperty(it.key());
0
2209-
2210 return diff;
never executed: return diff;
0
2211}-
2212-
2213static QString colorValue(QColor color)-
2214{-
2215 QString result;-
2216-
2217 if (color.alpha() == 255) {
color.alpha() == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2218 result = color.name();-
2219 } else if (color.alpha()) {
never executed: end of block
color.alpha()Description
TRUEnever evaluated
FALSEnever evaluated
0
2220 QString alphaValue = QString::number(color.alphaF(), 'f', 6).remove(QRegExp(QLatin1String("\\.?0*$")));-
2221 result = QString::fromLatin1("rgba(%1,%2,%3,%4)").arg(color.red())-
2222 .arg(color.green())-
2223 .arg(color.blue())-
2224 .arg(alphaValue);-
2225 } else {
never executed: end of block
0
2226 result = QLatin1String("transparent");-
2227 }
never executed: end of block
0
2228-
2229 return result;
never executed: return result;
0
2230}-
2231-
2232QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc)-
2233 : doc(_doc), fragmentMarkers(false)-
2234{-
2235 const QFont defaultFont = doc->defaultFont();-
2236 defaultCharFormat.setFont(defaultFont);-
2237 // don't export those for the default font since we cannot turn them off with CSS-
2238 defaultCharFormat.clearProperty(QTextFormat::FontUnderline);-
2239 defaultCharFormat.clearProperty(QTextFormat::FontOverline);-
2240 defaultCharFormat.clearProperty(QTextFormat::FontStrikeOut);-
2241 defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle);-
2242}
never executed: end of block
0
2243-
2244/*!-
2245 Returns the document in HTML format. The conversion may not be-
2246 perfect, especially for complex documents, due to the limitations-
2247 of HTML.-
2248*/-
2249QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode)-
2250{-
2251 html = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "-
2252 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"-
2253 "<html><head><meta name=\"qrichtext\" content=\"1\" />");-
2254 html.reserve(doc->docHandle()->length());-
2255-
2256 fragmentMarkers = (mode == ExportFragment);-
2257-
2258 if (!encoding.isEmpty())
!encoding.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2259 html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding));
never executed: html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding));
0
2260-
2261 QString title = doc->metaInformation(QTextDocument::DocumentTitle);-
2262 if (!title.isEmpty())
!title.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2263 html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>");
never executed: html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>");
0
2264 html += QLatin1String("<style type=\"text/css\">\n");-
2265 html += QLatin1String("p, li { white-space: pre-wrap; }\n");-
2266 html += QLatin1String("</style>");-
2267 html += QLatin1String("</head><body");-
2268-
2269 if (mode == ExportEntireDocument) {
mode == ExportEntireDocumentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2270 html += QLatin1String(" style=\"");-
2271-
2272 emitFontFamily(defaultCharFormat.fontFamily());-
2273-
2274 if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) {
defaultCharFor...FontPointSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2275 html += QLatin1String(" font-size:");-
2276 html += QString::number(defaultCharFormat.fontPointSize());-
2277 html += QLatin1String("pt;");-
2278 } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) {
never executed: end of block
defaultCharFor...FontPixelSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2279 html += QLatin1String(" font-size:");-
2280 html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize));-
2281 html += QLatin1String("px;");-
2282 }
never executed: end of block
0
2283-
2284 html += QLatin1String(" font-weight:");-
2285 html += QString::number(defaultCharFormat.fontWeight() * 8);-
2286 html += QLatin1Char(';');-
2287-
2288 html += QLatin1String(" font-style:");-
2289 html += (defaultCharFormat.fontItalic() ? QLatin1String("italic") : QLatin1String("normal"));
defaultCharFormat.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
0
2290 html += QLatin1Char(';');-
2291-
2292 // do not set text-decoration on the default font since those values are /always/ propagated-
2293 // and cannot be turned off with CSS-
2294-
2295 html += QLatin1Char('\"');-
2296-
2297 const QTextFrameFormat fmt = doc->rootFrame()->frameFormat();-
2298 emitBackgroundAttribute(fmt);-
2299-
2300 } else {
never executed: end of block
0
2301 defaultCharFormat = QTextCharFormat();-
2302 }
never executed: end of block
0
2303 html += QLatin1Char('>');-
2304-
2305 QTextFrameFormat rootFmt = doc->rootFrame()->frameFormat();-
2306 rootFmt.clearProperty(QTextFormat::BackgroundBrush);-
2307-
2308 QTextFrameFormat defaultFmt;-
2309 defaultFmt.setMargin(doc->documentMargin());-
2310-
2311 if (rootFmt == defaultFmt)
rootFmt == defaultFmtDescription
TRUEnever evaluated
FALSEnever evaluated
0
2312 emitFrame(doc->rootFrame()->begin());
never executed: emitFrame(doc->rootFrame()->begin());
0
2313 else-
2314 emitTextFrame(doc->rootFrame());
never executed: emitTextFrame(doc->rootFrame());
0
2315-
2316 html += QLatin1String("</body></html>");-
2317 return html;
never executed: return html;
0
2318}-
2319-
2320void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value)-
2321{-
2322 html += QLatin1Char(' ');-
2323 html += QLatin1String(attribute);-
2324 html += QLatin1String("=\"");-
2325 html += value.toHtmlEscaped();-
2326 html += QLatin1Char('"');-
2327}
never executed: end of block
0
2328-
2329bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)-
2330{-
2331 bool attributesEmitted = false;-
2332-
2333 {-
2334 const QString family = format.fontFamily();-
2335 if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) {
!family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
family != defa...t.fontFamily()Description
TRUEnever evaluated
FALSEnever evaluated
0
2336 emitFontFamily(family);-
2337 attributesEmitted = true;-
2338 }
never executed: end of block
0
2339 }-
2340-
2341 if (format.hasProperty(QTextFormat::FontPointSize)
format.hasProp...FontPointSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2342 && format.fontPointSize() != defaultCharFormat.fontPointSize()) {
format.fontPoi...ontPointSize()Description
TRUEnever evaluated
FALSEnever evaluated
0
2343 html += QLatin1String(" font-size:");-
2344 html += QString::number(format.fontPointSize());-
2345 html += QLatin1String("pt;");-
2346 attributesEmitted = true;-
2347 } else if (format.hasProperty(QTextFormat::FontSizeAdjustment)) {
never executed: end of block
format.hasProp...izeAdjustment)Description
TRUEnever evaluated
FALSEnever evaluated
0
2348 static const char sizeNameData[] =-
2349 "small" "\0"-
2350 "medium" "\0"-
2351 "xx-large" ;-
2352 static const quint8 sizeNameOffsets[] = {-
2353 0, // "small"-
2354 sizeof("small"), // "medium"-
2355 sizeof("small") + sizeof("medium") + 3, // "large" )-
2356 sizeof("small") + sizeof("medium") + 1, // "x-large" )> compressed into "xx-large"-
2357 sizeof("small") + sizeof("medium"), // "xx-large" )-
2358 };-
2359 const char *name = 0;-
2360 const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1;-
2361 if (idx >= 0 && idx <= 4) {
idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
idx <= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
2362 name = sizeNameData + sizeNameOffsets[idx];-
2363 }
never executed: end of block
0
2364 if (name) {
nameDescription
TRUEnever evaluated
FALSEnever evaluated
0
2365 html += QLatin1String(" font-size:");-
2366 html += QLatin1String(name);-
2367 html += QLatin1Char(';');-
2368 attributesEmitted = true;-
2369 }
never executed: end of block
0
2370 } else if (format.hasProperty(QTextFormat::FontPixelSize)) {
never executed: end of block
format.hasProp...FontPixelSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
2371 html += QLatin1String(" font-size:");-
2372 html += QString::number(format.intProperty(QTextFormat::FontPixelSize));-
2373 html += QLatin1String("px;");-
2374 attributesEmitted = true;-
2375 }
never executed: end of block
0
2376-
2377 if (format.hasProperty(QTextFormat::FontWeight)
format.hasProp...t::FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
2378 && format.fontWeight() != defaultCharFormat.fontWeight()) {
format.fontWei...t.fontWeight()Description
TRUEnever evaluated
FALSEnever evaluated
0
2379 html += QLatin1String(" font-weight:");-
2380 html += QString::number(format.fontWeight() * 8);-
2381 html += QLatin1Char(';');-
2382 attributesEmitted = true;-
2383 }
never executed: end of block
0
2384-
2385 if (format.hasProperty(QTextFormat::FontItalic)
format.hasProp...t::FontItalic)Description
TRUEnever evaluated
FALSEnever evaluated
0
2386 && format.fontItalic() != defaultCharFormat.fontItalic()) {
format.fontIta...t.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
0
2387 html += QLatin1String(" font-style:");-
2388 html += (format.fontItalic() ? QLatin1String("italic") : QLatin1String("normal"));
format.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
0
2389 html += QLatin1Char(';');-
2390 attributesEmitted = true;-
2391 }
never executed: end of block
0
2392-
2393 QLatin1String decorationTag(" text-decoration:");-
2394 html += decorationTag;-
2395 bool hasDecoration = false;-
2396 bool atLeastOneDecorationSet = false;-
2397-
2398 if ((format.hasProperty(QTextFormat::FontUnderline) || format.hasProperty(QTextFormat::TextUnderlineStyle))
format.hasProp...FontUnderline)Description
TRUEnever evaluated
FALSEnever evaluated
format.hasProp...nderlineStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
2399 && format.fontUnderline() != defaultCharFormat.fontUnderline()) {
format.fontUnd...ontUnderline()Description
TRUEnever evaluated
FALSEnever evaluated
0
2400 hasDecoration = true;-
2401 if (format.fontUnderline()) {
format.fontUnderline()Description
TRUEnever evaluated
FALSEnever evaluated
0
2402 html += QLatin1String(" underline");-
2403 atLeastOneDecorationSet = true;-
2404 }
never executed: end of block
0
2405 }
never executed: end of block
0
2406-
2407 if (format.hasProperty(QTextFormat::FontOverline)
format.hasProp...:FontOverline)Description
TRUEnever evaluated
FALSEnever evaluated
0
2408 && format.fontOverline() != defaultCharFormat.fontOverline()) {
format.fontOve...fontOverline()Description
TRUEnever evaluated
FALSEnever evaluated
0
2409 hasDecoration = true;-
2410 if (format.fontOverline()) {
format.fontOverline()Description
TRUEnever evaluated
FALSEnever evaluated
0
2411 html += QLatin1String(" overline");-
2412 atLeastOneDecorationSet = true;-
2413 }
never executed: end of block
0
2414 }
never executed: end of block
0
2415-
2416 if (format.hasProperty(QTextFormat::FontStrikeOut)
format.hasProp...FontStrikeOut)Description
TRUEnever evaluated
FALSEnever evaluated
0
2417 && format.fontStrikeOut() != defaultCharFormat.fontStrikeOut()) {
format.fontStr...ontStrikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
0
2418 hasDecoration = true;-
2419 if (format.fontStrikeOut()) {
format.fontStrikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
0
2420 html += QLatin1String(" line-through");-
2421 atLeastOneDecorationSet = true;-
2422 }
never executed: end of block
0
2423 }
never executed: end of block
0
2424-
2425 if (hasDecoration) {
hasDecorationDescription
TRUEnever evaluated
FALSEnever evaluated
0
2426 if (!atLeastOneDecorationSet)
!atLeastOneDecorationSetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2427 html += QLatin1String("none");
never executed: html += QLatin1String("none");
0
2428 html += QLatin1Char(';');-
2429 attributesEmitted = true;-
2430 } else {
never executed: end of block
0
2431 html.chop(qstrlen(decorationTag.latin1()));-
2432 }
never executed: end of block
0
2433-
2434 if (format.foreground() != defaultCharFormat.foreground()
format.foregro...t.foreground()Description
TRUEnever evaluated
FALSEnever evaluated
0
2435 && format.foreground().style() != Qt::NoBrush) {
format.foregro...!= Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
2436 html += QLatin1String(" color:");-
2437 html += colorValue(format.foreground().color());-
2438 html += QLatin1Char(';');-
2439 attributesEmitted = true;-
2440 }
never executed: end of block
0
2441-
2442 if (format.background() != defaultCharFormat.background()
format.backgro...t.background()Description
TRUEnever evaluated
FALSEnever evaluated
0
2443 && format.background().style() == Qt::SolidPattern) {
format.backgro...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
2444 html += QLatin1String(" background-color:");-
2445 html += colorValue(format.background().color());-
2446 html += QLatin1Char(';');-
2447 attributesEmitted = true;-
2448 }
never executed: end of block
0
2449-
2450 if (format.verticalAlignment() != defaultCharFormat.verticalAlignment()
format.vertica...calAlignment()Description
TRUEnever evaluated
FALSEnever evaluated
0
2451 && format.verticalAlignment() != QTextCharFormat::AlignNormal)
format.vertica...t::AlignNormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2452 {-
2453 html += QLatin1String(" vertical-align:");-
2454-
2455 QTextCharFormat::VerticalAlignment valign = format.verticalAlignment();-
2456 if (valign == QTextCharFormat::AlignSubScript)
valign == QTex...AlignSubScriptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2457 html += QLatin1String("sub");
never executed: html += QLatin1String("sub");
0
2458 else if (valign == QTextCharFormat::AlignSuperScript)
valign == QTex...ignSuperScriptDescription
TRUEnever evaluated
FALSEnever evaluated
0
2459 html += QLatin1String("super");
never executed: html += QLatin1String("super");
0
2460 else if (valign == QTextCharFormat::AlignMiddle)
valign == QTex...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2461 html += QLatin1String("middle");
never executed: html += QLatin1String("middle");
0
2462 else if (valign == QTextCharFormat::AlignTop)
valign == QTex...rmat::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
2463 html += QLatin1String("top");
never executed: html += QLatin1String("top");
0
2464 else if (valign == QTextCharFormat::AlignBottom)
valign == QTex...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
2465 html += QLatin1String("bottom");
never executed: html += QLatin1String("bottom");
0
2466-
2467 html += QLatin1Char(';');-
2468 attributesEmitted = true;-
2469 }
never executed: end of block
0
2470-
2471 if (format.fontCapitalization() != QFont::MixedCase) {
format.fontCap...ont::MixedCaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2472 const QFont::Capitalization caps = format.fontCapitalization();-
2473 if (caps == QFont::AllUppercase)
caps == QFont::AllUppercaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2474 html += QLatin1String(" text-transform:uppercase;");
never executed: html += QLatin1String(" text-transform:uppercase;");
0
2475 else if (caps == QFont::AllLowercase)
caps == QFont::AllLowercaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
2476 html += QLatin1String(" text-transform:lowercase;");
never executed: html += QLatin1String(" text-transform:lowercase;");
0
2477 else if (caps == QFont::SmallCaps)
caps == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2478 html += QLatin1String(" font-variant:small-caps;");
never executed: html += QLatin1String(" font-variant:small-caps;");
0
2479 attributesEmitted = true;-
2480 }
never executed: end of block
0
2481-
2482 if (format.fontWordSpacing() != 0.0) {
format.fontWor...acing() != 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
2483 html += QLatin1String(" word-spacing:");-
2484 html += QString::number(format.fontWordSpacing());-
2485 html += QLatin1String("px;");-
2486 attributesEmitted = true;-
2487 }
never executed: end of block
0
2488-
2489 return attributesEmitted;
never executed: return attributesEmitted;
0
2490}-
2491-
2492void QTextHtmlExporter::emitTextLength(const char *attribute, const QTextLength &length)-
2493{-
2494 if (length.type() == QTextLength::VariableLength) // default
length.type() ...VariableLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2495 return;
never executed: return;
0
2496-
2497 html += QLatin1Char(' ');-
2498 html += QLatin1String(attribute);-
2499 html += QLatin1String("=\"");-
2500 html += QString::number(length.rawValue());-
2501-
2502 if (length.type() == QTextLength::PercentageLength)
length.type() ...rcentageLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2503 html += QLatin1String("%\"");
never executed: html += QLatin1String("%\"");
0
2504 else-
2505 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
2506}-
2507-
2508void QTextHtmlExporter::emitAlignment(Qt::Alignment align)-
2509{-
2510 if (align & Qt::AlignLeft)
align & Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2511 return;
never executed: return;
0
2512 else if (align & Qt::AlignRight)
align & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2513 html += QLatin1String(" align=\"right\"");
never executed: html += QLatin1String(" align=\"right\"");
0
2514 else if (align & Qt::AlignHCenter)
align & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
2515 html += QLatin1String(" align=\"center\"");
never executed: html += QLatin1String(" align=\"center\"");
0
2516 else if (align & Qt::AlignJustify)
align & Qt::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2517 html += QLatin1String(" align=\"justify\"");
never executed: html += QLatin1String(" align=\"justify\"");
0
2518}
never executed: end of block
0
2519-
2520void QTextHtmlExporter::emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode)-
2521{-
2522 if (pos == QTextFrameFormat::InFlow)
pos == QTextFr...Format::InFlowDescription
TRUEnever evaluated
FALSEnever evaluated
0
2523 return;
never executed: return;
0
2524-
2525 if (mode == EmitStyleTag)
mode == EmitStyleTagDescription
TRUEnever evaluated
FALSEnever evaluated
0
2526 html += QLatin1String(" style=\"float:");
never executed: html += QLatin1String(" style=\"float:");
0
2527 else-
2528 html += QLatin1String(" float:");
never executed: html += QLatin1String(" float:");
0
2529-
2530 if (pos == QTextFrameFormat::FloatLeft)
pos == QTextFr...mat::FloatLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2531 html += QLatin1String(" left;");
never executed: html += QLatin1String(" left;");
0
2532 else if (pos == QTextFrameFormat::FloatRight)
pos == QTextFr...at::FloatRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2533 html += QLatin1String(" right;");
never executed: html += QLatin1String(" right;");
0
2534 else-
2535 Q_ASSERT_X(0, "QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type");
never executed: ((!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2535) : qt_noop());
0
2536-
2537 if (mode == EmitStyleTag)
mode == EmitStyleTagDescription
TRUEnever evaluated
FALSEnever evaluated
0
2538 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
2539}
never executed: end of block
0
2540-
2541void QTextHtmlExporter::emitBorderStyle(QTextFrameFormat::BorderStyle style)-
2542{-
2543 Q_ASSERT(style <= QTextFrameFormat::BorderStyle_Outset);-
2544-
2545 html += QLatin1String(" border-style:");-
2546-
2547 switch (style) {-
2548 case QTextFrameFormat::BorderStyle_None:
never executed: case QTextFrameFormat::BorderStyle_None:
0
2549 html += QLatin1String("none");-
2550 break;
never executed: break;
0
2551 case QTextFrameFormat::BorderStyle_Dotted:
never executed: case QTextFrameFormat::BorderStyle_Dotted:
0
2552 html += QLatin1String("dotted");-
2553 break;
never executed: break;
0
2554 case QTextFrameFormat::BorderStyle_Dashed:
never executed: case QTextFrameFormat::BorderStyle_Dashed:
0
2555 html += QLatin1String("dashed");-
2556 break;
never executed: break;
0
2557 case QTextFrameFormat::BorderStyle_Solid:
never executed: case QTextFrameFormat::BorderStyle_Solid:
0
2558 html += QLatin1String("solid");-
2559 break;
never executed: break;
0
2560 case QTextFrameFormat::BorderStyle_Double:
never executed: case QTextFrameFormat::BorderStyle_Double:
0
2561 html += QLatin1String("double");-
2562 break;
never executed: break;
0
2563 case QTextFrameFormat::BorderStyle_DotDash:
never executed: case QTextFrameFormat::BorderStyle_DotDash:
0
2564 html += QLatin1String("dot-dash");-
2565 break;
never executed: break;
0
2566 case QTextFrameFormat::BorderStyle_DotDotDash:
never executed: case QTextFrameFormat::BorderStyle_DotDotDash:
0
2567 html += QLatin1String("dot-dot-dash");-
2568 break;
never executed: break;
0
2569 case QTextFrameFormat::BorderStyle_Groove:
never executed: case QTextFrameFormat::BorderStyle_Groove:
0
2570 html += QLatin1String("groove");-
2571 break;
never executed: break;
0
2572 case QTextFrameFormat::BorderStyle_Ridge:
never executed: case QTextFrameFormat::BorderStyle_Ridge:
0
2573 html += QLatin1String("ridge");-
2574 break;
never executed: break;
0
2575 case QTextFrameFormat::BorderStyle_Inset:
never executed: case QTextFrameFormat::BorderStyle_Inset:
0
2576 html += QLatin1String("inset");-
2577 break;
never executed: break;
0
2578 case QTextFrameFormat::BorderStyle_Outset:
never executed: case QTextFrameFormat::BorderStyle_Outset:
0
2579 html += QLatin1String("outset");-
2580 break;
never executed: break;
0
2581 default:
never executed: default:
0
2582 Q_ASSERT(false);-
2583 break;
never executed: break;
0
2584 };-
2585-
2586 html += QLatin1Char(';');-
2587}
never executed: end of block
0
2588-
2589void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy)-
2590{-
2591 if (policy & QTextFormat::PageBreak_AlwaysBefore)
policy & QText...k_AlwaysBeforeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2592 html += QLatin1String(" page-break-before:always;");
never executed: html += QLatin1String(" page-break-before:always;");
0
2593-
2594 if (policy & QTextFormat::PageBreak_AlwaysAfter)
policy & QText...ak_AlwaysAfterDescription
TRUEnever evaluated
FALSEnever evaluated
0
2595 html += QLatin1String(" page-break-after:always;");
never executed: html += QLatin1String(" page-break-after:always;");
0
2596}
never executed: end of block
0
2597-
2598void QTextHtmlExporter::emitFontFamily(const QString &family)-
2599{-
2600 html += QLatin1String(" font-family:");-
2601-
2602 QLatin1String quote("\'");-
2603 if (family.contains(QLatin1Char('\'')))
family.contain...in1Char('\''))Description
TRUEnever evaluated
FALSEnever evaluated
0
2604 quote = QLatin1String("&quot;");
never executed: quote = QLatin1String("&quot;");
0
2605-
2606 html += quote;-
2607 html += family.toHtmlEscaped();-
2608 html += quote;-
2609 html += QLatin1Char(';');-
2610}
never executed: end of block
0
2611-
2612void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right)-
2613{-
2614 html += QLatin1String(" margin-top:");-
2615 html += top;-
2616 html += QLatin1String("px;");-
2617-
2618 html += QLatin1String(" margin-bottom:");-
2619 html += bottom;-
2620 html += QLatin1String("px;");-
2621-
2622 html += QLatin1String(" margin-left:");-
2623 html += left;-
2624 html += QLatin1String("px;");-
2625-
2626 html += QLatin1String(" margin-right:");-
2627 html += right;-
2628 html += QLatin1String("px;");-
2629}
never executed: end of block
0
2630-
2631void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)-
2632{-
2633 const QTextCharFormat format = fragment.charFormat();-
2634-
2635 bool closeAnchor = false;-
2636-
2637 if (format.isAnchor()) {
format.isAnchor()Description
TRUEnever evaluated
FALSEnever evaluated
0
2638 const QString name = format.anchorName();-
2639 if (!name.isEmpty()) {
!name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2640 html += QLatin1String("<a name=\"");-
2641 html += name.toHtmlEscaped();-
2642 html += QLatin1String("\"></a>");-
2643 }
never executed: end of block
0
2644 const QString href = format.anchorHref();-
2645 if (!href.isEmpty()) {
!href.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2646 html += QLatin1String("<a href=\"");-
2647 html += href.toHtmlEscaped();-
2648 html += QLatin1String("\">");-
2649 closeAnchor = true;-
2650 }
never executed: end of block
0
2651 }
never executed: end of block
0
2652-
2653 QString txt = fragment.text();-
2654 const bool isObject = txt.contains(QChar::ObjectReplacementCharacter);-
2655 const bool isImage = isObject && format.isImageFormat();
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
format.isImageFormat()Description
TRUEnever evaluated
FALSEnever evaluated
0
2656-
2657 QLatin1String styleTag("<span style=\"");-
2658 html += styleTag;-
2659-
2660 bool attributesEmitted = false;-
2661 if (!isImage)
!isImageDescription
TRUEnever evaluated
FALSEnever evaluated
0
2662 attributesEmitted = emitCharFormatStyle(format);
never executed: attributesEmitted = emitCharFormatStyle(format);
0
2663 if (attributesEmitted)
attributesEmittedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2664 html += QLatin1String("\">");
never executed: html += QLatin1String("\">");
0
2665 else-
2666 html.chop(qstrlen(styleTag.latin1()));
never executed: html.chop(qstrlen(styleTag.latin1()));
0
2667-
2668 if (isObject) {
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2669 for (int i = 0; isImage && i < txt.length(); ++i) {
isImageDescription
TRUEnever evaluated
FALSEnever evaluated
i < txt.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
2670 QTextImageFormat imgFmt = format.toImageFormat();-
2671-
2672 html += QLatin1String("<img");-
2673-
2674 if (imgFmt.hasProperty(QTextFormat::ImageName))
imgFmt.hasProp...at::ImageName)Description
TRUEnever evaluated
FALSEnever evaluated
0
2675 emitAttribute("src", imgFmt.name());
never executed: emitAttribute("src", imgFmt.name());
0
2676-
2677 if (imgFmt.hasProperty(QTextFormat::ImageWidth))
imgFmt.hasProp...t::ImageWidth)Description
TRUEnever evaluated
FALSEnever evaluated
0
2678 emitAttribute("width", QString::number(imgFmt.width()));
never executed: emitAttribute("width", QString::number(imgFmt.width()));
0
2679-
2680 if (imgFmt.hasProperty(QTextFormat::ImageHeight))
imgFmt.hasProp...::ImageHeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
2681 emitAttribute("height", QString::number(imgFmt.height()));
never executed: emitAttribute("height", QString::number(imgFmt.height()));
0
2682-
2683 if (imgFmt.verticalAlignment() == QTextCharFormat::AlignMiddle)
imgFmt.vertica...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2684 html += QLatin1String(" style=\"vertical-align: middle;\"");
never executed: html += QLatin1String(" style=\"vertical-align: middle;\"");
0
2685 else if (imgFmt.verticalAlignment() == QTextCharFormat::AlignTop)
imgFmt.vertica...rmat::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
2686 html += QLatin1String(" style=\"vertical-align: top;\"");
never executed: html += QLatin1String(" style=\"vertical-align: top;\"");
0
2687-
2688 if (QTextFrame *imageFrame = qobject_cast<QTextFrame *>(doc->objectForFormat(imgFmt)))
QTextFrame *im...ormat(imgFmt))Description
TRUEnever evaluated
FALSEnever evaluated
0
2689 emitFloatStyle(imageFrame->frameFormat().position());
never executed: emitFloatStyle(imageFrame->frameFormat().position());
0
2690-
2691 html += QLatin1String(" />");-
2692 }
never executed: end of block
0
2693 } else {
never executed: end of block
0
2694 Q_ASSERT(!txt.contains(QChar::ObjectReplacementCharacter));-
2695-
2696 txt = txt.toHtmlEscaped();-
2697-
2698 // split for [\n{LineSeparator}]-
2699 QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]");-
2700 forcedLineBreakRegExp[3] = QChar::LineSeparator;-
2701-
2702 const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp));-
2703 for (int i = 0; i < lines.count(); ++i) {
i < lines.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2704 if (i > 0)
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2705 html += QLatin1String("<br />"); // space on purpose for compatibility with Netscape, Lynx & Co.
never executed: html += QLatin1String("<br />");
0
2706 html += lines.at(i);-
2707 }
never executed: end of block
0
2708 }
never executed: end of block
0
2709-
2710 if (attributesEmitted)
attributesEmittedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2711 html += QLatin1String("</span>");
never executed: html += QLatin1String("</span>");
0
2712-
2713 if (closeAnchor)
closeAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2714 html += QLatin1String("</a>");
never executed: html += QLatin1String("</a>");
0
2715}
never executed: end of block
0
2716-
2717static bool isOrderedList(int style)-
2718{-
2719 return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
style == QText...t::ListDecimalDescription
TRUEnever evaluated
FALSEnever evaluated
style == QText...ListLowerAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2720 || style == QTextListFormat::ListUpperAlpha
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
style == QText...ListUpperAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2721 || style == QTextListFormat::ListUpperRoman
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
style == QText...ListUpperRomanDescription
TRUEnever evaluated
FALSEnever evaluated
0
2722 || style == QTextListFormat::ListLowerRoman
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
style == QText...ListLowerRomanDescription
TRUEnever evaluated
FALSEnever evaluated
0
2723 ;
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
2724}-
2725-
2726void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block)-
2727{-
2728 QTextBlockFormat format = block.blockFormat();-
2729 emitAlignment(format.alignment());-
2730-
2731 // assume default to not bloat the html too much-
2732 // html += QLatin1String(" dir='ltr'");-
2733 if (block.textDirection() == Qt::RightToLeft)
block.textDire...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
2734 html += QLatin1String(" dir='rtl'");
never executed: html += QLatin1String(" dir='rtl'");
0
2735-
2736 QLatin1String style(" style=\"");-
2737 html += style;-
2738-
2739 const bool emptyBlock = block.begin().atEnd();-
2740 if (emptyBlock) {
emptyBlockDescription
TRUEnever evaluated
FALSEnever evaluated
0
2741 html += QLatin1String("-qt-paragraph-type:empty;");-
2742 }
never executed: end of block
0
2743-
2744 emitMargins(QString::number(format.topMargin()),-
2745 QString::number(format.bottomMargin()),-
2746 QString::number(format.leftMargin()),-
2747 QString::number(format.rightMargin()));-
2748-
2749 html += QLatin1String(" -qt-block-indent:");-
2750 html += QString::number(format.indent());-
2751 html += QLatin1Char(';');-
2752-
2753 html += QLatin1String(" text-indent:");-
2754 html += QString::number(format.textIndent());-
2755 html += QLatin1String("px;");-
2756-
2757 if (block.userState() != -1) {
block.userState() != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2758 html += QLatin1String(" -qt-user-state:");-
2759 html += QString::number(block.userState());-
2760 html += QLatin1Char(';');-
2761 }
never executed: end of block
0
2762-
2763 if (format.lineHeightType() != QTextBlockFormat::SingleHeight) {
format.lineHei...::SingleHeightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2764 switch (format.lineHeightType()) {-
2765 case QTextBlockFormat::ProportionalHeight:
never executed: case QTextBlockFormat::ProportionalHeight:
0
2766 case QTextBlockFormat::FixedHeight:
never executed: case QTextBlockFormat::FixedHeight:
0
2767 html += QLatin1String(" line-height:");-
2768 break;
never executed: break;
0
2769 case QTextBlockFormat::MinimumHeight:
never executed: case QTextBlockFormat::MinimumHeight:
0
2770 html += QLatin1String(" min-height:");-
2771 break;
never executed: break;
0
2772 case QTextBlockFormat::LineDistanceHeight:
never executed: case QTextBlockFormat::LineDistanceHeight:
0
2773 html += QLatin1String(" line-spacing:");-
2774 break;
never executed: break;
0
2775 case QTextBlockFormat::SingleHeight:
never executed: case QTextBlockFormat::SingleHeight:
0
2776 default:
never executed: default:
0
2777 break; // Should never reach here
never executed: break;
0
2778 }-
2779 html += QString::number(format.lineHeight());-
2780 if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight)
format.lineHei...ortionalHeightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2781 html += QLatin1String("%;");
never executed: html += QLatin1String("%;");
0
2782 else-
2783 html += QLatin1String("px;");
never executed: html += QLatin1String("px;");
0
2784 }-
2785-
2786 emitPageBreakPolicy(format.pageBreakPolicy());-
2787-
2788 QTextCharFormat diff;-
2789 if (emptyBlock) { // only print character properties when we don't expect them to be repeated by actual text in the parag
emptyBlockDescription
TRUEnever evaluated
FALSEnever evaluated
0
2790 const QTextCharFormat blockCharFmt = block.charFormat();-
2791 diff = formatDifference(defaultCharFormat, blockCharFmt).toCharFormat();-
2792 }
never executed: end of block
0
2793-
2794 diff.clearProperty(QTextFormat::BackgroundBrush);-
2795 if (format.hasProperty(QTextFormat::BackgroundBrush)) {
format.hasProp...ckgroundBrush)Description
TRUEnever evaluated
FALSEnever evaluated
0
2796 QBrush bg = format.background();-
2797 if (bg.style() != Qt::NoBrush)
bg.style() != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
2798 diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush));
never executed: diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush));
0
2799 }
never executed: end of block
0
2800-
2801 if (!diff.properties().isEmpty())
!diff.properties().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2802 emitCharFormatStyle(diff);
never executed: emitCharFormatStyle(diff);
0
2803-
2804 html += QLatin1Char('"');-
2805-
2806}
never executed: end of block
0
2807-
2808void QTextHtmlExporter::emitBlock(const QTextBlock &block)-
2809{-
2810 if (block.begin().atEnd()) {
block.begin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2811 // ### HACK, remove once QTextFrame::Iterator is fixed-
2812 int p = block.position();-
2813 if (p > 0)
p > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2814 --p;
never executed: --p;
0
2815 QTextDocumentPrivate::FragmentIterator frag = doc->docHandle()->find(p);-
2816 QChar ch = doc->docHandle()->buffer().at(frag->stringPosition);-
2817 if (ch == QTextBeginningOfFrame
ch == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2818 || ch == QTextEndOfFrame)
ch == QChar(0xfdd1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2819 return;
never executed: return;
0
2820 }
never executed: end of block
0
2821-
2822 html += QLatin1Char('\n');-
2823-
2824 // save and later restore, in case we 'change' the default format by-
2825 // emitting block char format information-
2826 QTextCharFormat oldDefaultCharFormat = defaultCharFormat;-
2827-
2828 QTextList *list = block.textList();-
2829 if (list) {
listDescription
TRUEnever evaluated
FALSEnever evaluated
0
2830 if (list->itemNumber(block) == 0) { // first item? emit <ul> or appropriate
list->itemNumber(block) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2831 const QTextListFormat format = list->format();-
2832 const int style = format.style();-
2833 switch (style) {-
2834 case QTextListFormat::ListDecimal: html += QLatin1String("<ol"); break;
never executed: break;
never executed: case QTextListFormat::ListDecimal:
0
2835 case QTextListFormat::ListDisc: html += QLatin1String("<ul"); break;
never executed: break;
never executed: case QTextListFormat::ListDisc:
0
2836 case QTextListFormat::ListCircle: html += QLatin1String("<ul type=\"circle\""); break;
never executed: break;
never executed: case QTextListFormat::ListCircle:
0
2837 case QTextListFormat::ListSquare: html += QLatin1String("<ul type=\"square\""); break;
never executed: break;
never executed: case QTextListFormat::ListSquare:
0
2838 case QTextListFormat::ListLowerAlpha: html += QLatin1String("<ol type=\"a\""); break;
never executed: break;
never executed: case QTextListFormat::ListLowerAlpha:
0
2839 case QTextListFormat::ListUpperAlpha: html += QLatin1String("<ol type=\"A\""); break;
never executed: break;
never executed: case QTextListFormat::ListUpperAlpha:
0
2840 case QTextListFormat::ListLowerRoman: html += QLatin1String("<ol type=\"i\""); break;
never executed: break;
never executed: case QTextListFormat::ListLowerRoman:
0
2841 case QTextListFormat::ListUpperRoman: html += QLatin1String("<ol type=\"I\""); break;
never executed: break;
never executed: case QTextListFormat::ListUpperRoman:
0
2842 default: html += QLatin1String("<ul"); // ### should not happen
never executed: default:
0
2843 }
never executed: end of block
0
2844-
2845 QString styleString = QString::fromLatin1("margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");-
2846-
2847 if (format.hasProperty(QTextFormat::ListIndent)) {
format.hasProp...t::ListIndent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2848 styleString += QLatin1String(" -qt-list-indent: ");-
2849 styleString += QString::number(format.indent());-
2850 styleString += QLatin1Char(';');-
2851 }
never executed: end of block
0
2852-
2853 if (format.hasProperty(QTextFormat::ListNumberPrefix)) {
format.hasProp...tNumberPrefix)Description
TRUEnever evaluated
FALSEnever evaluated
0
2854 QString numberPrefix = format.numberPrefix();-
2855 numberPrefix.replace(QLatin1Char('"'), QLatin1String("\\22"));-
2856 numberPrefix.replace(QLatin1Char('\''), QLatin1String("\\27")); // FIXME: There's a problem in the CSS parser the prevents this from being correctly restored-
2857 styleString += QLatin1String(" -qt-list-number-prefix: ");-
2858 styleString += QLatin1Char('\'');-
2859 styleString += numberPrefix;-
2860 styleString += QLatin1Char('\'');-
2861 styleString += QLatin1Char(';');-
2862 }
never executed: end of block
0
2863-
2864 if (format.hasProperty(QTextFormat::ListNumberSuffix)) {
format.hasProp...tNumberSuffix)Description
TRUEnever evaluated
FALSEnever evaluated
0
2865 if (format.numberSuffix() != QLatin1String(".")) { // this is our default
format.numberS...in1String(".")Description
TRUEnever evaluated
FALSEnever evaluated
0
2866 QString numberSuffix = format.numberSuffix();-
2867 numberSuffix.replace(QLatin1Char('"'), QLatin1String("\\22"));-
2868 numberSuffix.replace(QLatin1Char('\''), QLatin1String("\\27")); // see above-
2869 styleString += QLatin1String(" -qt-list-number-suffix: ");-
2870 styleString += QLatin1Char('\'');-
2871 styleString += numberSuffix;-
2872 styleString += QLatin1Char('\'');-
2873 styleString += QLatin1Char(';');-
2874 }
never executed: end of block
0
2875 }
never executed: end of block
0
2876-
2877 html += QLatin1String(" style=\"");-
2878 html += styleString;-
2879 html += QLatin1String("\">");-
2880 }
never executed: end of block
0
2881-
2882 html += QLatin1String("<li");-
2883-
2884 const QTextCharFormat blockFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat();-
2885 if (!blockFmt.properties().isEmpty()) {
!blockFmt.prop...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2886 html += QLatin1String(" style=\"");-
2887 emitCharFormatStyle(blockFmt);-
2888 html += QLatin1Char('\"');-
2889-
2890 defaultCharFormat.merge(block.charFormat());-
2891 }
never executed: end of block
0
2892 }
never executed: end of block
0
2893-
2894 const QTextBlockFormat blockFormat = block.blockFormat();-
2895 if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
blockFormat.ha...talRulerWidth)Description
TRUEnever evaluated
FALSEnever evaluated
0
2896 html += QLatin1String("<hr");-
2897-
2898 QTextLength width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth);-
2899 if (width.type() != QTextLength::VariableLength)
width.type() !...VariableLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2900 emitTextLength("width", width);
never executed: emitTextLength("width", width);
0
2901 else-
2902 html += QLatin1Char(' ');
never executed: html += QLatin1Char(' ');
0
2903-
2904 html += QLatin1String("/>");-
2905 return;
never executed: return;
0
2906 }-
2907-
2908 const bool pre = blockFormat.nonBreakableLines();-
2909 if (pre) {
preDescription
TRUEnever evaluated
FALSEnever evaluated
0
2910 if (list)
listDescription
TRUEnever evaluated
FALSEnever evaluated
0
2911 html += QLatin1Char('>');
never executed: html += QLatin1Char('>');
0
2912 html += QLatin1String("<pre");-
2913 } else if (!list) {
never executed: end of block
!listDescription
TRUEnever evaluated
FALSEnever evaluated
0
2914 html += QLatin1String("<p");-
2915 }
never executed: end of block
0
2916-
2917 emitBlockAttributes(block);-
2918-
2919 html += QLatin1Char('>');-
2920 if (block.begin().atEnd())
block.begin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2921 html += QLatin1String("<br />");
never executed: html += QLatin1String("<br />");
0
2922-
2923 QTextBlock::Iterator it = block.begin();-
2924 if (fragmentMarkers && !it.atEnd() && block == doc->begin())
fragmentMarkersDescription
TRUEnever evaluated
FALSEnever evaluated
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
block == doc->begin()Description
TRUEnever evaluated
FALSEnever evaluated
0
2925 html += QLatin1String("<!--StartFragment-->");
never executed: html += QLatin1String("<!--StartFragment-->");
0
2926-
2927 for (; !it.atEnd(); ++it)
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2928 emitFragment(it.fragment());
never executed: emitFragment(it.fragment());
0
2929-
2930 if (fragmentMarkers && block.position() + block.length() == doc->docHandle()->length())
fragmentMarkersDescription
TRUEnever evaluated
FALSEnever evaluated
block.position...le()->length()Description
TRUEnever evaluated
FALSEnever evaluated
0
2931 html += QLatin1String("<!--EndFragment-->");
never executed: html += QLatin1String("<!--EndFragment-->");
0
2932-
2933 if (pre)
preDescription
TRUEnever evaluated
FALSEnever evaluated
0
2934 html += QLatin1String("</pre>");
never executed: html += QLatin1String("</pre>");
0
2935 else if (list)
listDescription
TRUEnever evaluated
FALSEnever evaluated
0
2936 html += QLatin1String("</li>");
never executed: html += QLatin1String("</li>");
0
2937 else-
2938 html += QLatin1String("</p>");
never executed: html += QLatin1String("</p>");
0
2939-
2940 if (list) {
listDescription
TRUEnever evaluated
FALSEnever evaluated
0
2941 if (list->itemNumber(block) == list->count() - 1) { // last item? close list
list->itemNumb...t->count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2942 if (isOrderedList(list->format().style()))
isOrderedList(...mat().style())Description
TRUEnever evaluated
FALSEnever evaluated
0
2943 html += QLatin1String("</ol>");
never executed: html += QLatin1String("</ol>");
0
2944 else-
2945 html += QLatin1String("</ul>");
never executed: html += QLatin1String("</ul>");
0
2946 }-
2947 }
never executed: end of block
0
2948-
2949 defaultCharFormat = oldDefaultCharFormat;-
2950}
never executed: end of block
0
2951-
2952extern bool qHasPixmapTexture(const QBrush& brush);-
2953-
2954QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap)-
2955{-
2956 QString url;-
2957 if (!doc)
!docDescription
TRUEnever evaluated
FALSEnever evaluated
0
2958 return url;
never executed: return url;
0
2959-
2960 if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent()))
QTextDocument ...doc->parent())Description
TRUEnever evaluated
FALSEnever evaluated
0
2961 return findUrlForImage(parent, cacheKey, isPixmap);
never executed: return findUrlForImage(parent, cacheKey, isPixmap);
0
2962-
2963 if (doc && doc->docHandle()) {
docDescription
TRUEnever evaluated
FALSEnever evaluated
doc->docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
0
2964 QTextDocumentPrivate *priv = doc->docHandle();-
2965 QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin();-
2966 for (; it != priv->cachedResources.constEnd(); ++it) {
it != priv->ca...ces.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2967-
2968 const QVariant &v = it.value();-
2969 if (v.type() == QVariant::Image && !isPixmap) {
v.type() == QVariant::ImageDescription
TRUEnever evaluated
FALSEnever evaluated
!isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2970 if (qvariant_cast<QImage>(v).cacheKey() == cacheKey)
qvariant_cast<...() == cacheKeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2971 break;
never executed: break;
0
2972 }
never executed: end of block
0
2973-
2974 if (v.type() == QVariant::Pixmap && isPixmap) {
v.type() == QVariant::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2975 if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey)
qvariant_cast<...() == cacheKeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2976 break;
never executed: break;
0
2977 }
never executed: end of block
0
2978 }
never executed: end of block
0
2979-
2980 if (it != priv->cachedResources.constEnd())
it != priv->ca...ces.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2981 url = it.key().toString();
never executed: url = it.key().toString();
0
2982 }
never executed: end of block
0
2983-
2984 return url;
never executed: return url;
0
2985}-
2986-
2987void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv)-
2988{-
2989 if (!priv)
!privDescription
TRUEnever evaluated
FALSEnever evaluated
0
2990 return;
never executed: return;
0
2991-
2992 cachedResources.unite(priv->cachedResources);-
2993}
never executed: end of block
0
2994-
2995void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format)-
2996{-
2997 if (format.hasProperty(QTextFormat::BackgroundImageUrl)) {
format.hasProp...roundImageUrl)Description
TRUEnever evaluated
FALSEnever evaluated
0
2998 QString url = format.property(QTextFormat::BackgroundImageUrl).toString();-
2999 emitAttribute("background", url);-
3000 } else {
never executed: end of block
0
3001 const QBrush &brush = format.background();-
3002 if (brush.style() == Qt::SolidPattern) {
brush.style() ...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
3003 emitAttribute("bgcolor", colorValue(brush.color()));-
3004 } else if (brush.style() == Qt::TexturePattern) {
never executed: end of block
brush.style() ...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
3005 const bool isPixmap = qHasPixmapTexture(brush);-
3006 const qint64 cacheKey = isPixmap ? brush.texture().cacheKey() : brush.textureImage().cacheKey();
isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
3007-
3008 const QString url = findUrlForImage(doc, cacheKey, isPixmap);-
3009-
3010 if (!url.isEmpty())
!url.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3011 emitAttribute("background", url);
never executed: emitAttribute("background", url);
0
3012 }
never executed: end of block
0
3013 }
never executed: end of block
0
3014}-
3015-
3016void QTextHtmlExporter::emitTable(const QTextTable *table)-
3017{-
3018 QTextTableFormat format = table->format();-
3019-
3020 html += QLatin1String("\n<table");-
3021-
3022 if (format.hasProperty(QTextFormat::FrameBorder))
format.hasProp...::FrameBorder)Description
TRUEnever evaluated
FALSEnever evaluated
0
3023 emitAttribute("border", QString::number(format.border()));
never executed: emitAttribute("border", QString::number(format.border()));
0
3024-
3025 emitFrameStyle(format, TableFrame);-
3026-
3027 emitAlignment(format.alignment());-
3028 emitTextLength("width", format.width());-
3029-
3030 if (format.hasProperty(QTextFormat::TableCellSpacing))
format.hasProp...leCellSpacing)Description
TRUEnever evaluated
FALSEnever evaluated
0
3031 emitAttribute("cellspacing", QString::number(format.cellSpacing()));
never executed: emitAttribute("cellspacing", QString::number(format.cellSpacing()));
0
3032 if (format.hasProperty(QTextFormat::TableCellPadding))
format.hasProp...leCellPadding)Description
TRUEnever evaluated
FALSEnever evaluated
0
3033 emitAttribute("cellpadding", QString::number(format.cellPadding()));
never executed: emitAttribute("cellpadding", QString::number(format.cellPadding()));
0
3034-
3035 emitBackgroundAttribute(format);-
3036-
3037 html += QLatin1Char('>');-
3038-
3039 const int rows = table->rows();-
3040 const int columns = table->columns();-
3041-
3042 QVector<QTextLength> columnWidths = format.columnWidthConstraints();-
3043 if (columnWidths.isEmpty()) {
columnWidths.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3044 columnWidths.resize(columns);-
3045 columnWidths.fill(QTextLength());-
3046 }
never executed: end of block
0
3047 Q_ASSERT(columnWidths.count() == columns);-
3048-
3049 QVarLengthArray<bool> widthEmittedForColumn(columns);-
3050 for (int i = 0; i < columns; ++i)
i < columnsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3051 widthEmittedForColumn[i] = false;
never executed: widthEmittedForColumn[i] = false;
0
3052-
3053 const int headerRowCount = qMin(format.headerRowCount(), rows);-
3054 if (headerRowCount > 0)
headerRowCount > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3055 html += QLatin1String("<thead>");
never executed: html += QLatin1String("<thead>");
0
3056-
3057 for (int row = 0; row < rows; ++row) {
row < rowsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3058 html += QLatin1String("\n<tr>");-
3059-
3060 for (int col = 0; col < columns; ++col) {
col < columnsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3061 const QTextTableCell cell = table->cellAt(row, col);-
3062-
3063 // for col/rowspans-
3064 if (cell.row() != row)
cell.row() != rowDescription
TRUEnever evaluated
FALSEnever evaluated
0
3065 continue;
never executed: continue;
0
3066-
3067 if (cell.column() != col)
cell.column() != colDescription
TRUEnever evaluated
FALSEnever evaluated
0
3068 continue;
never executed: continue;
0
3069-
3070 html += QLatin1String("\n<td");-
3071-
3072 if (!widthEmittedForColumn[col] && cell.columnSpan() == 1) {
!widthEmittedForColumn[col]Description
TRUEnever evaluated
FALSEnever evaluated
cell.columnSpan() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3073 emitTextLength("width", columnWidths.at(col));-
3074 widthEmittedForColumn[col] = true;-
3075 }
never executed: end of block
0
3076-
3077 if (cell.columnSpan() > 1)
cell.columnSpan() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3078 emitAttribute("colspan", QString::number(cell.columnSpan()));
never executed: emitAttribute("colspan", QString::number(cell.columnSpan()));
0
3079-
3080 if (cell.rowSpan() > 1)
cell.rowSpan() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3081 emitAttribute("rowspan", QString::number(cell.rowSpan()));
never executed: emitAttribute("rowspan", QString::number(cell.rowSpan()));
0
3082-
3083 const QTextTableCellFormat cellFormat = cell.format().toTableCellFormat();-
3084 emitBackgroundAttribute(cellFormat);-
3085-
3086 QTextCharFormat oldDefaultCharFormat = defaultCharFormat;-
3087-
3088 QTextCharFormat::VerticalAlignment valign = cellFormat.verticalAlignment();-
3089-
3090 QString styleString;-
3091 if (valign >= QTextCharFormat::AlignMiddle && valign <= QTextCharFormat::AlignBottom) {
valign >= QTex...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
valign <= QTex...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
3092 styleString += QLatin1String(" vertical-align:");-
3093 switch (valign) {-
3094 case QTextCharFormat::AlignMiddle:
never executed: case QTextCharFormat::AlignMiddle:
0
3095 styleString += QLatin1String("middle");-
3096 break;
never executed: break;
0
3097 case QTextCharFormat::AlignTop:
never executed: case QTextCharFormat::AlignTop:
0
3098 styleString += QLatin1String("top");-
3099 break;
never executed: break;
0
3100 case QTextCharFormat::AlignBottom:
never executed: case QTextCharFormat::AlignBottom:
0
3101 styleString += QLatin1String("bottom");-
3102 break;
never executed: break;
0
3103 default:
never executed: default:
0
3104 break;
never executed: break;
0
3105 }-
3106 styleString += QLatin1Char(';');-
3107-
3108 QTextCharFormat temp;-
3109 temp.setVerticalAlignment(valign);-
3110 defaultCharFormat.merge(temp);-
3111 }
never executed: end of block
0
3112-
3113 if (cellFormat.hasProperty(QTextFormat::TableCellLeftPadding))
cellFormat.has...llLeftPadding)Description
TRUEnever evaluated
FALSEnever evaluated
0
3114 styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';');
0
3115 if (cellFormat.hasProperty(QTextFormat::TableCellRightPadding))
cellFormat.has...lRightPadding)Description
TRUEnever evaluated
FALSEnever evaluated
0
3116 styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';');
0
3117 if (cellFormat.hasProperty(QTextFormat::TableCellTopPadding))
cellFormat.has...ellTopPadding)Description
TRUEnever evaluated
FALSEnever evaluated
0
3118 styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';');
0
3119 if (cellFormat.hasProperty(QTextFormat::TableCellBottomPadding))
cellFormat.has...BottomPadding)Description
TRUEnever evaluated
FALSEnever evaluated
0
3120 styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';');
0
3121-
3122 if (!styleString.isEmpty())
!styleString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3123 html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"');
never executed: html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"');
0
3124-
3125 html += QLatin1Char('>');-
3126-
3127 emitFrame(cell.begin());-
3128-
3129 html += QLatin1String("</td>");-
3130-
3131 defaultCharFormat = oldDefaultCharFormat;-
3132 }
never executed: end of block
0
3133-
3134 html += QLatin1String("</tr>");-
3135 if (headerRowCount > 0 && row == headerRowCount - 1)
headerRowCount > 0Description
TRUEnever evaluated
FALSEnever evaluated
row == headerRowCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3136 html += QLatin1String("</thead>");
never executed: html += QLatin1String("</thead>");
0
3137 }
never executed: end of block
0
3138-
3139 html += QLatin1String("</table>");-
3140}
never executed: end of block
0
3141-
3142void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt)-
3143{-
3144 if (!frameIt.atEnd()) {
!frameIt.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
3145 QTextFrame::Iterator next = frameIt;-
3146 ++next;-
3147 if (next.atEnd()
next.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
3148 && frameIt.currentFrame() == 0
frameIt.currentFrame() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3149 && frameIt.parentFrame() != doc->rootFrame()
frameIt.parent...c->rootFrame()Description
TRUEnever evaluated
FALSEnever evaluated
0
3150 && frameIt.currentBlock().begin().atEnd())
frameIt.curren...egin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
3151 return;
never executed: return;
0
3152 }
never executed: end of block
0
3153-
3154 for (QTextFrame::Iterator it = frameIt;-
3155 !it.atEnd(); ++it) {
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
3156 if (QTextFrame *f = it.currentFrame()) {
QTextFrame *f ...currentFrame()Description
TRUEnever evaluated
FALSEnever evaluated
0
3157 if (QTextTable *table = qobject_cast<QTextTable *>(f)) {
QTextTable *ta...extTable *>(f)Description
TRUEnever evaluated
FALSEnever evaluated
0
3158 emitTable(table);-
3159 } else {
never executed: end of block
0
3160 emitTextFrame(f);-
3161 }
never executed: end of block
0
3162 } else if (it.currentBlock().isValid()) {
it.currentBlock().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
3163 emitBlock(it.currentBlock());-
3164 }
never executed: end of block
0
3165 }
never executed: end of block
0
3166}
never executed: end of block
0
3167-
3168void QTextHtmlExporter::emitTextFrame(const QTextFrame *f)-
3169{-
3170 FrameType frameType = f->parentFrame() ? TextFrame : RootFrame;
f->parentFrame()Description
TRUEnever evaluated
FALSEnever evaluated
0
3171-
3172 html += QLatin1String("\n<table");-
3173 QTextFrameFormat format = f->frameFormat();-
3174-
3175 if (format.hasProperty(QTextFormat::FrameBorder))
format.hasProp...::FrameBorder)Description
TRUEnever evaluated
FALSEnever evaluated
0
3176 emitAttribute("border", QString::number(format.border()));
never executed: emitAttribute("border", QString::number(format.border()));
0
3177-
3178 emitFrameStyle(format, frameType);-
3179-
3180 emitTextLength("width", format.width());-
3181 emitTextLength("height", format.height());-
3182-
3183 // root frame's bcolor goes in the <body> tag-
3184 if (frameType != RootFrame)
frameType != RootFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
3185 emitBackgroundAttribute(format);
never executed: emitBackgroundAttribute(format);
0
3186-
3187 html += QLatin1Char('>');-
3188 html += QLatin1String("\n<tr>\n<td style=\"border: none;\">");-
3189 emitFrame(f->begin());-
3190 html += QLatin1String("</td></tr></table>");-
3191}
never executed: end of block
0
3192-
3193void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType frameType)-
3194{-
3195 QLatin1String styleAttribute(" style=\"");-
3196 html += styleAttribute;-
3197 const int originalHtmlLength = html.length();-
3198-
3199 if (frameType == TextFrame)
frameType == TextFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
3200 html += QLatin1String("-qt-table-type: frame;");
never executed: html += QLatin1String("-qt-table-type: frame;");
0
3201 else if (frameType == RootFrame)
frameType == RootFrameDescription
TRUEnever evaluated
FALSEnever evaluated
0
3202 html += QLatin1String("-qt-table-type: root;");
never executed: html += QLatin1String("-qt-table-type: root;");
0
3203-
3204 const QTextFrameFormat defaultFormat;-
3205-
3206 emitFloatStyle(format.position(), OmitStyleTag);-
3207 emitPageBreakPolicy(format.pageBreakPolicy());-
3208-
3209 if (format.borderBrush() != defaultFormat.borderBrush()) {
format.borderB....borderBrush()Description
TRUEnever evaluated
FALSEnever evaluated
0
3210 html += QLatin1String(" border-color:");-
3211 html += colorValue(format.borderBrush().color());-
3212 html += QLatin1Char(';');-
3213 }
never executed: end of block
0
3214-
3215 if (format.borderStyle() != defaultFormat.borderStyle())
format.borderS....borderStyle()Description
TRUEnever evaluated
FALSEnever evaluated
0
3216 emitBorderStyle(format.borderStyle());
never executed: emitBorderStyle(format.borderStyle());
0
3217-
3218 if (format.hasProperty(QTextFormat::FrameMargin)
format.hasProp...::FrameMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
3219 || format.hasProperty(QTextFormat::FrameLeftMargin)
format.hasProp...ameLeftMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
3220 || format.hasProperty(QTextFormat::FrameRightMargin)
format.hasProp...meRightMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
3221 || format.hasProperty(QTextFormat::FrameTopMargin)
format.hasProp...rameTopMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
3222 || format.hasProperty(QTextFormat::FrameBottomMargin))
format.hasProp...eBottomMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
3223 emitMargins(QString::number(format.topMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
3224 QString::number(format.bottomMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
3225 QString::number(format.leftMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
3226 QString::number(format.rightMargin()));
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
3227-
3228 if (html.length() == originalHtmlLength) // nothing emitted?
html.length() ...inalHtmlLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
3229 html.chop(qstrlen(styleAttribute.latin1()));
never executed: html.chop(qstrlen(styleAttribute.latin1()));
0
3230 else-
3231 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
3232}-
3233-
3234/*!-
3235 Returns a string containing an HTML representation of the document.-
3236-
3237 The \a encoding parameter specifies the value for the charset attribute-
3238 in the html header. For example if 'utf-8' is specified then the-
3239 beginning of the generated html will look like this:-
3240 \snippet code/src_gui_text_qtextdocument.cpp 0-
3241-
3242 If no encoding is specified then no such meta information is generated.-
3243-
3244 If you later on convert the returned html string into a byte array for-
3245 transmission over a network or when saving to disk you should specify-
3246 the encoding you're going to use for the conversion to a byte array here.-
3247-
3248 \sa {Supported HTML Subset}-
3249*/-
3250#ifndef QT_NO_TEXTHTMLPARSER-
3251QString QTextDocument::toHtml(const QByteArray &encoding) const-
3252{-
3253 return QTextHtmlExporter(this).toHtml(encoding);
never executed: return QTextHtmlExporter(this).toHtml(encoding);
0
3254}-
3255#endif // QT_NO_TEXTHTMLPARSER-
3256-
3257/*!-
3258 Returns a vector of text formats for all the formats used in the document.-
3259*/-
3260QVector<QTextFormat> QTextDocument::allFormats() const-
3261{-
3262 Q_D(const QTextDocument);-
3263 return d->formatCollection()->formats;
never executed: return d->formatCollection()->formats;
0
3264}-
3265-
3266-
3267/*!-
3268 \internal-
3269-
3270 So that not all classes have to be friends of each other...-
3271*/-
3272QTextDocumentPrivate *QTextDocument::docHandle() const-
3273{-
3274 Q_D(const QTextDocument);-
3275 return const_cast<QTextDocumentPrivate *>(d);
never executed: return const_cast<QTextDocumentPrivate *>(d);
0
3276}-
3277-
3278/*!-
3279 \since 4.4-
3280 \fn QTextDocument::undoCommandAdded()-
3281-
3282 This signal is emitted every time a new level of undo is added to the QTextDocument.-
3283*/-
3284-
3285QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9