text/qtextdocumentfragment.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 "qtextdocumentfragment.h" -
43#include "qtextdocumentfragment_p.h" -
44#include "qtextcursor_p.h" -
45#include "qtextlist.h" -
46 -
47#include <qdebug.h> -
48#include <qtextcodec.h> -
49#include <qbytearray.h> -
50#include <qdatastream.h> -
51#include <qdatetime.h> -
52 -
53QT_BEGIN_NAMESPACE -
54 -
55QTextCopyHelper::QTextCopyHelper(const QTextCursor &_source, const QTextCursor &_destination, bool forceCharFormat, const QTextCharFormat &fmt) -
56#if defined(Q_CC_DIAB) // compiler bug -
57 : formatCollection(*_destination.d->priv->formatCollection()), originalText((const QString)_source.d->priv->buffer()) -
58#else -
59 : formatCollection(*_destination.d->priv->formatCollection()), originalText(_source.d->priv->buffer()) -
60#endif -
61{ -
62 src = _source.d->priv;
executed (the execution status of this line is deduced): src = _source.d->priv;
-
63 dst = _destination.d->priv;
executed (the execution status of this line is deduced): dst = _destination.d->priv;
-
64 insertPos = _destination.position();
executed (the execution status of this line is deduced): insertPos = _destination.position();
-
65 this->forceCharFormat = forceCharFormat;
executed (the execution status of this line is deduced): this->forceCharFormat = forceCharFormat;
-
66 primaryCharFormatIndex = convertFormatIndex(fmt);
executed (the execution status of this line is deduced): primaryCharFormatIndex = convertFormatIndex(fmt);
-
67 cursor = _source;
executed (the execution status of this line is deduced): cursor = _source;
-
68}
executed: }
Execution Count:667
667
69 -
70int QTextCopyHelper::convertFormatIndex(const QTextFormat &oldFormat, int objectIndexToSet) -
71{ -
72 QTextFormat fmt = oldFormat;
executed (the execution status of this line is deduced): QTextFormat fmt = oldFormat;
-
73 if (objectIndexToSet != -1) {
evaluated: objectIndexToSet != -1
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:3386
15-3386
74 fmt.setObjectIndex(objectIndexToSet);
executed (the execution status of this line is deduced): fmt.setObjectIndex(objectIndexToSet);
-
75 } else if (fmt.objectIndex() != -1) {
executed: }
Execution Count:15
evaluated: fmt.objectIndex() != -1
TRUEFALSE
yes
Evaluation Count:373
yes
Evaluation Count:3013
15-3013
76 int newObjectIndex = objectIndexMap.value(fmt.objectIndex(), -1);
executed (the execution status of this line is deduced): int newObjectIndex = objectIndexMap.value(fmt.objectIndex(), -1);
-
77 if (newObjectIndex == -1) {
evaluated: newObjectIndex == -1
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:237
136-237
78 QTextFormat objFormat = src->formatCollection()->objectFormat(fmt.objectIndex());
executed (the execution status of this line is deduced): QTextFormat objFormat = src->formatCollection()->objectFormat(fmt.objectIndex());
-
79 Q_ASSERT(objFormat.objectIndex() == -1);
executed (the execution status of this line is deduced): qt_noop();
-
80 newObjectIndex = formatCollection.createObjectIndex(objFormat);
executed (the execution status of this line is deduced): newObjectIndex = formatCollection.createObjectIndex(objFormat);
-
81 objectIndexMap.insert(fmt.objectIndex(), newObjectIndex);
executed (the execution status of this line is deduced): objectIndexMap.insert(fmt.objectIndex(), newObjectIndex);
-
82 }
executed: }
Execution Count:136
136
83 fmt.setObjectIndex(newObjectIndex);
executed (the execution status of this line is deduced): fmt.setObjectIndex(newObjectIndex);
-
84 }
executed: }
Execution Count:373
373
85 int idx = formatCollection.indexForFormat(fmt);
executed (the execution status of this line is deduced): int idx = formatCollection.indexForFormat(fmt);
-
86 Q_ASSERT(formatCollection.format(idx).type() == oldFormat.type());
executed (the execution status of this line is deduced): qt_noop();
-
87 return idx;
executed: return idx;
Execution Count:3401
3401
88} -
89 -
90int QTextCopyHelper::appendFragment(int pos, int endPos, int objectIndex) -
91{ -
92 QTextDocumentPrivate::FragmentIterator fragIt = src->find(pos);
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator fragIt = src->find(pos);
-
93 const QTextFragmentData * const frag = fragIt.value();
executed (the execution status of this line is deduced): const QTextFragmentData * const frag = fragIt.value();
-
94 -
95 Q_ASSERT(objectIndex == -1
executed (the execution status of this line is deduced): qt_noop();
-
96 || (frag->size_array[0] == 1 && src->formatCollection()->format(frag->format).objectIndex() != -1)); -
97 -
98 int charFormatIndex;
executed (the execution status of this line is deduced): int charFormatIndex;
-
99 if (forceCharFormat)
evaluated: forceCharFormat
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1231
4-1231
100 charFormatIndex = primaryCharFormatIndex;
executed: charFormatIndex = primaryCharFormatIndex;
Execution Count:4
4
101 else -
102 charFormatIndex = convertFormatIndex(frag->format, objectIndex);
executed: charFormatIndex = convertFormatIndex(frag->format, objectIndex);
Execution Count:1231
1231
103 -
104 const int inFragmentOffset = qMax(0, pos - fragIt.position());
executed (the execution status of this line is deduced): const int inFragmentOffset = qMax(0, pos - fragIt.position());
-
105 int charsToCopy = qMin(int(frag->size_array[0] - inFragmentOffset), endPos - pos);
executed (the execution status of this line is deduced): int charsToCopy = qMin(int(frag->size_array[0] - inFragmentOffset), endPos - pos);
-
106 -
107 QTextBlock nextBlock = src->blocksFind(pos + 1);
executed (the execution status of this line is deduced): QTextBlock nextBlock = src->blocksFind(pos + 1);
-
108 -
109 int blockIdx = -2;
executed (the execution status of this line is deduced): int blockIdx = -2;
-
110 if (nextBlock.position() == pos + 1) {
evaluated: nextBlock.position() == pos + 1
TRUEFALSE
yes
Evaluation Count:437
yes
Evaluation Count:798
437-798
111 blockIdx = convertFormatIndex(nextBlock.blockFormat());
executed (the execution status of this line is deduced): blockIdx = convertFormatIndex(nextBlock.blockFormat());
-
112 } else if (pos == 0 && insertPos == 0) {
executed: }
Execution Count:437
evaluated: pos == 0
TRUEFALSE
yes
Evaluation Count:526
yes
Evaluation Count:272
evaluated: insertPos == 0
TRUEFALSE
yes
Evaluation Count:520
yes
Evaluation Count:6
6-526
113 dst->setBlockFormat(dst->blocksBegin(), dst->blocksBegin(), convertFormat(src->blocksBegin().blockFormat()).toBlockFormat());
executed (the execution status of this line is deduced): dst->setBlockFormat(dst->blocksBegin(), dst->blocksBegin(), convertFormat(src->blocksBegin().blockFormat()).toBlockFormat());
-
114 dst->setCharFormat(-1, 1, convertFormat(src->blocksBegin().charFormat()).toCharFormat());
executed (the execution status of this line is deduced): dst->setCharFormat(-1, 1, convertFormat(src->blocksBegin().charFormat()).toCharFormat());
-
115 }
executed: }
Execution Count:520
520
116 -
117 QString txtToInsert(originalText.constData() + frag->stringPosition + inFragmentOffset, charsToCopy);
executed (the execution status of this line is deduced): QString txtToInsert(originalText.constData() + frag->stringPosition + inFragmentOffset, charsToCopy);
-
118 if (txtToInsert.length() == 1
evaluated: txtToInsert.length() == 1
TRUEFALSE
yes
Evaluation Count:727
yes
Evaluation Count:508
508-727
119 && (txtToInsert.at(0) == QChar::ParagraphSeparator
evaluated: txtToInsert.at(0) == QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:614
113-614
120 || txtToInsert.at(0) == QTextBeginningOfFrame
evaluated: txtToInsert.at(0) == QChar(0xfdd0)
TRUEFALSE
yes
Evaluation Count:229
yes
Evaluation Count:385
229-385
121 || txtToInsert.at(0) == QTextEndOfFrame
evaluated: txtToInsert.at(0) == QChar(0xfdd1)
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:290
95-290
122 )
executed (the execution status of this line is deduced): )
-
123 ) { -
124 dst->insertBlock(txtToInsert.at(0), insertPos, blockIdx, charFormatIndex);
executed (the execution status of this line is deduced): dst->insertBlock(txtToInsert.at(0), insertPos, blockIdx, charFormatIndex);
-
125 ++insertPos;
executed (the execution status of this line is deduced): ++insertPos;
-
126 } else {
executed: }
Execution Count:437
437
127 if (nextBlock.textList()) {
evaluated: nextBlock.textList()
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:754
44-754
128 QTextBlock dstBlock = dst->blocksFind(insertPos);
executed (the execution status of this line is deduced): QTextBlock dstBlock = dst->blocksFind(insertPos);
-
129 if (!dstBlock.textList()) {
evaluated: !dstBlock.textList()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:42
2-42
130 // insert a new text block with the block and char format from the -
131 // source block to make sure that the following text fragments -
132 // end up in a list as they should -
133 int listBlockFormatIndex = convertFormatIndex(nextBlock.blockFormat());
executed (the execution status of this line is deduced): int listBlockFormatIndex = convertFormatIndex(nextBlock.blockFormat());
-
134 int listCharFormatIndex = convertFormatIndex(nextBlock.charFormat());
executed (the execution status of this line is deduced): int listCharFormatIndex = convertFormatIndex(nextBlock.charFormat());
-
135 dst->insertBlock(insertPos, listBlockFormatIndex, listCharFormatIndex);
executed (the execution status of this line is deduced): dst->insertBlock(insertPos, listBlockFormatIndex, listCharFormatIndex);
-
136 ++insertPos;
executed (the execution status of this line is deduced): ++insertPos;
-
137 }
executed: }
Execution Count:2
2
138 }
executed: }
Execution Count:44
44
139 dst->insert(insertPos, txtToInsert, charFormatIndex);
executed (the execution status of this line is deduced): dst->insert(insertPos, txtToInsert, charFormatIndex);
-
140 const int userState = nextBlock.userState();
executed (the execution status of this line is deduced): const int userState = nextBlock.userState();
-
141 if (userState != -1)
evaluated: userState != -1
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:790
8-790
142 dst->blocksFind(insertPos).setUserState(userState);
executed: dst->blocksFind(insertPos).setUserState(userState);
Execution Count:8
8
143 insertPos += txtToInsert.length();
executed (the execution status of this line is deduced): insertPos += txtToInsert.length();
-
144 }
executed: }
Execution Count:798
798
145 -
146 return charsToCopy;
executed: return charsToCopy;
Execution Count:1235
1235
147} -
148 -
149void QTextCopyHelper::appendFragments(int pos, int endPos) -
150{ -
151 Q_ASSERT(pos < endPos);
executed (the execution status of this line is deduced): qt_noop();
-
152 -
153 while (pos < endPos)
evaluated: pos < endPos
TRUEFALSE
yes
Evaluation Count:1231
yes
Evaluation Count:674
674-1231
154 pos += appendFragment(pos, endPos);
executed: pos += appendFragment(pos, endPos);
Execution Count:1231
1231
155}
executed: }
Execution Count:674
674
156 -
157void QTextCopyHelper::copy() -
158{ -
159 if (cursor.hasComplexSelection()) {
evaluated: cursor.hasComplexSelection()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:663
4-663
160 QTextTable *table = cursor.currentTable();
executed (the execution status of this line is deduced): QTextTable *table = cursor.currentTable();
-
161 int row_start, col_start, num_rows, num_cols;
executed (the execution status of this line is deduced): int row_start, col_start, num_rows, num_cols;
-
162 cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
executed (the execution status of this line is deduced): cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
-
163 -
164 QTextTableFormat tableFormat = table->format();
executed (the execution status of this line is deduced): QTextTableFormat tableFormat = table->format();
-
165 tableFormat.setColumns(num_cols);
executed (the execution status of this line is deduced): tableFormat.setColumns(num_cols);
-
166 tableFormat.clearColumnWidthConstraints();
executed (the execution status of this line is deduced): tableFormat.clearColumnWidthConstraints();
-
167 const int objectIndex = dst->formatCollection()->createObjectIndex(tableFormat);
executed (the execution status of this line is deduced): const int objectIndex = dst->formatCollection()->createObjectIndex(tableFormat);
-
168 -
169 Q_ASSERT(row_start != -1);
executed (the execution status of this line is deduced): qt_noop();
-
170 for (int r = row_start; r < row_start + num_rows; ++r) {
evaluated: r < row_start + num_rows
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
171 for (int c = col_start; c < col_start + num_cols; ++c) {
evaluated: c < col_start + num_cols
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:8
8-11
172 QTextTableCell cell = table->cellAt(r, c);
executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(r, c);
-
173 const int rspan = cell.rowSpan();
executed (the execution status of this line is deduced): const int rspan = cell.rowSpan();
-
174 const int cspan = cell.columnSpan();
executed (the execution status of this line is deduced): const int cspan = cell.columnSpan();
-
175 if (rspan != 1) {
partially evaluated: rspan != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
176 int cr = cell.row();
never executed (the execution status of this line is deduced): int cr = cell.row();
-
177 if (cr != r)
never evaluated: cr != r
0
178 continue;
never executed: continue;
0
179 }
never executed: }
0
180 if (cspan != 1) {
evaluated: cspan != 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
181 int cc = cell.column();
executed (the execution status of this line is deduced): int cc = cell.column();
-
182 if (cc != c)
partially evaluated: cc != c
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
183 continue;
never executed: continue;
0
184 }
executed: }
Execution Count:1
1
185 -
186 // add the QTextBeginningOfFrame -
187 QTextCharFormat cellFormat = cell.format();
executed (the execution status of this line is deduced): QTextCharFormat cellFormat = cell.format();
-
188 if (r + rspan >= row_start + num_rows) {
evaluated: r + rspan >= row_start + num_rows
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:5
5-6
189 cellFormat.setTableCellRowSpan(row_start + num_rows - r);
executed (the execution status of this line is deduced): cellFormat.setTableCellRowSpan(row_start + num_rows - r);
-
190 }
executed: }
Execution Count:6
6
191 if (c + cspan >= col_start + num_cols) {
evaluated: c + cspan >= col_start + num_cols
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3
3-8
192 cellFormat.setTableCellColumnSpan(col_start + num_cols - c);
executed (the execution status of this line is deduced): cellFormat.setTableCellColumnSpan(col_start + num_cols - c);
-
193 }
executed: }
Execution Count:8
8
194 const int charFormatIndex = convertFormatIndex(cellFormat, objectIndex);
executed (the execution status of this line is deduced): const int charFormatIndex = convertFormatIndex(cellFormat, objectIndex);
-
195 -
196 int blockIdx = -2;
executed (the execution status of this line is deduced): int blockIdx = -2;
-
197 const int cellPos = cell.firstPosition();
executed (the execution status of this line is deduced): const int cellPos = cell.firstPosition();
-
198 QTextBlock block = src->blocksFind(cellPos);
executed (the execution status of this line is deduced): QTextBlock block = src->blocksFind(cellPos);
-
199 if (block.position() == cellPos) {
partially evaluated: block.position() == cellPos
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
200 blockIdx = convertFormatIndex(block.blockFormat());
executed (the execution status of this line is deduced): blockIdx = convertFormatIndex(block.blockFormat());
-
201 }
executed: }
Execution Count:11
11
202 -
203 dst->insertBlock(QTextBeginningOfFrame, insertPos, blockIdx, charFormatIndex);
executed (the execution status of this line is deduced): dst->insertBlock(QChar(0xfdd0), insertPos, blockIdx, charFormatIndex);
-
204 ++insertPos;
executed (the execution status of this line is deduced): ++insertPos;
-
205 -
206 // nothing to add for empty cells -
207 if (cell.lastPosition() > cellPos) {
partially evaluated: cell.lastPosition() > cellPos
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
208 // add the contents -
209 appendFragments(cellPos, cell.lastPosition());
executed (the execution status of this line is deduced): appendFragments(cellPos, cell.lastPosition());
-
210 }
executed: }
Execution Count:11
11
211 }
executed: }
Execution Count:11
11
212 }
executed: }
Execution Count:8
8
213 -
214 // add end of table -
215 int end = table->lastPosition();
executed (the execution status of this line is deduced): int end = table->lastPosition();
-
216 appendFragment(end, end+1, objectIndex);
executed (the execution status of this line is deduced): appendFragment(end, end+1, objectIndex);
-
217 } else {
executed: }
Execution Count:4
4
218 appendFragments(cursor.selectionStart(), cursor.selectionEnd());
executed (the execution status of this line is deduced): appendFragments(cursor.selectionStart(), cursor.selectionEnd());
-
219 }
executed: }
Execution Count:663
663
220} -
221 -
222QTextDocumentFragmentPrivate::QTextDocumentFragmentPrivate(const QTextCursor &_cursor) -
223 : ref(1), doc(new QTextDocument), importedFromPlainText(false) -
224{ -
225 doc->setUndoRedoEnabled(false);
executed (the execution status of this line is deduced): doc->setUndoRedoEnabled(false);
-
226 -
227 if (!_cursor.hasSelection())
evaluated: !_cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:480
yes
Evaluation Count:116
116-480
228 return;
executed: return;
Execution Count:480
480
229 -
230 doc->docHandle()->beginEditBlock();
executed (the execution status of this line is deduced): doc->docHandle()->beginEditBlock();
-
231 QTextCursor destCursor(doc);
executed (the execution status of this line is deduced): QTextCursor destCursor(doc);
-
232 QTextCopyHelper(_cursor, destCursor).copy();
executed (the execution status of this line is deduced): QTextCopyHelper(_cursor, destCursor).copy();
-
233 doc->docHandle()->endEditBlock();
executed (the execution status of this line is deduced): doc->docHandle()->endEditBlock();
-
234 -
235 if (_cursor.d)
partially evaluated: _cursor.d
TRUEFALSE
yes
Evaluation Count:116
no
Evaluation Count:0
0-116
236 doc->docHandle()->mergeCachedResources(_cursor.d->priv);
executed: doc->docHandle()->mergeCachedResources(_cursor.d->priv);
Execution Count:116
116
237}
executed: }
Execution Count:116
116
238 -
239void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const -
240{ -
241 if (_cursor.isNull())
partially evaluated: _cursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:551
0-551
242 return;
never executed: return;
0
243 -
244 QTextDocumentPrivate *destPieceTable = _cursor.d->priv;
executed (the execution status of this line is deduced): QTextDocumentPrivate *destPieceTable = _cursor.d->priv;
-
245 destPieceTable->beginEditBlock();
executed (the execution status of this line is deduced): destPieceTable->beginEditBlock();
-
246 -
247 QTextCursor sourceCursor(doc);
executed (the execution status of this line is deduced): QTextCursor sourceCursor(doc);
-
248 sourceCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
executed (the execution status of this line is deduced): sourceCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
-
249 QTextCopyHelper(sourceCursor, _cursor, importedFromPlainText, _cursor.charFormat()).copy();
executed (the execution status of this line is deduced): QTextCopyHelper(sourceCursor, _cursor, importedFromPlainText, _cursor.charFormat()).copy();
-
250 -
251 destPieceTable->endEditBlock();
executed (the execution status of this line is deduced): destPieceTable->endEditBlock();
-
252}
executed: }
Execution Count:551
551
253 -
254/*! -
255 \class QTextDocumentFragment -
256 \reentrant -
257 -
258 \inmodule QtGui -
259 \brief The QTextDocumentFragment class represents a piece of formatted text -
260 from a QTextDocument. -
261 -
262 \ingroup richtext-processing -
263 \ingroup shared -
264 -
265 A QTextDocumentFragment is a fragment of rich text, that can be inserted into -
266 a QTextDocument. A document fragment can be created from a -
267 QTextDocument, from a QTextCursor's selection, or from another -
268 document fragment. Document fragments can also be created by the -
269 static functions, fromPlainText() and fromHtml(). -
270 -
271 The contents of a document fragment can be obtained as plain text -
272 by using the toPlainText() function, or it can be obtained as HTML -
273 with toHtml(). -
274*/ -
275 -
276 -
277/*! -
278 Constructs an empty QTextDocumentFragment. -
279 -
280 \sa isEmpty() -
281*/ -
282QTextDocumentFragment::QTextDocumentFragment() -
283 : d(0) -
284{ -
285}
executed: }
Execution Count:487
487
286 -
287/*! -
288 Converts the given \a document into a QTextDocumentFragment. -
289 Note that the QTextDocumentFragment only stores the document contents, not meta information -
290 like the document's title. -
291*/ -
292QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) -
293 : d(0) -
294{ -
295 if (!document)
partially evaluated: !document
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:85
0-85
296 return;
never executed: return;
0
297 -
298 QTextCursor cursor(const_cast<QTextDocument *>(document));
executed (the execution status of this line is deduced): QTextCursor cursor(const_cast<QTextDocument *>(document));
-
299 cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
-
300 d = new QTextDocumentFragmentPrivate(cursor);
executed (the execution status of this line is deduced): d = new QTextDocumentFragmentPrivate(cursor);
-
301}
executed: }
Execution Count:85
85
302 -
303/*! -
304 Creates a QTextDocumentFragment from the \a{cursor}'s selection. -
305 If the cursor doesn't have a selection, the created fragment is empty. -
306 -
307 \sa isEmpty(), QTextCursor::selection() -
308*/ -
309QTextDocumentFragment::QTextDocumentFragment(const QTextCursor &cursor) -
310 : d(0) -
311{ -
312 if (!cursor.hasSelection())
partially evaluated: !cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
313 return;
never executed: return;
0
314 -
315 d = new QTextDocumentFragmentPrivate(cursor);
executed (the execution status of this line is deduced): d = new QTextDocumentFragmentPrivate(cursor);
-
316}
executed: }
Execution Count:35
35
317 -
318/*! -
319 \fn QTextDocumentFragment::QTextDocumentFragment(const QTextDocumentFragment &other) -
320 -
321 Copy constructor. Creates a copy of the \a other fragment. -
322*/ -
323QTextDocumentFragment::QTextDocumentFragment(const QTextDocumentFragment &rhs) -
324 : d(rhs.d) -
325{ -
326 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:137
no
Evaluation Count:0
0-137
327 d->ref.ref();
executed: d->ref.ref();
Execution Count:137
137
328}
executed: }
Execution Count:137
137
329 -
330/*! -
331 \fn QTextDocumentFragment &QTextDocumentFragment::operator=(const QTextDocumentFragment &other) -
332 -
333 Assigns the \a other fragment to this fragment. -
334*/ -
335QTextDocumentFragment &QTextDocumentFragment::operator=(const QTextDocumentFragment &rhs) -
336{ -
337 if (rhs.d)
evaluated: rhs.d
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3
3-11
338 rhs.d->ref.ref();
executed: rhs.d->ref.ref();
Execution Count:11
11
339 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
partially evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-8
340 delete d;
executed: delete d;
Execution Count:6
6
341 d = rhs.d;
executed (the execution status of this line is deduced): d = rhs.d;
-
342 return *this;
executed: return *this;
Execution Count:14
14
343} -
344 -
345/*! -
346 Destroys the document fragment. -
347*/ -
348QTextDocumentFragment::~QTextDocumentFragment() -
349{ -
350 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:738
yes
Evaluation Count:5
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:590
yes
Evaluation Count:148
5-738
351 delete d;
executed: delete d;
Execution Count:590
590
352}
executed: }
Execution Count:743
743
353 -
354/*! -
355 Returns true if the fragment is empty; otherwise returns false. -
356*/ -
357bool QTextDocumentFragment::isEmpty() const -
358{ -
359 return !d || !d->doc || d->doc->docHandle()->length() <= 1;
executed: return !d || !d->doc || d->doc->docHandle()->length() <= 1;
Execution Count:573
573
360} -
361 -
362/*! -
363 Returns the document fragment's text as plain text (i.e. with no -
364 formatting information). -
365 -
366 \sa toHtml() -
367*/ -
368QString QTextDocumentFragment::toPlainText() const -
369{ -
370 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
371 return QString();
never executed: return QString();
0
372 -
373 return d->doc->toPlainText();
executed: return d->doc->toPlainText();
Execution Count:24
24
374} -
375 -
376#ifndef QT_NO_TEXTHTMLPARSER -
377 -
378/*! -
379 \since 4.2 -
380 -
381 Returns the contents of the document fragment as HTML, -
382 using the specified \a encoding (e.g., "UTF-8", "ISO 8859-1"). -
383 -
384 \sa toPlainText(), QTextDocument::toHtml(), QTextCodec -
385*/ -
386QString QTextDocumentFragment::toHtml(const QByteArray &encoding) const -
387{ -
388 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
389 return QString();
never executed: return QString();
0
390 -
391 return QTextHtmlExporter(d->doc).toHtml(encoding, QTextHtmlExporter::ExportFragment);
executed: return QTextHtmlExporter(d->doc).toHtml(encoding, QTextHtmlExporter::ExportFragment);
Execution Count:9
9
392} -
393 -
394#endif // QT_NO_TEXTHTMLPARSER -
395 -
396/*! -
397 Returns a document fragment that contains the given \a plainText. -
398 -
399 When inserting such a fragment into a QTextDocument the current char format of -
400 the QTextCursor used for insertion is used as format for the text. -
401*/ -
402QTextDocumentFragment QTextDocumentFragment::fromPlainText(const QString &plainText) -
403{ -
404 QTextDocumentFragment res;
executed (the execution status of this line is deduced): QTextDocumentFragment res;
-
405 -
406 res.d = new QTextDocumentFragmentPrivate;
executed (the execution status of this line is deduced): res.d = new QTextDocumentFragmentPrivate;
-
407 res.d->importedFromPlainText = true;
executed (the execution status of this line is deduced): res.d->importedFromPlainText = true;
-
408 QTextCursor cursor(res.d->doc);
executed (the execution status of this line is deduced): QTextCursor cursor(res.d->doc);
-
409 cursor.insertText(plainText);
executed (the execution status of this line is deduced): cursor.insertText(plainText);
-
410 return res;
executed: return res;
Execution Count:4
4
411} -
412 -
413static QTextListFormat::Style nextListStyle(QTextListFormat::Style style) -
414{ -
415 if (style == QTextListFormat::ListDisc)
partially evaluated: style == QTextListFormat::ListDisc
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
416 return QTextListFormat::ListCircle;
executed: return QTextListFormat::ListCircle;
Execution Count:8
8
417 else if (style == QTextListFormat::ListCircle)
never evaluated: style == QTextListFormat::ListCircle
0
418 return QTextListFormat::ListSquare;
never executed: return QTextListFormat::ListSquare;
0
419 return style;
never executed: return style;
0
420} -
421 -
422#ifndef QT_NO_TEXTHTMLPARSER -
423 -
424QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html, ImportMode mode, const QTextDocument *resourceProvider) -
425 : indent(0), compressNextWhitespace(PreserveWhiteSpace), doc(_doc), importMode(mode) -
426{ -
427 cursor = QTextCursor(doc);
executed (the execution status of this line is deduced): cursor = QTextCursor(doc);
-
428 wsm = QTextHtmlParserNode::WhiteSpaceNormal;
executed (the execution status of this line is deduced): wsm = QTextHtmlParserNode::WhiteSpaceNormal;
-
429 -
430 QString html = _html;
executed (the execution status of this line is deduced): QString html = _html;
-
431 const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->"));
executed (the execution status of this line is deduced): const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->"));
-
432 if (startFragmentPos != -1) {
evaluated: startFragmentPos != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:700
6-700
433 QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
executed (the execution status of this line is deduced): QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
-
434 -
435 // Hack for Qt3 -
436 const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader);
executed (the execution status of this line is deduced): const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader);
-
437 -
438 const int endFragmentPos = html.indexOf(QLatin1String("<!--EndFragment-->"));
executed (the execution status of this line is deduced): const int endFragmentPos = html.indexOf(QLatin1String("<!--EndFragment-->"));
-
439 if (startFragmentPos < endFragmentPos)
partially evaluated: startFragmentPos < endFragmentPos
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
440 html = html.mid(startFragmentPos, endFragmentPos - startFragmentPos);
executed: html = html.mid(startFragmentPos, endFragmentPos - startFragmentPos);
Execution Count:6
6
441 else -
442 html = html.mid(startFragmentPos);
never executed: html = html.mid(startFragmentPos);
0
443 -
444 if (hasQtRichtextMetaTag)
evaluated: hasQtRichtextMetaTag
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
445 html.prepend(qt3RichTextHeader);
executed: html.prepend(qt3RichTextHeader);
Execution Count:3
3
446 }
executed: }
Execution Count:6
6
447 -
448 parse(html, resourceProvider ? resourceProvider : doc);
executed (the execution status of this line is deduced): parse(html, resourceProvider ? resourceProvider : doc);
-
449// dumpHtml(); -
450}
executed: }
Execution Count:706
706
451 -
452void QTextHtmlImporter::import() -
453{ -
454 cursor.beginEditBlock();
executed (the execution status of this line is deduced): cursor.beginEditBlock();
-
455 hasBlock = true;
executed (the execution status of this line is deduced): hasBlock = true;
-
456 forceBlockMerging = false;
executed (the execution status of this line is deduced): forceBlockMerging = false;
-
457 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
458 blockTagClosed = false;
executed (the execution status of this line is deduced): blockTagClosed = false;
-
459 for (currentNodeIdx = 0; currentNodeIdx < count(); ++currentNodeIdx) {
evaluated: currentNodeIdx < count()
TRUEFALSE
yes
Evaluation Count:3039
yes
Evaluation Count:706
706-3039
460 currentNode = &at(currentNodeIdx);
executed (the execution status of this line is deduced): currentNode = &at(currentNodeIdx);
-
461 wsm = textEditMode ? QTextHtmlParserNode::WhiteSpacePreWrap : currentNode->wsm;
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:2902
137-2902
462 -
463 /* -
464 * process each node in three stages: -
465 * 1) check if the hierarchy changed and we therefore passed the -
466 * equivalent of a closing tag -> we may need to finish off -
467 * some structures like tables -
468 * -
469 * 2) check if the current node is a special node like a -
470 * <table>, <ul> or <img> tag that requires special processing -
471 * -
472 * 3) if the node should result in a QTextBlock create one and -
473 * finally insert text that may be attached to the node -
474 */ -
475 -
476 /* emit 'closing' table blocks or adjust current indent level -
477 * if we -
478 * 1) are beyond the first node -
479 * 2) the current node not being a child of the previous node -
480 * means there was a tag closing in the input html -
481 */ -
482 if (currentNodeIdx > 0 && (currentNode->parent != currentNodeIdx - 1)) {
evaluated: currentNodeIdx > 0
TRUEFALSE
yes
Evaluation Count:2333
yes
Evaluation Count:706
evaluated: (currentNode->parent != currentNodeIdx - 1)
TRUEFALSE
yes
Evaluation Count:1159
yes
Evaluation Count:1174
706-2333
483 blockTagClosed = closeTag();
executed (the execution status of this line is deduced): blockTagClosed = closeTag();
-
484 // visually collapse subsequent block tags, but if the element after the closed block tag -
485 // is for example an inline element (!isBlock) we have to make sure we start a new paragraph by setting -
486 // hasBlock to false. -
487 if (blockTagClosed
evaluated: blockTagClosed
TRUEFALSE
yes
Evaluation Count:654
yes
Evaluation Count:505
505-654
488 && !currentNode->isBlock()
evaluated: !currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:495
yes
Evaluation Count:159
159-495
489 && currentNode->id != Html_unknown)
evaluated: currentNode->id != Html_unknown
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:462
33-462
490 { -
491 hasBlock = false;
executed (the execution status of this line is deduced): hasBlock = false;
-
492 } else if (hasBlock) {
executed: }
Execution Count:33
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:132
yes
Evaluation Count:994
33-994
493 // when collapsing subsequent block tags we need to clear the block format -
494 QTextBlockFormat blockFormat = currentNode->blockFormat;
executed (the execution status of this line is deduced): QTextBlockFormat blockFormat = currentNode->blockFormat;
-
495 blockFormat.setIndent(indent);
executed (the execution status of this line is deduced): blockFormat.setIndent(indent);
-
496 -
497 QTextBlockFormat oldFormat = cursor.blockFormat();
executed (the execution status of this line is deduced): QTextBlockFormat oldFormat = cursor.blockFormat();
-
498 if (oldFormat.hasProperty(QTextFormat::PageBreakPolicy)) {
evaluated: oldFormat.hasProperty(QTextFormat::PageBreakPolicy)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:130
2-130
499 QTextFormat::PageBreakFlags pageBreak = oldFormat.pageBreakPolicy();
executed (the execution status of this line is deduced): QTextFormat::PageBreakFlags pageBreak = oldFormat.pageBreakPolicy();
-
500 if (pageBreak == QTextFormat::PageBreak_AlwaysAfter)
evaluated: pageBreak == QTextFormat::PageBreak_AlwaysAfter
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
501 /* We remove an empty paragrah that requested a page break after. -
502 moving that request to the next paragraph means we also need to make -
503 that a pagebreak before to keep the same visual appearance. -
504 */ -
505 pageBreak = QTextFormat::PageBreak_AlwaysBefore;
executed: pageBreak = QTextFormat::PageBreak_AlwaysBefore;
Execution Count:1
1
506 blockFormat.setPageBreakPolicy(pageBreak);
executed (the execution status of this line is deduced): blockFormat.setPageBreakPolicy(pageBreak);
-
507 }
executed: }
Execution Count:2
2
508 -
509 cursor.setBlockFormat(blockFormat);
executed (the execution status of this line is deduced): cursor.setBlockFormat(blockFormat);
-
510 }
executed: }
Execution Count:132
132
511 } -
512 -
513 if (currentNode->displayMode == QTextHtmlElement::DisplayNone) {
evaluated: currentNode->displayMode == QTextHtmlElement::DisplayNone
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:2932
107-2932
514 if (currentNode->id == Html_title)
evaluated: currentNode->id == Html_title
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:87
20-87
515 doc->setMetaInformation(QTextDocument::DocumentTitle, currentNode->text);
executed: doc->setMetaInformation(QTextDocument::DocumentTitle, currentNode->text);
Execution Count:20
20
516 // ignore explicitly 'invisible' elements -
517 continue;
executed: continue;
Execution Count:107
107
518 } -
519 -
520 if (processSpecialNodes() == ContinueWithNextNode)
evaluated: processSpecialNodes() == ContinueWithNextNode
TRUEFALSE
yes
Evaluation Count:255
yes
Evaluation Count:2677
255-2677
521 continue;
executed: continue;
Execution Count:255
255
522 -
523 // make sure there's a block for 'Blah' after <ul><li>foo</ul>Blah -
524 if (blockTagClosed
evaluated: blockTagClosed
TRUEFALSE
yes
Evaluation Count:653
yes
Evaluation Count:2024
653-2024
525 && !hasBlock
evaluated: !hasBlock
TRUEFALSE
yes
Evaluation Count:627
yes
Evaluation Count:26
26-627
526 && !currentNode->isBlock()
evaluated: !currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:470
yes
Evaluation Count:157
157-470
527 && !currentNode->text.isEmpty() && !currentNode->hasOnlyWhitespace()
evaluated: !currentNode->text.isEmpty()
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:405
evaluated: !currentNode->hasOnlyWhitespace()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:48
17-405
528 && currentNode->displayMode == QTextHtmlElement::DisplayInline) {
partially evaluated: currentNode->displayMode == QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
529 -
530 QTextBlockFormat block = currentNode->blockFormat;
executed (the execution status of this line is deduced): QTextBlockFormat block = currentNode->blockFormat;
-
531 block.setIndent(indent);
executed (the execution status of this line is deduced): block.setIndent(indent);
-
532 -
533 appendBlock(block, currentNode->charFormat);
executed (the execution status of this line is deduced): appendBlock(block, currentNode->charFormat);
-
534 -
535 hasBlock = true;
executed (the execution status of this line is deduced): hasBlock = true;
-
536 }
executed: }
Execution Count:17
17
537 -
538 if (currentNode->isBlock()) {
evaluated: currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:854
yes
Evaluation Count:1823
854-1823
539 QTextHtmlImporter::ProcessNodeResult result = processBlockNode();
executed (the execution status of this line is deduced): QTextHtmlImporter::ProcessNodeResult result = processBlockNode();
-
540 if (result == ContinueWithNextNode) {
partially evaluated: result == ContinueWithNextNode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:854
0-854
541 continue;
never executed: continue;
0
542 } else if (result == ContinueWithNextSibling) {
evaluated: result == ContinueWithNextSibling
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:821
33-821
543 currentNodeIdx += currentNode->children.size();
executed (the execution status of this line is deduced): currentNodeIdx += currentNode->children.size();
-
544 continue;
executed: continue;
Execution Count:33
33
545 } -
546 } -
547 -
548 if (currentNode->charFormat.isAnchor() && !currentNode->charFormat.anchorName().isEmpty()) {
evaluated: currentNode->charFormat.isAnchor()
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:2570
evaluated: !currentNode->charFormat.anchorName().isEmpty()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:48
26-2570
549 namedAnchors.append(currentNode->charFormat.anchorName());
executed (the execution status of this line is deduced): namedAnchors.append(currentNode->charFormat.anchorName());
-
550 }
executed: }
Execution Count:26
26
551 -
552 if (appendNodeText())
evaluated: appendNodeText()
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1498
1146-1498
553 hasBlock = false; // if we actually appended text then we don't
executed: hasBlock = false;
Execution Count:1146
1146
554 // have an empty block anymore -
555 }
executed: }
Execution Count:2644
2644
556 -
557 cursor.endEditBlock();
executed (the execution status of this line is deduced): cursor.endEditBlock();
-
558}
executed: }
Execution Count:706
706
559 -
560bool QTextHtmlImporter::appendNodeText() -
561{ -
562 const int initialCursorPosition = cursor.position();
executed (the execution status of this line is deduced): const int initialCursorPosition = cursor.position();
-
563 QTextCharFormat format = currentNode->charFormat;
executed (the execution status of this line is deduced): QTextCharFormat format = currentNode->charFormat;
-
564 -
565 if(wsm == QTextHtmlParserNode::WhiteSpacePre || wsm == QTextHtmlParserNode::WhiteSpacePreWrap)
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:372
yes
Evaluation Count:2272
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:2203
69-2272
566 compressNextWhitespace = PreserveWhiteSpace;
executed: compressNextWhitespace = PreserveWhiteSpace;
Execution Count:441
441
567 -
568 QString text = currentNode->text;
executed (the execution status of this line is deduced): QString text = currentNode->text;
-
569 -
570 QString textToInsert;
executed (the execution status of this line is deduced): QString textToInsert;
-
571 textToInsert.reserve(text.size());
executed (the execution status of this line is deduced): textToInsert.reserve(text.size());
-
572 -
573 for (int i = 0; i < text.length(); ++i) {
evaluated: i < text.length()
TRUEFALSE
yes
Evaluation Count:302597
yes
Evaluation Count:2644
2644-302597
574 QChar ch = text.at(i);
executed (the execution status of this line is deduced): QChar ch = text.at(i);
-
575 -
576 if (ch.isSpace()
evaluated: ch.isSpace()
TRUEFALSE
yes
Evaluation Count:60412
yes
Evaluation Count:242185
60412-242185
577 && ch != QChar::Nbsp
evaluated: ch != QChar::Nbsp
TRUEFALSE
yes
Evaluation Count:60409
yes
Evaluation Count:3
3-60409
578 && ch != QChar::ParagraphSeparator) {
partially evaluated: ch != QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:60409
no
Evaluation Count:0
0-60409
579 -
580 if (compressNextWhitespace == CollapseWhiteSpace)
evaluated: compressNextWhitespace == CollapseWhiteSpace
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:60407
2-60407
581 compressNextWhitespace = RemoveWhiteSpace; // allow this one, and remove the ones coming next.
executed: compressNextWhitespace = RemoveWhiteSpace;
Execution Count:2
2
582 else if(compressNextWhitespace == RemoveWhiteSpace)
evaluated: compressNextWhitespace == RemoveWhiteSpace
TRUEFALSE
yes
Evaluation Count:295
yes
Evaluation Count:60112
295-60112
583 continue;
executed: continue;
Execution Count:295
295
584 -
585 if (wsm == QTextHtmlParserNode::WhiteSpacePre
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:60002
112-60002
586 || textEditMode
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:59871
131-59871
587 ) { -
588 if (ch == QLatin1Char('\n')) {
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:220
23-220
589 if (textEditMode)
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:3
3-20
590 continue;
executed: continue;
Execution Count:20
20
591 } else if (ch == QLatin1Char('\r')) {
executed: }
Execution Count:3
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:219
1-219
592 continue;
executed: continue;
Execution Count:1
1
593 } -
594 } else if (wsm != QTextHtmlParserNode::WhiteSpacePreWrap) {
evaluated: wsm != QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:59863
yes
Evaluation Count:8
8-59863
595 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
596 if (wsm == QTextHtmlParserNode::WhiteSpaceNoWrap)
evaluated: wsm == QTextHtmlParserNode::WhiteSpaceNoWrap
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:59858
5-59858
597 ch = QChar::Nbsp;
executed: ch = QChar::Nbsp;
Execution Count:5
5
598 else -
599 ch = QLatin1Char(' ');
executed: ch = QLatin1Char(' ');
Execution Count:59858
59858
600 } -
601 } else { -
602 compressNextWhitespace = PreserveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = PreserveWhiteSpace;
-
603 }
executed: }
Execution Count:242188
242188
604 -
605 if (ch == QLatin1Char('\n')
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:302278
3-302278
606 || ch == QChar::ParagraphSeparator) {
partially evaluated: ch == QChar::ParagraphSeparator
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:302278
0-302278
607 -
608 if (!textToInsert.isEmpty()) {
evaluated: !textToInsert.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
609 cursor.insertText(textToInsert, format);
executed (the execution status of this line is deduced): cursor.insertText(textToInsert, format);
-
610 textToInsert.clear();
executed (the execution status of this line is deduced): textToInsert.clear();
-
611 }
executed: }
Execution Count:2
2
612 -
613 QTextBlockFormat fmt = cursor.blockFormat();
executed (the execution status of this line is deduced): QTextBlockFormat fmt = cursor.blockFormat();
-
614 -
615 if (fmt.hasProperty(QTextFormat::BlockBottomMargin)) {
partially evaluated: fmt.hasProperty(QTextFormat::BlockBottomMargin)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
616 QTextBlockFormat tmp = fmt;
executed (the execution status of this line is deduced): QTextBlockFormat tmp = fmt;
-
617 tmp.clearProperty(QTextFormat::BlockBottomMargin);
executed (the execution status of this line is deduced): tmp.clearProperty(QTextFormat::BlockBottomMargin);
-
618 cursor.setBlockFormat(tmp);
executed (the execution status of this line is deduced): cursor.setBlockFormat(tmp);
-
619 }
executed: }
Execution Count:3
3
620 -
621 fmt.clearProperty(QTextFormat::BlockTopMargin);
executed (the execution status of this line is deduced): fmt.clearProperty(QTextFormat::BlockTopMargin);
-
622 appendBlock(fmt, cursor.charFormat());
executed (the execution status of this line is deduced): appendBlock(fmt, cursor.charFormat());
-
623 } else {
executed: }
Execution Count:3
3
624 if (!namedAnchors.isEmpty()) {
evaluated: !namedAnchors.isEmpty()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:302253
25-302253
625 if (!textToInsert.isEmpty()) {
partially evaluated: !textToInsert.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
626 cursor.insertText(textToInsert, format);
never executed (the execution status of this line is deduced): cursor.insertText(textToInsert, format);
-
627 textToInsert.clear();
never executed (the execution status of this line is deduced): textToInsert.clear();
-
628 }
never executed: }
0
629 -
630 format.setAnchor(true);
executed (the execution status of this line is deduced): format.setAnchor(true);
-
631 format.setAnchorNames(namedAnchors);
executed (the execution status of this line is deduced): format.setAnchorNames(namedAnchors);
-
632 cursor.insertText(ch, format);
executed (the execution status of this line is deduced): cursor.insertText(ch, format);
-
633 namedAnchors.clear();
executed (the execution status of this line is deduced): namedAnchors.clear();
-
634 format.clearProperty(QTextFormat::IsAnchor);
executed (the execution status of this line is deduced): format.clearProperty(QTextFormat::IsAnchor);
-
635 format.clearProperty(QTextFormat::AnchorName);
executed (the execution status of this line is deduced): format.clearProperty(QTextFormat::AnchorName);
-
636 } else {
executed: }
Execution Count:25
25
637 textToInsert += ch;
executed (the execution status of this line is deduced): textToInsert += ch;
-
638 }
executed: }
Execution Count:302253
302253
639 } -
640 } -
641 -
642 if (!textToInsert.isEmpty()) {
evaluated: !textToInsert.isEmpty()
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1498
1146-1498
643 cursor.insertText(textToInsert, format);
executed (the execution status of this line is deduced): cursor.insertText(textToInsert, format);
-
644 }
executed: }
Execution Count:1146
1146
645 -
646 return cursor.position() != initialCursorPosition;
executed: return cursor.position() != initialCursorPosition;
Execution Count:2644
2644
647} -
648 -
649QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() -
650{ -
651 switch (currentNode->id) { -
652 case Html_body: -
653 if (currentNode->charFormat.background().style() != Qt::NoBrush) {
evaluated: currentNode->charFormat.background().style() != Qt::NoBrush
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:60
12-60
654 QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
executed (the execution status of this line is deduced): QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
-
655 fmt.setBackground(currentNode->charFormat.background());
executed (the execution status of this line is deduced): fmt.setBackground(currentNode->charFormat.background());
-
656 doc->rootFrame()->setFrameFormat(fmt);
executed (the execution status of this line is deduced): doc->rootFrame()->setFrameFormat(fmt);
-
657 const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush);
executed (the execution status of this line is deduced): const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush);
-
658 }
executed: }
Execution Count:12
12
659 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
660 break;
executed: break;
Execution Count:72
72
661 -
662 case Html_ol: -
663 case Html_ul: { -
664 QTextListFormat::Style style = currentNode->listStyle;
executed (the execution status of this line is deduced): QTextListFormat::Style style = currentNode->listStyle;
-
665 -
666 if (currentNode->id == Html_ul && !currentNode->hasOwnListStyle && currentNode->parent) {
evaluated: currentNode->id == Html_ul
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:5
evaluated: !currentNode->hasOwnListStyle
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:10
evaluated: currentNode->parent
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:15
5-35
667 const QTextHtmlParserNode *n = &at(currentNode->parent);
executed (the execution status of this line is deduced): const QTextHtmlParserNode *n = &at(currentNode->parent);
-
668 while (n) {
evaluated: n
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:10
10-19
669 if (n->id == Html_ul) {
evaluated: n->id == Html_ul
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:11
8-11
670 style = nextListStyle(currentNode->listStyle);
executed (the execution status of this line is deduced): style = nextListStyle(currentNode->listStyle);
-
671 }
executed: }
Execution Count:8
8
672 if (n->parent)
evaluated: n->parent
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:10
9-10
673 n = &at(n->parent);
executed: n = &at(n->parent);
Execution Count:9
9
674 else -
675 n = 0;
executed: n = 0;
Execution Count:10
10
676 } -
677 }
executed: }
Execution Count:10
10
678 -
679 QTextListFormat listFmt;
executed (the execution status of this line is deduced): QTextListFormat listFmt;
-
680 listFmt.setStyle(style);
executed (the execution status of this line is deduced): listFmt.setStyle(style);
-
681 if (!currentNode->textListNumberPrefix.isNull())
evaluated: !currentNode->textListNumberPrefix.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:39
1-39
682 listFmt.setNumberPrefix(currentNode->textListNumberPrefix);
executed: listFmt.setNumberPrefix(currentNode->textListNumberPrefix);
Execution Count:1
1
683 if (!currentNode->textListNumberSuffix.isNull())
evaluated: !currentNode->textListNumberSuffix.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:39
1-39
684 listFmt.setNumberSuffix(currentNode->textListNumberSuffix);
executed: listFmt.setNumberSuffix(currentNode->textListNumberSuffix);
Execution Count:1
1
685 -
686 ++indent;
executed (the execution status of this line is deduced): ++indent;
-
687 if (currentNode->hasCssListIndent)
evaluated: currentNode->hasCssListIndent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38
2-38
688 listFmt.setIndent(currentNode->cssListIndent);
executed: listFmt.setIndent(currentNode->cssListIndent);
Execution Count:2
2
689 else -
690 listFmt.setIndent(indent);
executed: listFmt.setIndent(indent);
Execution Count:38
38
691 -
692 List l;
executed (the execution status of this line is deduced): List l;
-
693 l.format = listFmt;
executed (the execution status of this line is deduced): l.format = listFmt;
-
694 l.listNode = currentNodeIdx;
executed (the execution status of this line is deduced): l.listNode = currentNodeIdx;
-
695 lists.append(l);
executed (the execution status of this line is deduced): lists.append(l);
-
696 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
697 -
698 // broken html: <ul>Text here<li>Foo -
699 const QString simpl = currentNode->text.simplified();
executed (the execution status of this line is deduced): const QString simpl = currentNode->text.simplified();
-
700 if (simpl.isEmpty() || simpl.at(0).isSpace())
evaluated: simpl.isEmpty()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:1
partially evaluated: simpl.at(0).isSpace()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-39
701 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:39
39
702 break;
executed: break;
Execution Count:1
1
703 } -
704 -
705 case Html_table: { -
706 Table t = scanTable(currentNodeIdx);
executed (the execution status of this line is deduced): Table t = scanTable(currentNodeIdx);
-
707 tables.append(t);
executed (the execution status of this line is deduced): tables.append(t);
-
708 hasBlock = false;
executed (the execution status of this line is deduced): hasBlock = false;
-
709 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
710 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:79
79
711 } -
712 -
713 case Html_tr: -
714 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:104
104
715 -
716 case Html_img: { -
717 QTextImageFormat fmt;
executed (the execution status of this line is deduced): QTextImageFormat fmt;
-
718 fmt.setName(currentNode->imageName);
executed (the execution status of this line is deduced): fmt.setName(currentNode->imageName);
-
719 -
720 fmt.merge(currentNode->charFormat);
executed (the execution status of this line is deduced): fmt.merge(currentNode->charFormat);
-
721 -
722 if (currentNode->imageWidth != -1)
evaluated: currentNode->imageWidth != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:20
4-20
723 fmt.setWidth(currentNode->imageWidth);
executed: fmt.setWidth(currentNode->imageWidth);
Execution Count:4
4
724 if (currentNode->imageHeight != -1)
evaluated: currentNode->imageHeight != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:20
4-20
725 fmt.setHeight(currentNode->imageHeight);
executed: fmt.setHeight(currentNode->imageHeight);
Execution Count:4
4
726 -
727 cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
executed (the execution status of this line is deduced): cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat));
-
728 -
729 cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
-
730 cursor.mergeCharFormat(currentNode->charFormat);
executed (the execution status of this line is deduced): cursor.mergeCharFormat(currentNode->charFormat);
-
731 cursor.movePosition(QTextCursor::Right);
executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::Right);
-
732 compressNextWhitespace = CollapseWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = CollapseWhiteSpace;
-
733 -
734 hasBlock = false;
executed (the execution status of this line is deduced): hasBlock = false;
-
735 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:24
24
736 } -
737 -
738 case Html_hr: { -
739 QTextBlockFormat blockFormat = currentNode->blockFormat;
executed (the execution status of this line is deduced): QTextBlockFormat blockFormat = currentNode->blockFormat;
-
740 blockFormat.setTopMargin(topMargin(currentNodeIdx));
executed (the execution status of this line is deduced): blockFormat.setTopMargin(topMargin(currentNodeIdx));
-
741 blockFormat.setBottomMargin(bottomMargin(currentNodeIdx));
executed (the execution status of this line is deduced): blockFormat.setBottomMargin(bottomMargin(currentNodeIdx));
-
742 blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width);
executed (the execution status of this line is deduced): blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width);
-
743 if (hasBlock && importMode == ImportToDocument)
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
evaluated: importMode == ImportToDocument
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-5
744 cursor.mergeBlockFormat(blockFormat);
executed: cursor.mergeBlockFormat(blockFormat);
Execution Count:2
2
745 else -
746 appendBlock(blockFormat);
executed: appendBlock(blockFormat);
Execution Count:7
7
747 hasBlock = false;
executed (the execution status of this line is deduced): hasBlock = false;
-
748 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
749 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:9
9
750 } -
751 -
752 default: break;
executed: break;
Execution Count:2604
2604
753 } -
754 return ContinueWithCurrentNode;
executed: return ContinueWithCurrentNode;
Execution Count:2677
2677
755} -
756 -
757// returns true if a block tag was closed -
758bool QTextHtmlImporter::closeTag() -
759{ -
760 const QTextHtmlParserNode *closedNode = &at(currentNodeIdx - 1);
executed (the execution status of this line is deduced): const QTextHtmlParserNode *closedNode = &at(currentNodeIdx - 1);
-
761 const int endDepth = depth(currentNodeIdx) - 1;
executed (the execution status of this line is deduced): const int endDepth = depth(currentNodeIdx) - 1;
-
762 int depth = this->depth(currentNodeIdx - 1);
executed (the execution status of this line is deduced): int depth = this->depth(currentNodeIdx - 1);
-
763 bool blockTagClosed = false;
executed (the execution status of this line is deduced): bool blockTagClosed = false;
-
764 -
765 while (depth > endDepth) {
evaluated: depth > endDepth
TRUEFALSE
yes
Evaluation Count:1616
yes
Evaluation Count:1159
1159-1616
766 Table *t = 0;
executed (the execution status of this line is deduced): Table *t = 0;
-
767 if (!tables.isEmpty())
evaluated: !tables.isEmpty()
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:1235
381-1235
768 t = &tables.last();
executed: t = &tables.last();
Execution Count:381
381
769 -
770 switch (closedNode->id) { -
771 case Html_tr: -
772 if (t && !t->isTextFrame) {
partially evaluated: t
TRUEFALSE
yes
Evaluation Count:99
no
Evaluation Count:0
evaluated: !t->isTextFrame
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:4
0-99
773 ++t->currentRow;
executed (the execution status of this line is deduced): ++t->currentRow;
-
774 -
775 // for broken html with rowspans but missing tr tags -
776 while (!t->currentCell.atEnd() && t->currentCell.row < t->currentRow)
evaluated: !t->currentCell.atEnd()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:68
evaluated: t->currentCell.row < t->currentRow
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:27
5-68
777 ++t->currentCell;
executed: ++t->currentCell;
Execution Count:5
5
778 }
executed: }
Execution Count:95
95
779 -
780 blockTagClosed = true;
executed (the execution status of this line is deduced): blockTagClosed = true;
-
781 break;
executed: break;
Execution Count:99
99
782 -
783 case Html_table: -
784 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
785 break;
never executed: break;
0
786 indent = t->lastIndent;
executed (the execution status of this line is deduced): indent = t->lastIndent;
-
787 -
788 tables.resize(tables.size() - 1);
executed (the execution status of this line is deduced): tables.resize(tables.size() - 1);
-
789 t = 0;
executed (the execution status of this line is deduced): t = 0;
-
790 -
791 if (tables.isEmpty()) {
evaluated: tables.isEmpty()
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:6
6-65
792 cursor = doc->rootFrame()->lastCursorPosition();
executed (the execution status of this line is deduced): cursor = doc->rootFrame()->lastCursorPosition();
-
793 } else {
executed: }
Execution Count:65
65
794 t = &tables.last();
executed (the execution status of this line is deduced): t = &tables.last();
-
795 if (t->isTextFrame)
partially evaluated: t->isTextFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
796 cursor = t->frame->lastCursorPosition();
never executed: cursor = t->frame->lastCursorPosition();
0
797 else if (!t->currentCell.atEnd())
evaluated: !t->currentCell.atEnd()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
798 cursor = t->currentCell.cell().lastCursorPosition();
executed: cursor = t->currentCell.cell().lastCursorPosition();
Execution Count:5
5
799 } -
800 -
801 // we don't need an extra block after tables, so we don't -
802 // claim to have closed one for the creation of a new one -
803 // in import() -
804 blockTagClosed = false;
executed (the execution status of this line is deduced): blockTagClosed = false;
-
805 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
806 break;
executed: break;
Execution Count:71
71
807 -
808 case Html_th: -
809 case Html_td: -
810 if (t && !t->isTextFrame)
partially evaluated: t
TRUEFALSE
yes
Evaluation Count:154
no
Evaluation Count:0
evaluated: !t->isTextFrame
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:4
0-154
811 ++t->currentCell;
executed: ++t->currentCell;
Execution Count:150
150
812 blockTagClosed = true;
executed (the execution status of this line is deduced): blockTagClosed = true;
-
813 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
814 break;
executed: break;
Execution Count:154
154
815 -
816 case Html_ol: -
817 case Html_ul: -
818 if (lists.isEmpty())
partially evaluated: lists.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
819 break;
never executed: break;
0
820 lists.resize(lists.size() - 1);
executed (the execution status of this line is deduced): lists.resize(lists.size() - 1);
-
821 --indent;
executed (the execution status of this line is deduced): --indent;
-
822 blockTagClosed = true;
executed (the execution status of this line is deduced): blockTagClosed = true;
-
823 break;
executed: break;
Execution Count:34
34
824 -
825 case Html_br: -
826 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
827 break;
executed: break;
Execution Count:127
127
828 -
829 case Html_div: -
830 if (closedNode->children.isEmpty())
evaluated: closedNode->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
831 break;
executed: break;
Execution Count:12
12
832 // fall through -
833 default:
code before this statement executed: default:
Execution Count:1
1
834 if (closedNode->isBlock())
evaluated: closedNode->isBlock()
TRUEFALSE
yes
Evaluation Count:594
yes
Evaluation Count:525
525-594
835 blockTagClosed = true;
executed: blockTagClosed = true;
Execution Count:594
594
836 break;
executed: break;
Execution Count:1119
1119
837 } -
838 -
839 closedNode = &at(closedNode->parent);
executed (the execution status of this line is deduced): closedNode = &at(closedNode->parent);
-
840 --depth;
executed (the execution status of this line is deduced): --depth;
-
841 }
executed: }
Execution Count:1616
1616
842 -
843 return blockTagClosed;
executed: return blockTagClosed;
Execution Count:1159
1159
844} -
845 -
846QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) -
847{ -
848 Table table;
executed (the execution status of this line is deduced): Table table;
-
849 table.columns = 0;
executed (the execution status of this line is deduced): table.columns = 0;
-
850 -
851 QVector<QTextLength> columnWidths;
executed (the execution status of this line is deduced): QVector<QTextLength> columnWidths;
-
852 -
853 int tableHeaderRowCount = 0;
executed (the execution status of this line is deduced): int tableHeaderRowCount = 0;
-
854 QVector<int> rowNodes;
executed (the execution status of this line is deduced): QVector<int> rowNodes;
-
855 rowNodes.reserve(at(tableNodeIdx).children.count());
executed (the execution status of this line is deduced): rowNodes.reserve(at(tableNodeIdx).children.count());
-
856 foreach (int row, at(tableNodeIdx).children)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(at(tableNodeIdx).children)> _container_(at(tableNodeIdx).children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (int row = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
857 switch (at(row).id) { -
858 case Html_tr: -
859 rowNodes += row;
executed (the execution status of this line is deduced): rowNodes += row;
-
860 break;
executed: break;
Execution Count:99
99
861 case Html_thead: -
862 case Html_tbody: -
863 case Html_tfoot: -
864 foreach (int potentialRow, at(row).children)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(at(row).children)> _container_(at(row).children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (int potentialRow = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
865 if (at(potentialRow).id == Html_tr) {
partially evaluated: at(potentialRow).id == Html_tr
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
866 rowNodes += potentialRow;
executed (the execution status of this line is deduced): rowNodes += potentialRow;
-
867 if (at(row).id == Html_thead)
evaluated: at(row).id == Html_thead
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
868 ++tableHeaderRowCount;
executed: ++tableHeaderRowCount;
Execution Count:2
2
869 }
executed: }
Execution Count:5
5
870 break;
executed: break;
Execution Count:5
5
871 default: break;
executed: break;
Execution Count:4
4
872 }
never executed: }
0
873 -
874 QVector<RowColSpanInfo> rowColSpans;
executed (the execution status of this line is deduced): QVector<RowColSpanInfo> rowColSpans;
-
875 QVector<RowColSpanInfo> rowColSpanForColumn;
executed (the execution status of this line is deduced): QVector<RowColSpanInfo> rowColSpanForColumn;
-
876 -
877 int effectiveRow = 0;
executed (the execution status of this line is deduced): int effectiveRow = 0;
-
878 foreach (int row, rowNodes) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(rowNodes)> _container_(rowNodes); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (int row = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
879 int colsInRow = 0;
executed (the execution status of this line is deduced): int colsInRow = 0;
-
880 -
881 foreach (int cell, at(row).children)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(at(row).children)> _container_(at(row).children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (int cell = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
882 if (at(cell).isTableCell()) {
partially evaluated: at(cell).isTableCell()
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-158
883 // skip all columns with spans from previous rows -
884 while (colsInRow < rowColSpanForColumn.size()) {
evaluated: colsInRow < rowColSpanForColumn.size()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:115
45-115
885 const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow];
executed (the execution status of this line is deduced): const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow];
-
886 -
887 if (spanInfo.row + spanInfo.rowSpan > effectiveRow) {
evaluated: spanInfo.row + spanInfo.rowSpan > effectiveRow
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:43
2-43
888 Q_ASSERT(spanInfo.col == colsInRow);
executed (the execution status of this line is deduced): qt_noop();
-
889 colsInRow += spanInfo.colSpan;
executed (the execution status of this line is deduced): colsInRow += spanInfo.colSpan;
-
890 } else
executed: }
Execution Count:2
2
891 break;
executed: break;
Execution Count:43
43
892 } -
893 -
894 const QTextHtmlParserNode &c = at(cell);
executed (the execution status of this line is deduced): const QTextHtmlParserNode &c = at(cell);
-
895 const int currentColumn = colsInRow;
executed (the execution status of this line is deduced): const int currentColumn = colsInRow;
-
896 colsInRow += c.tableCellColSpan;
executed (the execution status of this line is deduced): colsInRow += c.tableCellColSpan;
-
897 -
898 RowColSpanInfo spanInfo;
executed (the execution status of this line is deduced): RowColSpanInfo spanInfo;
-
899 spanInfo.row = effectiveRow;
executed (the execution status of this line is deduced): spanInfo.row = effectiveRow;
-
900 spanInfo.col = currentColumn;
executed (the execution status of this line is deduced): spanInfo.col = currentColumn;
-
901 spanInfo.colSpan = c.tableCellColSpan;
executed (the execution status of this line is deduced): spanInfo.colSpan = c.tableCellColSpan;
-
902 spanInfo.rowSpan = c.tableCellRowSpan;
executed (the execution status of this line is deduced): spanInfo.rowSpan = c.tableCellRowSpan;
-
903 if (spanInfo.colSpan > 1 || spanInfo.rowSpan > 1)
evaluated: spanInfo.colSpan > 1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:152
evaluated: spanInfo.rowSpan > 1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:145
6-152
904 rowColSpans.append(spanInfo);
executed: rowColSpans.append(spanInfo);
Execution Count:13
13
905 -
906 columnWidths.resize(qMax(columnWidths.count(), colsInRow));
executed (the execution status of this line is deduced): columnWidths.resize(qMax(columnWidths.count(), colsInRow));
-
907 rowColSpanForColumn.resize(columnWidths.size());
executed (the execution status of this line is deduced): rowColSpanForColumn.resize(columnWidths.size());
-
908 for (int i = currentColumn; i < currentColumn + c.tableCellColSpan; ++i) {
evaluated: i < currentColumn + c.tableCellColSpan
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:158
158-170
909 if (columnWidths.at(i).type() == QTextLength::VariableLength) {
evaluated: columnWidths.at(i).type() == QTextLength::VariableLength
TRUEFALSE
yes
Evaluation Count:166
yes
Evaluation Count:4
4-166
910 QTextLength w = c.width;
executed (the execution status of this line is deduced): QTextLength w = c.width;
-
911 if (c.tableCellColSpan > 1 && w.type() != QTextLength::VariableLength)
evaluated: c.tableCellColSpan > 1
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:148
evaluated: w.type() != QTextLength::VariableLength
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
4-148
912 w = QTextLength(w.type(), w.value(100.) / c.tableCellColSpan);
executed: w = QTextLength(w.type(), w.value(100.) / c.tableCellColSpan);
Execution Count:4
4
913 columnWidths[i] = w;
executed (the execution status of this line is deduced): columnWidths[i] = w;
-
914 }
executed: }
Execution Count:166
166
915 rowColSpanForColumn[i] = spanInfo;
executed (the execution status of this line is deduced): rowColSpanForColumn[i] = spanInfo;
-
916 }
executed: }
Execution Count:170
170
917 }
executed: }
Execution Count:158
158
918 -
919 table.columns = qMax(table.columns, colsInRow);
executed (the execution status of this line is deduced): table.columns = qMax(table.columns, colsInRow);
-
920 -
921 ++effectiveRow;
executed (the execution status of this line is deduced): ++effectiveRow;
-
922 }
executed: }
Execution Count:104
104
923 table.rows = effectiveRow;
executed (the execution status of this line is deduced): table.rows = effectiveRow;
-
924 -
925 table.lastIndent = indent;
executed (the execution status of this line is deduced): table.lastIndent = indent;
-
926 indent = 0;
executed (the execution status of this line is deduced): indent = 0;
-
927 -
928 if (table.rows == 0 || table.columns == 0)
evaluated: table.rows == 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:75
partially evaluated: table.columns == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
929 return table;
executed: return table;
Execution Count:4
4
930 -
931 QTextFrameFormat fmt;
executed (the execution status of this line is deduced): QTextFrameFormat fmt;
-
932 const QTextHtmlParserNode &node = at(tableNodeIdx);
executed (the execution status of this line is deduced): const QTextHtmlParserNode &node = at(tableNodeIdx);
-
933 -
934 if (!node.isTextFrame) {
evaluated: !node.isTextFrame
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:4
4-71
935 QTextTableFormat tableFmt;
executed (the execution status of this line is deduced): QTextTableFormat tableFmt;
-
936 tableFmt.setCellSpacing(node.tableCellSpacing);
executed (the execution status of this line is deduced): tableFmt.setCellSpacing(node.tableCellSpacing);
-
937 tableFmt.setCellPadding(node.tableCellPadding);
executed (the execution status of this line is deduced): tableFmt.setCellPadding(node.tableCellPadding);
-
938 if (node.blockFormat.hasProperty(QTextFormat::BlockAlignment))
evaluated: node.blockFormat.hasProperty(QTextFormat::BlockAlignment)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:65
6-65
939 tableFmt.setAlignment(node.blockFormat.alignment());
executed: tableFmt.setAlignment(node.blockFormat.alignment());
Execution Count:6
6
940 tableFmt.setColumns(table.columns);
executed (the execution status of this line is deduced): tableFmt.setColumns(table.columns);
-
941 tableFmt.setColumnWidthConstraints(columnWidths);
executed (the execution status of this line is deduced): tableFmt.setColumnWidthConstraints(columnWidths);
-
942 tableFmt.setHeaderRowCount(tableHeaderRowCount);
executed (the execution status of this line is deduced): tableFmt.setHeaderRowCount(tableHeaderRowCount);
-
943 fmt = tableFmt;
executed (the execution status of this line is deduced): fmt = tableFmt;
-
944 }
executed: }
Execution Count:71
71
945 -
946 fmt.setTopMargin(topMargin(tableNodeIdx));
executed (the execution status of this line is deduced): fmt.setTopMargin(topMargin(tableNodeIdx));
-
947 fmt.setBottomMargin(bottomMargin(tableNodeIdx));
executed (the execution status of this line is deduced): fmt.setBottomMargin(bottomMargin(tableNodeIdx));
-
948 fmt.setLeftMargin(leftMargin(tableNodeIdx)
executed (the execution status of this line is deduced): fmt.setLeftMargin(leftMargin(tableNodeIdx)
-
949 + table.lastIndent * 40 // ##### not a good emulation
executed (the execution status of this line is deduced): + table.lastIndent * 40
-
950 );
executed (the execution status of this line is deduced): );
-
951 fmt.setRightMargin(rightMargin(tableNodeIdx));
executed (the execution status of this line is deduced): fmt.setRightMargin(rightMargin(tableNodeIdx));
-
952 -
953 // compatibility -
954 if (qFuzzyCompare(fmt.leftMargin(), fmt.rightMargin())
evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.rightMargin())
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:2
2-73
955 && qFuzzyCompare(fmt.leftMargin(), fmt.topMargin())
evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.topMargin())
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:2
2-71
956 && qFuzzyCompare(fmt.leftMargin(), fmt.bottomMargin()))
partially evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.bottomMargin())
TRUEFALSE
yes
Evaluation Count:71
no
Evaluation Count:0
0-71
957 fmt.setProperty(QTextFormat::FrameMargin, fmt.leftMargin());
executed: fmt.setProperty(QTextFormat::FrameMargin, fmt.leftMargin());
Execution Count:71
71
958 -
959 fmt.setBorderStyle(node.borderStyle);
executed (the execution status of this line is deduced): fmt.setBorderStyle(node.borderStyle);
-
960 fmt.setBorderBrush(node.borderBrush);
executed (the execution status of this line is deduced): fmt.setBorderBrush(node.borderBrush);
-
961 fmt.setBorder(node.tableBorder);
executed (the execution status of this line is deduced): fmt.setBorder(node.tableBorder);
-
962 fmt.setWidth(node.width);
executed (the execution status of this line is deduced): fmt.setWidth(node.width);
-
963 fmt.setHeight(node.height);
executed (the execution status of this line is deduced): fmt.setHeight(node.height);
-
964 if (node.blockFormat.hasProperty(QTextFormat::PageBreakPolicy))
partially evaluated: node.blockFormat.hasProperty(QTextFormat::PageBreakPolicy)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
965 fmt.setPageBreakPolicy(node.blockFormat.pageBreakPolicy());
never executed: fmt.setPageBreakPolicy(node.blockFormat.pageBreakPolicy());
0
966 -
967 if (node.blockFormat.hasProperty(QTextFormat::LayoutDirection))
evaluated: node.blockFormat.hasProperty(QTextFormat::LayoutDirection)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:69
6-69
968 fmt.setLayoutDirection(node.blockFormat.layoutDirection());
executed: fmt.setLayoutDirection(node.blockFormat.layoutDirection());
Execution Count:6
6
969 if (node.charFormat.background().style() != Qt::NoBrush)
evaluated: node.charFormat.background().style() != Qt::NoBrush
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:73
2-73
970 fmt.setBackground(node.charFormat.background());
executed: fmt.setBackground(node.charFormat.background());
Execution Count:2
2
971 fmt.setPosition(QTextFrameFormat::Position(node.cssFloat));
executed (the execution status of this line is deduced): fmt.setPosition(QTextFrameFormat::Position(node.cssFloat));
-
972 -
973 if (node.isTextFrame) {
evaluated: node.isTextFrame
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:71
4-71
974 if (node.isRootFrame) {
evaluated: node.isRootFrame
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
975 table.frame = cursor.currentFrame();
executed (the execution status of this line is deduced): table.frame = cursor.currentFrame();
-
976 table.frame->setFrameFormat(fmt);
executed (the execution status of this line is deduced): table.frame->setFrameFormat(fmt);
-
977 } else
executed: }
Execution Count:1
1
978 table.frame = cursor.insertFrame(fmt);
executed: table.frame = cursor.insertFrame(fmt);
Execution Count:3
3
979 -
980 table.isTextFrame = true;
executed (the execution status of this line is deduced): table.isTextFrame = true;
-
981 } else {
executed: }
Execution Count:4
4
982 const int oldPos = cursor.position();
executed (the execution status of this line is deduced): const int oldPos = cursor.position();
-
983 QTextTable *textTable = cursor.insertTable(table.rows, table.columns, fmt.toTableFormat());
executed (the execution status of this line is deduced): QTextTable *textTable = cursor.insertTable(table.rows, table.columns, fmt.toTableFormat());
-
984 table.frame = textTable;
executed (the execution status of this line is deduced): table.frame = textTable;
-
985 -
986 for (int i = 0; i < rowColSpans.count(); ++i) {
evaluated: i < rowColSpans.count()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:71
13-71
987 const RowColSpanInfo &nfo = rowColSpans.at(i);
executed (the execution status of this line is deduced): const RowColSpanInfo &nfo = rowColSpans.at(i);
-
988 textTable->mergeCells(nfo.row, nfo.col, nfo.rowSpan, nfo.colSpan);
executed (the execution status of this line is deduced): textTable->mergeCells(nfo.row, nfo.col, nfo.rowSpan, nfo.colSpan);
-
989 }
executed: }
Execution Count:13
13
990 -
991 table.currentCell = TableCellIterator(textTable);
executed (the execution status of this line is deduced): table.currentCell = TableCellIterator(textTable);
-
992 cursor.setPosition(oldPos); // restore for caption support which needs to be inserted right before the table
executed (the execution status of this line is deduced): cursor.setPosition(oldPos);
-
993 }
executed: }
Execution Count:71
71
994 return table;
executed: return table;
Execution Count:75
75
995} -
996 -
997QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() -
998{ -
999 QTextBlockFormat block;
executed (the execution status of this line is deduced): QTextBlockFormat block;
-
1000 QTextCharFormat charFmt;
executed (the execution status of this line is deduced): QTextCharFormat charFmt;
-
1001 bool modifiedBlockFormat = true;
executed (the execution status of this line is deduced): bool modifiedBlockFormat = true;
-
1002 bool modifiedCharFormat = true;
executed (the execution status of this line is deduced): bool modifiedCharFormat = true;
-
1003 -
1004 if (currentNode->isTableCell() && !tables.isEmpty()) {
evaluated: currentNode->isTableCell()
TRUEFALSE
yes
Evaluation Count:158
yes
Evaluation Count:696
partially evaluated: !tables.isEmpty()
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-696
1005 Table &t = tables.last();
executed (the execution status of this line is deduced): Table &t = tables.last();
-
1006 if (!t.isTextFrame && !t.currentCell.atEnd()) {
evaluated: !t.isTextFrame
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:4
partially evaluated: !t.currentCell.atEnd()
TRUEFALSE
yes
Evaluation Count:154
no
Evaluation Count:0
0-154
1007 QTextTableCell cell = t.currentCell.cell();
executed (the execution status of this line is deduced): QTextTableCell cell = t.currentCell.cell();
-
1008 if (cell.isValid()) {
partially evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:154
no
Evaluation Count:0
0-154
1009 QTextTableCellFormat fmt = cell.format().toTableCellFormat();
executed (the execution status of this line is deduced): QTextTableCellFormat fmt = cell.format().toTableCellFormat();
-
1010 if (topPadding(currentNodeIdx) >= 0)
evaluated: topPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
1011 fmt.setTopPadding(topPadding(currentNodeIdx));
executed: fmt.setTopPadding(topPadding(currentNodeIdx));
Execution Count:2
2
1012 if (bottomPadding(currentNodeIdx) >= 0)
evaluated: bottomPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
1013 fmt.setBottomPadding(bottomPadding(currentNodeIdx));
executed: fmt.setBottomPadding(bottomPadding(currentNodeIdx));
Execution Count:2
2
1014 if (leftPadding(currentNodeIdx) >= 0)
evaluated: leftPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
1015 fmt.setLeftPadding(leftPadding(currentNodeIdx));
executed: fmt.setLeftPadding(leftPadding(currentNodeIdx));
Execution Count:2
2
1016 if (rightPadding(currentNodeIdx) >= 0)
evaluated: rightPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
1017 fmt.setRightPadding(rightPadding(currentNodeIdx));
executed: fmt.setRightPadding(rightPadding(currentNodeIdx));
Execution Count:2
2
1018 cell.setFormat(fmt);
executed (the execution status of this line is deduced): cell.setFormat(fmt);
-
1019 -
1020 cursor.setPosition(cell.firstPosition());
executed (the execution status of this line is deduced): cursor.setPosition(cell.firstPosition());
-
1021 }
executed: }
Execution Count:154
154
1022 }
executed: }
Execution Count:154
154
1023 hasBlock = true;
executed (the execution status of this line is deduced): hasBlock = true;
-
1024 compressNextWhitespace = RemoveWhiteSpace;
executed (the execution status of this line is deduced): compressNextWhitespace = RemoveWhiteSpace;
-
1025 -
1026 if (currentNode->charFormat.background().style() != Qt::NoBrush) {
evaluated: currentNode->charFormat.background().style() != Qt::NoBrush
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:150
8-150
1027 charFmt.setBackground(currentNode->charFormat.background());
executed (the execution status of this line is deduced): charFmt.setBackground(currentNode->charFormat.background());
-
1028 cursor.mergeBlockCharFormat(charFmt);
executed (the execution status of this line is deduced): cursor.mergeBlockCharFormat(charFmt);
-
1029 }
executed: }
Execution Count:8
8
1030 }
executed: }
Execution Count:158
158
1031 -
1032 if (hasBlock) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:738
yes
Evaluation Count:116
116-738
1033 block = cursor.blockFormat();
executed (the execution status of this line is deduced): block = cursor.blockFormat();
-
1034 charFmt = cursor.blockCharFormat();
executed (the execution status of this line is deduced): charFmt = cursor.blockCharFormat();
-
1035 modifiedBlockFormat = false;
executed (the execution status of this line is deduced): modifiedBlockFormat = false;
-
1036 modifiedCharFormat = false;
executed (the execution status of this line is deduced): modifiedCharFormat = false;
-
1037 }
executed: }
Execution Count:738
738
1038 -
1039 // collapse -
1040 { -
1041 qreal tm = qreal(topMargin(currentNodeIdx));
executed (the execution status of this line is deduced): qreal tm = qreal(topMargin(currentNodeIdx));
-
1042 if (tm > block.topMargin()) {
evaluated: tm > block.topMargin()
TRUEFALSE
yes
Evaluation Count:518
yes
Evaluation Count:336
336-518
1043 block.setTopMargin(tm);
executed (the execution status of this line is deduced): block.setTopMargin(tm);
-
1044 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1045 }
executed: }
Execution Count:518
518
1046 } -
1047 -
1048 int bottomMargin = this->bottomMargin(currentNodeIdx);
executed (the execution status of this line is deduced): int bottomMargin = this->bottomMargin(currentNodeIdx);
-
1049 -
1050 // for list items we may want to collapse with the bottom margin of the -
1051 // list. -
1052 const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : 0;
evaluated: currentNode->parent
TRUEFALSE
yes
Evaluation Count:370
yes
Evaluation Count:484
370-484
1053 if ((currentNode->id == Html_li || currentNode->id == Html_dt || currentNode->id == Html_dd)
evaluated: currentNode->id == Html_li
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:789
evaluated: currentNode->id == Html_dt
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:787
evaluated: currentNode->id == Html_dd
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:784
2-789
1054 && parentNode
partially evaluated: parentNode
TRUEFALSE
yes
Evaluation Count:70
no
Evaluation Count:0
0-70
1055 && (parentNode->isListStart() || parentNode->id == Html_dl)
evaluated: parentNode->isListStart()
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:6
evaluated: parentNode->id == Html_dl
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-64
1056 && (parentNode->children.last() == currentNodeIdx)) {
evaluated: (parentNode->children.last() == currentNodeIdx)
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:35
34-35
1057 bottomMargin = qMax(bottomMargin, this->bottomMargin(currentNode->parent));
executed (the execution status of this line is deduced): bottomMargin = qMax(bottomMargin, this->bottomMargin(currentNode->parent));
-
1058 }
executed: }
Execution Count:34
34
1059 -
1060 if (block.bottomMargin() != bottomMargin) {
evaluated: block.bottomMargin() != bottomMargin
TRUEFALSE
yes
Evaluation Count:551
yes
Evaluation Count:303
303-551
1061 block.setBottomMargin(bottomMargin);
executed (the execution status of this line is deduced): block.setBottomMargin(bottomMargin);
-
1062 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1063 }
executed: }
Execution Count:551
551
1064 -
1065 { -
1066 const qreal lm = leftMargin(currentNodeIdx);
executed (the execution status of this line is deduced): const qreal lm = leftMargin(currentNodeIdx);
-
1067 const qreal rm = rightMargin(currentNodeIdx);
executed (the execution status of this line is deduced): const qreal rm = rightMargin(currentNodeIdx);
-
1068 -
1069 if (block.leftMargin() != lm) {
evaluated: block.leftMargin() != lm
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:843
11-843
1070 block.setLeftMargin(lm);
executed (the execution status of this line is deduced): block.setLeftMargin(lm);
-
1071 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1072 }
executed: }
Execution Count:11
11
1073 if (block.rightMargin() != rm) {
evaluated: block.rightMargin() != rm
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:852
2-852
1074 block.setRightMargin(rm);
executed (the execution status of this line is deduced): block.setRightMargin(rm);
-
1075 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1076 }
executed: }
Execution Count:2
2
1077 } -
1078 -
1079 if (currentNode->id != Html_li
evaluated: currentNode->id != Html_li
TRUEFALSE
yes
Evaluation Count:789
yes
Evaluation Count:65
65-789
1080 && indent != 0
evaluated: indent != 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:782
7-782
1081 && (lists.isEmpty()
partially evaluated: lists.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1082 || !hasBlock
evaluated: !hasBlock
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
1083 || !lists.last().list
evaluated: !lists.last().list
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1084 || lists.last().list->itemNumber(cursor.block()) == -1
partially evaluated: lists.last().list->itemNumber(cursor.block()) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1085 )
executed (the execution status of this line is deduced): )
-
1086 ) { -
1087 block.setIndent(indent);
executed (the execution status of this line is deduced): block.setIndent(indent);
-
1088 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1089 }
executed: }
Execution Count:6
6
1090 -
1091 if (currentNode->blockFormat.propertyCount() > 0) {
evaluated: currentNode->blockFormat.propertyCount() > 0
TRUEFALSE
yes
Evaluation Count:337
yes
Evaluation Count:517
337-517
1092 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1093 block.merge(currentNode->blockFormat);
executed (the execution status of this line is deduced): block.merge(currentNode->blockFormat);
-
1094 }
executed: }
Execution Count:337
337
1095 -
1096 if (currentNode->charFormat.propertyCount() > 0) {
evaluated: currentNode->charFormat.propertyCount() > 0
TRUEFALSE
yes
Evaluation Count:404
yes
Evaluation Count:450
404-450
1097 modifiedCharFormat = true;
executed (the execution status of this line is deduced): modifiedCharFormat = true;
-
1098 charFmt.merge(currentNode->charFormat);
executed (the execution status of this line is deduced): charFmt.merge(currentNode->charFormat);
-
1099 }
executed: }
Execution Count:404
404
1100 -
1101 // #################### -
1102 // block.setFloatPosition(node->cssFloat); -
1103 -
1104 if (wsm == QTextHtmlParserNode::WhiteSpacePre) {
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:581
273-581
1105 block.setNonBreakableLines(true);
executed (the execution status of this line is deduced): block.setNonBreakableLines(true);
-
1106 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1107 }
executed: }
Execution Count:273
273
1108 -
1109 if (currentNode->charFormat.background().style() != Qt::NoBrush && !currentNode->isTableCell()) {
evaluated: currentNode->charFormat.background().style() != Qt::NoBrush
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:815
evaluated: !currentNode->isTableCell()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:8
8-815
1110 block.setBackground(currentNode->charFormat.background());
executed (the execution status of this line is deduced): block.setBackground(currentNode->charFormat.background());
-
1111 modifiedBlockFormat = true;
executed (the execution status of this line is deduced): modifiedBlockFormat = true;
-
1112 }
executed: }
Execution Count:31
31
1113 -
1114 if (hasBlock && (!currentNode->isEmptyParagraph || forceBlockMerging)) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:738
yes
Evaluation Count:116
evaluated: !currentNode->isEmptyParagraph
TRUEFALSE
yes
Evaluation Count:735
yes
Evaluation Count:3
evaluated: forceBlockMerging
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-738
1115 if (modifiedBlockFormat)
evaluated: modifiedBlockFormat
TRUEFALSE
yes
Evaluation Count:706
yes
Evaluation Count:31
31-706
1116 cursor.setBlockFormat(block);
executed: cursor.setBlockFormat(block);
Execution Count:706
706
1117 if (modifiedCharFormat)
evaluated: modifiedCharFormat
TRUEFALSE
yes
Evaluation Count:355
yes
Evaluation Count:382
355-382
1118 cursor.setBlockCharFormat(charFmt);
executed: cursor.setBlockCharFormat(charFmt);
Execution Count:355
355
1119 } else {
executed: }
Execution Count:737
737
1120 if (currentNodeIdx == 1 && cursor.position() == 0 && currentNode->isEmptyParagraph) {
evaluated: currentNodeIdx == 1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:111
evaluated: cursor.position() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
partially evaluated: currentNode->isEmptyParagraph
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-111
1121 cursor.setBlockFormat(block);
executed (the execution status of this line is deduced): cursor.setBlockFormat(block);
-
1122 cursor.setBlockCharFormat(charFmt);
executed (the execution status of this line is deduced): cursor.setBlockCharFormat(charFmt);
-
1123 } else {
executed: }
Execution Count:1
1
1124 appendBlock(block, charFmt);
executed (the execution status of this line is deduced): appendBlock(block, charFmt);
-
1125 }
executed: }
Execution Count:116
116
1126 } -
1127 -
1128 if (currentNode->userState != -1)
evaluated: currentNode->userState != -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:852
2-852
1129 cursor.block().setUserState(currentNode->userState);
executed: cursor.block().setUserState(currentNode->userState);
Execution Count:2
2
1130 -
1131 if (currentNode->id == Html_li && !lists.isEmpty()) {
evaluated: currentNode->id == Html_li
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:789
partially evaluated: !lists.isEmpty()
TRUEFALSE
yes
Evaluation Count:65
no
Evaluation Count:0
0-789
1132 List &l = lists.last();
executed (the execution status of this line is deduced): List &l = lists.last();
-
1133 if (l.list) {
evaluated: l.list
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:33
32-33
1134 l.list->add(cursor.block());
executed (the execution status of this line is deduced): l.list->add(cursor.block());
-
1135 } else {
executed: }
Execution Count:32
32
1136 l.list = cursor.createList(l.format);
executed (the execution status of this line is deduced): l.list = cursor.createList(l.format);
-
1137 const qreal listTopMargin = topMargin(l.listNode);
executed (the execution status of this line is deduced): const qreal listTopMargin = topMargin(l.listNode);
-
1138 if (listTopMargin > block.topMargin()) {
evaluated: listTopMargin > block.topMargin()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:6
6-27
1139 block.setTopMargin(listTopMargin);
executed (the execution status of this line is deduced): block.setTopMargin(listTopMargin);
-
1140 cursor.mergeBlockFormat(block);
executed (the execution status of this line is deduced): cursor.mergeBlockFormat(block);
-
1141 }
executed: }
Execution Count:27
27
1142 }
executed: }
Execution Count:33
33
1143 if (hasBlock) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:35
30-35
1144 QTextBlockFormat fmt;
executed (the execution status of this line is deduced): QTextBlockFormat fmt;
-
1145 fmt.setIndent(0);
executed (the execution status of this line is deduced): fmt.setIndent(0);
-
1146 cursor.mergeBlockFormat(fmt);
executed (the execution status of this line is deduced): cursor.mergeBlockFormat(fmt);
-
1147 }
executed: }
Execution Count:30
30
1148 }
executed: }
Execution Count:65
65
1149 -
1150 forceBlockMerging = false;
executed (the execution status of this line is deduced): forceBlockMerging = false;
-
1151 if (currentNode->id == Html_body || currentNode->id == Html_html)
evaluated: currentNode->id == Html_body
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:782
partially evaluated: currentNode->id == Html_html
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:782
0-782
1152 forceBlockMerging = true;
executed: forceBlockMerging = true;
Execution Count:72
72
1153 -
1154 if (currentNode->isEmptyParagraph) {
evaluated: currentNode->isEmptyParagraph
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:821
33-821
1155 hasBlock = false;
executed (the execution status of this line is deduced): hasBlock = false;
-
1156 return ContinueWithNextSibling;
executed: return ContinueWithNextSibling;
Execution Count:33
33
1157 } -
1158 -
1159 hasBlock = true;
executed (the execution status of this line is deduced): hasBlock = true;
-
1160 blockTagClosed = false;
executed (the execution status of this line is deduced): blockTagClosed = false;
-
1161 return ContinueWithCurrentNode;
executed: return ContinueWithCurrentNode;
Execution Count:821
821
1162} -
1163 -
1164void QTextHtmlImporter::appendBlock(const QTextBlockFormat &format, QTextCharFormat charFmt) -
1165{ -
1166 if (!namedAnchors.isEmpty()) {
partially evaluated: !namedAnchors.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:143
0-143
1167 charFmt.setAnchor(true);
never executed (the execution status of this line is deduced): charFmt.setAnchor(true);
-
1168 charFmt.setAnchorNames(namedAnchors);
never executed (the execution status of this line is deduced): charFmt.setAnchorNames(namedAnchors);
-
1169 namedAnchors.clear();
never executed (the execution status of this line is deduced): namedAnchors.clear();
-
1170 }
never executed: }
0
1171 -
1172 cursor.insertBlock(format, charFmt);
executed (the execution status of this line is deduced): cursor.insertBlock(format, charFmt);
-
1173 -
1174 if (wsm != QTextHtmlParserNode::WhiteSpacePre && wsm != QTextHtmlParserNode::WhiteSpacePreWrap)
evaluated: wsm != QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:133
yes
Evaluation Count:10
evaluated: wsm != QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:32
10-133
1175 compressNextWhitespace = RemoveWhiteSpace;
executed: compressNextWhitespace = RemoveWhiteSpace;
Execution Count:101
101
1176}
executed: }
Execution Count:143
143
1177 -
1178#endif // QT_NO_TEXTHTMLPARSER -
1179 -
1180/*! -
1181 \fn QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &text) -
1182 -
1183 Returns a QTextDocumentFragment based on the arbitrary piece of -
1184 HTML in the given \a text. The formatting is preserved as much as -
1185 possible; for example, "<b>bold</b>" will become a document -
1186 fragment with the text "bold" with a bold character format. -
1187*/ -
1188 -
1189#ifndef QT_NO_TEXTHTMLPARSER -
1190 -
1191QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html) -
1192{ -
1193 return fromHtml(html, 0);
executed: return fromHtml(html, 0);
Execution Count:456
456
1194} -
1195 -
1196/*! -
1197 \fn QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &text, const QTextDocument *resourceProvider) -
1198 \since 4.2 -
1199 -
1200 Returns a QTextDocumentFragment based on the arbitrary piece of -
1201 HTML in the given \a text. The formatting is preserved as much as -
1202 possible; for example, "<b>bold</b>" will become a document -
1203 fragment with the text "bold" with a bold character format. -
1204 -
1205 If the provided HTML contains references to external resources such as imported style sheets, then -
1206 they will be loaded through the \a resourceProvider. -
1207*/ -
1208 -
1209QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html, const QTextDocument *resourceProvider) -
1210{ -
1211 QTextDocumentFragment res;
executed (the execution status of this line is deduced): QTextDocumentFragment res;
-
1212 res.d = new QTextDocumentFragmentPrivate;
executed (the execution status of this line is deduced): res.d = new QTextDocumentFragmentPrivate;
-
1213 -
1214 QTextHtmlImporter importer(res.d->doc, html, QTextHtmlImporter::ImportToFragment, resourceProvider);
executed (the execution status of this line is deduced): QTextHtmlImporter importer(res.d->doc, html, QTextHtmlImporter::ImportToFragment, resourceProvider);
-
1215 importer.import();
executed (the execution status of this line is deduced): importer.import();
-
1216 return res;
executed: return res;
Execution Count:472
472
1217} -
1218 -
1219QT_END_NAMESPACE -
1220#endif // QT_NO_TEXTHTMLPARSER -
1221 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial