OpenCoverage

qtextdocument.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextdocument.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8__attribute__((visibility("default"))) unsigned int qt_int_sqrt(unsigned int n);-
9bool Qt::mightBeRichText(const QString& text)-
10{-
11 if (text.isEmpty()
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
12 return
never executed: return false;
false;
never executed: return false;
0
13 int start = 0;-
14-
15 while (start < text.length()
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(start).isSpace()
text.at(start).isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
16 ++
never executed: ++start;
start;
never executed: ++start;
0
17-
18-
19 if (text.mid(start, 5) == QLatin1String("<?xml")
text.mid(start...tring("<?xml")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
20 while (start < text.length()
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
21 if (text.at(start) == QLatin1Char('?')
text.at(start)...atin1Char('?')Description
TRUEnever evaluated
FALSEnever evaluated
0
22 && start + 2 < text.length()
start + 2 < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
23 && text.at(start + 1) == QLatin1Char('>')
text.at(start ...atin1Char('>')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
24 start += 2;-
25 break;
never executed: break;
0
26 }-
27 ++start;-
28 }
never executed: end of block
0
29-
30 while (start < text.length()
start < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(start).isSpace()
text.at(start).isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
31 ++
never executed: ++start;
start;
never executed: ++start;
0
32 }
never executed: end of block
0
33-
34 if (text.mid(start, 5).toLower() == QLatin1String("<!doc")
text.mid(start...tring("<!doc")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
35 return
never executed: return true;
true;
never executed: return true;
0
36 int open = start;-
37 while (open < text.length()
open < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(open) != QLatin1Char('<')
text.at(open) ...atin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
0
38 && text.at(open) != QLatin1Char('\n')
text.at(open) ...tin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
39 if (text.at(open) == QLatin1Char('&')
text.at(open) ...atin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
&& text.mid(open+1,3) == QLatin1String("lt;")
text.mid(open+...1String("lt;")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
40 return
never executed: return true;
true;
never executed: return true;
0
41 ++open;-
42 }
never executed: end of block
0
43 if (open < text.length()
open < text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(open) == QLatin1Char('<')
text.at(open) ...atin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
44 const int close = text.indexOf(QLatin1Char('>'), open);-
45 if (close > -1
close > -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
46 QString tag;-
47 for (int i = open+1; i < close
i < closeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
48 if (text[i].isDigit()
text[i].isDigit()Description
TRUEnever evaluated
FALSEnever evaluated
|| text[i].isLetter()
text[i].isLetter()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
49 tag += text[i];
never executed: tag += text[i];
0
50 else if (!tag.isEmpty()
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& text[i].isSpace()
text[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
51 break;
never executed: break;
0
52 else if (!tag.isEmpty()
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& text[i] == QLatin1Char('/')
text[i] == QLatin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
&& i + 1 == close
i + 1 == closeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
53 break;
never executed: break;
0
54 else if (!text[i].isSpace()
!text[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
&& (!tag.isEmpty()
!tag.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| text[i] != QLatin1Char('!')
text[i] != QLatin1Char('!')Description
TRUEnever evaluated
FALSEnever evaluated
))
0
55 return
never executed: return false;
false;
never executed: return false;
0
56 }
never executed: end of block
0
57-
58 return
never executed: return QTextHtmlParser::lookupElement(tag.toLower()) != -1;
QTextHtmlParser::lookupElement(tag.toLower()) != -1;
never executed: return QTextHtmlParser::lookupElement(tag.toLower()) != -1;
0
59-
60-
61-
62 }-
63 }
never executed: end of block
0
64 return
never executed: return false;
false;
never executed: return false;
0
65}-
66QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode)-
67{-
68 int col = 0;-
69 QString rich;-
70 rich += QLatin1String("<p>");-
71 for (int i = 0; i < plain.length()
i < plain.length()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
72 if (plain[i] == QLatin1Char('\n')
plain[i] == QLatin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
){
0
73 int c = 1;-
74 while (i+1 < plain.length()
i+1 < plain.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& plain[i+1] == QLatin1Char('\n')
plain[i+1] == ...tin1Char('\n')Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
75 i++;-
76 c++;-
77 }
never executed: end of block
0
78 if (c == 1
c == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
79 rich += QLatin1String("<br>\n");
never executed: rich += QLatin1String("<br>\n");
0
80 else {-
81 rich += QLatin1String("</p>\n");-
82 while (--
--c > 1Description
TRUEnever evaluated
FALSEnever evaluated
c > 1
--c > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
83 rich += QLatin1String("<br>\n");
never executed: rich += QLatin1String("<br>\n");
0
84 rich += QLatin1String("<p>");-
85 }
never executed: end of block
0
86 col = 0;-
87 }
never executed: end of block
else {
0
88 if (mode == Qt::WhiteSpacePre
mode == Qt::WhiteSpacePreDescription
TRUEnever evaluated
FALSEnever evaluated
&& plain[i] == QLatin1Char('\t')
plain[i] == QLatin1Char('\t')Description
TRUEnever evaluated
FALSEnever evaluated
){
0
89 rich += QChar(0x00a0U);-
90 ++col;-
91 while (col % 8
col % 8Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
92 rich += QChar(0x00a0U);-
93 ++col;-
94 }
never executed: end of block
0
95 }
never executed: end of block
0
96 else if (mode == Qt::WhiteSpacePre
mode == Qt::WhiteSpacePreDescription
TRUEnever evaluated
FALSEnever evaluated
&& plain[i].isSpace()
plain[i].isSpace()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
97 rich += QChar(0x00a0U);
never executed: rich += QChar(0x00a0U);
0
98 else if (plain[i] == QLatin1Char('<')
plain[i] == QLatin1Char('<')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 rich += QLatin1String("&lt;");
never executed: rich += QLatin1String("&lt;");
0
100 else if (plain[i] == QLatin1Char('>')
plain[i] == QLatin1Char('>')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
101 rich += QLatin1String("&gt;");
never executed: rich += QLatin1String("&gt;");
0
102 else if (plain[i] == QLatin1Char('&')
plain[i] == QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
103 rich += QLatin1String("&amp;");
never executed: rich += QLatin1String("&amp;");
0
104 else-
105 rich += plain[i];
never executed: rich += plain[i];
0
106 ++col;-
107 }
never executed: end of block
0
108 }-
109 if (col != 0
col != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
110 rich += QLatin1String("</p>");
never executed: rich += QLatin1String("</p>");
0
111 return
never executed: return rich;
rich;
never executed: return rich;
0
112}-
113-
114-
115-
116-
117-
118-
119-
120QTextCodec *Qt::codecForHtml(const QByteArray &ba)-
121{-
122 return
never executed: return QTextCodec::codecForHtml(ba);
QTextCodec::codecForHtml(ba);
never executed: return QTextCodec::codecForHtml(ba);
0
123}-
124QTextDocument::QTextDocument(QObject *parent)-
125 : QObject(*new QTextDocumentPrivate, parent)-
126{-
127 QTextDocumentPrivate * const d = d_func();-
128 d->init();-
129}
never executed: end of block
0
130-
131-
132-
133-
134-
135QTextDocument::QTextDocument(const QString &text, QObject *parent)-
136 : QObject(*new QTextDocumentPrivate, parent)-
137{-
138 QTextDocumentPrivate * const d = d_func();-
139 d->init();-
140 QTextCursor(this).insertText(text);-
141}
never executed: end of block
0
142-
143-
144-
145-
146QTextDocument::QTextDocument(QTextDocumentPrivate &dd, QObject *parent)-
147 : QObject(dd, parent)-
148{-
149 QTextDocumentPrivate * const d = d_func();-
150 d->init();-
151}
never executed: end of block
0
152-
153-
154-
155-
156QTextDocument::~QTextDocument()-
157{-
158}-
159-
160-
161-
162-
163-
164-
165QTextDocument *QTextDocument::clone(QObject *parent) const-
166{-
167 const QTextDocumentPrivate * const d = d_func();-
168 QTextDocument *doc = new QTextDocument(parent);-
169 QTextCursor(doc).insertFragment(QTextDocumentFragment(this));-
170 doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat());-
171 QTextDocumentPrivate *priv = doc->d_func();-
172 priv->title = d->title;-
173 priv->url = d->url;-
174 priv->pageSize = d->pageSize;-
175 priv->indentWidth = d->indentWidth;-
176 priv->defaultTextOption = d->defaultTextOption;-
177 priv->setDefaultFont(d->defaultFont());-
178 priv->resources = d->resources;-
179 priv->cachedResources.clear();-
180-
181 priv->defaultStyleSheet = d->defaultStyleSheet;-
182 priv->parsedDefaultStyleSheet = d->parsedDefaultStyleSheet;-
183-
184 return
never executed: return doc;
doc;
never executed: return doc;
0
185}-
186-
187-
188-
189-
190bool QTextDocument::isEmpty() const-
191{-
192 const QTextDocumentPrivate * const d = d_func();-
193-
194-
195 return
never executed: return d->length() <= 1;
d->length() <= 1;
never executed: return d->length() <= 1;
0
196}-
197-
198-
199-
200-
201void QTextDocument::clear()-
202{-
203 QTextDocumentPrivate * const d = d_func();-
204 d->clear();-
205 d->resources.clear();-
206}
never executed: end of block
0
207void QTextDocument::undo(QTextCursor *cursor)-
208{-
209 QTextDocumentPrivate * const d = d_func();-
210 const int pos = d->undoRedo(true);-
211 if (cursor
cursorDescription
TRUEnever evaluated
FALSEnever evaluated
&& pos >= 0
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
212 *cursor = QTextCursor(this);-
213 cursor->setPosition(pos);-
214 }
never executed: end of block
0
215}
never executed: end of block
0
216void QTextDocument::redo(QTextCursor *cursor)-
217{-
218 QTextDocumentPrivate * const d = d_func();-
219 const int pos = d->undoRedo(false);-
220 if (cursor
cursorDescription
TRUEnever evaluated
FALSEnever evaluated
&& pos >= 0
pos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
221 *cursor = QTextCursor(this);-
222 cursor->setPosition(pos);-
223 }
never executed: end of block
0
224}
never executed: end of block
0
225void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear)-
226{-
227 QTextDocumentPrivate * const d = d_func();-
228 d->clearUndoRedoStacks(stacksToClear, true);-
229}
never executed: end of block
0
230-
231-
232-
233-
234-
235void QTextDocument::undo()-
236{-
237 QTextDocumentPrivate * const d = d_func();-
238 d->undoRedo(true);-
239}
never executed: end of block
0
240-
241-
242-
243-
244-
245void QTextDocument::redo()-
246{-
247 QTextDocumentPrivate * const d = d_func();-
248 d->undoRedo(false);-
249}
never executed: end of block
0
250-
251-
252-
253-
254-
255-
256void QTextDocument::appendUndoItem(QAbstractUndoItem *item)-
257{-
258 QTextDocumentPrivate * const d = d_func();-
259 d->appendUndoItem(item);-
260}
never executed: end of block
0
261void QTextDocument::setUndoRedoEnabled(bool enable)-
262{-
263 QTextDocumentPrivate * const d = d_func();-
264 d->enableUndoRedo(enable);-
265}
never executed: end of block
0
266-
267bool QTextDocument::isUndoRedoEnabled() const-
268{-
269 const QTextDocumentPrivate * const d = d_func();-
270 return
never executed: return d->isUndoRedoEnabled();
d->isUndoRedoEnabled();
never executed: return d->isUndoRedoEnabled();
0
271}-
272int QTextDocument::maximumBlockCount() const-
273{-
274 const QTextDocumentPrivate * const d = d_func();-
275 return
never executed: return d->maximumBlockCount;
d->maximumBlockCount;
never executed: return d->maximumBlockCount;
0
276}-
277-
278void QTextDocument::setMaximumBlockCount(int maximum)-
279{-
280 QTextDocumentPrivate * const d = d_func();-
281 d->maximumBlockCount = maximum;-
282 d->ensureMaximumBlockCount();-
283 setUndoRedoEnabled(false);-
284}
never executed: end of block
0
285QTextOption QTextDocument::defaultTextOption() const-
286{-
287 const QTextDocumentPrivate * const d = d_func();-
288 return
never executed: return d->defaultTextOption;
d->defaultTextOption;
never executed: return d->defaultTextOption;
0
289}-
290-
291-
292-
293-
294-
295-
296void QTextDocument::setDefaultTextOption(const QTextOption &option)-
297{-
298 QTextDocumentPrivate * const d = d_func();-
299 d->defaultTextOption = option;-
300 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
301 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
302}
never executed: end of block
0
303QUrl QTextDocument::baseUrl() const-
304{-
305 const QTextDocumentPrivate * const d = d_func();-
306 return
never executed: return d->baseUrl;
d->baseUrl;
never executed: return d->baseUrl;
0
307}-
308-
309void QTextDocument::setBaseUrl(const QUrl &url)-
310{-
311 QTextDocumentPrivate * const d = d_func();-
312 if (d->baseUrl != url
d->baseUrl != urlDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
313 d->baseUrl = url;-
314 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
315 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
316 baseUrlChanged(url);-
317 }
never executed: end of block
0
318}
never executed: end of block
0
319-
320-
321-
322-
323-
324-
325-
326Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const-
327{-
328 const QTextDocumentPrivate * const d = d_func();-
329 return
never executed: return d->defaultCursorMoveStyle;
d->defaultCursorMoveStyle;
never executed: return d->defaultCursorMoveStyle;
0
330}-
331-
332-
333-
334-
335-
336-
337void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style)-
338{-
339 QTextDocumentPrivate * const d = d_func();-
340 d->defaultCursorMoveStyle = style;-
341}
never executed: end of block
0
342void QTextDocument::markContentsDirty(int from, int length)-
343{-
344 QTextDocumentPrivate * const d = d_func();-
345 d->documentChange(from, length);-
346 if (!d->inContentsChange
!d->inContentsChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
347 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
348 d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength);-
349 d->docChangeFrom = -1;-
350 }
never executed: end of block
0
351 }
never executed: end of block
0
352}
never executed: end of block
0
353void QTextDocument::setUseDesignMetrics(bool b)-
354{-
355 QTextDocumentPrivate * const d = d_func();-
356 if (b == d->defaultTextOption.useDesignMetrics()
b == d->defaul...esignMetrics()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return;
never executed: return;
0
358 d->defaultTextOption.setUseDesignMetrics(b);-
359 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
360 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
361}
never executed: end of block
0
362-
363bool QTextDocument::useDesignMetrics() const-
364{-
365 const QTextDocumentPrivate * const d = d_func();-
366 return
never executed: return d->defaultTextOption.useDesignMetrics();
d->defaultTextOption.useDesignMetrics();
never executed: return d->defaultTextOption.useDesignMetrics();
0
367}-
368-
369-
370-
371-
372-
373-
374-
375void QTextDocument::drawContents(QPainter *p, const QRectF &rect)-
376{-
377 p->save();-
378 QAbstractTextDocumentLayout::PaintContext ctx;-
379 if (rect.isValid()
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
380 p->setClipRect(rect);-
381 ctx.clip = rect;-
382 }
never executed: end of block
0
383 documentLayout()->draw(p, ctx);-
384 p->restore();-
385}
never executed: end of block
0
386void QTextDocument::setTextWidth(qreal width)-
387{-
388 QTextDocumentPrivate * const d = d_func();-
389 QSizeF sz = d->pageSize;-
390 sz.setWidth(width);-
391 sz.setHeight(-1);-
392 setPageSize(sz);-
393}
never executed: end of block
0
394-
395qreal QTextDocument::textWidth() const-
396{-
397 const QTextDocumentPrivate * const d = d_func();-
398 return
never executed: return d->pageSize.width();
d->pageSize.width();
never executed: return d->pageSize.width();
0
399}-
400qreal QTextDocument::idealWidth() const-
401{-
402 if (QTextDocumentLayout *lout = qobject_cast<QTextDocumentLayout *>(documentLayout())
QTextDocumentL...umentLayout())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
403 return
never executed: return lout->idealWidth();
lout->idealWidth();
never executed: return lout->idealWidth();
0
404 return
never executed: return textWidth();
textWidth();
never executed: return textWidth();
0
405}-
406-
407-
408-
409-
410-
411-
412-
413qreal QTextDocument::documentMargin() const-
414{-
415 const QTextDocumentPrivate * const d = d_func();-
416 return
never executed: return d->documentMargin;
d->documentMargin;
never executed: return d->documentMargin;
0
417}-
418-
419void QTextDocument::setDocumentMargin(qreal margin)-
420{-
421 QTextDocumentPrivate * const d = d_func();-
422 if (d->documentMargin != margin
d->documentMargin != marginDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
423 d->documentMargin = margin;-
424-
425 QTextFrame* root = rootFrame();-
426 QTextFrameFormat format = root->frameFormat();-
427 format.setMargin(margin);-
428 root->setFrameFormat(format);-
429-
430 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
431 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
432 }
never executed: end of block
0
433}
never executed: end of block
0
434qreal QTextDocument::indentWidth() const-
435{-
436 const QTextDocumentPrivate * const d = d_func();-
437 return
never executed: return d->indentWidth;
d->indentWidth;
never executed: return d->indentWidth;
0
438}-
439void QTextDocument::setIndentWidth(qreal width)-
440{-
441 QTextDocumentPrivate * const d = d_func();-
442 if (d->indentWidth != width
d->indentWidth != widthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
443 d->indentWidth = width;-
444 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
445 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
446 }
never executed: end of block
0
447}
never executed: end of block
0
448void QTextDocument::adjustSize()-
449{-
450-
451 QFont f = defaultFont();-
452 QFontMetrics fm(f);-
453 int mw = fm.width(QLatin1Char('x')) * 80;-
454 int w = mw;-
455 setTextWidth(w);-
456 QSizeF size = documentLayout()->documentSize();-
457 if (size.width() != 0
size.width() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
458 w = qt_int_sqrt((uint)(5 * size.height() * size.width() / 3));-
459 setTextWidth(qMin(w, mw));-
460-
461 size = documentLayout()->documentSize();-
462 if (w*3 < 5*size.height()
w*3 < 5*size.height()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
463 w = qt_int_sqrt((uint)(2 * size.height() * size.width()));-
464 setTextWidth(qMin(w, mw));-
465 }
never executed: end of block
0
466 }
never executed: end of block
0
467 setTextWidth(idealWidth());-
468}
never executed: end of block
0
469QSizeF QTextDocument::size() const-
470{-
471 return
never executed: return documentLayout()->documentSize();
documentLayout()->documentSize();
never executed: return documentLayout()->documentSize();
0
472}-
473int QTextDocument::blockCount() const-
474{-
475 const QTextDocumentPrivate * const d = d_func();-
476 return
never executed: return d->blockMap().numNodes();
d->blockMap().numNodes();
never executed: return d->blockMap().numNodes();
0
477}-
478int QTextDocument::lineCount() const-
479{-
480 const QTextDocumentPrivate * const d = d_func();-
481 return
never executed: return d->blockMap().length(2);
d->blockMap().length(2);
never executed: return d->blockMap().length(2);
0
482}-
483int QTextDocument::characterCount() const-
484{-
485 const QTextDocumentPrivate * const d = d_func();-
486 return
never executed: return d->length();
d->length();
never executed: return d->length();
0
487}-
488QChar QTextDocument::characterAt(int pos) const-
489{-
490 const QTextDocumentPrivate * const d = d_func();-
491 if (pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| pos >= d->length()
pos >= d->length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
492 return
never executed: return QChar();
QChar();
never executed: return QChar();
0
493 QTextDocumentPrivate::FragmentIterator fragIt = d->find(pos);-
494 const QTextFragmentData * const frag = fragIt.value();-
495 const int offsetInFragment = qMax(0, pos - fragIt.position());-
496 return
never executed: return d->text.at(frag->stringPosition + offsetInFragment);
d->text.at(frag->stringPosition + offsetInFragment);
never executed: return d->text.at(frag->stringPosition + offsetInFragment);
0
497}-
498void QTextDocument::setDefaultStyleSheet(const QString &sheet)-
499{-
500 QTextDocumentPrivate * const d = d_func();-
501 d->defaultStyleSheet = sheet;-
502 QCss::Parser parser(sheet);-
503 d->parsedDefaultStyleSheet = QCss::StyleSheet();-
504 d->parsedDefaultStyleSheet.origin = QCss::StyleSheetOrigin_UserAgent;-
505 parser.parse(&d->parsedDefaultStyleSheet);-
506}
never executed: end of block
0
507-
508QString QTextDocument::defaultStyleSheet() const-
509{-
510 const QTextDocumentPrivate * const d = d_func();-
511 return
never executed: return d->defaultStyleSheet;
d->defaultStyleSheet;
never executed: return d->defaultStyleSheet;
0
512}-
513bool QTextDocument::isUndoAvailable() const-
514{-
515 const QTextDocumentPrivate * const d = d_func();-
516 return
never executed: return d->isUndoAvailable();
d->isUndoAvailable();
never executed: return d->isUndoAvailable();
0
517}-
518-
519-
520-
521-
522-
523-
524bool QTextDocument::isRedoAvailable() const-
525{-
526 const QTextDocumentPrivate * const d = d_func();-
527 return
never executed: return d->isRedoAvailable();
d->isRedoAvailable();
never executed: return d->isRedoAvailable();
0
528}-
529-
530-
531-
532-
533-
534-
535-
536int QTextDocument::availableUndoSteps() const-
537{-
538 const QTextDocumentPrivate * const d = d_func();-
539 return
never executed: return d->availableUndoSteps();
d->availableUndoSteps();
never executed: return d->availableUndoSteps();
0
540}-
541-
542-
543-
544-
545-
546-
547-
548int QTextDocument::availableRedoSteps() const-
549{-
550 const QTextDocumentPrivate * const d = d_func();-
551 return
never executed: return d->availableRedoSteps();
d->availableRedoSteps();
never executed: return d->availableRedoSteps();
0
552}-
553int QTextDocument::revision() const-
554{-
555 const QTextDocumentPrivate * const d = d_func();-
556 return
never executed: return d->revision;
d->revision;
never executed: return d->revision;
0
557}-
558void QTextDocument::setDocumentLayout(QAbstractTextDocumentLayout *layout)-
559{-
560 QTextDocumentPrivate * const d = d_func();-
561 d->setLayout(layout);-
562}
never executed: end of block
0
563-
564-
565-
566-
567QAbstractTextDocumentLayout *QTextDocument::documentLayout() const-
568{-
569 const QTextDocumentPrivate * const d = d_func();-
570 if (!d->lout
!d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
571 QTextDocument *that = const_cast<QTextDocument *>(this);-
572 that->d_func()->setLayout(new QTextDocumentLayout(that));-
573 }
never executed: end of block
0
574 return
never executed: return d->lout;
d->lout;
never executed: return d->lout;
0
575}-
576QString QTextDocument::metaInformation(MetaInformation info) const-
577{-
578 const QTextDocumentPrivate * const d = d_func();-
579 switch (info) {-
580 case
never executed: case DocumentTitle:
DocumentTitle:
never executed: case DocumentTitle:
0
581 return
never executed: return d->title;
d->title;
never executed: return d->title;
0
582 case
never executed: case DocumentUrl:
DocumentUrl:
never executed: case DocumentUrl:
0
583 return
never executed: return d->url;
d->url;
never executed: return d->url;
0
584 }-
585 return
never executed: return QString();
QString();
never executed: return QString();
0
586}-
587-
588-
589-
590-
591-
592-
593-
594void QTextDocument::setMetaInformation(MetaInformation info, const QString &string)-
595{-
596 QTextDocumentPrivate * const d = d_func();-
597 switch (info) {-
598 case
never executed: case DocumentTitle:
DocumentTitle:
never executed: case DocumentTitle:
0
599 d->title = string;-
600 break;
never executed: break;
0
601 case
never executed: case DocumentUrl:
DocumentUrl:
never executed: case DocumentUrl:
0
602 d->url = string;-
603 break;
never executed: break;
0
604 }-
605}
never executed: end of block
0
606QString QTextDocument::toPlainText() const-
607{-
608 const QTextDocumentPrivate * const d = d_func();-
609 QString txt = d->plainText();-
610-
611 QChar *uc = txt.data();-
612 QChar *e = uc + txt.size();-
613-
614 for (; uc != e
uc != eDescription
TRUEnever evaluated
FALSEnever evaluated
; ++uc) {
0
615 switch (uc->unicode()) {-
616 case
never executed: case 0xfdd0:
0xfdd0:
never executed: case 0xfdd0:
0
617 case
never executed: case 0xfdd1:
0xfdd1:
never executed: case 0xfdd1:
0
618 case
never executed: case QChar::ParagraphSeparator:
QChar::ParagraphSeparator:
never executed: case QChar::ParagraphSeparator:
0
619 case
never executed: case QChar::LineSeparator:
QChar::LineSeparator:
never executed: case QChar::LineSeparator:
0
620 *uc = QLatin1Char('\n');-
621 break;
never executed: break;
0
622 case
never executed: case QChar::Nbsp:
QChar::Nbsp:
never executed: case QChar::Nbsp:
0
623 *uc = QLatin1Char(' ');-
624 break;
never executed: break;
0
625 default
never executed: default:
:
never executed: default:
0
626 ;-
627 }
never executed: end of block
0
628 }-
629 return
never executed: return txt;
txt;
never executed: return txt;
0
630}-
631-
632-
633-
634-
635-
636-
637-
638void QTextDocument::setPlainText(const QString &text)-
639{-
640 QTextDocumentPrivate * const d = d_func();-
641 bool previousState = d->isUndoRedoEnabled();-
642 d->enableUndoRedo(false);-
643 d->beginEditBlock();-
644 d->clear();-
645 QTextCursor(this).insertText(text);-
646 d->endEditBlock();-
647 d->enableUndoRedo(previousState);-
648}
never executed: end of block
0
649void QTextDocument::setHtml(const QString &html)-
650{-
651 QTextDocumentPrivate * const d = d_func();-
652 bool previousState = d->isUndoRedoEnabled();-
653 d->enableUndoRedo(false);-
654 d->beginEditBlock();-
655 d->clear();-
656 QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import();-
657 d->endEditBlock();-
658 d->enableUndoRedo(previousState);-
659}
never executed: end of block
0
660static bool findInBlock(const QTextBlock &block, const QString &expression, int offset,-
661 QTextDocument::FindFlags options, QTextCursor *cursor)-
662{-
663 QString text = block.text();-
664 text.replace(QChar::Nbsp, QLatin1Char(' '));-
665 Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively
options & QTex...aseSensitivelyDescription
TRUEnever evaluated
FALSEnever evaluated
? Qt::CaseSensitive : Qt::CaseInsensitive;
0
666 int idx = -1;-
667-
668 while (offset >= 0
offset >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& offset <= text.length()
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
669 idx = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
?
0
670 text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity);-
671 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
672 return
never executed: return false;
false;
never executed: return false;
0
673-
674 if (options & QTextDocument::FindWholeWords
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
675 const int start = idx;-
676 const int end = start + expression.length();-
677 if ((start != 0
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(start - 1).isLetterOrNumber()
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
678 || (end != text.length()
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(end).isLetterOrNumber()
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
679-
680 offset = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
? idx-1 : end+1;
0
681 idx = -1;-
682 continue;
never executed: continue;
0
683 }-
684 }
never executed: end of block
0
685-
686 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
687 cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor);-
688 return
never executed: return true;
true;
never executed: return true;
0
689 }-
690 return
never executed: return false;
false;
never executed: return false;
0
691}-
692QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags options) const-
693{-
694 const QTextDocumentPrivate * const d = d_func();-
695-
696 if (subString.isEmpty()
subString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
697 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
698-
699 int pos = from;-
700-
701-
702 if (options & FindBackward
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
703 --pos ;-
704 if (pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
705 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
706 }
never executed: end of block
0
707-
708 QTextCursor cursor;-
709 QTextBlock block = d->blocksFind(pos);-
710 int blockOffset = pos - block.position();-
711-
712 if (!(options & FindBackward)
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
713 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
714 if (findInBlock(block, subString, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
715 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
716 block = block.next();-
717 blockOffset = 0;-
718 }
never executed: end of block
0
719 }
never executed: end of block
else {
0
720 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
721 if (findInBlock(block, subString, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
722 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
723 block = block.previous();-
724 blockOffset = block.length() - 2;-
725 }
never executed: end of block
0
726 }
never executed: end of block
0
727-
728 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
729}-
730QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const-
731{-
732 int pos = 0;-
733 if (!cursor.isNull()
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
734 if (options & QTextDocument::FindBackward
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
735 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
736 else-
737 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
738 }-
739-
740 return
never executed: return find(subString, pos, options);
find(subString, pos, options);
never executed: return find(subString, pos, options);
0
741}-
742-
743-
744-
745static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset,-
746 QTextDocument::FindFlags options, QTextCursor *cursor)-
747{-
748 QRegExp expr(expression);-
749 QString text = block.text();-
750 text.replace(QChar::Nbsp, QLatin1Char(' '));-
751-
752 int idx = -1;-
753 while (offset >=0
offset >=0Description
TRUEnever evaluated
FALSEnever evaluated
&& offset <= text.length()
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
754 idx = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
?
0
755 expr.lastIndexIn(text, offset) : expr.indexIn(text, offset);-
756 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
757 return
never executed: return false;
false;
never executed: return false;
0
758-
759 if (options & QTextDocument::FindWholeWords
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
760 const int start = idx;-
761 const int end = start + expr.matchedLength();-
762 if ((start != 0
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(start - 1).isLetterOrNumber()
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
763 || (end != text.length()
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(end).isLetterOrNumber()
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
764-
765 offset = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
? idx-1 : end+1;
0
766 idx = -1;-
767 continue;
never executed: continue;
0
768 }-
769 }
never executed: end of block
0
770-
771 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
772 cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor);-
773 return
never executed: return true;
true;
never executed: return true;
0
774 }-
775 return
never executed: return false;
false;
never executed: return false;
0
776}-
777QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags options) const-
778{-
779 const QTextDocumentPrivate * const d = d_func();-
780-
781 if (expr.isEmpty()
expr.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
782 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
783-
784 int pos = from;-
785-
786-
787 if (options & FindBackward
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
788 --pos ;-
789 if(pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
790 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
791 }
never executed: end of block
0
792-
793 QTextCursor cursor;-
794 QTextBlock block = d->blocksFind(pos);-
795 int blockOffset = pos - block.position();-
796 if (!(options & FindBackward)
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
797 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
798 if (findInBlock(block, expr, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
799 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
800 block = block.next();-
801 blockOffset = 0;-
802 }
never executed: end of block
0
803 }
never executed: end of block
else {
0
804 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
805 if (findInBlock(block, expr, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
806 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
807 block = block.previous();-
808 blockOffset = block.length() - 1;-
809 }
never executed: end of block
0
810 }
never executed: end of block
0
811-
812 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
813}-
814QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const-
815{-
816 int pos = 0;-
817 if (!cursor.isNull()
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
818 if (options & QTextDocument::FindBackward
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
819 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
820 else-
821 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
822 }-
823 return
never executed: return find(expr, pos, options);
find(expr, pos, options);
never executed: return find(expr, pos, options);
0
824}-
825-
826-
827-
828static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset,-
829 QTextDocument::FindFlags options, QTextCursor *cursor)-
830{-
831 QRegularExpression expr(expression);-
832 if (!(options & QTextDocument::FindCaseSensitively)
!(options & QT...seSensitively)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
833 expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption);
never executed: expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption);
0
834 else-
835 expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
never executed: expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
0
836-
837 QString text = block.text();-
838 text.replace(QChar::Nbsp, QLatin1Char(' '));-
839 QRegularExpressionMatch match;-
840 int idx = -1;-
841-
842 while (offset >= 0
offset >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& offset <= text.length()
offset <= text.length()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
843 idx = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
?
0
844 text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match);-
845 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
846 return
never executed: return false;
false;
never executed: return false;
0
847-
848 if (options & QTextDocument::FindWholeWords
options & QTex...FindWholeWordsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
849 const int start = idx;-
850 const int end = start + match.capturedLength();-
851 if ((start != 0
start != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(start - 1).isLetterOrNumber()
text.at(start ...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
852 || (end != text.length()
end != text.length()Description
TRUEnever evaluated
FALSEnever evaluated
&& text.at(end).isLetterOrNumber()
text.at(end).i...tterOrNumber()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
853-
854 offset = (
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
options & QTextDocument::FindBackward)
(options & QTe...:FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
? idx-1 : end+1;
0
855 idx = -1;-
856 continue;
never executed: continue;
0
857 }-
858 }
never executed: end of block
0
859-
860 *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);-
861 cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor);-
862 return
never executed: return true;
true;
never executed: return true;
0
863 }-
864 return
never executed: return false;
false;
never executed: return false;
0
865}-
866QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const-
867{-
868 const QTextDocumentPrivate * const d = d_func();-
869-
870 if (!expr.isValid()
!expr.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
871 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
872-
873 int pos = from;-
874-
875-
876 if (options & FindBackward
options & FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
877 --pos ;-
878 if (pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
879 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
880 }
never executed: end of block
0
881-
882 QTextCursor cursor;-
883 QTextBlock block = d->blocksFind(pos);-
884 int blockOffset = pos - block.position();-
885-
886 if (!(options & FindBackward)
!(options & FindBackward)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
887 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
888 if (findInBlock(block, expr, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
889 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
890 block = block.next();-
891 blockOffset = 0;-
892 }
never executed: end of block
0
893 }
never executed: end of block
else {
0
894 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
895 if (findInBlock(block, expr, blockOffset, options, &cursor)
findInBlock(bl...ions, &cursor)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
896 return
never executed: return cursor;
cursor;
never executed: return cursor;
0
897 block = block.previous();-
898 blockOffset = block.length() - 1;-
899 }
never executed: end of block
0
900 }
never executed: end of block
0
901-
902 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
903}-
904QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options) const-
905{-
906 int pos = 0;-
907 if (!cursor.isNull()
!cursor.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
908 if (options & QTextDocument::FindBackward
options & QTex...::FindBackwardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
909 pos = cursor.selectionStart();
never executed: pos = cursor.selectionStart();
0
910 else-
911 pos = cursor.selectionEnd();
never executed: pos = cursor.selectionEnd();
0
912 }-
913 return
never executed: return find(expr, pos, options);
find(expr, pos, options);
never executed: return find(expr, pos, options);
0
914}-
915QTextObject *QTextDocument::createObject(const QTextFormat &f)-
916{-
917 QTextObject *obj = 0;-
918 if (f.isListFormat()
f.isListFormat()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
919 obj = new QTextList(this);
never executed: obj = new QTextList(this);
0
920 else if (f.isTableFormat()
f.isTableFormat()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
921 obj = new QTextTable(this);
never executed: obj = new QTextTable(this);
0
922 else if (f.isFrameFormat()
f.isFrameFormat()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
923 obj = new QTextFrame(this);
never executed: obj = new QTextFrame(this);
0
924-
925 return
never executed: return obj;
obj;
never executed: return obj;
0
926}-
927-
928-
929-
930-
931-
932-
933QTextFrame *QTextDocument::frameAt(int pos) const-
934{-
935 const QTextDocumentPrivate * const d = d_func();-
936 return
never executed: return d->frameAt(pos);
d->frameAt(pos);
never executed: return d->frameAt(pos);
0
937}-
938-
939-
940-
941-
942QTextFrame *QTextDocument::rootFrame() const-
943{-
944 const QTextDocumentPrivate * const d = d_func();-
945 return
never executed: return d->rootFrame();
d->rootFrame();
never executed: return d->rootFrame();
0
946}-
947-
948-
949-
950-
951QTextObject *QTextDocument::object(int objectIndex) const-
952{-
953 const QTextDocumentPrivate * const d = d_func();-
954 return
never executed: return d->objectForIndex(objectIndex);
d->objectForIndex(objectIndex);
never executed: return d->objectForIndex(objectIndex);
0
955}-
956-
957-
958-
959-
960QTextObject *QTextDocument::objectForFormat(const QTextFormat &f) const-
961{-
962 const QTextDocumentPrivate * const d = d_func();-
963 return
never executed: return d->objectForFormat(f);
d->objectForFormat(f);
never executed: return d->objectForFormat(f);
0
964}-
965-
966-
967-
968-
969-
970QTextBlock QTextDocument::findBlock(int pos) const-
971{-
972 const QTextDocumentPrivate * const d = d_func();-
973 return
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(pos));
QTextBlock(docHandle(), d->blockMap().findNode(pos));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(pos));
0
974}-
975-
976-
977-
978-
979-
980-
981-
982QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const-
983{-
984 const QTextDocumentPrivate * const d = d_func();-
985 return
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));
0
986}-
987-
988-
989-
990-
991-
992-
993-
994QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const-
995{-
996 const QTextDocumentPrivate * const d = d_func();-
997 return
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
never executed: return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));
0
998}-
999-
1000-
1001-
1002-
1003-
1004-
1005QTextBlock QTextDocument::begin() const-
1006{-
1007 const QTextDocumentPrivate * const d = d_func();-
1008 return
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
QTextBlock(docHandle(), d->blockMap().begin().n);
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
0
1009}-
1010QTextBlock QTextDocument::end() const-
1011{-
1012 return
never executed: return QTextBlock(docHandle(), 0);
QTextBlock(docHandle(), 0);
never executed: return QTextBlock(docHandle(), 0);
0
1013}-
1014-
1015-
1016-
1017-
1018-
1019QTextBlock QTextDocument::firstBlock() const-
1020{-
1021 const QTextDocumentPrivate * const d = d_func();-
1022 return
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
QTextBlock(docHandle(), d->blockMap().begin().n);
never executed: return QTextBlock(docHandle(), d->blockMap().begin().n);
0
1023}-
1024-
1025-
1026-
1027-
1028-
1029QTextBlock QTextDocument::lastBlock() const-
1030{-
1031 const QTextDocumentPrivate * const d = d_func();-
1032 return
never executed: return QTextBlock(docHandle(), d->blockMap().last().n);
QTextBlock(docHandle(), d->blockMap().last().n);
never executed: return QTextBlock(docHandle(), d->blockMap().last().n);
0
1033}-
1034void QTextDocument::setPageSize(const QSizeF &size)-
1035{-
1036 QTextDocumentPrivate * const d = d_func();-
1037 d->pageSize = size;-
1038 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1039 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
1040}
never executed: end of block
0
1041-
1042QSizeF QTextDocument::pageSize() const-
1043{-
1044 const QTextDocumentPrivate * const d = d_func();-
1045 return
never executed: return d->pageSize;
d->pageSize;
never executed: return d->pageSize;
0
1046}-
1047-
1048-
1049-
1050-
1051int QTextDocument::pageCount() const-
1052{-
1053 return
never executed: return documentLayout()->pageCount();
documentLayout()->pageCount();
never executed: return documentLayout()->pageCount();
0
1054}-
1055-
1056-
1057-
1058-
1059void QTextDocument::setDefaultFont(const QFont &font)-
1060{-
1061 QTextDocumentPrivate * const d = d_func();-
1062 d->setDefaultFont(font);-
1063 if (d->lout
d->loutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1064 d->lout->documentChanged(0, 0, d->length());
never executed: d->lout->documentChanged(0, 0, d->length());
0
1065}
never executed: end of block
0
1066-
1067-
1068-
1069-
1070QFont QTextDocument::defaultFont() const-
1071{-
1072 const QTextDocumentPrivate * const d = d_func();-
1073 return
never executed: return d->defaultFont();
d->defaultFont();
never executed: return d->defaultFont();
0
1074}-
1075bool QTextDocument::isModified() const-
1076{-
1077 return
never executed: return docHandle()->isModified();
docHandle()->isModified();
never executed: return docHandle()->isModified();
0
1078}-
1079-
1080void QTextDocument::setModified(bool m)-
1081{-
1082 docHandle()->setModified(m);-
1083}
never executed: end of block
0
1084-
1085-
1086static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos)-
1087{-
1088 painter->save();-
1089 painter->translate(body.left(), body.top() - (index - 1) * body.height());-
1090 QRectF view(0, (index - 1) * body.height(), body.width(), body.height());-
1091-
1092 QAbstractTextDocumentLayout *layout = doc->documentLayout();-
1093 QAbstractTextDocumentLayout::PaintContext ctx;-
1094-
1095 painter->setClipRect(view);-
1096 ctx.clip = view;-
1097-
1098-
1099-
1100-
1101 ctx.palette.setColor(QPalette::Text, Qt::black);-
1102-
1103 layout->draw(painter, ctx);-
1104-
1105 if (!pageNumberPos.isNull()
!pageNumberPos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1106 painter->setClipping(false);-
1107 painter->setFont(QFont(doc->defaultFont()));-
1108 const QString pageString = QString::number(index);-
1109-
1110 painter->drawText(qRound(pageNumberPos.x() - painter->fontMetrics().width(pageString)),-
1111 qRound(pageNumberPos.y() + view.top()),-
1112 pageString);-
1113 }
never executed: end of block
0
1114-
1115 painter->restore();-
1116}
never executed: end of block
0
1117void QTextDocument::print(QPagedPaintDevice *printer) const-
1118{-
1119 const QTextDocumentPrivate * const d = d_func();-
1120-
1121 if (!printer
!printerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1122 return;
never executed: return;
0
1123-
1124 bool documentPaginated = d->pageSize.isValid()
d->pageSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->pageSize.isNull()
!d->pageSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1125 && d->pageSize.height() != 2147483647
d->pageSize.he... != 2147483647Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1126-
1127 QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer);-
1128-
1129-
1130 QPagedPaintDevice::Margins m = printer->margins();-
1131 if (!documentPaginated
!documentPaginatedDescription
TRUEnever evaluated
FALSEnever evaluated
&& m.left == 0.
m.left == 0.Description
TRUEnever evaluated
FALSEnever evaluated
&& m.right == 0.
m.right == 0.Description
TRUEnever evaluated
FALSEnever evaluated
&& m.top == 0.
m.top == 0.Description
TRUEnever evaluated
FALSEnever evaluated
&& m.bottom == 0.
m.bottom == 0.Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1132 m.left = m.right = m.top = m.bottom = 2.;-
1133 printer->setMargins(m);-
1134 }
never executed: end of block
0
1135-
1136-
1137 QPainter p(printer);-
1138-
1139-
1140 if (!p.isActive()
!p.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1141 return;
never executed: return;
0
1142-
1143 const QTextDocument *doc = this;-
1144 QScopedPointer<QTextDocument> clonedDoc;-
1145 (void)doc->documentLayout();-
1146-
1147 QRectF body = QRectF(QPointF(0, 0), d->pageSize);-
1148 QPointF pageNumberPos;-
1149-
1150 if (documentPaginated
documentPaginatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1151 qreal sourceDpiX = qt_defaultDpi();-
1152 qreal sourceDpiY = sourceDpiX;-
1153-
1154 QPaintDevice *dev = doc->documentLayout()->paintDevice();-
1155 if (dev
devDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1156 sourceDpiX = dev->logicalDpiX();-
1157 sourceDpiY = dev->logicalDpiY();-
1158 }
never executed: end of block
0
1159-
1160 const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;-
1161 const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;-
1162-
1163-
1164 p.scale(dpiScaleX, dpiScaleY);-
1165-
1166 QSizeF scaledPageSize = d->pageSize;-
1167 scaledPageSize.rwidth() *= dpiScaleX;-
1168 scaledPageSize.rheight() *= dpiScaleY;-
1169-
1170 const QSizeF printerPageSize(printer->width(), printer->height());-
1171-
1172-
1173 p.scale(printerPageSize.width() / scaledPageSize.width(),-
1174 printerPageSize.height() / scaledPageSize.height());-
1175 }
never executed: end of block
else {
0
1176 doc = clone(const_cast<QTextDocument *>(this));-
1177 clonedDoc.reset(const_cast<QTextDocument *>(doc));-
1178-
1179 for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock();-
1180 srcBlock.isValid()
srcBlock.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& dstBlock.isValid()
dstBlock.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1181 srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {-
1182 dstBlock.layout()->setFormats(srcBlock.layout()->formats());-
1183 }
never executed: end of block
0
1184-
1185 QAbstractTextDocumentLayout *layout = doc->documentLayout();-
1186 layout->setPaintDevice(p.device());-
1187-
1188-
1189 layout->d_func()->handlers = documentLayout()->d_func()->handlers;-
1190-
1191 int dpiy = p.device()->logicalDpiY();-
1192 int margin = (int) ((2/2.54)*dpiy);-
1193 QTextFrameFormat fmt = doc->rootFrame()->frameFormat();-
1194 fmt.setMargin(margin);-
1195 doc->rootFrame()->setFrameFormat(fmt);-
1196-
1197 body = QRectF(0, 0, printer->width(), printer->height());-
1198 pageNumberPos = QPointF(body.width() - margin,-
1199 body.height() - margin-
1200 + QFontMetrics(doc->defaultFont(), p.device()).ascent()-
1201 + 5 * dpiy / 72.0);-
1202 clonedDoc->setPageSize(body.size());-
1203 }
never executed: end of block
0
1204-
1205 int fromPage = pd->fromPage;-
1206 int toPage = pd->toPage;-
1207 bool ascending = true;-
1208-
1209 if (fromPage == 0
fromPage == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& toPage == 0
toPage == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1210 fromPage = 1;-
1211 toPage = doc->pageCount();-
1212 }
never executed: end of block
0
1213-
1214 fromPage = qMax(1, fromPage);-
1215 toPage = qMin(doc->pageCount(), toPage);-
1216-
1217 if (toPage < fromPage
toPage < fromPageDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1218-
1219-
1220 return;
never executed: return;
0
1221 }-
1222 int page = fromPage;-
1223 while (true) {-
1224 printPage(page, &p, doc, body, pageNumberPos);-
1225-
1226 if (page == toPage
page == toPageDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1227 break;
never executed: break;
0
1228-
1229 if (ascending
ascendingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1230 ++
never executed: ++page;
page;
never executed: ++page;
0
1231 else-
1232 --
never executed: --page;
page;
never executed: --page;
0
1233-
1234 if (!printer->newPage()
!printer->newPage()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1235 return;
never executed: return;
0
1236 }
never executed: end of block
0
1237}
never executed: end of block
0
1238QVariant QTextDocument::resource(int type, const QUrl &name) const-
1239{-
1240 const QTextDocumentPrivate * const d = d_func();-
1241 const QUrl url = d->baseUrl.resolved(name);-
1242 QVariant r = d->resources.value(url);-
1243 if (!r.isValid()
!r.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1244 r = d->cachedResources.value(url);-
1245 if (!r.isValid()
!r.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1246 r = const_cast<QTextDocument *>(this)->loadResource(type, url);
never executed: r = const_cast<QTextDocument *>(this)->loadResource(type, url);
0
1247 }
never executed: end of block
0
1248 return
never executed: return r;
r;
never executed: return r;
0
1249}-
1250void QTextDocument::addResource(int type, const QUrl &name, const QVariant &resource)-
1251{-
1252 (void)type;;-
1253 QTextDocumentPrivate * const d = d_func();-
1254 d->resources.insert(name, resource);-
1255}
never executed: end of block
0
1256QVariant QTextDocument::loadResource(int type, const QUrl &name)-
1257{-
1258 QTextDocumentPrivate * const d = d_func();-
1259 QVariant r;-
1260-
1261 QObject *p = parent();-
1262 if (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1263 const QMetaObject *me = p->metaObject();-
1264 int index = me->indexOfMethod("loadResource(int,QUrl)");-
1265 if (index >= 0
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1266 QMetaMethod loader = me->method(index);-
1267 loader.invoke(p, QReturnArgument<QVariant >("QVariant", r), QArgument<int >("int", type), QArgument<QUrl >("QUrl", name));-
1268 }
never executed: end of block
0
1269 }
never executed: end of block
0
1270-
1271-
1272 if (r.isNull()
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0
name.scheme()....ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1273 QString mimetype;-
1274 QByteArray payload;-
1275 if (qDecodeDataUrl(name, mimetype, payload)
qDecodeDataUrl...type, payload)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1276 r = payload;
never executed: r = payload;
0
1277 }
never executed: end of block
0
1278-
1279-
1280 if (!qobject_cast<QTextDocument *>(p)
!qobject_cast<...Document *>(p)Description
TRUEnever evaluated
FALSEnever evaluated
&& r.isNull()
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1281 QUrl resourceUrl = name;-
1282-
1283 if (name.isRelative()
name.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1284 QUrl currentURL = d->url;-
1285-
1286-
1287 if (!(currentURL.isRelative()
currentURL.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
0
1288 || (currentURL.scheme() == QLatin1String("file")
currentURL.sch...String("file")Description
TRUEnever evaluated
FALSEnever evaluated
0
1289 && !QFileInfo(currentURL.toLocalFile()).isAbsolute()
!QFileInfo(cur...).isAbsolute()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
1290 || (name.hasFragment()
name.hasFragment()Description
TRUEnever evaluated
FALSEnever evaluated
&& name.path().isEmpty()
name.path().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1291 resourceUrl = currentURL.resolved(name);-
1292 }
never executed: end of block
else {
0
1293-
1294-
1295-
1296 QFileInfo fi(currentURL.toLocalFile());-
1297 if (fi.exists()
fi.exists()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1298 resourceUrl =-
1299 QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name);-
1300 }
never executed: end of block
else if (currentURL.isEmpty()
currentURL.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1301 resourceUrl.setScheme(QLatin1String("file"));-
1302 }
never executed: end of block
0
1303 }
never executed: end of block
0
1304 }-
1305-
1306 QString s = resourceUrl.toLocalFile();-
1307 QFile f(s);-
1308 if (!s.isEmpty()
!s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& f.open(QFile::ReadOnly)
f.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1309 r = f.readAll();-
1310 f.close();-
1311 }
never executed: end of block
0
1312 }
never executed: end of block
0
1313-
1314 if (!r.isNull()
!r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1315 if (type == ImageResource
type == ImageResourceDescription
TRUEnever evaluated
FALSEnever evaluated
&& r.type() == QVariant::ByteArray
r.type() == QV...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1316 if (QCoreApplication::instance()->thread() != QThread::currentThread()
QCoreApplicati...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1317-
1318 QImage image;-
1319 image.loadFromData(r.toByteArray());-
1320 if (!image.isNull()
!image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1321 r = image;
never executed: r = image;
0
1322 }
never executed: end of block
else {
0
1323 QPixmap pm;-
1324 pm.loadFromData(r.toByteArray());-
1325 if (!pm.isNull()
!pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1326 r = pm;
never executed: r = pm;
0
1327 }
never executed: end of block
0
1328 }-
1329 d->cachedResources.insert(name, r);-
1330 }
never executed: end of block
0
1331 return
never executed: return r;
r;
never executed: return r;
0
1332}-
1333-
1334static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to)-
1335{-
1336 QTextFormat diff = to;-
1337-
1338 const QMap<int, QVariant> props = to.properties();-
1339 for (QMap<int, QVariant>::ConstIterator it = props.begin(), end = props.end();-
1340 it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
1341 if (it.value() == from.property(it.key())
it.value() == ...erty(it.key())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1342 diff.clearProperty(it.key());
never executed: diff.clearProperty(it.key());
0
1343-
1344 return
never executed: return diff;
diff;
never executed: return diff;
0
1345}-
1346-
1347static QString colorValue(QColor color)-
1348{-
1349 QString result;-
1350-
1351 if (color.alpha() == 255
color.alpha() == 255Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1352 result = color.name();-
1353 }
never executed: end of block
else if (color.alpha()
color.alpha()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1354 QString alphaValue = QString::number(color.alphaF(), 'f', 6).remove(QRegExp(QLatin1String("\\.?0*$")));-
1355 result = QString::fromLatin1("rgba(%1,%2,%3,%4)").arg(color.red())-
1356 .arg(color.green())-
1357 .arg(color.blue())-
1358 .arg(alphaValue);-
1359 }
never executed: end of block
else {
0
1360 result = QLatin1String("transparent");-
1361 }
never executed: end of block
0
1362-
1363 return
never executed: return result;
result;
never executed: return result;
0
1364}-
1365-
1366QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc)-
1367 : doc(_doc), fragmentMarkers(false)-
1368{-
1369 const QFont defaultFont = doc->defaultFont();-
1370 defaultCharFormat.setFont(defaultFont);-
1371-
1372 defaultCharFormat.clearProperty(QTextFormat::FontUnderline);-
1373 defaultCharFormat.clearProperty(QTextFormat::FontOverline);-
1374 defaultCharFormat.clearProperty(QTextFormat::FontStrikeOut);-
1375 defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle);-
1376}
never executed: end of block
0
1377-
1378-
1379-
1380-
1381-
1382-
1383QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode)-
1384{-
1385 html = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "-
1386 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"-
1387 "<html><head><meta name=\"qrichtext\" content=\"1\" />");-
1388 html.reserve(doc->docHandle()->length());-
1389-
1390 fragmentMarkers = (mode == ExportFragment);-
1391-
1392 if (!encoding.isEmpty()
!encoding.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1393 html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding));
never executed: html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding));
0
1394-
1395 QString title = doc->metaInformation(QTextDocument::DocumentTitle);-
1396 if (!title.isEmpty()
!title.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1397 html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>");
never executed: html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>");
0
1398 html += QLatin1String("<style type=\"text/css\">\n");-
1399 html += QLatin1String("p, li { white-space: pre-wrap; }\n");-
1400 html += QLatin1String("</style>");-
1401 html += QLatin1String("</head><body");-
1402-
1403 if (mode == ExportEntireDocument
mode == ExportEntireDocumentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1404 html += QLatin1String(" style=\"");-
1405-
1406 emitFontFamily(defaultCharFormat.fontFamily());-
1407-
1408 if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)
defaultCharFor...FontPointSize)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1409 html += QLatin1String(" font-size:");-
1410 html += QString::number(defaultCharFormat.fontPointSize());-
1411 html += QLatin1String("pt;");-
1412 }
never executed: end of block
else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)
defaultCharFor...FontPixelSize)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1413 html += QLatin1String(" font-size:");-
1414 html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize));-
1415 html += QLatin1String("px;");-
1416 }
never executed: end of block
0
1417-
1418 html += QLatin1String(" font-weight:");-
1419 html += QString::number(defaultCharFormat.fontWeight() * 8);-
1420 html += QLatin1Char(';');-
1421-
1422 html += QLatin1String(" font-style:");-
1423 html += (defaultCharFormat.fontItalic()
defaultCharFormat.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String("italic") : QLatin1String("normal"));
0
1424 html += QLatin1Char(';');-
1425-
1426-
1427-
1428-
1429 html += QLatin1Char('\"');-
1430-
1431 const QTextFrameFormat fmt = doc->rootFrame()->frameFormat();-
1432 emitBackgroundAttribute(fmt);-
1433-
1434 }
never executed: end of block
else {
0
1435 defaultCharFormat = QTextCharFormat();-
1436 }
never executed: end of block
0
1437 html += QLatin1Char('>');-
1438-
1439 QTextFrameFormat rootFmt = doc->rootFrame()->frameFormat();-
1440 rootFmt.clearProperty(QTextFormat::BackgroundBrush);-
1441-
1442 QTextFrameFormat defaultFmt;-
1443 defaultFmt.setMargin(doc->documentMargin());-
1444-
1445 if (rootFmt == defaultFmt
rootFmt == defaultFmtDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1446 emitFrame(doc->rootFrame()->begin());
never executed: emitFrame(doc->rootFrame()->begin());
0
1447 else-
1448 emitTextFrame(doc->rootFrame());
never executed: emitTextFrame(doc->rootFrame());
0
1449-
1450 html += QLatin1String("</body></html>");-
1451 return
never executed: return html;
html;
never executed: return html;
0
1452}-
1453-
1454void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value)-
1455{-
1456 html += QLatin1Char(' ');-
1457 html += QLatin1String(attribute);-
1458 html += QLatin1String("=\"");-
1459 html += value.toHtmlEscaped();-
1460 html += QLatin1Char('"');-
1461}
never executed: end of block
0
1462-
1463bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)-
1464{-
1465 bool attributesEmitted = false;-
1466-
1467 {-
1468 const QString family = format.fontFamily();-
1469 if (!family.isEmpty()
!family.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& family != defaultCharFormat.fontFamily()
family != defa...t.fontFamily()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1470 emitFontFamily(family);-
1471 attributesEmitted = true;-
1472 }
never executed: end of block
0
1473 }-
1474-
1475 if (format.hasProperty(QTextFormat::FontPointSize)
format.hasProp...FontPointSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
1476 && format.fontPointSize() != defaultCharFormat.fontPointSize()
format.fontPoi...ontPointSize()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1477 html += QLatin1String(" font-size:");-
1478 html += QString::number(format.fontPointSize());-
1479 html += QLatin1String("pt;");-
1480 attributesEmitted = true;-
1481 }
never executed: end of block
else if (format.hasProperty(QTextFormat::FontSizeAdjustment)
format.hasProp...izeAdjustment)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1482 static const char sizeNameData[] =-
1483 "small" "\0"-
1484 "medium" "\0"-
1485 "xx-large" ;-
1486 static const quint8 sizeNameOffsets[] = {-
1487 0,-
1488 sizeof("small"),-
1489 sizeof("small") + sizeof("medium") + 3,-
1490 sizeof("small") + sizeof("medium") + 1,-
1491 sizeof("small") + sizeof("medium"),-
1492 };-
1493 const char *name = 0;-
1494 const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1;-
1495 if (idx >= 0
idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& idx <= 4
idx <= 4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1496 name = sizeNameData + sizeNameOffsets[idx];-
1497 }
never executed: end of block
0
1498 if (name
nameDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1499 html += QLatin1String(" font-size:");-
1500 html += QLatin1String(name);-
1501 html += QLatin1Char(';');-
1502 attributesEmitted = true;-
1503 }
never executed: end of block
0
1504 }
never executed: end of block
else if (format.hasProperty(QTextFormat::FontPixelSize)
format.hasProp...FontPixelSize)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1505 html += QLatin1String(" font-size:");-
1506 html += QString::number(format.intProperty(QTextFormat::FontPixelSize));-
1507 html += QLatin1String("px;");-
1508 attributesEmitted = true;-
1509 }
never executed: end of block
0
1510-
1511 if (format.hasProperty(QTextFormat::FontWeight)
format.hasProp...t::FontWeight)Description
TRUEnever evaluated
FALSEnever evaluated
0
1512 && format.fontWeight() != defaultCharFormat.fontWeight()
format.fontWei...t.fontWeight()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1513 html += QLatin1String(" font-weight:");-
1514 html += QString::number(format.fontWeight() * 8);-
1515 html += QLatin1Char(';');-
1516 attributesEmitted = true;-
1517 }
never executed: end of block
0
1518-
1519 if (format.hasProperty(QTextFormat::FontItalic)
format.hasProp...t::FontItalic)Description
TRUEnever evaluated
FALSEnever evaluated
0
1520 && format.fontItalic() != defaultCharFormat.fontItalic()
format.fontIta...t.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1521 html += QLatin1String(" font-style:");-
1522 html += (format.fontItalic()
format.fontItalic()Description
TRUEnever evaluated
FALSEnever evaluated
? QLatin1String("italic") : QLatin1String("normal"));
0
1523 html += QLatin1Char(';');-
1524 attributesEmitted = true;-
1525 }
never executed: end of block
0
1526-
1527 QLatin1String decorationTag(" text-decoration:");-
1528 html += decorationTag;-
1529 bool hasDecoration = false;-
1530 bool atLeastOneDecorationSet = false;-
1531-
1532 if ((format.hasProperty(QTextFormat::FontUnderline)
format.hasProp...FontUnderline)Description
TRUEnever evaluated
FALSEnever evaluated
|| format.hasProperty(QTextFormat::TextUnderlineStyle)
format.hasProp...nderlineStyle)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1533 && format.fontUnderline() != defaultCharFormat.fontUnderline()
format.fontUnd...ontUnderline()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1534 hasDecoration = true;-
1535 if (format.fontUnderline()
format.fontUnderline()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1536 html += QLatin1String(" underline");-
1537 atLeastOneDecorationSet = true;-
1538 }
never executed: end of block
0
1539 }
never executed: end of block
0
1540-
1541 if (format.hasProperty(QTextFormat::FontOverline)
format.hasProp...:FontOverline)Description
TRUEnever evaluated
FALSEnever evaluated
0
1542 && format.fontOverline() != defaultCharFormat.fontOverline()
format.fontOve...fontOverline()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1543 hasDecoration = true;-
1544 if (format.fontOverline()
format.fontOverline()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1545 html += QLatin1String(" overline");-
1546 atLeastOneDecorationSet = true;-
1547 }
never executed: end of block
0
1548 }
never executed: end of block
0
1549-
1550 if (format.hasProperty(QTextFormat::FontStrikeOut)
format.hasProp...FontStrikeOut)Description
TRUEnever evaluated
FALSEnever evaluated
0
1551 && format.fontStrikeOut() != defaultCharFormat.fontStrikeOut()
format.fontStr...ontStrikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1552 hasDecoration = true;-
1553 if (format.fontStrikeOut()
format.fontStrikeOut()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1554 html += QLatin1String(" line-through");-
1555 atLeastOneDecorationSet = true;-
1556 }
never executed: end of block
0
1557 }
never executed: end of block
0
1558-
1559 if (hasDecoration
hasDecorationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1560 if (!atLeastOneDecorationSet
!atLeastOneDecorationSetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1561 html += QLatin1String("none");
never executed: html += QLatin1String("none");
0
1562 html += QLatin1Char(';');-
1563 attributesEmitted = true;-
1564 }
never executed: end of block
else {
0
1565 html.chop(decorationTag.size());-
1566 }
never executed: end of block
0
1567-
1568 if (format.foreground() != defaultCharFormat.foreground()
format.foregro...t.foreground()Description
TRUEnever evaluated
FALSEnever evaluated
0
1569 && format.foreground().style() != Qt::NoBrush
format.foregro...!= Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1570 html += QLatin1String(" color:");-
1571 html += colorValue(format.foreground().color());-
1572 html += QLatin1Char(';');-
1573 attributesEmitted = true;-
1574 }
never executed: end of block
0
1575-
1576 if (format.background() != defaultCharFormat.background()
format.backgro...t.background()Description
TRUEnever evaluated
FALSEnever evaluated
0
1577 && format.background().style() == Qt::SolidPattern
format.backgro...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1578 html += QLatin1String(" background-color:");-
1579 html += colorValue(format.background().color());-
1580 html += QLatin1Char(';');-
1581 attributesEmitted = true;-
1582 }
never executed: end of block
0
1583-
1584 if (format.verticalAlignment() != defaultCharFormat.verticalAlignment()
format.vertica...calAlignment()Description
TRUEnever evaluated
FALSEnever evaluated
0
1585 && format.verticalAlignment() != QTextCharFormat::AlignNormal
format.vertica...t::AlignNormalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1586 {-
1587 html += QLatin1String(" vertical-align:");-
1588-
1589 QTextCharFormat::VerticalAlignment valign = format.verticalAlignment();-
1590 if (valign == QTextCharFormat::AlignSubScript
valign == QTex...AlignSubScriptDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1591 html += QLatin1String("sub");
never executed: html += QLatin1String("sub");
0
1592 else if (valign == QTextCharFormat::AlignSuperScript
valign == QTex...ignSuperScriptDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1593 html += QLatin1String("super");
never executed: html += QLatin1String("super");
0
1594 else if (valign == QTextCharFormat::AlignMiddle
valign == QTex...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1595 html += QLatin1String("middle");
never executed: html += QLatin1String("middle");
0
1596 else if (valign == QTextCharFormat::AlignTop
valign == QTex...rmat::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1597 html += QLatin1String("top");
never executed: html += QLatin1String("top");
0
1598 else if (valign == QTextCharFormat::AlignBottom
valign == QTex...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1599 html += QLatin1String("bottom");
never executed: html += QLatin1String("bottom");
0
1600-
1601 html += QLatin1Char(';');-
1602 attributesEmitted = true;-
1603 }
never executed: end of block
0
1604-
1605 if (format.fontCapitalization() != QFont::MixedCase
format.fontCap...ont::MixedCaseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1606 const QFont::Capitalization caps = format.fontCapitalization();-
1607 if (caps == QFont::AllUppercase
caps == QFont::AllUppercaseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1608 html += QLatin1String(" text-transform:uppercase;");
never executed: html += QLatin1String(" text-transform:uppercase;");
0
1609 else if (caps == QFont::AllLowercase
caps == QFont::AllLowercaseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1610 html += QLatin1String(" text-transform:lowercase;");
never executed: html += QLatin1String(" text-transform:lowercase;");
0
1611 else if (caps == QFont::SmallCaps
caps == QFont::SmallCapsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1612 html += QLatin1String(" font-variant:small-caps;");
never executed: html += QLatin1String(" font-variant:small-caps;");
0
1613 attributesEmitted = true;-
1614 }
never executed: end of block
0
1615-
1616 if (format.fontWordSpacing() != 0.0
format.fontWor...acing() != 0.0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1617 html += QLatin1String(" word-spacing:");-
1618 html += QString::number(format.fontWordSpacing());-
1619 html += QLatin1String("px;");-
1620 attributesEmitted = true;-
1621 }
never executed: end of block
0
1622-
1623 return
never executed: return attributesEmitted;
attributesEmitted;
never executed: return attributesEmitted;
0
1624}-
1625-
1626void QTextHtmlExporter::emitTextLength(const char *attribute, const QTextLength &length)-
1627{-
1628 if (length.type() == QTextLength::VariableLength
length.type() ...VariableLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1629 return;
never executed: return;
0
1630-
1631 html += QLatin1Char(' ');-
1632 html += QLatin1String(attribute);-
1633 html += QLatin1String("=\"");-
1634 html += QString::number(length.rawValue());-
1635-
1636 if (length.type() == QTextLength::PercentageLength
length.type() ...rcentageLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1637 html += QLatin1String("%\"");
never executed: html += QLatin1String("%\"");
0
1638 else-
1639 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
1640}-
1641-
1642void QTextHtmlExporter::emitAlignment(Qt::Alignment align)-
1643{-
1644 if (align & Qt::AlignLeft
align & Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1645 return;
never executed: return;
0
1646 else if (align & Qt::AlignRight
align & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1647 html += QLatin1String(" align=\"right\"");
never executed: html += QLatin1String(" align=\"right\"");
0
1648 else if (align & Qt::AlignHCenter
align & Qt::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1649 html += QLatin1String(" align=\"center\"");
never executed: html += QLatin1String(" align=\"center\"");
0
1650 else if (align & Qt::AlignJustify
align & Qt::AlignJustifyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1651 html += QLatin1String(" align=\"justify\"");
never executed: html += QLatin1String(" align=\"justify\"");
0
1652}
never executed: end of block
0
1653-
1654void QTextHtmlExporter::emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode)-
1655{-
1656 if (pos == QTextFrameFormat::InFlow
pos == QTextFr...Format::InFlowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1657 return;
never executed: return;
0
1658-
1659 if (mode == EmitStyleTag
mode == EmitStyleTagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1660 html += QLatin1String(" style=\"float:");
never executed: html += QLatin1String(" style=\"float:");
0
1661 else-
1662 html += QLatin1String(" float:");
never executed: html += QLatin1String(" float:");
0
1663-
1664 if (pos == QTextFrameFormat::FloatLeft
pos == QTextFr...mat::FloatLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1665 html += QLatin1String(" left;");
never executed: html += QLatin1String(" left;");
0
1666 else if (pos == QTextFrameFormat::FloatRight
pos == QTextFr...at::FloatRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1667 html += QLatin1String(" right;");
never executed: html += QLatin1String(" right;");
0
1668 else-
1669 ((
never executed: ((!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2541) : qt_noop());
!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2541) : qt_noop());
never executed: ((!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2541) : qt_noop());
0
1670-
1671 if (mode == EmitStyleTag
mode == EmitStyleTagDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1672 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
1673}
never executed: end of block
0
1674-
1675void QTextHtmlExporter::emitBorderStyle(QTextFrameFormat::BorderStyle style)-
1676{-
1677 ((!(style <= QTextFrameFormat::BorderStyle_Outset)) ? qt_assert("style <= QTextFrameFormat::BorderStyle_Outset",__FILE__,2549) : qt_noop());-
1678-
1679 html += QLatin1String(" border-style:");-
1680-
1681 switch (style) {-
1682 case
never executed: case QTextFrameFormat::BorderStyle_None:
QTextFrameFormat::BorderStyle_None:
never executed: case QTextFrameFormat::BorderStyle_None:
0
1683 html += QLatin1String("none");-
1684 break;
never executed: break;
0
1685 case
never executed: case QTextFrameFormat::BorderStyle_Dotted:
QTextFrameFormat::BorderStyle_Dotted:
never executed: case QTextFrameFormat::BorderStyle_Dotted:
0
1686 html += QLatin1String("dotted");-
1687 break;
never executed: break;
0
1688 case
never executed: case QTextFrameFormat::BorderStyle_Dashed:
QTextFrameFormat::BorderStyle_Dashed:
never executed: case QTextFrameFormat::BorderStyle_Dashed:
0
1689 html += QLatin1String("dashed");-
1690 break;
never executed: break;
0
1691 case
never executed: case QTextFrameFormat::BorderStyle_Solid:
QTextFrameFormat::BorderStyle_Solid:
never executed: case QTextFrameFormat::BorderStyle_Solid:
0
1692 html += QLatin1String("solid");-
1693 break;
never executed: break;
0
1694 case
never executed: case QTextFrameFormat::BorderStyle_Double:
QTextFrameFormat::BorderStyle_Double:
never executed: case QTextFrameFormat::BorderStyle_Double:
0
1695 html += QLatin1String("double");-
1696 break;
never executed: break;
0
1697 case
never executed: case QTextFrameFormat::BorderStyle_DotDash:
QTextFrameFormat::BorderStyle_DotDash:
never executed: case QTextFrameFormat::BorderStyle_DotDash:
0
1698 html += QLatin1String("dot-dash");-
1699 break;
never executed: break;
0
1700 case
never executed: case QTextFrameFormat::BorderStyle_DotDotDash:
QTextFrameFormat::BorderStyle_DotDotDash:
never executed: case QTextFrameFormat::BorderStyle_DotDotDash:
0
1701 html += QLatin1String("dot-dot-dash");-
1702 break;
never executed: break;
0
1703 case
never executed: case QTextFrameFormat::BorderStyle_Groove:
QTextFrameFormat::BorderStyle_Groove:
never executed: case QTextFrameFormat::BorderStyle_Groove:
0
1704 html += QLatin1String("groove");-
1705 break;
never executed: break;
0
1706 case
never executed: case QTextFrameFormat::BorderStyle_Ridge:
QTextFrameFormat::BorderStyle_Ridge:
never executed: case QTextFrameFormat::BorderStyle_Ridge:
0
1707 html += QLatin1String("ridge");-
1708 break;
never executed: break;
0
1709 case
never executed: case QTextFrameFormat::BorderStyle_Inset:
QTextFrameFormat::BorderStyle_Inset:
never executed: case QTextFrameFormat::BorderStyle_Inset:
0
1710 html += QLatin1String("inset");-
1711 break;
never executed: break;
0
1712 case
never executed: case QTextFrameFormat::BorderStyle_Outset:
QTextFrameFormat::BorderStyle_Outset:
never executed: case QTextFrameFormat::BorderStyle_Outset:
0
1713 html += QLatin1String("outset");-
1714 break;
never executed: break;
0
1715 default
never executed: default:
:
never executed: default:
0
1716 ((!(false)) ? qt_assert("false",__FILE__,2588) : qt_noop());-
1717 break;
never executed: break;
0
1718 };-
1719-
1720 html += QLatin1Char(';');-
1721}
never executed: end of block
0
1722-
1723void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy)-
1724{-
1725 if (policy & QTextFormat::PageBreak_AlwaysBefore
policy & QText...k_AlwaysBeforeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1726 html += QLatin1String(" page-break-before:always;");
never executed: html += QLatin1String(" page-break-before:always;");
0
1727-
1728 if (policy & QTextFormat::PageBreak_AlwaysAfter
policy & QText...ak_AlwaysAfterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1729 html += QLatin1String(" page-break-after:always;");
never executed: html += QLatin1String(" page-break-after:always;");
0
1730}
never executed: end of block
0
1731-
1732void QTextHtmlExporter::emitFontFamily(const QString &family)-
1733{-
1734 html += QLatin1String(" font-family:");-
1735-
1736 QLatin1String quote("\'");-
1737 if (family.contains(QLatin1Char('\''))
family.contain...in1Char('\''))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1738 quote = QLatin1String("&quot;");
never executed: quote = QLatin1String("&quot;");
0
1739-
1740 html += quote;-
1741 html += family.toHtmlEscaped();-
1742 html += quote;-
1743 html += QLatin1Char(';');-
1744}
never executed: end of block
0
1745-
1746void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right)-
1747{-
1748 html += QLatin1String(" margin-top:");-
1749 html += top;-
1750 html += QLatin1String("px;");-
1751-
1752 html += QLatin1String(" margin-bottom:");-
1753 html += bottom;-
1754 html += QLatin1String("px;");-
1755-
1756 html += QLatin1String(" margin-left:");-
1757 html += left;-
1758 html += QLatin1String("px;");-
1759-
1760 html += QLatin1String(" margin-right:");-
1761 html += right;-
1762 html += QLatin1String("px;");-
1763}
never executed: end of block
0
1764-
1765void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)-
1766{-
1767 const QTextCharFormat format = fragment.charFormat();-
1768-
1769 bool closeAnchor = false;-
1770-
1771 if (format.isAnchor()
format.isAnchor()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1772 const QString name = format.anchorName();-
1773 if (!name.isEmpty()
!name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1774 html += QLatin1String("<a name=\"");-
1775 html += name.toHtmlEscaped();-
1776 html += QLatin1String("\"></a>");-
1777 }
never executed: end of block
0
1778 const QString href = format.anchorHref();-
1779 if (!href.isEmpty()
!href.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1780 html += QLatin1String("<a href=\"");-
1781 html += href.toHtmlEscaped();-
1782 html += QLatin1String("\">");-
1783 closeAnchor = true;-
1784 }
never executed: end of block
0
1785 }
never executed: end of block
0
1786-
1787 QString txt = fragment.text();-
1788 const bool isObject = txt.contains(QChar::ObjectReplacementCharacter);-
1789 const bool isImage = isObject
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
&& format.isImageFormat()
format.isImageFormat()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
1790-
1791 QLatin1String styleTag("<span style=\"");-
1792 html += styleTag;-
1793-
1794 bool attributesEmitted = false;-
1795 if (!isImage
!isImageDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1796 attributesEmitted = emitCharFormatStyle(format);
never executed: attributesEmitted = emitCharFormatStyle(format);
0
1797 if (attributesEmitted
attributesEmittedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1798 html += QLatin1String("\">");
never executed: html += QLatin1String("\">");
0
1799 else-
1800 html.chop(styleTag.size());
never executed: html.chop(styleTag.size());
0
1801-
1802 if (isObject
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1803 for (int i = 0; isImage
isImageDescription
TRUEnever evaluated
FALSEnever evaluated
&& i < txt.length()
i < txt.length()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1804 QTextImageFormat imgFmt = format.toImageFormat();-
1805-
1806 html += QLatin1String("<img");-
1807-
1808 if (imgFmt.hasProperty(QTextFormat::ImageName)
imgFmt.hasProp...at::ImageName)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1809 emitAttribute("src", imgFmt.name());
never executed: emitAttribute("src", imgFmt.name());
0
1810-
1811 if (imgFmt.hasProperty(QTextFormat::ImageWidth)
imgFmt.hasProp...t::ImageWidth)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1812 emitAttribute("width", QString::number(imgFmt.width()));
never executed: emitAttribute("width", QString::number(imgFmt.width()));
0
1813-
1814 if (imgFmt.hasProperty(QTextFormat::ImageHeight)
imgFmt.hasProp...::ImageHeight)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1815 emitAttribute("height", QString::number(imgFmt.height()));
never executed: emitAttribute("height", QString::number(imgFmt.height()));
0
1816-
1817 if (imgFmt.verticalAlignment() == QTextCharFormat::AlignMiddle
imgFmt.vertica...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1818 html += QLatin1String(" style=\"vertical-align: middle;\"");
never executed: html += QLatin1String(" style=\"vertical-align: middle;\"");
0
1819 else if (imgFmt.verticalAlignment() == QTextCharFormat::AlignTop
imgFmt.vertica...rmat::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1820 html += QLatin1String(" style=\"vertical-align: top;\"");
never executed: html += QLatin1String(" style=\"vertical-align: top;\"");
0
1821-
1822 if (QTextFrame *imageFrame = qobject_cast<QTextFrame *>(doc->objectForFormat(imgFmt))
QTextFrame *im...ormat(imgFmt))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1823 emitFloatStyle(imageFrame->frameFormat().position());
never executed: emitFloatStyle(imageFrame->frameFormat().position());
0
1824-
1825 html += QLatin1String(" />");-
1826 }
never executed: end of block
0
1827 }
never executed: end of block
else {
0
1828 ((!(!txt.contains(QChar::ObjectReplacementCharacter))) ? qt_assert("!txt.contains(QChar::ObjectReplacementCharacter)",__FILE__,2700) : qt_noop());-
1829-
1830 txt = txt.toHtmlEscaped();-
1831-
1832-
1833 QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]");-
1834 forcedLineBreakRegExp[3] = QChar::LineSeparator;-
1835-
1836 html += txt.replace(QRegExp(forcedLineBreakRegExp), QLatin1String("<br />"));-
1837 }
never executed: end of block
0
1838-
1839 if (attributesEmitted
attributesEmittedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1840 html += QLatin1String("</span>");
never executed: html += QLatin1String("</span>");
0
1841-
1842 if (closeAnchor
closeAnchorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1843 html += QLatin1String("</a>");
never executed: html += QLatin1String("</a>");
0
1844}
never executed: end of block
0
1845-
1846static bool isOrderedList(int style)-
1847{-
1848 return
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
1849 || style == QTextListFormat::ListUpperAlpha
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
1850 || style == QTextListFormat::ListUpperRoman
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
1851 || style == QTextListFormat::ListLowerRoman
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
1852 ;
never executed: return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
0
1853}-
1854-
1855void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block)-
1856{-
1857 QTextBlockFormat format = block.blockFormat();-
1858 emitAlignment(format.alignment());-
1859-
1860-
1861-
1862 if (block.textDirection() == Qt::RightToLeft
block.textDire...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1863 html += QLatin1String(" dir='rtl'");
never executed: html += QLatin1String(" dir='rtl'");
0
1864-
1865 QLatin1String style(" style=\"");-
1866 html += style;-
1867-
1868 const bool emptyBlock = block.begin().atEnd();-
1869 if (emptyBlock
emptyBlockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1870 html += QLatin1String("-qt-paragraph-type:empty;");-
1871 }
never executed: end of block
0
1872-
1873 emitMargins(QString::number(format.topMargin()),-
1874 QString::number(format.bottomMargin()),-
1875 QString::number(format.leftMargin()),-
1876 QString::number(format.rightMargin()));-
1877-
1878 html += QLatin1String(" -qt-block-indent:");-
1879 html += QString::number(format.indent());-
1880 html += QLatin1Char(';');-
1881-
1882 html += QLatin1String(" text-indent:");-
1883 html += QString::number(format.textIndent());-
1884 html += QLatin1String("px;");-
1885-
1886 if (block.userState() != -1
block.userState() != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1887 html += QLatin1String(" -qt-user-state:");-
1888 html += QString::number(block.userState());-
1889 html += QLatin1Char(';');-
1890 }
never executed: end of block
0
1891-
1892 if (format.lineHeightType() != QTextBlockFormat::SingleHeight
format.lineHei...::SingleHeightDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1893 html += QLatin1String(" line-height:")-
1894 + QString::number(format.lineHeight());-
1895 switch (format.lineHeightType()) {-
1896 case
never executed: case QTextBlockFormat::ProportionalHeight:
QTextBlockFormat::ProportionalHeight:
never executed: case QTextBlockFormat::ProportionalHeight:
0
1897 html += QLatin1String("%;");-
1898 break;
never executed: break;
0
1899 case
never executed: case QTextBlockFormat::FixedHeight:
QTextBlockFormat::FixedHeight:
never executed: case QTextBlockFormat::FixedHeight:
0
1900 html += QLatin1String("; -qt-line-height-type: fixed;");-
1901 break;
never executed: break;
0
1902 case
never executed: case QTextBlockFormat::MinimumHeight:
QTextBlockFormat::MinimumHeight:
never executed: case QTextBlockFormat::MinimumHeight:
0
1903 html += QLatin1String("px;");-
1904 break;
never executed: break;
0
1905 case
never executed: case QTextBlockFormat::LineDistanceHeight:
QTextBlockFormat::LineDistanceHeight:
never executed: case QTextBlockFormat::LineDistanceHeight:
0
1906 html += QLatin1String("; -qt-line-height-type: line-distance;");-
1907 break;
never executed: break;
0
1908 default
never executed: default:
:
never executed: default:
0
1909 html += QLatin1String(";");-
1910 break;
never executed: break;
0
1911 }-
1912 }-
1913-
1914 emitPageBreakPolicy(format.pageBreakPolicy());-
1915-
1916 QTextCharFormat diff;-
1917 if (emptyBlock
emptyBlockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1918 const QTextCharFormat blockCharFmt = block.charFormat();-
1919 diff = formatDifference(defaultCharFormat, blockCharFmt).toCharFormat();-
1920 }
never executed: end of block
0
1921-
1922 diff.clearProperty(QTextFormat::BackgroundBrush);-
1923 if (format.hasProperty(QTextFormat::BackgroundBrush)
format.hasProp...ckgroundBrush)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1924 QBrush bg = format.background();-
1925 if (bg.style() != Qt::NoBrush
bg.style() != Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1926 diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush));
never executed: diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush));
0
1927 }
never executed: end of block
0
1928-
1929 if (!diff.properties().isEmpty()
!diff.properties().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1930 emitCharFormatStyle(diff);
never executed: emitCharFormatStyle(diff);
0
1931-
1932 html += QLatin1Char('"');-
1933-
1934}
never executed: end of block
0
1935-
1936void QTextHtmlExporter::emitBlock(const QTextBlock &block)-
1937{-
1938 if (block.begin().atEnd()
block.begin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1939-
1940 int p = block.position();-
1941 if (p > 0
p > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1942 --
never executed: --p;
p;
never executed: --p;
0
1943 QTextDocumentPrivate::FragmentIterator frag = doc->docHandle()->find(p);-
1944 QChar ch = doc->docHandle()->buffer().at(frag->stringPosition);-
1945 if (ch == QChar(0xfdd0)
ch == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1946 || ch == QChar(0xfdd1)
ch == QChar(0xfdd1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1947 return;
never executed: return;
0
1948 }
never executed: end of block
0
1949-
1950 html += QLatin1Char('\n');-
1951-
1952-
1953-
1954 QTextCharFormat oldDefaultCharFormat = defaultCharFormat;-
1955-
1956 QTextList *list = block.textList();-
1957 if (list
listDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1958 if (list->itemNumber(block) == 0
list->itemNumber(block) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1959 const QTextListFormat format = list->format();-
1960 const int style = format.style();-
1961 switch (style) {-
1962 case
never executed: case QTextListFormat::ListDecimal:
QTextListFormat::ListDecimal:
never executed: case QTextListFormat::ListDecimal:
html += QLatin1String("<ol"); break;
never executed: break;
0
1963 case
never executed: case QTextListFormat::ListDisc:
QTextListFormat::ListDisc:
never executed: case QTextListFormat::ListDisc:
html += QLatin1String("<ul"); break;
never executed: break;
0
1964 case
never executed: case QTextListFormat::ListCircle:
QTextListFormat::ListCircle:
never executed: case QTextListFormat::ListCircle:
html += QLatin1String("<ul type=\"circle\""); break;
never executed: break;
0
1965 case
never executed: case QTextListFormat::ListSquare:
QTextListFormat::ListSquare:
never executed: case QTextListFormat::ListSquare:
html += QLatin1String("<ul type=\"square\""); break;
never executed: break;
0
1966 case
never executed: case QTextListFormat::ListLowerAlpha:
QTextListFormat::ListLowerAlpha:
never executed: case QTextListFormat::ListLowerAlpha:
html += QLatin1String("<ol type=\"a\""); break;
never executed: break;
0
1967 case
never executed: case QTextListFormat::ListUpperAlpha:
QTextListFormat::ListUpperAlpha:
never executed: case QTextListFormat::ListUpperAlpha:
html += QLatin1String("<ol type=\"A\""); break;
never executed: break;
0
1968 case
never executed: case QTextListFormat::ListLowerRoman:
QTextListFormat::ListLowerRoman:
never executed: case QTextListFormat::ListLowerRoman:
html += QLatin1String("<ol type=\"i\""); break;
never executed: break;
0
1969 case
never executed: case QTextListFormat::ListUpperRoman:
QTextListFormat::ListUpperRoman:
never executed: case QTextListFormat::ListUpperRoman:
html += QLatin1String("<ol type=\"I\""); break;
never executed: break;
0
1970 default
never executed: default:
:
never executed: default:
html += QLatin1String("<ul");
0
1971 }
never executed: end of block
0
1972-
1973 QString styleString = QString::fromLatin1("margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");-
1974-
1975 if (format.hasProperty(QTextFormat::ListIndent)
format.hasProp...t::ListIndent)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1976 styleString += QLatin1String(" -qt-list-indent: ");-
1977 styleString += QString::number(format.indent());-
1978 styleString += QLatin1Char(';');-
1979 }
never executed: end of block
0
1980-
1981 if (format.hasProperty(QTextFormat::ListNumberPrefix)
format.hasProp...tNumberPrefix)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1982 QString numberPrefix = format.numberPrefix();-
1983 numberPrefix.replace(QLatin1Char('"'), QLatin1String("\\22"));-
1984 numberPrefix.replace(QLatin1Char('\''), QLatin1String("\\27"));-
1985 styleString += QLatin1String(" -qt-list-number-prefix: ");-
1986 styleString += QLatin1Char('\'');-
1987 styleString += numberPrefix;-
1988 styleString += QLatin1Char('\'');-
1989 styleString += QLatin1Char(';');-
1990 }
never executed: end of block
0
1991-
1992 if (format.hasProperty(QTextFormat::ListNumberSuffix)
format.hasProp...tNumberSuffix)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1993 if (format.numberSuffix() != QLatin1String(".")
format.numberS...in1String(".")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1994 QString numberSuffix = format.numberSuffix();-
1995 numberSuffix.replace(QLatin1Char('"'), QLatin1String("\\22"));-
1996 numberSuffix.replace(QLatin1Char('\''), QLatin1String("\\27"));-
1997 styleString += QLatin1String(" -qt-list-number-suffix: ");-
1998 styleString += QLatin1Char('\'');-
1999 styleString += numberSuffix;-
2000 styleString += QLatin1Char('\'');-
2001 styleString += QLatin1Char(';');-
2002 }
never executed: end of block
0
2003 }
never executed: end of block
0
2004-
2005 html += QLatin1String(" style=\"");-
2006 html += styleString;-
2007 html += QLatin1String("\">");-
2008 }
never executed: end of block
0
2009-
2010 html += QLatin1String("<li");-
2011-
2012 const QTextCharFormat blockFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat();-
2013 if (!blockFmt.properties().isEmpty()
!blockFmt.prop...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2014 html += QLatin1String(" style=\"");-
2015 emitCharFormatStyle(blockFmt);-
2016 html += QLatin1Char('\"');-
2017-
2018 defaultCharFormat.merge(block.charFormat());-
2019 }
never executed: end of block
0
2020 }
never executed: end of block
0
2021-
2022 const QTextBlockFormat blockFormat = block.blockFormat();-
2023 if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)
blockFormat.ha...talRulerWidth)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2024 html += QLatin1String("<hr");-
2025-
2026 QTextLength width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth);-
2027 if (width.type() != QTextLength::VariableLength
width.type() !...VariableLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2028 emitTextLength("width", width);
never executed: emitTextLength("width", width);
0
2029 else-
2030 html += QLatin1Char(' ');
never executed: html += QLatin1Char(' ');
0
2031-
2032 html += QLatin1String("/>");-
2033 return;
never executed: return;
0
2034 }-
2035-
2036 const bool pre = blockFormat.nonBreakableLines();-
2037 if (pre
preDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2038 if (list
listDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2039 html += QLatin1Char('>');
never executed: html += QLatin1Char('>');
0
2040 html += QLatin1String("<pre");-
2041 }
never executed: end of block
else if (!list
!listDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2042 html += QLatin1String("<p");-
2043 }
never executed: end of block
0
2044-
2045 emitBlockAttributes(block);-
2046-
2047 html += QLatin1Char('>');-
2048 if (block.begin().atEnd()
block.begin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2049 html += QLatin1String("<br />");
never executed: html += QLatin1String("<br />");
0
2050-
2051 QTextBlock::Iterator it = block.begin();-
2052 if (fragmentMarkers
fragmentMarkersDescription
TRUEnever evaluated
FALSEnever evaluated
&& !it.atEnd()
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
&& block == doc->begin()
block == doc->begin()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2053 html += QLatin1String("<!--StartFragment-->");
never executed: html += QLatin1String("<!--StartFragment-->");
0
2054-
2055 for (; !it.atEnd()
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
2056 emitFragment(it.fragment());
never executed: emitFragment(it.fragment());
0
2057-
2058 if (fragmentMarkers
fragmentMarkersDescription
TRUEnever evaluated
FALSEnever evaluated
&& block.position() + block.length() == doc->docHandle()->length()
block.position...le()->length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2059 html += QLatin1String("<!--EndFragment-->");
never executed: html += QLatin1String("<!--EndFragment-->");
0
2060-
2061 if (pre
preDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2062 html += QLatin1String("</pre>");
never executed: html += QLatin1String("</pre>");
0
2063 else if (list
listDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2064 html += QLatin1String("</li>");
never executed: html += QLatin1String("</li>");
0
2065 else-
2066 html += QLatin1String("</p>");
never executed: html += QLatin1String("</p>");
0
2067-
2068 if (list
listDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2069 if (list->itemNumber(block) == list->count() - 1
list->itemNumb...t->count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2070 if (isOrderedList(list->format().style())
isOrderedList(...mat().style())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2071 html += QLatin1String("</ol>");
never executed: html += QLatin1String("</ol>");
0
2072 else-
2073 html += QLatin1String("</ul>");
never executed: html += QLatin1String("</ul>");
0
2074 }-
2075 }
never executed: end of block
0
2076-
2077 defaultCharFormat = oldDefaultCharFormat;-
2078}
never executed: end of block
0
2079-
2080extern bool qHasPixmapTexture(const QBrush& brush);-
2081-
2082QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap)-
2083{-
2084 QString url;-
2085 if (!doc
!docDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2086 return
never executed: return url;
url;
never executed: return url;
0
2087-
2088 if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent())
QTextDocument ...doc->parent())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2089 return
never executed: return findUrlForImage(parent, cacheKey, isPixmap);
findUrlForImage(parent, cacheKey, isPixmap);
never executed: return findUrlForImage(parent, cacheKey, isPixmap);
0
2090-
2091 if (doc
docDescription
TRUEnever evaluated
FALSEnever evaluated
&& doc->docHandle()
doc->docHandle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2092 QTextDocumentPrivate *priv = doc->docHandle();-
2093 QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin();-
2094 for (; it != priv->cachedResources.constEnd()
it != priv->ca...ces.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
2095-
2096 const QVariant &v = it.value();-
2097 if (v.type() == QVariant::Image
v.type() == QVariant::ImageDescription
TRUEnever evaluated
FALSEnever evaluated
&& !isPixmap
!isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2098 if (qvariant_cast<QImage>(v).cacheKey() == cacheKey
qvariant_cast<...() == cacheKeyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2099 break;
never executed: break;
0
2100 }
never executed: end of block
0
2101-
2102 if (v.type() == QVariant::Pixmap
v.type() == QVariant::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
&& isPixmap
isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2103 if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey
qvariant_cast<...() == cacheKeyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2104 break;
never executed: break;
0
2105 }
never executed: end of block
0
2106 }
never executed: end of block
0
2107-
2108 if (it != priv->cachedResources.constEnd()
it != priv->ca...ces.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2109 url = it.key().toString();
never executed: url = it.key().toString();
0
2110 }
never executed: end of block
0
2111-
2112 return
never executed: return url;
url;
never executed: return url;
0
2113}-
2114-
2115void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv)-
2116{-
2117 if (!priv
!privDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2118 return;
never executed: return;
0
2119-
2120 cachedResources.unite(priv->cachedResources);-
2121}
never executed: end of block
0
2122-
2123void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format)-
2124{-
2125 if (format.hasProperty(QTextFormat::BackgroundImageUrl)
format.hasProp...roundImageUrl)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2126 QString url = format.property(QTextFormat::BackgroundImageUrl).toString();-
2127 emitAttribute("background", url);-
2128 }
never executed: end of block
else {
0
2129 const QBrush &brush = format.background();-
2130 if (brush.style() == Qt::SolidPattern
brush.style() ...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2131 emitAttribute("bgcolor", colorValue(brush.color()));-
2132 }
never executed: end of block
else if (brush.style() == Qt::TexturePattern
brush.style() ...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2133 const bool isPixmap = qHasPixmapTexture(brush);-
2134 const qint64 cacheKey = isPixmap
isPixmapDescription
TRUEnever evaluated
FALSEnever evaluated
? brush.texture().cacheKey() : brush.textureImage().cacheKey();
0
2135-
2136 const QString url = findUrlForImage(doc, cacheKey, isPixmap);-
2137-
2138 if (!url.isEmpty()
!url.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2139 emitAttribute("background", url);
never executed: emitAttribute("background", url);
0
2140 }
never executed: end of block
0
2141 }
never executed: end of block
0
2142}-
2143-
2144void QTextHtmlExporter::emitTable(const QTextTable *table)-
2145{-
2146 QTextTableFormat format = table->format();-
2147-
2148 html += QLatin1String("\n<table");-
2149-
2150 if (format.hasProperty(QTextFormat::FrameBorder)
format.hasProp...::FrameBorder)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2151 emitAttribute("border", QString::number(format.border()));
never executed: emitAttribute("border", QString::number(format.border()));
0
2152-
2153 emitFrameStyle(format, TableFrame);-
2154-
2155 emitAlignment(format.alignment());-
2156 emitTextLength("width", format.width());-
2157-
2158 if (format.hasProperty(QTextFormat::TableCellSpacing)
format.hasProp...leCellSpacing)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2159 emitAttribute("cellspacing", QString::number(format.cellSpacing()));
never executed: emitAttribute("cellspacing", QString::number(format.cellSpacing()));
0
2160 if (format.hasProperty(QTextFormat::TableCellPadding)
format.hasProp...leCellPadding)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2161 emitAttribute("cellpadding", QString::number(format.cellPadding()));
never executed: emitAttribute("cellpadding", QString::number(format.cellPadding()));
0
2162-
2163 emitBackgroundAttribute(format);-
2164-
2165 html += QLatin1Char('>');-
2166-
2167 const int rows = table->rows();-
2168 const int columns = table->columns();-
2169-
2170 QVector<QTextLength> columnWidths = format.columnWidthConstraints();-
2171 if (columnWidths.isEmpty()
columnWidths.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2172 columnWidths.resize(columns);-
2173 columnWidths.fill(QTextLength());-
2174 }
never executed: end of block
0
2175 ((!(columnWidths.count() == columns)) ? qt_assert("columnWidths.count() == columns",__FILE__,3047) : qt_noop());-
2176-
2177 QVarLengthArray<bool> widthEmittedForColumn(columns);-
2178 for (int i = 0; i < columns
i < columnsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
2179 widthEmittedForColumn[i] = false;
never executed: widthEmittedForColumn[i] = false;
0
2180-
2181 const int headerRowCount = qMin(format.headerRowCount(), rows);-
2182 if (headerRowCount > 0
headerRowCount > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2183 html += QLatin1String("<thead>");
never executed: html += QLatin1String("<thead>");
0
2184-
2185 for (int row = 0; row < rows
row < rowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++row) {
0
2186 html += QLatin1String("\n<tr>");-
2187-
2188 for (int col = 0; col < columns
col < columnsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++col) {
0
2189 const QTextTableCell cell = table->cellAt(row, col);-
2190-
2191-
2192 if (cell.row() != row
cell.row() != rowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2193 continue;
never executed: continue;
0
2194-
2195 if (cell.column() != col
cell.column() != colDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2196 continue;
never executed: continue;
0
2197-
2198 html += QLatin1String("\n<td");-
2199-
2200 if (!widthEmittedForColumn[col]
!widthEmittedForColumn[col]Description
TRUEnever evaluated
FALSEnever evaluated
&& cell.columnSpan() == 1
cell.columnSpan() == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2201 emitTextLength("width", columnWidths.at(col));-
2202 widthEmittedForColumn[col] = true;-
2203 }
never executed: end of block
0
2204-
2205 if (cell.columnSpan() > 1
cell.columnSpan() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2206 emitAttribute("colspan", QString::number(cell.columnSpan()));
never executed: emitAttribute("colspan", QString::number(cell.columnSpan()));
0
2207-
2208 if (cell.rowSpan() > 1
cell.rowSpan() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2209 emitAttribute("rowspan", QString::number(cell.rowSpan()));
never executed: emitAttribute("rowspan", QString::number(cell.rowSpan()));
0
2210-
2211 const QTextTableCellFormat cellFormat = cell.format().toTableCellFormat();-
2212 emitBackgroundAttribute(cellFormat);-
2213-
2214 QTextCharFormat oldDefaultCharFormat = defaultCharFormat;-
2215-
2216 QTextCharFormat::VerticalAlignment valign = cellFormat.verticalAlignment();-
2217-
2218 QString styleString;-
2219 if (valign >= QTextCharFormat::AlignMiddle
valign >= QTex...t::AlignMiddleDescription
TRUEnever evaluated
FALSEnever evaluated
&& valign <= QTextCharFormat::AlignBottom
valign <= QTex...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2220 styleString += QLatin1String(" vertical-align:");-
2221 switch (valign) {-
2222 case
never executed: case QTextCharFormat::AlignMiddle:
QTextCharFormat::AlignMiddle:
never executed: case QTextCharFormat::AlignMiddle:
0
2223 styleString += QLatin1String("middle");-
2224 break;
never executed: break;
0
2225 case
never executed: case QTextCharFormat::AlignTop:
QTextCharFormat::AlignTop:
never executed: case QTextCharFormat::AlignTop:
0
2226 styleString += QLatin1String("top");-
2227 break;
never executed: break;
0
2228 case
never executed: case QTextCharFormat::AlignBottom:
QTextCharFormat::AlignBottom:
never executed: case QTextCharFormat::AlignBottom:
0
2229 styleString += QLatin1String("bottom");-
2230 break;
never executed: break;
0
2231 default
never executed: default:
:
never executed: default:
0
2232 break;
never executed: break;
0
2233 }-
2234 styleString += QLatin1Char(';');-
2235-
2236 QTextCharFormat temp;-
2237 temp.setVerticalAlignment(valign);-
2238 defaultCharFormat.merge(temp);-
2239 }
never executed: end of block
0
2240-
2241 if (cellFormat.hasProperty(QTextFormat::TableCellLeftPadding)
cellFormat.has...llLeftPadding)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2242 styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';');
0
2243 if (cellFormat.hasProperty(QTextFormat::TableCellRightPadding)
cellFormat.has...lRightPadding)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2244 styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';');
0
2245 if (cellFormat.hasProperty(QTextFormat::TableCellTopPadding)
cellFormat.has...ellTopPadding)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2246 styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';');
0
2247 if (cellFormat.hasProperty(QTextFormat::TableCellBottomPadding)
cellFormat.has...BottomPadding)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2248 styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';');
never executed: styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';');
0
2249-
2250 if (!styleString.isEmpty()
!styleString.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2251 html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"');
never executed: html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"');
0
2252-
2253 html += QLatin1Char('>');-
2254-
2255 emitFrame(cell.begin());-
2256-
2257 html += QLatin1String("</td>");-
2258-
2259 defaultCharFormat = oldDefaultCharFormat;-
2260 }
never executed: end of block
0
2261-
2262 html += QLatin1String("</tr>");-
2263 if (headerRowCount > 0
headerRowCount > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& row == headerRowCount - 1
row == headerRowCount - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2264 html += QLatin1String("</thead>");
never executed: html += QLatin1String("</thead>");
0
2265 }
never executed: end of block
0
2266-
2267 html += QLatin1String("</table>");-
2268}
never executed: end of block
0
2269-
2270void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt)-
2271{-
2272 if (!frameIt.atEnd()
!frameIt.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2273 QTextFrame::Iterator next = frameIt;-
2274 ++next;-
2275 if (next.atEnd()
next.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
2276 && frameIt.currentFrame() == 0
frameIt.currentFrame() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2277 && frameIt.parentFrame() != doc->rootFrame()
frameIt.parent...c->rootFrame()Description
TRUEnever evaluated
FALSEnever evaluated
0
2278 && frameIt.currentBlock().begin().atEnd()
frameIt.curren...egin().atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2279 return;
never executed: return;
0
2280 }
never executed: end of block
0
2281-
2282 for (QTextFrame::Iterator it = frameIt;-
2283 !it.atEnd()
!it.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
2284 if (QTextFrame *f = it.currentFrame()
QTextFrame *f ...currentFrame()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2285 if (QTextTable *table = qobject_cast<QTextTable *>(f)
QTextTable *ta...extTable *>(f)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2286 emitTable(table);-
2287 }
never executed: end of block
else {
0
2288 emitTextFrame(f);-
2289 }
never executed: end of block
0
2290 } else if (it.currentBlock().isValid()
it.currentBlock().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2291 emitBlock(it.currentBlock());-
2292 }
never executed: end of block
0
2293 }
never executed: end of block
0
2294}
never executed: end of block
0
2295-
2296void QTextHtmlExporter::emitTextFrame(const QTextFrame *f)-
2297{-
2298 FrameType frameType = f->parentFrame()
f->parentFrame()Description
TRUEnever evaluated
FALSEnever evaluated
? TextFrame : RootFrame;
0
2299-
2300 html += QLatin1String("\n<table");-
2301 QTextFrameFormat format = f->frameFormat();-
2302-
2303 if (format.hasProperty(QTextFormat::FrameBorder)
format.hasProp...::FrameBorder)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2304 emitAttribute("border", QString::number(format.border()));
never executed: emitAttribute("border", QString::number(format.border()));
0
2305-
2306 emitFrameStyle(format, frameType);-
2307-
2308 emitTextLength("width", format.width());-
2309 emitTextLength("height", format.height());-
2310-
2311-
2312 if (frameType != RootFrame
frameType != RootFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2313 emitBackgroundAttribute(format);
never executed: emitBackgroundAttribute(format);
0
2314-
2315 html += QLatin1Char('>');-
2316 html += QLatin1String("\n<tr>\n<td style=\"border: none;\">");-
2317 emitFrame(f->begin());-
2318 html += QLatin1String("</td></tr></table>");-
2319}
never executed: end of block
0
2320-
2321void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType frameType)-
2322{-
2323 QLatin1String styleAttribute(" style=\"");-
2324 html += styleAttribute;-
2325 const int originalHtmlLength = html.length();-
2326-
2327 if (frameType == TextFrame
frameType == TextFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2328 html += QLatin1String("-qt-table-type: frame;");
never executed: html += QLatin1String("-qt-table-type: frame;");
0
2329 else if (frameType == RootFrame
frameType == RootFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2330 html += QLatin1String("-qt-table-type: root;");
never executed: html += QLatin1String("-qt-table-type: root;");
0
2331-
2332 const QTextFrameFormat defaultFormat;-
2333-
2334 emitFloatStyle(format.position(), OmitStyleTag);-
2335 emitPageBreakPolicy(format.pageBreakPolicy());-
2336-
2337 if (format.borderBrush() != defaultFormat.borderBrush()
format.borderB....borderBrush()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2338 html += QLatin1String(" border-color:");-
2339 html += colorValue(format.borderBrush().color());-
2340 html += QLatin1Char(';');-
2341 }
never executed: end of block
0
2342-
2343 if (format.borderStyle() != defaultFormat.borderStyle()
format.borderS....borderStyle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2344 emitBorderStyle(format.borderStyle());
never executed: emitBorderStyle(format.borderStyle());
0
2345-
2346 if (format.hasProperty(QTextFormat::FrameMargin)
format.hasProp...::FrameMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2347 || format.hasProperty(QTextFormat::FrameLeftMargin)
format.hasProp...ameLeftMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2348 || format.hasProperty(QTextFormat::FrameRightMargin)
format.hasProp...meRightMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2349 || format.hasProperty(QTextFormat::FrameTopMargin)
format.hasProp...rameTopMargin)Description
TRUEnever evaluated
FALSEnever evaluated
0
2350 || format.hasProperty(QTextFormat::FrameBottomMargin)
format.hasProp...eBottomMargin)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2351 emitMargins(QString::number(format.topMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
2352 QString::number(format.bottomMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
2353 QString::number(format.leftMargin()),
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
2354 QString::number(format.rightMargin()));
never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));
0
2355-
2356 if (html.length() == originalHtmlLength
html.length() ...inalHtmlLengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2357 html.chop(styleAttribute.size());
never executed: html.chop(styleAttribute.size());
0
2358 else-
2359 html += QLatin1Char('\"');
never executed: html += QLatin1Char('\"');
0
2360}-
2361QString QTextDocument::toHtml(const QByteArray &encoding) const-
2362{-
2363 return
never executed: return QTextHtmlExporter(this).toHtml(encoding);
QTextHtmlExporter(this).toHtml(encoding);
never executed: return QTextHtmlExporter(this).toHtml(encoding);
0
2364}-
2365-
2366-
2367-
2368-
2369-
2370QVector<QTextFormat> QTextDocument::allFormats() const-
2371{-
2372 const QTextDocumentPrivate * const d = d_func();-
2373 return
never executed: return d->formatCollection()->formats;
d->formatCollection()->formats;
never executed: return d->formatCollection()->formats;
0
2374}-
2375-
2376-
2377-
2378-
2379-
2380-
2381-
2382QTextDocumentPrivate *QTextDocument::docHandle() const-
2383{-
2384 const QTextDocumentPrivate * const d = d_func();-
2385 return
never executed: return const_cast<QTextDocumentPrivate *>(d);
const_cast<QTextDocumentPrivate *>(d);
never executed: return const_cast<QTextDocumentPrivate *>(d);
0
2386}-
2387-
Switch to Source codePreprocessed file

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