text/qtextdocumentfragment.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5QTextCopyHelper::QTextCopyHelper(const QTextCursor &_source, const QTextCursor &_destination, bool forceCharFormat, const QTextCharFormat &fmt) -
6 -
7 -
8 -
9 : formatCollection(*_destination.d->priv->formatCollection()), originalText(_source.d->priv->buffer()) -
10 -
11{ -
12 src = _source.d->priv; -
13 dst = _destination.d->priv; -
14 insertPos = _destination.position(); -
15 this->forceCharFormat = forceCharFormat; -
16 primaryCharFormatIndex = convertFormatIndex(fmt); -
17 cursor = _source; -
18}
executed: }
Execution Count:667
667
19 -
20int QTextCopyHelper::convertFormatIndex(const QTextFormat &oldFormat, int objectIndexToSet) -
21{ -
22 QTextFormat fmt = oldFormat; -
23 if (objectIndexToSet != -1) {
evaluated: objectIndexToSet != -1
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:3386
15-3386
24 fmt.setObjectIndex(objectIndexToSet); -
25 } else if (fmt.objectIndex() != -1) {
executed: }
Execution Count:15
evaluated: fmt.objectIndex() != -1
TRUEFALSE
yes
Evaluation Count:373
yes
Evaluation Count:3013
15-3013
26 int newObjectIndex = objectIndexMap.value(fmt.objectIndex(), -1); -
27 if (newObjectIndex == -1) {
evaluated: newObjectIndex == -1
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:237
136-237
28 QTextFormat objFormat = src->formatCollection()->objectFormat(fmt.objectIndex()); -
29 qt_noop(); -
30 newObjectIndex = formatCollection.createObjectIndex(objFormat); -
31 objectIndexMap.insert(fmt.objectIndex(), newObjectIndex); -
32 }
executed: }
Execution Count:136
136
33 fmt.setObjectIndex(newObjectIndex); -
34 }
executed: }
Execution Count:373
373
35 int idx = formatCollection.indexForFormat(fmt); -
36 qt_noop(); -
37 return idx;
executed: return idx;
Execution Count:3401
3401
38} -
39 -
40int QTextCopyHelper::appendFragment(int pos, int endPos, int objectIndex) -
41{ -
42 QTextDocumentPrivate::FragmentIterator fragIt = src->find(pos); -
43 const QTextFragmentData * const frag = fragIt.value(); -
44 -
45 qt_noop(); -
46 -
47 -
48 int charFormatIndex; -
49 if (forceCharFormat)
evaluated: forceCharFormat
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1231
4-1231
50 charFormatIndex = primaryCharFormatIndex;
executed: charFormatIndex = primaryCharFormatIndex;
Execution Count:4
4
51 else -
52 charFormatIndex = convertFormatIndex(frag->format, objectIndex);
executed: charFormatIndex = convertFormatIndex(frag->format, objectIndex);
Execution Count:1231
1231
53 -
54 const int inFragmentOffset = qMax(0, pos - fragIt.position()); -
55 int charsToCopy = qMin(int(frag->size_array[0] - inFragmentOffset), endPos - pos); -
56 -
57 QTextBlock nextBlock = src->blocksFind(pos + 1); -
58 -
59 int blockIdx = -2; -
60 if (nextBlock.position() == pos + 1) {
evaluated: nextBlock.position() == pos + 1
TRUEFALSE
yes
Evaluation Count:437
yes
Evaluation Count:798
437-798
61 blockIdx = convertFormatIndex(nextBlock.blockFormat()); -
62 } else if (pos == 0 && insertPos == 0) {
evaluated: pos == 0
TRUEFALSE
yes
Evaluation Count:526
yes
Evaluation Count:272
evaluated: insertPos == 0
TRUEFALSE
yes
Evaluation Count:520
yes
Evaluation Count:6
executed: }
Execution Count:437
6-526
63 dst->setBlockFormat(dst->blocksBegin(), dst->blocksBegin(), convertFormat(src->blocksBegin().blockFormat()).toBlockFormat()); -
64 dst->setCharFormat(-1, 1, convertFormat(src->blocksBegin().charFormat()).toCharFormat()); -
65 }
executed: }
Execution Count:520
520
66 -
67 QString txtToInsert(originalText.constData() + frag->stringPosition + inFragmentOffset, charsToCopy); -
68 if (txtToInsert.length() == 1
evaluated: txtToInsert.length() == 1
TRUEFALSE
yes
Evaluation Count:727
yes
Evaluation Count:508
508-727
69 && (txtToInsert.at(0) == QChar::ParagraphSeparator
evaluated: txtToInsert.at(0) == QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:614
113-614
70 || txtToInsert.at(0) == QChar(0xfdd0)
evaluated: txtToInsert.at(0) == QChar(0xfdd0)
TRUEFALSE
yes
Evaluation Count:229
yes
Evaluation Count:385
229-385
71 || txtToInsert.at(0) == QChar(0xfdd1)
evaluated: txtToInsert.at(0) == QChar(0xfdd1)
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:290
95-290
72 ) -
73 ) { -
74 dst->insertBlock(txtToInsert.at(0), insertPos, blockIdx, charFormatIndex); -
75 ++insertPos; -
76 } else {
executed: }
Execution Count:437
437
77 if (nextBlock.textList()) {
evaluated: nextBlock.textList()
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:754
44-754
78 QTextBlock dstBlock = dst->blocksFind(insertPos); -
79 if (!dstBlock.textList()) {
evaluated: !dstBlock.textList()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:42
2-42
80 -
81 -
82 -
83 int listBlockFormatIndex = convertFormatIndex(nextBlock.blockFormat()); -
84 int listCharFormatIndex = convertFormatIndex(nextBlock.charFormat()); -
85 dst->insertBlock(insertPos, listBlockFormatIndex, listCharFormatIndex); -
86 ++insertPos; -
87 }
executed: }
Execution Count:2
2
88 }
executed: }
Execution Count:44
44
89 dst->insert(insertPos, txtToInsert, charFormatIndex); -
90 const int userState = nextBlock.userState(); -
91 if (userState != -1)
evaluated: userState != -1
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:790
8-790
92 dst->blocksFind(insertPos).setUserState(userState);
executed: dst->blocksFind(insertPos).setUserState(userState);
Execution Count:8
8
93 insertPos += txtToInsert.length(); -
94 }
executed: }
Execution Count:798
798
95 -
96 return charsToCopy;
executed: return charsToCopy;
Execution Count:1235
1235
97} -
98 -
99void QTextCopyHelper::appendFragments(int pos, int endPos) -
100{ -
101 qt_noop(); -
102 -
103 while (pos < endPos)
evaluated: pos < endPos
TRUEFALSE
yes
Evaluation Count:1231
yes
Evaluation Count:674
674-1231
104 pos += appendFragment(pos, endPos);
executed: pos += appendFragment(pos, endPos);
Execution Count:1231
1231
105}
executed: }
Execution Count:674
674
106 -
107void QTextCopyHelper::copy() -
108{ -
109 if (cursor.hasComplexSelection()) {
evaluated: cursor.hasComplexSelection()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:663
4-663
110 QTextTable *table = cursor.currentTable(); -
111 int row_start, col_start, num_rows, num_cols; -
112 cursor.selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); -
113 -
114 QTextTableFormat tableFormat = table->format(); -
115 tableFormat.setColumns(num_cols); -
116 tableFormat.clearColumnWidthConstraints(); -
117 const int objectIndex = dst->formatCollection()->createObjectIndex(tableFormat); -
118 -
119 qt_noop(); -
120 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
121 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
122 QTextTableCell cell = table->cellAt(r, c); -
123 const int rspan = cell.rowSpan(); -
124 const int cspan = cell.columnSpan(); -
125 if (rspan != 1) {
partially evaluated: rspan != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
126 int cr = cell.row(); -
127 if (cr != r)
never evaluated: cr != r
0
128 continue;
never executed: continue;
0
129 }
never executed: }
0
130 if (cspan != 1) {
evaluated: cspan != 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
131 int cc = cell.column(); -
132 if (cc != c)
partially evaluated: cc != c
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
133 continue;
never executed: continue;
0
134 }
executed: }
Execution Count:1
1
135 -
136 -
137 QTextCharFormat cellFormat = cell.format(); -
138 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
139 cellFormat.setTableCellRowSpan(row_start + num_rows - r); -
140 }
executed: }
Execution Count:6
6
141 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
142 cellFormat.setTableCellColumnSpan(col_start + num_cols - c); -
143 }
executed: }
Execution Count:8
8
144 const int charFormatIndex = convertFormatIndex(cellFormat, objectIndex); -
145 -
146 int blockIdx = -2; -
147 const int cellPos = cell.firstPosition(); -
148 QTextBlock block = src->blocksFind(cellPos); -
149 if (block.position() == cellPos) {
partially evaluated: block.position() == cellPos
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
150 blockIdx = convertFormatIndex(block.blockFormat()); -
151 }
executed: }
Execution Count:11
11
152 -
153 dst->insertBlock(QChar(0xfdd0), insertPos, blockIdx, charFormatIndex); -
154 ++insertPos; -
155 -
156 -
157 if (cell.lastPosition() > cellPos) {
partially evaluated: cell.lastPosition() > cellPos
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
158 -
159 appendFragments(cellPos, cell.lastPosition()); -
160 }
executed: }
Execution Count:11
11
161 }
executed: }
Execution Count:11
11
162 }
executed: }
Execution Count:8
8
163 -
164 -
165 int end = table->lastPosition(); -
166 appendFragment(end, end+1, objectIndex); -
167 } else {
executed: }
Execution Count:4
4
168 appendFragments(cursor.selectionStart(), cursor.selectionEnd()); -
169 }
executed: }
Execution Count:663
663
170} -
171 -
172QTextDocumentFragmentPrivate::QTextDocumentFragmentPrivate(const QTextCursor &_cursor) -
173 : ref(1), doc(new QTextDocument), importedFromPlainText(false) -
174{ -
175 doc->setUndoRedoEnabled(false); -
176 -
177 if (!_cursor.hasSelection())
evaluated: !_cursor.hasSelection()
TRUEFALSE
yes
Evaluation Count:480
yes
Evaluation Count:116
116-480
178 return;
executed: return;
Execution Count:480
480
179 -
180 doc->docHandle()->beginEditBlock(); -
181 QTextCursor destCursor(doc); -
182 QTextCopyHelper(_cursor, destCursor).copy(); -
183 doc->docHandle()->endEditBlock(); -
184 -
185 if (_cursor.d)
partially evaluated: _cursor.d
TRUEFALSE
yes
Evaluation Count:116
no
Evaluation Count:0
0-116
186 doc->docHandle()->mergeCachedResources(_cursor.d->priv);
executed: doc->docHandle()->mergeCachedResources(_cursor.d->priv);
Execution Count:116
116
187}
executed: }
Execution Count:116
116
188 -
189void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const -
190{ -
191 if (_cursor.isNull())
partially evaluated: _cursor.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:551
0-551
192 return;
never executed: return;
0
193 -
194 QTextDocumentPrivate *destPieceTable = _cursor.d->priv; -
195 destPieceTable->beginEditBlock(); -
196 -
197 QTextCursor sourceCursor(doc); -
198 sourceCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); -
199 QTextCopyHelper(sourceCursor, _cursor, importedFromPlainText, _cursor.charFormat()).copy(); -
200 -
201 destPieceTable->endEditBlock(); -
202}
executed: }
Execution Count:551
551
203QTextDocumentFragment::QTextDocumentFragment() -
204 : d(0) -
205{ -
206}
executed: }
Execution Count:487
487
207 -
208 -
209 -
210 -
211 -
212 -
213QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) -
214 : d(0) -
215{ -
216 if (!document)
partially evaluated: !document
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:85
0-85
217 return;
never executed: return;
0
218 -
219 QTextCursor cursor(const_cast<QTextDocument *>(document)); -
220 cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); -
221 d = new QTextDocumentFragmentPrivate(cursor); -
222}
executed: }
Execution Count:85
85
223 -
224 -
225 -
226 -
227 -
228 -
229 -
230QTextDocumentFragment::QTextDocumentFragment(const QTextCursor &cursor) -
231 : d(0) -
232{ -
233 if (!cursor.hasSelection())
partially evaluated: !cursor.hasSelection()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
234 return;
never executed: return;
0
235 -
236 d = new QTextDocumentFragmentPrivate(cursor); -
237}
executed: }
Execution Count:35
35
238 -
239 -
240 -
241 -
242 -
243 -
244QTextDocumentFragment::QTextDocumentFragment(const QTextDocumentFragment &rhs) -
245 : d(rhs.d) -
246{ -
247 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:137
no
Evaluation Count:0
0-137
248 d->ref.ref();
executed: d->ref.ref();
Execution Count:137
137
249}
executed: }
Execution Count:137
137
250 -
251 -
252 -
253 -
254 -
255 -
256QTextDocumentFragment &QTextDocumentFragment::operator=(const QTextDocumentFragment &rhs) -
257{ -
258 if (rhs.d)
evaluated: rhs.d
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3
3-11
259 rhs.d->ref.ref();
executed: rhs.d->ref.ref();
Execution Count:11
11
260 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
261 delete d;
executed: delete d;
Execution Count:6
6
262 d = rhs.d; -
263 return *this;
executed: return *this;
Execution Count:14
14
264} -
265 -
266 -
267 -
268 -
269QTextDocumentFragment::~QTextDocumentFragment() -
270{ -
271 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
272 delete d;
executed: delete d;
Execution Count:590
590
273}
executed: }
Execution Count:743
743
274 -
275 -
276 -
277 -
278bool QTextDocumentFragment::isEmpty() const -
279{ -
280 return !d || !d->doc || d->doc->docHandle()->length() <= 1;
executed: return !d || !d->doc || d->doc->docHandle()->length() <= 1;
Execution Count:573
573
281} -
282 -
283 -
284 -
285 -
286 -
287 -
288 -
289QString QTextDocumentFragment::toPlainText() const -
290{ -
291 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
292 return QString();
never executed: return QString();
0
293 -
294 return d->doc->toPlainText();
executed: return d->doc->toPlainText();
Execution Count:24
24
295} -
296QString QTextDocumentFragment::toHtml(const QByteArray &encoding) const -
297{ -
298 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
299 return QString();
never executed: return QString();
0
300 -
301 return QTextHtmlExporter(d->doc).toHtml(encoding, QTextHtmlExporter::ExportFragment);
executed: return QTextHtmlExporter(d->doc).toHtml(encoding, QTextHtmlExporter::ExportFragment);
Execution Count:9
9
302} -
303QTextDocumentFragment QTextDocumentFragment::fromPlainText(const QString &plainText) -
304{ -
305 QTextDocumentFragment res; -
306 -
307 res.d = new QTextDocumentFragmentPrivate; -
308 res.d->importedFromPlainText = true; -
309 QTextCursor cursor(res.d->doc); -
310 cursor.insertText(plainText); -
311 return res;
executed: return res;
Execution Count:4
4
312} -
313 -
314static QTextListFormat::Style nextListStyle(QTextListFormat::Style style) -
315{ -
316 if (style == QTextListFormat::ListDisc)
partially evaluated: style == QTextListFormat::ListDisc
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
317 return QTextListFormat::ListCircle;
executed: return QTextListFormat::ListCircle;
Execution Count:8
8
318 else if (style == QTextListFormat::ListCircle)
never evaluated: style == QTextListFormat::ListCircle
0
319 return QTextListFormat::ListSquare;
never executed: return QTextListFormat::ListSquare;
0
320 return style;
never executed: return style;
0
321} -
322 -
323 -
324 -
325QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html, ImportMode mode, const QTextDocument *resourceProvider) -
326 : indent(0), compressNextWhitespace(PreserveWhiteSpace), doc(_doc), importMode(mode) -
327{ -
328 cursor = QTextCursor(doc); -
329 wsm = QTextHtmlParserNode::WhiteSpaceNormal; -
330 -
331 QString html = _html; -
332 const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->")); -
333 if (startFragmentPos != -1) {
evaluated: startFragmentPos != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:700
6-700
334 QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")); -
335 -
336 -
337 const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader); -
338 -
339 const int endFragmentPos = html.indexOf(QLatin1String("<!--EndFragment-->")); -
340 if (startFragmentPos < endFragmentPos)
partially evaluated: startFragmentPos < endFragmentPos
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
341 html = html.mid(startFragmentPos, endFragmentPos - startFragmentPos);
executed: html = html.mid(startFragmentPos, endFragmentPos - startFragmentPos);
Execution Count:6
6
342 else -
343 html = html.mid(startFragmentPos);
never executed: html = html.mid(startFragmentPos);
0
344 -
345 if (hasQtRichtextMetaTag)
evaluated: hasQtRichtextMetaTag
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
346 html.prepend(qt3RichTextHeader);
executed: html.prepend(qt3RichTextHeader);
Execution Count:3
3
347 }
executed: }
Execution Count:6
6
348 -
349 parse(html, resourceProvider ? resourceProvider : doc); -
350 -
351}
executed: }
Execution Count:706
706
352 -
353void QTextHtmlImporter::import() -
354{ -
355 cursor.beginEditBlock(); -
356 hasBlock = true; -
357 forceBlockMerging = false; -
358 compressNextWhitespace = RemoveWhiteSpace; -
359 blockTagClosed = false; -
360 for (currentNodeIdx = 0; currentNodeIdx < count(); ++currentNodeIdx) {
evaluated: currentNodeIdx < count()
TRUEFALSE
yes
Evaluation Count:3039
yes
Evaluation Count:706
706-3039
361 currentNode = &at(currentNodeIdx); -
362 wsm = textEditMode ? QTextHtmlParserNode::WhiteSpacePreWrap : currentNode->wsm;
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:2902
137-2902
363 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
364 blockTagClosed = closeTag(); -
365 -
366 -
367 -
368 if (blockTagClosed
evaluated: blockTagClosed
TRUEFALSE
yes
Evaluation Count:654
yes
Evaluation Count:505
505-654
369 && !currentNode->isBlock()
evaluated: !currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:495
yes
Evaluation Count:159
159-495
370 && currentNode->id != Html_unknown)
evaluated: currentNode->id != Html_unknown
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:462
33-462
371 { -
372 hasBlock = false; -
373 } else if (hasBlock) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:132
yes
Evaluation Count:994
executed: }
Execution Count:33
33-994
374 -
375 QTextBlockFormat blockFormat = currentNode->blockFormat; -
376 blockFormat.setIndent(indent); -
377 -
378 QTextBlockFormat oldFormat = cursor.blockFormat(); -
379 if (oldFormat.hasProperty(QTextFormat::PageBreakPolicy)) {
evaluated: oldFormat.hasProperty(QTextFormat::PageBreakPolicy)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:130
2-130
380 QTextFormat::PageBreakFlags pageBreak = oldFormat.pageBreakPolicy(); -
381 if (pageBreak == QTextFormat::PageBreak_AlwaysAfter)
evaluated: pageBreak == QTextFormat::PageBreak_AlwaysAfter
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
382 -
383 -
384 -
385 -
386 pageBreak = QTextFormat::PageBreak_AlwaysBefore;
executed: pageBreak = QTextFormat::PageBreak_AlwaysBefore;
Execution Count:1
1
387 blockFormat.setPageBreakPolicy(pageBreak); -
388 }
executed: }
Execution Count:2
2
389 -
390 cursor.setBlockFormat(blockFormat); -
391 }
executed: }
Execution Count:132
132
392 } -
393 -
394 if (currentNode->displayMode == QTextHtmlElement::DisplayNone) {
evaluated: currentNode->displayMode == QTextHtmlElement::DisplayNone
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:2932
107-2932
395 if (currentNode->id == Html_title)
evaluated: currentNode->id == Html_title
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:87
20-87
396 doc->setMetaInformation(QTextDocument::DocumentTitle, currentNode->text);
executed: doc->setMetaInformation(QTextDocument::DocumentTitle, currentNode->text);
Execution Count:20
20
397 -
398 continue;
executed: continue;
Execution Count:107
107
399 } -
400 -
401 if (processSpecialNodes() == ContinueWithNextNode)
evaluated: processSpecialNodes() == ContinueWithNextNode
TRUEFALSE
yes
Evaluation Count:255
yes
Evaluation Count:2677
255-2677
402 continue;
executed: continue;
Execution Count:255
255
403 -
404 -
405 if (blockTagClosed
evaluated: blockTagClosed
TRUEFALSE
yes
Evaluation Count:653
yes
Evaluation Count:2024
653-2024
406 && !hasBlock
evaluated: !hasBlock
TRUEFALSE
yes
Evaluation Count:627
yes
Evaluation Count:26
26-627
407 && !currentNode->isBlock()
evaluated: !currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:470
yes
Evaluation Count:157
157-470
408 && !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
409 && currentNode->displayMode == QTextHtmlElement::DisplayInline) {
partially evaluated: currentNode->displayMode == QTextHtmlElement::DisplayInline
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
410 -
411 QTextBlockFormat block = currentNode->blockFormat; -
412 block.setIndent(indent); -
413 -
414 appendBlock(block, currentNode->charFormat); -
415 -
416 hasBlock = true; -
417 }
executed: }
Execution Count:17
17
418 -
419 if (currentNode->isBlock()) {
evaluated: currentNode->isBlock()
TRUEFALSE
yes
Evaluation Count:854
yes
Evaluation Count:1823
854-1823
420 QTextHtmlImporter::ProcessNodeResult result = processBlockNode(); -
421 if (result == ContinueWithNextNode) {
partially evaluated: result == ContinueWithNextNode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:854
0-854
422 continue;
never executed: continue;
0
423 } else if (result == ContinueWithNextSibling) {
evaluated: result == ContinueWithNextSibling
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:821
33-821
424 currentNodeIdx += currentNode->children.size(); -
425 continue;
executed: continue;
Execution Count:33
33
426 } -
427 } -
428 -
429 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
430 namedAnchors.append(currentNode->charFormat.anchorName()); -
431 }
executed: }
Execution Count:26
26
432 -
433 if (appendNodeText())
evaluated: appendNodeText()
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1498
1146-1498
434 hasBlock = false;
executed: hasBlock = false;
Execution Count:1146
1146
435 -
436 }
executed: }
Execution Count:2644
2644
437 -
438 cursor.endEditBlock(); -
439}
executed: }
Execution Count:706
706
440 -
441bool QTextHtmlImporter::appendNodeText() -
442{ -
443 const int initialCursorPosition = cursor.position(); -
444 QTextCharFormat format = currentNode->charFormat; -
445 -
446 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
447 compressNextWhitespace = PreserveWhiteSpace;
executed: compressNextWhitespace = PreserveWhiteSpace;
Execution Count:441
441
448 -
449 QString text = currentNode->text; -
450 -
451 QString textToInsert; -
452 textToInsert.reserve(text.size()); -
453 -
454 for (int i = 0; i < text.length(); ++i) {
evaluated: i < text.length()
TRUEFALSE
yes
Evaluation Count:302597
yes
Evaluation Count:2644
2644-302597
455 QChar ch = text.at(i); -
456 -
457 if (ch.isSpace()
evaluated: ch.isSpace()
TRUEFALSE
yes
Evaluation Count:60412
yes
Evaluation Count:242185
60412-242185
458 && ch != QChar::Nbsp
evaluated: ch != QChar::Nbsp
TRUEFALSE
yes
Evaluation Count:60409
yes
Evaluation Count:3
3-60409
459 && ch != QChar::ParagraphSeparator) {
partially evaluated: ch != QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:60409
no
Evaluation Count:0
0-60409
460 -
461 if (compressNextWhitespace == CollapseWhiteSpace)
evaluated: compressNextWhitespace == CollapseWhiteSpace
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:60407
2-60407
462 compressNextWhitespace = RemoveWhiteSpace;
executed: compressNextWhitespace = RemoveWhiteSpace;
Execution Count:2
2
463 else if(compressNextWhitespace == RemoveWhiteSpace)
evaluated: compressNextWhitespace == RemoveWhiteSpace
TRUEFALSE
yes
Evaluation Count:295
yes
Evaluation Count:60112
295-60112
464 continue;
executed: continue;
Execution Count:295
295
465 -
466 if (wsm == QTextHtmlParserNode::WhiteSpacePre
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:60002
112-60002
467 || textEditMode
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:59871
131-59871
468 ) { -
469 if (ch == QLatin1Char('\n')) {
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:220
23-220
470 if (textEditMode)
evaluated: textEditMode
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:3
3-20
471 continue;
executed: continue;
Execution Count:20
20
472 } else if (ch == QLatin1Char('\r')) {
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:219
executed: }
Execution Count:3
1-219
473 continue;
executed: continue;
Execution Count:1
1
474 } -
475 } else if (wsm != QTextHtmlParserNode::WhiteSpacePreWrap) {
evaluated: wsm != QTextHtmlParserNode::WhiteSpacePreWrap
TRUEFALSE
yes
Evaluation Count:59863
yes
Evaluation Count:8
8-59863
476 compressNextWhitespace = RemoveWhiteSpace; -
477 if (wsm == QTextHtmlParserNode::WhiteSpaceNoWrap)
evaluated: wsm == QTextHtmlParserNode::WhiteSpaceNoWrap
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:59858
5-59858
478 ch = QChar::Nbsp;
executed: ch = QChar::Nbsp;
Execution Count:5
5
479 else -
480 ch = QLatin1Char(' ');
executed: ch = QLatin1Char(' ');
Execution Count:59858
59858
481 } -
482 } else { -
483 compressNextWhitespace = PreserveWhiteSpace; -
484 }
executed: }
Execution Count:242188
242188
485 -
486 if (ch == QLatin1Char('\n')
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:302278
3-302278
487 || ch == QChar::ParagraphSeparator) {
partially evaluated: ch == QChar::ParagraphSeparator
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:302278
0-302278
488 -
489 if (!textToInsert.isEmpty()) {
evaluated: !textToInsert.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
490 cursor.insertText(textToInsert, format); -
491 textToInsert.clear(); -
492 }
executed: }
Execution Count:2
2
493 -
494 QTextBlockFormat fmt = cursor.blockFormat(); -
495 -
496 if (fmt.hasProperty(QTextFormat::BlockBottomMargin)) {
partially evaluated: fmt.hasProperty(QTextFormat::BlockBottomMargin)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
497 QTextBlockFormat tmp = fmt; -
498 tmp.clearProperty(QTextFormat::BlockBottomMargin); -
499 cursor.setBlockFormat(tmp); -
500 }
executed: }
Execution Count:3
3
501 -
502 fmt.clearProperty(QTextFormat::BlockTopMargin); -
503 appendBlock(fmt, cursor.charFormat()); -
504 } else {
executed: }
Execution Count:3
3
505 if (!namedAnchors.isEmpty()) {
evaluated: !namedAnchors.isEmpty()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:302253
25-302253
506 if (!textToInsert.isEmpty()) {
partially evaluated: !textToInsert.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
507 cursor.insertText(textToInsert, format); -
508 textToInsert.clear(); -
509 }
never executed: }
0
510 -
511 format.setAnchor(true); -
512 format.setAnchorNames(namedAnchors); -
513 cursor.insertText(ch, format); -
514 namedAnchors.clear(); -
515 format.clearProperty(QTextFormat::IsAnchor); -
516 format.clearProperty(QTextFormat::AnchorName); -
517 } else {
executed: }
Execution Count:25
25
518 textToInsert += ch; -
519 }
executed: }
Execution Count:302253
302253
520 } -
521 } -
522 -
523 if (!textToInsert.isEmpty()) {
evaluated: !textToInsert.isEmpty()
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1498
1146-1498
524 cursor.insertText(textToInsert, format); -
525 }
executed: }
Execution Count:1146
1146
526 -
527 return cursor.position() != initialCursorPosition;
executed: return cursor.position() != initialCursorPosition;
Execution Count:2644
2644
528} -
529 -
530QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() -
531{ -
532 switch (currentNode->id) { -
533 case Html_body: -
534 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
535 QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); -
536 fmt.setBackground(currentNode->charFormat.background()); -
537 doc->rootFrame()->setFrameFormat(fmt); -
538 const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush); -
539 }
executed: }
Execution Count:12
12
540 compressNextWhitespace = RemoveWhiteSpace; -
541 break;
executed: break;
Execution Count:72
72
542 -
543 case Html_ol: -
544 case Html_ul: { -
545 QTextListFormat::Style style = currentNode->listStyle; -
546 -
547 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
548 const QTextHtmlParserNode *n = &at(currentNode->parent); -
549 while (n) {
evaluated: n
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:10
10-19
550 if (n->id == Html_ul) {
evaluated: n->id == Html_ul
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:11
8-11
551 style = nextListStyle(currentNode->listStyle); -
552 }
executed: }
Execution Count:8
8
553 if (n->parent)
evaluated: n->parent
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:10
9-10
554 n = &at(n->parent);
executed: n = &at(n->parent);
Execution Count:9
9
555 else -
556 n = 0;
executed: n = 0;
Execution Count:10
10
557 } -
558 }
executed: }
Execution Count:10
10
559 -
560 QTextListFormat listFmt; -
561 listFmt.setStyle(style); -
562 if (!currentNode->textListNumberPrefix.isNull())
evaluated: !currentNode->textListNumberPrefix.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:39
1-39
563 listFmt.setNumberPrefix(currentNode->textListNumberPrefix);
executed: listFmt.setNumberPrefix(currentNode->textListNumberPrefix);
Execution Count:1
1
564 if (!currentNode->textListNumberSuffix.isNull())
evaluated: !currentNode->textListNumberSuffix.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:39
1-39
565 listFmt.setNumberSuffix(currentNode->textListNumberSuffix);
executed: listFmt.setNumberSuffix(currentNode->textListNumberSuffix);
Execution Count:1
1
566 -
567 ++indent; -
568 if (currentNode->hasCssListIndent)
evaluated: currentNode->hasCssListIndent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38
2-38
569 listFmt.setIndent(currentNode->cssListIndent);
executed: listFmt.setIndent(currentNode->cssListIndent);
Execution Count:2
2
570 else -
571 listFmt.setIndent(indent);
executed: listFmt.setIndent(indent);
Execution Count:38
38
572 -
573 List l; -
574 l.format = listFmt; -
575 l.listNode = currentNodeIdx; -
576 lists.append(l); -
577 compressNextWhitespace = RemoveWhiteSpace; -
578 -
579 -
580 const QString simpl = currentNode->text.simplified(); -
581 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
582 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:39
39
583 break;
executed: break;
Execution Count:1
1
584 } -
585 -
586 case Html_table: { -
587 Table t = scanTable(currentNodeIdx); -
588 tables.append(t); -
589 hasBlock = false; -
590 compressNextWhitespace = RemoveWhiteSpace; -
591 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:79
79
592 } -
593 -
594 case Html_tr: -
595 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:104
104
596 -
597 case Html_img: { -
598 QTextImageFormat fmt; -
599 fmt.setName(currentNode->imageName); -
600 -
601 fmt.merge(currentNode->charFormat); -
602 -
603 if (currentNode->imageWidth != -1)
evaluated: currentNode->imageWidth != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:20
4-20
604 fmt.setWidth(currentNode->imageWidth);
executed: fmt.setWidth(currentNode->imageWidth);
Execution Count:4
4
605 if (currentNode->imageHeight != -1)
evaluated: currentNode->imageHeight != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:20
4-20
606 fmt.setHeight(currentNode->imageHeight);
executed: fmt.setHeight(currentNode->imageHeight);
Execution Count:4
4
607 -
608 cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat)); -
609 -
610 cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); -
611 cursor.mergeCharFormat(currentNode->charFormat); -
612 cursor.movePosition(QTextCursor::Right); -
613 compressNextWhitespace = CollapseWhiteSpace; -
614 -
615 hasBlock = false; -
616 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:24
24
617 } -
618 -
619 case Html_hr: { -
620 QTextBlockFormat blockFormat = currentNode->blockFormat; -
621 blockFormat.setTopMargin(topMargin(currentNodeIdx)); -
622 blockFormat.setBottomMargin(bottomMargin(currentNodeIdx)); -
623 blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width); -
624 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
625 cursor.mergeBlockFormat(blockFormat);
executed: cursor.mergeBlockFormat(blockFormat);
Execution Count:2
2
626 else -
627 appendBlock(blockFormat);
executed: appendBlock(blockFormat);
Execution Count:7
7
628 hasBlock = false; -
629 compressNextWhitespace = RemoveWhiteSpace; -
630 return ContinueWithNextNode;
executed: return ContinueWithNextNode;
Execution Count:9
9
631 } -
632 -
633 default: break;
executed: break;
Execution Count:2604
2604
634 } -
635 return ContinueWithCurrentNode;
executed: return ContinueWithCurrentNode;
Execution Count:2677
2677
636} -
637 -
638 -
639bool QTextHtmlImporter::closeTag() -
640{ -
641 const QTextHtmlParserNode *closedNode = &at(currentNodeIdx - 1); -
642 const int endDepth = depth(currentNodeIdx) - 1; -
643 int depth = this->depth(currentNodeIdx - 1); -
644 bool blockTagClosed = false; -
645 -
646 while (depth > endDepth) {
evaluated: depth > endDepth
TRUEFALSE
yes
Evaluation Count:1616
yes
Evaluation Count:1159
1159-1616
647 Table *t = 0; -
648 if (!tables.isEmpty())
evaluated: !tables.isEmpty()
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:1235
381-1235
649 t = &tables.last();
executed: t = &tables.last();
Execution Count:381
381
650 -
651 switch (closedNode->id) { -
652 case Html_tr: -
653 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
654 ++t->currentRow; -
655 -
656 -
657 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
658 ++t->currentCell;
executed: ++t->currentCell;
Execution Count:5
5
659 }
executed: }
Execution Count:95
95
660 -
661 blockTagClosed = true; -
662 break;
executed: break;
Execution Count:99
99
663 -
664 case Html_table: -
665 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
666 break;
never executed: break;
0
667 indent = t->lastIndent; -
668 -
669 tables.resize(tables.size() - 1); -
670 t = 0; -
671 -
672 if (tables.isEmpty()) {
evaluated: tables.isEmpty()
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:6
6-65
673 cursor = doc->rootFrame()->lastCursorPosition(); -
674 } else {
executed: }
Execution Count:65
65
675 t = &tables.last(); -
676 if (t->isTextFrame)
partially evaluated: t->isTextFrame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
677 cursor = t->frame->lastCursorPosition();
never executed: cursor = t->frame->lastCursorPosition();
0
678 else if (!t->currentCell.atEnd())
evaluated: !t->currentCell.atEnd()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
679 cursor = t->currentCell.cell().lastCursorPosition();
executed: cursor = t->currentCell.cell().lastCursorPosition();
Execution Count:5
5
680 } -
681 -
682 -
683 -
684 -
685 blockTagClosed = false; -
686 compressNextWhitespace = RemoveWhiteSpace; -
687 break;
executed: break;
Execution Count:71
71
688 -
689 case Html_th: -
690 case Html_td: -
691 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
692 ++t->currentCell;
executed: ++t->currentCell;
Execution Count:150
150
693 blockTagClosed = true; -
694 compressNextWhitespace = RemoveWhiteSpace; -
695 break;
executed: break;
Execution Count:154
154
696 -
697 case Html_ol: -
698 case Html_ul: -
699 if (lists.isEmpty())
partially evaluated: lists.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
700 break;
never executed: break;
0
701 lists.resize(lists.size() - 1); -
702 --indent; -
703 blockTagClosed = true; -
704 break;
executed: break;
Execution Count:34
34
705 -
706 case Html_br: -
707 compressNextWhitespace = RemoveWhiteSpace; -
708 break;
executed: break;
Execution Count:127
127
709 -
710 case Html_div: -
711 if (closedNode->children.isEmpty())
evaluated: closedNode->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
712 break;
executed: break;
Execution Count:12
12
713 -
714 default:
code before this statement executed: default:
Execution Count:1
1
715 if (closedNode->isBlock())
evaluated: closedNode->isBlock()
TRUEFALSE
yes
Evaluation Count:594
yes
Evaluation Count:525
525-594
716 blockTagClosed = true;
executed: blockTagClosed = true;
Execution Count:594
594
717 break;
executed: break;
Execution Count:1119
1119
718 } -
719 -
720 closedNode = &at(closedNode->parent); -
721 --depth; -
722 }
executed: }
Execution Count:1616
1616
723 -
724 return blockTagClosed;
executed: return blockTagClosed;
Execution Count:1159
1159
725} -
726 -
727QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) -
728{ -
729 Table table; -
730 table.columns = 0; -
731 -
732 QVector<QTextLength> columnWidths; -
733 -
734 int tableHeaderRowCount = 0; -
735 QVector<int> rowNodes; -
736 rowNodes.reserve(at(tableNodeIdx).children.count()); -
737 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;})) -
738 switch (at(row).id) { -
739 case Html_tr: -
740 rowNodes += row; -
741 break;
executed: break;
Execution Count:99
99
742 case Html_thead: -
743 case Html_tbody: -
744 case Html_tfoot: -
745 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;})) -
746 if (at(potentialRow).id == Html_tr) {
partially evaluated: at(potentialRow).id == Html_tr
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
747 rowNodes += potentialRow; -
748 if (at(row).id == Html_thead)
evaluated: at(row).id == Html_thead
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
749 ++tableHeaderRowCount;
executed: ++tableHeaderRowCount;
Execution Count:2
2
750 }
executed: }
Execution Count:5
5
751 break;
executed: break;
Execution Count:5
5
752 default: break;
executed: break;
Execution Count:4
4
753 }
never executed: }
0
754 -
755 QVector<RowColSpanInfo> rowColSpans; -
756 QVector<RowColSpanInfo> rowColSpanForColumn; -
757 -
758 int effectiveRow = 0; -
759 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;})) { -
760 int colsInRow = 0; -
761 -
762 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;})) -
763 if (at(cell).isTableCell()) {
partially evaluated: at(cell).isTableCell()
TRUEFALSE
yes
Evaluation Count:158
no
Evaluation Count:0
0-158
764 -
765 while (colsInRow < rowColSpanForColumn.size()) {
evaluated: colsInRow < rowColSpanForColumn.size()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:115
45-115
766 const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow]; -
767 -
768 if (spanInfo.row + spanInfo.rowSpan > effectiveRow) {
evaluated: spanInfo.row + spanInfo.rowSpan > effectiveRow
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:43
2-43
769 qt_noop(); -
770 colsInRow += spanInfo.colSpan; -
771 } else
executed: }
Execution Count:2
2
772 break;
executed: break;
Execution Count:43
43
773 } -
774 -
775 const QTextHtmlParserNode &c = at(cell); -
776 const int currentColumn = colsInRow; -
777 colsInRow += c.tableCellColSpan; -
778 -
779 RowColSpanInfo spanInfo; -
780 spanInfo.row = effectiveRow; -
781 spanInfo.col = currentColumn; -
782 spanInfo.colSpan = c.tableCellColSpan; -
783 spanInfo.rowSpan = c.tableCellRowSpan; -
784 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
785 rowColSpans.append(spanInfo);
executed: rowColSpans.append(spanInfo);
Execution Count:13
13
786 -
787 columnWidths.resize(qMax(columnWidths.count(), colsInRow)); -
788 rowColSpanForColumn.resize(columnWidths.size()); -
789 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
790 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
791 QTextLength w = c.width; -
792 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
793 w = QTextLength(w.type(), w.value(100.) / c.tableCellColSpan);
executed: w = QTextLength(w.type(), w.value(100.) / c.tableCellColSpan);
Execution Count:4
4
794 columnWidths[i] = w; -
795 }
executed: }
Execution Count:166
166
796 rowColSpanForColumn[i] = spanInfo; -
797 }
executed: }
Execution Count:170
170
798 }
executed: }
Execution Count:158
158
799 -
800 table.columns = qMax(table.columns, colsInRow); -
801 -
802 ++effectiveRow; -
803 }
executed: }
Execution Count:104
104
804 table.rows = effectiveRow; -
805 -
806 table.lastIndent = indent; -
807 indent = 0; -
808 -
809 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
810 return table;
executed: return table;
Execution Count:4
4
811 -
812 QTextFrameFormat fmt; -
813 const QTextHtmlParserNode &node = at(tableNodeIdx); -
814 -
815 if (!node.isTextFrame) {
evaluated: !node.isTextFrame
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:4
4-71
816 QTextTableFormat tableFmt; -
817 tableFmt.setCellSpacing(node.tableCellSpacing); -
818 tableFmt.setCellPadding(node.tableCellPadding); -
819 if (node.blockFormat.hasProperty(QTextFormat::BlockAlignment))
evaluated: node.blockFormat.hasProperty(QTextFormat::BlockAlignment)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:65
6-65
820 tableFmt.setAlignment(node.blockFormat.alignment());
executed: tableFmt.setAlignment(node.blockFormat.alignment());
Execution Count:6
6
821 tableFmt.setColumns(table.columns); -
822 tableFmt.setColumnWidthConstraints(columnWidths); -
823 tableFmt.setHeaderRowCount(tableHeaderRowCount); -
824 fmt = tableFmt; -
825 }
executed: }
Execution Count:71
71
826 -
827 fmt.setTopMargin(topMargin(tableNodeIdx)); -
828 fmt.setBottomMargin(bottomMargin(tableNodeIdx)); -
829 fmt.setLeftMargin(leftMargin(tableNodeIdx) -
830 + table.lastIndent * 40 -
831 ); -
832 fmt.setRightMargin(rightMargin(tableNodeIdx)); -
833 -
834 -
835 if (qFuzzyCompare(fmt.leftMargin(), fmt.rightMargin())
evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.rightMargin())
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:2
2-73
836 && qFuzzyCompare(fmt.leftMargin(), fmt.topMargin())
evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.topMargin())
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:2
2-71
837 && qFuzzyCompare(fmt.leftMargin(), fmt.bottomMargin()))
partially evaluated: qFuzzyCompare(fmt.leftMargin(), fmt.bottomMargin())
TRUEFALSE
yes
Evaluation Count:71
no
Evaluation Count:0
0-71
838 fmt.setProperty(QTextFormat::FrameMargin, fmt.leftMargin());
executed: fmt.setProperty(QTextFormat::FrameMargin, fmt.leftMargin());
Execution Count:71
71
839 -
840 fmt.setBorderStyle(node.borderStyle); -
841 fmt.setBorderBrush(node.borderBrush); -
842 fmt.setBorder(node.tableBorder); -
843 fmt.setWidth(node.width); -
844 fmt.setHeight(node.height); -
845 if (node.blockFormat.hasProperty(QTextFormat::PageBreakPolicy))
partially evaluated: node.blockFormat.hasProperty(QTextFormat::PageBreakPolicy)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
846 fmt.setPageBreakPolicy(node.blockFormat.pageBreakPolicy());
never executed: fmt.setPageBreakPolicy(node.blockFormat.pageBreakPolicy());
0
847 -
848 if (node.blockFormat.hasProperty(QTextFormat::LayoutDirection))
evaluated: node.blockFormat.hasProperty(QTextFormat::LayoutDirection)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:69
6-69
849 fmt.setLayoutDirection(node.blockFormat.layoutDirection());
executed: fmt.setLayoutDirection(node.blockFormat.layoutDirection());
Execution Count:6
6
850 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
851 fmt.setBackground(node.charFormat.background());
executed: fmt.setBackground(node.charFormat.background());
Execution Count:2
2
852 fmt.setPosition(QTextFrameFormat::Position(node.cssFloat)); -
853 -
854 if (node.isTextFrame) {
evaluated: node.isTextFrame
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:71
4-71
855 if (node.isRootFrame) {
evaluated: node.isRootFrame
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
856 table.frame = cursor.currentFrame(); -
857 table.frame->setFrameFormat(fmt); -
858 } else
executed: }
Execution Count:1
1
859 table.frame = cursor.insertFrame(fmt);
executed: table.frame = cursor.insertFrame(fmt);
Execution Count:3
3
860 -
861 table.isTextFrame = true; -
862 } else {
executed: }
Execution Count:4
4
863 const int oldPos = cursor.position(); -
864 QTextTable *textTable = cursor.insertTable(table.rows, table.columns, fmt.toTableFormat()); -
865 table.frame = textTable; -
866 -
867 for (int i = 0; i < rowColSpans.count(); ++i) {
evaluated: i < rowColSpans.count()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:71
13-71
868 const RowColSpanInfo &nfo = rowColSpans.at(i); -
869 textTable->mergeCells(nfo.row, nfo.col, nfo.rowSpan, nfo.colSpan); -
870 }
executed: }
Execution Count:13
13
871 -
872 table.currentCell = TableCellIterator(textTable); -
873 cursor.setPosition(oldPos); -
874 }
executed: }
Execution Count:71
71
875 return table;
executed: return table;
Execution Count:75
75
876} -
877 -
878QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() -
879{ -
880 QTextBlockFormat block; -
881 QTextCharFormat charFmt; -
882 bool modifiedBlockFormat = true; -
883 bool modifiedCharFormat = true; -
884 -
885 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
886 Table &t = tables.last(); -
887 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
888 QTextTableCell cell = t.currentCell.cell(); -
889 if (cell.isValid()) {
partially evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:154
no
Evaluation Count:0
0-154
890 QTextTableCellFormat fmt = cell.format().toTableCellFormat(); -
891 if (topPadding(currentNodeIdx) >= 0)
evaluated: topPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
892 fmt.setTopPadding(topPadding(currentNodeIdx));
executed: fmt.setTopPadding(topPadding(currentNodeIdx));
Execution Count:2
2
893 if (bottomPadding(currentNodeIdx) >= 0)
evaluated: bottomPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
894 fmt.setBottomPadding(bottomPadding(currentNodeIdx));
executed: fmt.setBottomPadding(bottomPadding(currentNodeIdx));
Execution Count:2
2
895 if (leftPadding(currentNodeIdx) >= 0)
evaluated: leftPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
896 fmt.setLeftPadding(leftPadding(currentNodeIdx));
executed: fmt.setLeftPadding(leftPadding(currentNodeIdx));
Execution Count:2
2
897 if (rightPadding(currentNodeIdx) >= 0)
evaluated: rightPadding(currentNodeIdx) >= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:152
2-152
898 fmt.setRightPadding(rightPadding(currentNodeIdx));
executed: fmt.setRightPadding(rightPadding(currentNodeIdx));
Execution Count:2
2
899 cell.setFormat(fmt); -
900 -
901 cursor.setPosition(cell.firstPosition()); -
902 }
executed: }
Execution Count:154
154
903 }
executed: }
Execution Count:154
154
904 hasBlock = true; -
905 compressNextWhitespace = RemoveWhiteSpace; -
906 -
907 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
908 charFmt.setBackground(currentNode->charFormat.background()); -
909 cursor.mergeBlockCharFormat(charFmt); -
910 }
executed: }
Execution Count:8
8
911 }
executed: }
Execution Count:158
158
912 -
913 if (hasBlock) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:738
yes
Evaluation Count:116
116-738
914 block = cursor.blockFormat(); -
915 charFmt = cursor.blockCharFormat(); -
916 modifiedBlockFormat = false; -
917 modifiedCharFormat = false; -
918 }
executed: }
Execution Count:738
738
919 -
920 -
921 { -
922 qreal tm = qreal(topMargin(currentNodeIdx)); -
923 if (tm > block.topMargin()) {
evaluated: tm > block.topMargin()
TRUEFALSE
yes
Evaluation Count:518
yes
Evaluation Count:336
336-518
924 block.setTopMargin(tm); -
925 modifiedBlockFormat = true; -
926 }
executed: }
Execution Count:518
518
927 } -
928 -
929 int bottomMargin = this->bottomMargin(currentNodeIdx); -
930 -
931 -
932 -
933 const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : 0;
evaluated: currentNode->parent
TRUEFALSE
yes
Evaluation Count:370
yes
Evaluation Count:484
370-484
934 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
935 && parentNode
partially evaluated: parentNode
TRUEFALSE
yes
Evaluation Count:70
no
Evaluation Count:0
0-70
936 && (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
937 && (parentNode->children.last() == currentNodeIdx)) {
evaluated: (parentNode->children.last() == currentNodeIdx)
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:35
34-35
938 bottomMargin = qMax(bottomMargin, this->bottomMargin(currentNode->parent)); -
939 }
executed: }
Execution Count:34
34
940 -
941 if (block.bottomMargin() != bottomMargin) {
evaluated: block.bottomMargin() != bottomMargin
TRUEFALSE
yes
Evaluation Count:551
yes
Evaluation Count:303
303-551
942 block.setBottomMargin(bottomMargin); -
943 modifiedBlockFormat = true; -
944 }
executed: }
Execution Count:551
551
945 -
946 { -
947 const qreal lm = leftMargin(currentNodeIdx); -
948 const qreal rm = rightMargin(currentNodeIdx); -
949 -
950 if (block.leftMargin() != lm) {
evaluated: block.leftMargin() != lm
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:843
11-843
951 block.setLeftMargin(lm); -
952 modifiedBlockFormat = true; -
953 }
executed: }
Execution Count:11
11
954 if (block.rightMargin() != rm) {
evaluated: block.rightMargin() != rm
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:852
2-852
955 block.setRightMargin(rm); -
956 modifiedBlockFormat = true; -
957 }
executed: }
Execution Count:2
2
958 } -
959 -
960 if (currentNode->id != Html_li
evaluated: currentNode->id != Html_li
TRUEFALSE
yes
Evaluation Count:789
yes
Evaluation Count:65
65-789
961 && indent != 0
evaluated: indent != 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:782
7-782
962 && (lists.isEmpty()
partially evaluated: lists.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
963 || !hasBlock
evaluated: !hasBlock
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
964 || !lists.last().list
evaluated: !lists.last().list
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
965 || 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
966 ) -
967 ) { -
968 block.setIndent(indent); -
969 modifiedBlockFormat = true; -
970 }
executed: }
Execution Count:6
6
971 -
972 if (currentNode->blockFormat.propertyCount() > 0) {
evaluated: currentNode->blockFormat.propertyCount() > 0
TRUEFALSE
yes
Evaluation Count:337
yes
Evaluation Count:517
337-517
973 modifiedBlockFormat = true; -
974 block.merge(currentNode->blockFormat); -
975 }
executed: }
Execution Count:337
337
976 -
977 if (currentNode->charFormat.propertyCount() > 0) {
evaluated: currentNode->charFormat.propertyCount() > 0
TRUEFALSE
yes
Evaluation Count:404
yes
Evaluation Count:450
404-450
978 modifiedCharFormat = true; -
979 charFmt.merge(currentNode->charFormat); -
980 }
executed: }
Execution Count:404
404
981 -
982 -
983 -
984 -
985 if (wsm == QTextHtmlParserNode::WhiteSpacePre) {
evaluated: wsm == QTextHtmlParserNode::WhiteSpacePre
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:581
273-581
986 block.setNonBreakableLines(true); -
987 modifiedBlockFormat = true; -
988 }
executed: }
Execution Count:273
273
989 -
990 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
991 block.setBackground(currentNode->charFormat.background()); -
992 modifiedBlockFormat = true; -
993 }
executed: }
Execution Count:31
31
994 -
995 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
996 if (modifiedBlockFormat)
evaluated: modifiedBlockFormat
TRUEFALSE
yes
Evaluation Count:706
yes
Evaluation Count:31
31-706
997 cursor.setBlockFormat(block);
executed: cursor.setBlockFormat(block);
Execution Count:706
706
998 if (modifiedCharFormat)
evaluated: modifiedCharFormat
TRUEFALSE
yes
Evaluation Count:355
yes
Evaluation Count:382
355-382
999 cursor.setBlockCharFormat(charFmt);
executed: cursor.setBlockCharFormat(charFmt);
Execution Count:355
355
1000 } else {
executed: }
Execution Count:737
737
1001 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
1002 cursor.setBlockFormat(block); -
1003 cursor.setBlockCharFormat(charFmt); -
1004 } else {
executed: }
Execution Count:1
1
1005 appendBlock(block, charFmt); -
1006 }
executed: }
Execution Count:116
116
1007 } -
1008 -
1009 if (currentNode->userState != -1)
evaluated: currentNode->userState != -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:852
2-852
1010 cursor.block().setUserState(currentNode->userState);
executed: cursor.block().setUserState(currentNode->userState);
Execution Count:2
2
1011 -
1012 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
1013 List &l = lists.last(); -
1014 if (l.list) {
evaluated: l.list
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:33
32-33
1015 l.list->add(cursor.block()); -
1016 } else {
executed: }
Execution Count:32
32
1017 l.list = cursor.createList(l.format); -
1018 const qreal listTopMargin = topMargin(l.listNode); -
1019 if (listTopMargin > block.topMargin()) {
evaluated: listTopMargin > block.topMargin()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:6
6-27
1020 block.setTopMargin(listTopMargin); -
1021 cursor.mergeBlockFormat(block); -
1022 }
executed: }
Execution Count:27
27
1023 }
executed: }
Execution Count:33
33
1024 if (hasBlock) {
evaluated: hasBlock
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:35
30-35
1025 QTextBlockFormat fmt; -
1026 fmt.setIndent(0); -
1027 cursor.mergeBlockFormat(fmt); -
1028 }
executed: }
Execution Count:30
30
1029 }
executed: }
Execution Count:65
65
1030 -
1031 forceBlockMerging = false; -
1032 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
1033 forceBlockMerging = true;
executed: forceBlockMerging = true;
Execution Count:72
72
1034 -
1035 if (currentNode->isEmptyParagraph) {
evaluated: currentNode->isEmptyParagraph
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:821
33-821
1036 hasBlock = false; -
1037 return ContinueWithNextSibling;
executed: return ContinueWithNextSibling;
Execution Count:33
33
1038 } -
1039 -
1040 hasBlock = true; -
1041 blockTagClosed = false; -
1042 return ContinueWithCurrentNode;
executed: return ContinueWithCurrentNode;
Execution Count:821
821
1043} -
1044 -
1045void QTextHtmlImporter::appendBlock(const QTextBlockFormat &format, QTextCharFormat charFmt) -
1046{ -
1047 if (!namedAnchors.isEmpty()) {
partially evaluated: !namedAnchors.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:143
0-143
1048 charFmt.setAnchor(true); -
1049 charFmt.setAnchorNames(namedAnchors); -
1050 namedAnchors.clear(); -
1051 }
never executed: }
0
1052 -
1053 cursor.insertBlock(format, charFmt); -
1054 -
1055 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
1056 compressNextWhitespace = RemoveWhiteSpace;
executed: compressNextWhitespace = RemoveWhiteSpace;
Execution Count:101
101
1057}
executed: }
Execution Count:143
143
1058QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html) -
1059{ -
1060 return fromHtml(html, 0);
executed: return fromHtml(html, 0);
Execution Count:456
456
1061} -
1062QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html, const QTextDocument *resourceProvider) -
1063{ -
1064 QTextDocumentFragment res; -
1065 res.d = new QTextDocumentFragmentPrivate; -
1066 -
1067 QTextHtmlImporter importer(res.d->doc, html, QTextHtmlImporter::ImportToFragment, resourceProvider); -
1068 importer.import(); -
1069 return res;
executed: return res;
Execution Count:472
472
1070} -
1071 -
1072 -
1073 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial