text/qtextdocument.cpp

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

Generated by Squish Coco Non-Commercial