qtextdocumentfragment.cpp

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

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