qtextobject.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextobject.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8QTextObject::QTextObject(QTextDocument *doc)-
9 : QObject(*new QTextObjectPrivate(doc), doc)-
10{-
11}
never executed: end of block
0
12-
13-
14-
15-
16-
17-
18QTextObject::QTextObject(QTextObjectPrivate &p, QTextDocument *doc)-
19 : QObject(p, doc)-
20{-
21}
never executed: end of block
0
22-
23-
24-
25-
26-
27-
28-
29QTextObject::~QTextObject()-
30{-
31}-
32-
33-
34-
35-
36-
37-
38QTextFormat QTextObject::format() const-
39{-
40 const QTextObjectPrivate * const d = d_func();-
41 return
never executed: return d->pieceTable->formatCollection()->objectFormat(d->objectIndex);
d->pieceTable->formatCollection()->objectFormat(d->objectIndex);
never executed: return d->pieceTable->formatCollection()->objectFormat(d->objectIndex);
0
42}-
43-
44-
45-
46-
47-
48-
49-
50int QTextObject::formatIndex() const-
51{-
52 const QTextObjectPrivate * const d = d_func();-
53 return
never executed: return d->pieceTable->formatCollection()->objectFormatIndex(d->objectIndex);
d->pieceTable->formatCollection()->objectFormatIndex(d->objectIndex);
never executed: return d->pieceTable->formatCollection()->objectFormatIndex(d->objectIndex);
0
54}-
55-
56-
57-
58-
59-
60-
61-
62void QTextObject::setFormat(const QTextFormat &format)-
63{-
64 QTextObjectPrivate * const d = d_func();-
65 int idx = d->pieceTable->formatCollection()->indexForFormat(format);-
66 d->pieceTable->changeObjectFormat(this, idx);-
67}
never executed: end of block
0
68-
69-
70-
71-
72-
73int QTextObject::objectIndex() const-
74{-
75 const QTextObjectPrivate * const d = d_func();-
76 return
never executed: return d->objectIndex;
d->objectIndex;
never executed: return d->objectIndex;
0
77}-
78-
79-
80-
81-
82-
83-
84QTextDocument *QTextObject::document() const-
85{-
86 return
never executed: return static_cast<QTextDocument *>(parent());
static_cast<QTextDocument *>(parent());
never executed: return static_cast<QTextDocument *>(parent());
0
87}-
88-
89-
90-
91-
92QTextDocumentPrivate *QTextObject::docHandle() const-
93{-
94 return
never executed: return static_cast<const QTextDocument *>(parent())->docHandle();
static_cast<const QTextDocument *>(parent())->docHandle();
never executed: return static_cast<const QTextDocument *>(parent())->docHandle();
0
95}-
96void QTextBlockGroupPrivate::markBlocksDirty()-
97{-
98 for (int i = 0; i < blocks.count()
i < blocks.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
99 const QTextBlock &block = blocks.at(i);-
100 pieceTable->documentChange(block.position(), block.length());-
101 }
never executed: end of block
0
102}
never executed: end of block
0
103QTextBlockGroup::QTextBlockGroup(QTextDocument *doc)-
104 : QTextObject(*new QTextBlockGroupPrivate(doc), doc)-
105{-
106}
never executed: end of block
0
107-
108-
109-
110-
111QTextBlockGroup::QTextBlockGroup(QTextBlockGroupPrivate &p, QTextDocument *doc)-
112 : QTextObject(p, doc)-
113{-
114}
never executed: end of block
0
115-
116-
117-
118-
119-
120QTextBlockGroup::~QTextBlockGroup()-
121{-
122}-
123void QTextBlockGroup::blockInserted(const QTextBlock &block)-
124{-
125 QTextBlockGroupPrivate * const d = d_func();-
126 QTextBlockGroupPrivate::BlockList::Iterator it = std::lower_bound(d->blocks.begin(), d->blocks.end(), block);-
127 d->blocks.insert(it, block);-
128 d->markBlocksDirty();-
129}
never executed: end of block
0
130-
131-
132-
133-
134-
135-
136void QTextBlockGroup::blockRemoved(const QTextBlock &block)-
137{-
138 QTextBlockGroupPrivate * const d = d_func();-
139 d->blocks.removeAll(block);-
140 d->markBlocksDirty();-
141 if (d->blocks.isEmpty()
d->blocks.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
142 document()->docHandle()->deleteObject(this);-
143 return;
never executed: return;
0
144 }-
145}
never executed: end of block
0
146-
147-
148-
149-
150-
151-
152-
153void QTextBlockGroup::blockFormatChanged(const QTextBlock &)-
154{-
155}-
156-
157-
158-
159-
160-
161QList<QTextBlock> QTextBlockGroup::blockList() const-
162{-
163 const QTextBlockGroupPrivate * const d = d_func();-
164 return
never executed: return d->blocks;
d->blocks;
never executed: return d->blocks;
0
165}-
166-
167-
168-
169QTextFrameLayoutData::~QTextFrameLayoutData()-
170{-
171}-
172QTextFrame::QTextFrame(QTextDocument *doc)-
173 : QTextObject(*new QTextFramePrivate(doc), doc)-
174{-
175}
never executed: end of block
0
176QTextFrame::~QTextFrame()-
177{-
178 QTextFramePrivate * const d = d_func();-
179 delete d->layoutData;-
180}
never executed: end of block
0
181-
182-
183-
184-
185QTextFrame::QTextFrame(QTextFramePrivate &p, QTextDocument *doc)-
186 : QTextObject(p, doc)-
187{-
188}
never executed: end of block
0
189-
190-
191-
192-
193-
194-
195QList<QTextFrame *> QTextFrame::childFrames() const-
196{-
197 const QTextFramePrivate * const d = d_func();-
198 return
never executed: return d->childFrames;
d->childFrames;
never executed: return d->childFrames;
0
199}-
200-
201-
202-
203-
204-
205-
206-
207QTextFrame *QTextFrame::parentFrame() const-
208{-
209 const QTextFramePrivate * const d = d_func();-
210 return
never executed: return d->parentFrame;
d->parentFrame;
never executed: return d->parentFrame;
0
211}-
212-
213-
214-
215-
216-
217-
218-
219QTextCursor QTextFrame::firstCursorPosition() const-
220{-
221 const QTextFramePrivate * const d = d_func();-
222 return
never executed: return QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition());
QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition());
never executed: return QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition());
0
223}-
224-
225-
226-
227-
228-
229-
230QTextCursor QTextFrame::lastCursorPosition() const-
231{-
232 const QTextFramePrivate * const d = d_func();-
233 return
never executed: return QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition());
QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition());
never executed: return QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition());
0
234}-
235-
236-
237-
238-
239-
240-
241int QTextFrame::firstPosition() const-
242{-
243 const QTextFramePrivate * const d = d_func();-
244 if (!d->fragment_start
!d->fragment_startDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
245 return
never executed: return 0;
0;
never executed: return 0;
0
246 return
never executed: return d->pieceTable->fragmentMap().position(d->fragment_start) + 1;
d->pieceTable->fragmentMap().position(d->fragment_start) + 1;
never executed: return d->pieceTable->fragmentMap().position(d->fragment_start) + 1;
0
247}-
248-
249-
250-
251-
252-
253-
254int QTextFrame::lastPosition() const-
255{-
256 const QTextFramePrivate * const d = d_func();-
257 if (!d->fragment_end
!d->fragment_endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
258 return
never executed: return d->pieceTable->length() - 1;
d->pieceTable->length() - 1;
never executed: return d->pieceTable->length() - 1;
0
259 return
never executed: return d->pieceTable->fragmentMap().position(d->fragment_end);
d->pieceTable->fragmentMap().position(d->fragment_end);
never executed: return d->pieceTable->fragmentMap().position(d->fragment_end);
0
260}-
261-
262-
263-
264-
265QTextFrameLayoutData *QTextFrame::layoutData() const-
266{-
267 const QTextFramePrivate * const d = d_func();-
268 return
never executed: return d->layoutData;
d->layoutData;
never executed: return d->layoutData;
0
269}-
270-
271-
272-
273-
274void QTextFrame::setLayoutData(QTextFrameLayoutData *data)-
275{-
276 QTextFramePrivate * const d = d_func();-
277 delete d->layoutData;-
278 d->layoutData = data;-
279}
never executed: end of block
0
280-
281-
282-
283void QTextFramePrivate::fragmentAdded(QChar type, uint fragment)-
284{-
285 if (type == QChar(0xfdd0)
type == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
286 ((!(!fragment_start)) ? qt_assert("!fragment_start",__FILE__,538) : qt_noop());-
287 fragment_start = fragment;-
288 }
never executed: end of block
else if (type == QChar(0xfdd1)
type == QChar(0xfdd1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
289 ((!(!fragment_end)) ? qt_assert("!fragment_end",__FILE__,541) : qt_noop());-
290 fragment_end = fragment;-
291 }
never executed: end of block
else if (type == QChar::ObjectReplacementCharacter
type == QChar:...ementCharacterDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
292 ((!(!fragment_start)) ? qt_assert("!fragment_start",__FILE__,544) : qt_noop());-
293 ((!(!fragment_end)) ? qt_assert("!fragment_end",__FILE__,545) : qt_noop());-
294 fragment_start = fragment;-
295 fragment_end = fragment;-
296 }
never executed: end of block
else {
0
297 ((!(false)) ? qt_assert("false",__FILE__,549) : qt_noop());-
298 }
never executed: end of block
0
299}-
300-
301void QTextFramePrivate::fragmentRemoved(QChar type, uint fragment)-
302{-
303 (void)fragment;;-
304 if (type == QChar(0xfdd0)
type == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
305 ((!(fragment_start == fragment)) ? qt_assert("fragment_start == fragment",__FILE__,557) : qt_noop());-
306 fragment_start = 0;-
307 }
never executed: end of block
else if (type == QChar(0xfdd1)
type == QChar(0xfdd1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
308 ((!(fragment_end == fragment)) ? qt_assert("fragment_end == fragment",__FILE__,560) : qt_noop());-
309 fragment_end = 0;-
310 }
never executed: end of block
else if (type == QChar::ObjectReplacementCharacter
type == QChar:...ementCharacterDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
311 ((!(fragment_start == fragment)) ? qt_assert("fragment_start == fragment",__FILE__,563) : qt_noop());-
312 ((!(fragment_end == fragment)) ? qt_assert("fragment_end == fragment",__FILE__,564) : qt_noop());-
313 fragment_start = 0;-
314 fragment_end = 0;-
315 }
never executed: end of block
else {
0
316 ((!(false)) ? qt_assert("false",__FILE__,568) : qt_noop());-
317 }
never executed: end of block
0
318 remove_me();-
319}
never executed: end of block
0
320-
321-
322void QTextFramePrivate::remove_me()-
323{-
324 QTextFrame * const q = q_func();-
325 if (fragment_start == 0
fragment_start == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& fragment_end == 0
fragment_end == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
326 && !parentFrame
!parentFrameDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
327 q->document()->docHandle()->deleteObject(q);-
328 return;
never executed: return;
0
329 }-
330-
331 if (!parentFrame
!parentFrameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
332 return;
never executed: return;
0
333-
334 int index = parentFrame->d_func()->childFrames.indexOf(q);-
335-
336-
337 for (int i = 0; i < childFrames.size()
i < childFrames.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
338 QTextFrame *c = childFrames.at(i);-
339 parentFrame->d_func()->childFrames.insert(index, c);-
340 c->d_func()->parentFrame = parentFrame;-
341 ++index;-
342 }
never executed: end of block
0
343 ((!(parentFrame->d_func()->childFrames.at(index) == q)) ? qt_assert("parentFrame->d_func()->childFrames.at(index) == q",__FILE__,595) : qt_noop());-
344 parentFrame->d_func()->childFrames.removeAt(index);-
345-
346 childFrames.clear();-
347 parentFrame = 0;-
348}
never executed: end of block
0
349QTextFrame::iterator QTextFrame::begin() const-
350{-
351 const QTextDocumentPrivate *priv = docHandle();-
352 int b = priv->blockMap().findNode(firstPosition());-
353 int e = priv->blockMap().findNode(lastPosition()+1);-
354 return
never executed: return iterator(const_cast<QTextFrame *>(this), b, b, e);
iterator(const_cast<QTextFrame *>(this), b, b, e);
never executed: return iterator(const_cast<QTextFrame *>(this), b, b, e);
0
355}-
356-
357-
358-
359-
360-
361-
362QTextFrame::iterator QTextFrame::end() const-
363{-
364 const QTextDocumentPrivate *priv = docHandle();-
365 int b = priv->blockMap().findNode(firstPosition());-
366 int e = priv->blockMap().findNode(lastPosition()+1);-
367 return
never executed: return iterator(const_cast<QTextFrame *>(this), e, b, e);
iterator(const_cast<QTextFrame *>(this), e, b, e);
never executed: return iterator(const_cast<QTextFrame *>(this), e, b, e);
0
368}-
369-
370-
371-
372-
373QTextFrame::iterator::iterator()-
374{-
375 f = 0;-
376 b = 0;-
377 e = 0;-
378 cf = 0;-
379 cb = 0;-
380}
never executed: end of block
0
381-
382-
383-
384-
385QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end)-
386{-
387 f = frame;-
388 b = begin;-
389 e = end;-
390 cf = 0;-
391 cb = block;-
392}
never executed: end of block
0
393-
394-
395-
396-
397-
398-
399QTextFrame::iterator::iterator(const iterator &other) noexcept-
400{-
401 f = other.f;-
402 b = other.b;-
403 e = other.e;-
404 cf = other.cf;-
405 cb = other.cb;-
406}
never executed: end of block
0
407-
408-
409-
410-
411-
412QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) noexcept-
413{-
414 f = other.f;-
415 b = other.b;-
416 e = other.e;-
417 cf = other.cf;-
418 cb = other.cb;-
419 return
never executed: return *this;
*this;
never executed: return *this;
0
420}-
421QTextFrame *QTextFrame::iterator::currentFrame() const-
422{-
423 return
never executed: return cf;
cf;
never executed: return cf;
0
424}-
425-
426-
427-
428-
429-
430-
431-
432QTextBlock QTextFrame::iterator::currentBlock() const-
433{-
434 if (!f
!fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
435 return
never executed: return QTextBlock();
QTextBlock();
never executed: return QTextBlock();
0
436 return
never executed: return QTextBlock(f->docHandle(), cb);
QTextBlock(f->docHandle(), cb);
never executed: return QTextBlock(f->docHandle(), cb);
0
437}-
438-
439-
440-
441-
442-
443-
444QTextFrame::iterator &QTextFrame::iterator::operator++()-
445{-
446 const QTextDocumentPrivate *priv = f->docHandle();-
447 const QTextDocumentPrivate::BlockMap &map = priv->blockMap();-
448 if (cf
cfDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 int end = cf->lastPosition() + 1;-
450 cb = map.findNode(end);-
451 cf = 0;-
452 }
never executed: end of block
else if (cb
cbDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
453 cb = map.next(cb);-
454 if (cb == e
cb == eDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
455 return
never executed: return *this;
*this;
never executed: return *this;
0
456-
457 if (!f->d_func()->childFrames.isEmpty()
!f->d_func()->...ames.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
458 int pos = map.position(cb);-
459-
460 QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1);-
461 if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator
priv->buffer()...graphSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
462 QTextFrame *nf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format));-
463 if (nf
nfDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
464 if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd0)
priv->buffer()... QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
&& nf != f
nf != fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
465 cf = nf;-
466 cb = 0;-
467 }
never executed: end of block
else {
0
468 ((!(priv->buffer().at(frag->stringPosition) != QChar(0xfdd1))) ? qt_assert("priv->buffer().at(frag->stringPosition) != QTextEndOfFrame",__FILE__,759) : qt_noop());-
469 }
never executed: end of block
0
470 }-
471 }
never executed: end of block
0
472 }
never executed: end of block
0
473 }
never executed: end of block
0
474 return
never executed: return *this;
*this;
never executed: return *this;
0
475}-
476-
477-
478-
479-
480-
481-
482QTextFrame::iterator &QTextFrame::iterator::operator--()-
483{-
484 const QTextDocumentPrivate *priv = f->docHandle();-
485 const QTextDocumentPrivate::BlockMap &map = priv->blockMap();-
486 if (cf
cfDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
487 int start = cf->firstPosition() - 1;-
488 cb = map.findNode(start);-
489 cf = 0;-
490 }
never executed: end of block
else {
0
491 if (cb == b
cb == bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
492 goto
never executed: goto end;
end;
never executed: goto end;
0
493 if (cb != e
cb != eDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
494 int pos = map.position(cb);-
495-
496 QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1);-
497 if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator
priv->buffer()...graphSeparatorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
498 QTextFrame *pf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format));-
499 if (pf
pfDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
500 if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd0)
priv->buffer()... QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
501 ((!(pf == f)) ? qt_assert("pf == f",__FILE__,792) : qt_noop());-
502 }
never executed: end of block
else if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd1)
priv->buffer()... QChar(0xfdd1)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
503 ((!(pf != f)) ? qt_assert("pf != f",__FILE__,794) : qt_noop());-
504 cf = pf;-
505 cb = 0;-
506 goto
never executed: goto end;
end;
never executed: goto end;
0
507 }-
508 }
never executed: end of block
0
509 }
never executed: end of block
0
510 }
never executed: end of block
0
511 cb = map.previous(cb);-
512 }
never executed: end of block
0
513 end:
code before this statement never executed: end:
0
514 return
never executed: return *this;
*this;
never executed: return *this;
0
515}-
516QTextBlockUserData::~QTextBlockUserData()-
517{-
518}-
519bool QTextBlock::isValid() const-
520{-
521 return
never executed: return p != 0 && p->blockMap().isValid(n);
p != 0 && p->blockMap().isValid(n);
never executed: return p != 0 && p->blockMap().isValid(n);
0
522}-
523int QTextBlock::position() const-
524{-
525 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
526 return
never executed: return 0;
0;
never executed: return 0;
0
527-
528 return
never executed: return p->blockMap().position(n);
p->blockMap().position(n);
never executed: return p->blockMap().position(n);
0
529}-
530int QTextBlock::length() const-
531{-
532 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
533 return
never executed: return 0;
0;
never executed: return 0;
0
534-
535 return
never executed: return p->blockMap().size(n);
p->blockMap().size(n);
never executed: return p->blockMap().size(n);
0
536}-
537-
538-
539-
540-
541-
542bool QTextBlock::contains(int position) const-
543{-
544 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
545 return
never executed: return false;
false;
never executed: return false;
0
546-
547 int pos = p->blockMap().position(n);-
548 int len = p->blockMap().size(n);-
549 return
never executed: return position >= pos && position < pos + len;
position >= pos && position < pos + len;
never executed: return position >= pos && position < pos + len;
0
550}-
551QTextLayout *QTextBlock::layout() const-
552{-
553 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
554 return
never executed: return 0;
0;
never executed: return 0;
0
555-
556 const QTextBlockData *b = p->blockMap().fragment(n);-
557 if (!b->layout
!b->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
558 b->layout = new QTextLayout(*this);
never executed: b->layout = new QTextLayout(*this);
0
559 return
never executed: return b->layout;
b->layout;
never executed: return b->layout;
0
560}-
561void QTextBlock::clearLayout()-
562{-
563 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
564 return;
never executed: return;
0
565-
566 const QTextBlockData *b = p->blockMap().fragment(n);-
567 if (b->layout
b->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
568 b->layout->clearLayout();
never executed: b->layout->clearLayout();
0
569}
never executed: end of block
0
570-
571-
572-
573-
574-
575-
576QTextBlockFormat QTextBlock::blockFormat() const-
577{-
578 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
579 return
never executed: return QTextFormat().toBlockFormat();
QTextFormat().toBlockFormat();
never executed: return QTextFormat().toBlockFormat();
0
580-
581 return
never executed: return p->formatCollection()->blockFormat(p->blockMap().fragment(n)->format);
p->formatCollection()->blockFormat(p->blockMap().fragment(n)->format);
never executed: return p->formatCollection()->blockFormat(p->blockMap().fragment(n)->format);
0
582}-
583-
584-
585-
586-
587-
588-
589-
590int QTextBlock::blockFormatIndex() const-
591{-
592 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
593 return
never executed: return -1;
-1;
never executed: return -1;
0
594-
595 return
never executed: return p->blockMap().fragment(n)->format;
p->blockMap().fragment(n)->format;
never executed: return p->blockMap().fragment(n)->format;
0
596}-
597QTextCharFormat QTextBlock::charFormat() const-
598{-
599 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
600 return
never executed: return QTextFormat().toCharFormat();
QTextFormat().toCharFormat();
never executed: return QTextFormat().toCharFormat();
0
601-
602 return
never executed: return p->formatCollection()->charFormat(charFormatIndex());
p->formatCollection()->charFormat(charFormatIndex());
never executed: return p->formatCollection()->charFormat(charFormatIndex());
0
603}-
604-
605-
606-
607-
608-
609-
610-
611int QTextBlock::charFormatIndex() const-
612{-
613 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
614 return
never executed: return -1;
-1;
never executed: return -1;
0
615-
616 return
never executed: return p->blockCharFormatIndex(n);
p->blockCharFormatIndex(n);
never executed: return p->blockCharFormatIndex(n);
0
617}-
618Qt::LayoutDirection QTextBlock::textDirection() const-
619{-
620 Qt::LayoutDirection dir = blockFormat().layoutDirection();-
621 if (dir != Qt::LayoutDirectionAuto
dir != Qt::LayoutDirectionAutoDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
622 return
never executed: return dir;
dir;
never executed: return dir;
0
623-
624 dir = p->defaultTextOption.textDirection();-
625 if (dir != Qt::LayoutDirectionAuto
dir != Qt::LayoutDirectionAutoDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
626 return
never executed: return dir;
dir;
never executed: return dir;
0
627-
628 const QString buffer = p->buffer();-
629-
630 const int pos = position();-
631 QTextDocumentPrivate::FragmentIterator it = p->find(pos);-
632 QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1);-
633 for (; it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
634 const QTextFragmentData * const frag = it.value();-
635 const QChar *p = buffer.constData() + frag->stringPosition;-
636 const QChar * const end = p + frag->size_array[0];-
637 while (p < end
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
638 uint ucs4 = p->unicode();-
639 if (QChar::isHighSurrogate(ucs4)
QChar::isHighSurrogate(ucs4)Description
TRUEnever evaluated
FALSEnever evaluated
&& p + 1 < end
p + 1 < endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
640 ushort low = p[1].unicode();-
641 if (QChar::isLowSurrogate(low)
QChar::isLowSurrogate(low)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
642 ucs4 = QChar::surrogateToUcs4(ucs4, low);-
643 ++p;-
644 }
never executed: end of block
0
645 }
never executed: end of block
0
646 switch (QChar::direction(ucs4)) {-
647 case
never executed: case QChar::DirL:
QChar::DirL:
never executed: case QChar::DirL:
0
648 return
never executed: return Qt::LeftToRight;
Qt::LeftToRight;
never executed: return Qt::LeftToRight;
0
649 case
never executed: case QChar::DirR:
QChar::DirR:
never executed: case QChar::DirR:
0
650 case
never executed: case QChar::DirAL:
QChar::DirAL:
never executed: case QChar::DirAL:
0
651 return
never executed: return Qt::RightToLeft;
Qt::RightToLeft;
never executed: return Qt::RightToLeft;
0
652 default
never executed: default:
:
never executed: default:
0
653 break;
never executed: break;
0
654 }-
655 ++p;-
656 }
never executed: end of block
0
657 }
never executed: end of block
0
658 return
never executed: return Qt::LeftToRight;
Qt::LeftToRight;
never executed: return Qt::LeftToRight;
0
659}-
660-
661-
662-
663-
664-
665-
666QString QTextBlock::text() const-
667{-
668 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
669 return
never executed: return QString();
QString();
never executed: return QString();
0
670-
671 const QString buffer = p->buffer();-
672 QString text;-
673 text.reserve(length());-
674-
675 const int pos = position();-
676 QTextDocumentPrivate::FragmentIterator it = p->find(pos);-
677 QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1);-
678 for (; it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
679 const QTextFragmentData * const frag = it.value();-
680 text += QString::fromRawData(buffer.constData() + frag->stringPosition, frag->size_array[0]);-
681 }
never executed: end of block
0
682-
683 return
never executed: return text;
text;
never executed: return text;
0
684}-
685QVector<QTextLayout::FormatRange> QTextBlock::textFormats() const-
686{-
687 QVector<QTextLayout::FormatRange> formats;-
688 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
689 return
never executed: return formats;
formats;
never executed: return formats;
0
690-
691 const QTextFormatCollection *formatCollection = p->formatCollection();-
692-
693 int start = 0;-
694 int cur = start;-
695 int format = -1;-
696-
697 const int pos = position();-
698 QTextDocumentPrivate::FragmentIterator it = p->find(pos);-
699 QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1);-
700 for (; it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
701 const QTextFragmentData * const frag = it.value();-
702 if (format != it.value()->format
format != it.value()->formatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
703 if (cur - start > 0
cur - start > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
704 QTextLayout::FormatRange range;-
705 range.start = start;-
706 range.length = cur - start;-
707 range.format = formatCollection->charFormat(format);-
708 formats.append(range);-
709 }
never executed: end of block
0
710-
711 format = frag->format;-
712 start = cur;-
713 }
never executed: end of block
0
714 cur += frag->size_array[0];-
715 }
never executed: end of block
0
716 if (cur - start > 0
cur - start > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
717 QTextLayout::FormatRange range;-
718 range.start = start;-
719 range.length = cur - start;-
720 range.format = formatCollection->charFormat(format);-
721 formats.append(range);-
722 }
never executed: end of block
0
723-
724 return
never executed: return formats;
formats;
never executed: return formats;
0
725}-
726-
727-
728-
729-
730-
731const QTextDocument *QTextBlock::document() const-
732{-
733 return
never executed: return p ? p->document() : 0;
p ? p->document() : 0;
never executed: return p ? p->document() : 0;
0
734}-
735-
736-
737-
738-
739-
740QTextList *QTextBlock::textList() const-
741{-
742 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
743 return
never executed: return 0;
0;
never executed: return 0;
0
744-
745 const QTextBlockFormat fmt = blockFormat();-
746 QTextObject *obj = p->document()->objectForFormat(fmt);-
747 return
never executed: return qobject_cast<QTextList *>(obj);
qobject_cast<QTextList *>(obj);
never executed: return qobject_cast<QTextList *>(obj);
0
748}-
749-
750-
751-
752-
753-
754-
755-
756QTextBlockUserData *QTextBlock::userData() const-
757{-
758 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
759 return
never executed: return 0;
0;
never executed: return 0;
0
760-
761 const QTextBlockData *b = p->blockMap().fragment(n);-
762 return
never executed: return b->userData;
b->userData;
never executed: return b->userData;
0
763}-
764void QTextBlock::setUserData(QTextBlockUserData *data)-
765{-
766 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
767 return;
never executed: return;
0
768-
769 const QTextBlockData *b = p->blockMap().fragment(n);-
770 if (data != b->userData
data != b->userDataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
771 delete b->userData;
never executed: delete b->userData;
0
772 b->userData = data;-
773}
never executed: end of block
0
774-
775-
776-
777-
778-
779-
780int QTextBlock::userState() const-
781{-
782 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
783 return
never executed: return -1;
-1;
never executed: return -1;
0
784-
785 const QTextBlockData *b = p->blockMap().fragment(n);-
786 return
never executed: return b->userState;
b->userState;
never executed: return b->userState;
0
787}-
788-
789-
790-
791-
792-
793-
794-
795void QTextBlock::setUserState(int state)-
796{-
797 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
798 return;
never executed: return;
0
799-
800 const QTextBlockData *b = p->blockMap().fragment(n);-
801 b->userState = state;-
802}
never executed: end of block
0
803int QTextBlock::revision() const-
804{-
805 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
806 return
never executed: return -1;
-1;
never executed: return -1;
0
807-
808 const QTextBlockData *b = p->blockMap().fragment(n);-
809 return
never executed: return b->revision;
b->revision;
never executed: return b->revision;
0
810}-
811void QTextBlock::setRevision(int rev)-
812{-
813 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
814 return;
never executed: return;
0
815-
816 const QTextBlockData *b = p->blockMap().fragment(n);-
817 b->revision = rev;-
818}
never executed: end of block
0
819bool QTextBlock::isVisible() const-
820{-
821 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
822 return
never executed: return true;
true;
never executed: return true;
0
823-
824 const QTextBlockData *b = p->blockMap().fragment(n);-
825 return
never executed: return !b->hidden;
!b->hidden;
never executed: return !b->hidden;
0
826}-
827void QTextBlock::setVisible(bool visible)-
828{-
829 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
830 return;
never executed: return;
0
831-
832 const QTextBlockData *b = p->blockMap().fragment(n);-
833 b->hidden = !visible;-
834}
never executed: end of block
0
835int QTextBlock::blockNumber() const-
836{-
837 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
838 return
never executed: return -1;
-1;
never executed: return -1;
0
839 return
never executed: return p->blockMap().position(n, 1);
p->blockMap().position(n, 1);
never executed: return p->blockMap().position(n, 1);
0
840}-
841int QTextBlock::firstLineNumber() const-
842{-
843 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
844 return
never executed: return -1;
-1;
never executed: return -1;
0
845 return
never executed: return p->blockMap().position(n, 2);
p->blockMap().position(n, 2);
never executed: return p->blockMap().position(n, 2);
0
846}-
847void QTextBlock::setLineCount(int count)-
848{-
849 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
850 return;
never executed: return;
0
851 p->blockMap().setSize(n, count, 2);-
852}
never executed: end of block
0
853-
854-
855-
856-
857-
858-
859-
860int QTextBlock::lineCount() const-
861{-
862 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
863 return
never executed: return -1;
-1;
never executed: return -1;
0
864 return
never executed: return p->blockMap().size(n, 2);
p->blockMap().size(n, 2);
never executed: return p->blockMap().size(n, 2);
0
865}-
866QTextBlock::iterator QTextBlock::begin() const-
867{-
868 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
869 return
never executed: return iterator();
iterator();
never executed: return iterator();
0
870-
871 int pos = position();-
872 int len = length() - 1;-
873 int b = p->fragmentMap().findNode(pos);-
874 int e = p->fragmentMap().findNode(pos+len);-
875 return
never executed: return iterator(p, b, e, b);
iterator(p, b, e, b);
never executed: return iterator(p, b, e, b);
0
876}-
877-
878-
879-
880-
881-
882-
883-
884QTextBlock::iterator QTextBlock::end() const-
885{-
886 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
887 return
never executed: return iterator();
iterator();
never executed: return iterator();
0
888-
889 int pos = position();-
890 int len = length() - 1;-
891 int b = p->fragmentMap().findNode(pos);-
892 int e = p->fragmentMap().findNode(pos+len);-
893 return
never executed: return iterator(p, b, e, e);
iterator(p, b, e, e);
never executed: return iterator(p, b, e, e);
0
894}-
895QTextBlock QTextBlock::next() const-
896{-
897 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
898 return
never executed: return QTextBlock();
QTextBlock();
never executed: return QTextBlock();
0
899-
900 return
never executed: return QTextBlock(p, p->blockMap().next(n));
QTextBlock(p, p->blockMap().next(n));
never executed: return QTextBlock(p, p->blockMap().next(n));
0
901}-
902QTextBlock QTextBlock::previous() const-
903{-
904 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
905 return
never executed: return QTextBlock();
QTextBlock();
never executed: return QTextBlock();
0
906-
907 return
never executed: return QTextBlock(p, p->blockMap().previous(n));
QTextBlock(p, p->blockMap().previous(n));
never executed: return QTextBlock(p, p->blockMap().previous(n));
0
908}-
909-
910-
911-
912-
913-
914QTextFragment QTextBlock::iterator::fragment() const-
915{-
916 int ne = n;-
917 int formatIndex = p->fragmentMap().fragment(n)->format;-
918 do {-
919 ne = p->fragmentMap().next(ne);-
920 }
never executed: end of block
while (ne != e
ne != eDescription
TRUEnever evaluated
FALSEnever evaluated
&& p->fragmentMap().fragment(ne)->format == formatIndex
p->fragmentMap...== formatIndexDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
921 return
never executed: return QTextFragment(p, n, ne);
QTextFragment(p, n, ne);
never executed: return QTextFragment(p, n, ne);
0
922}-
923-
924-
925-
926-
927-
928-
929-
930QTextBlock::iterator &QTextBlock::iterator::operator++()-
931{-
932 int ne = n;-
933 int formatIndex = p->fragmentMap().fragment(n)->format;-
934 do {-
935 ne = p->fragmentMap().next(ne);-
936 }
never executed: end of block
while (ne != e
ne != eDescription
TRUEnever evaluated
FALSEnever evaluated
&& p->fragmentMap().fragment(ne)->format == formatIndex
p->fragmentMap...== formatIndexDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
937 n = ne;-
938 return
never executed: return *this;
*this;
never executed: return *this;
0
939}-
940-
941-
942-
943-
944-
945-
946QTextBlock::iterator &QTextBlock::iterator::operator--()-
947{-
948 n = p->fragmentMap().previous(n);-
949-
950 if (n == b
n == bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
951 return
never executed: return *this;
*this;
never executed: return *this;
0
952-
953 int formatIndex = p->fragmentMap().fragment(n)->format;-
954 int last = n;-
955-
956 while (n != b
n != bDescription
TRUEnever evaluated
FALSEnever evaluated
&& p->fragmentMap().fragment(n)->format != formatIndex
p->fragmentMap...!= formatIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
957 last = n;-
958 n = p->fragmentMap().previous(n);-
959 }
never executed: end of block
0
960-
961 n = last;-
962 return
never executed: return *this;
*this;
never executed: return *this;
0
963}-
964QList<QGlyphRun> QTextFragment::glyphRuns(int pos, int len) const-
965{-
966 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
967 return
never executed: return QList<QGlyphRun>();
QList<QGlyphRun>();
never executed: return QList<QGlyphRun>();
0
968-
969 int blockNode = p->blockMap().findNode(position());-
970-
971 const QTextBlockData *blockData = p->blockMap().fragment(blockNode);-
972 QTextLayout *layout = blockData->layout;-
973-
974 int blockPosition = p->blockMap().position(blockNode);-
975 if (pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
976 pos = position() - blockPosition;
never executed: pos = position() - blockPosition;
0
977 if (len < 0
len < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
978 len = length();
never executed: len = length();
0
979 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
980 return
never executed: return QList<QGlyphRun>();
QList<QGlyphRun>();
never executed: return QList<QGlyphRun>();
0
981-
982 QList<QGlyphRun> ret;-
983 for (int i=0; i<layout->lineCount()
i<layout->lineCount()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
984 QTextLine textLine = layout->lineAt(i);-
985 ret += textLine.glyphRuns(pos, len);-
986 }
never executed: end of block
0
987-
988 return
never executed: return ret;
ret;
never executed: return ret;
0
989}-
990-
991-
992-
993-
994-
995int QTextFragment::position() const-
996{-
997 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
998 return
never executed: return 0;
0;
never executed: return 0;
0
999-
1000 return
never executed: return p->fragmentMap().position(n);
p->fragmentMap().position(n);
never executed: return p->fragmentMap().position(n);
0
1001}-
1002-
1003-
1004-
1005-
1006-
1007-
1008int QTextFragment::length() const-
1009{-
1010 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1011 return
never executed: return 0;
0;
never executed: return 0;
0
1012-
1013 int len = 0;-
1014 int f = n;-
1015 while (f != ne
f != neDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1016 len += p->fragmentMap().size(f);-
1017 f = p->fragmentMap().next(f);-
1018 }
never executed: end of block
0
1019 return
never executed: return len;
len;
never executed: return len;
0
1020}-
1021-
1022-
1023-
1024-
1025-
1026bool QTextFragment::contains(int position) const-
1027{-
1028 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1029 return
never executed: return false;
false;
never executed: return false;
0
1030 int pos = this->position();-
1031 return
never executed: return position >= pos && position < pos + length();
position >= pos && position < pos + length();
never executed: return position >= pos && position < pos + length();
0
1032}-
1033-
1034-
1035-
1036-
1037-
1038-
1039QTextCharFormat QTextFragment::charFormat() const-
1040{-
1041 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1042 return
never executed: return QTextCharFormat();
QTextCharFormat();
never executed: return QTextCharFormat();
0
1043 const QTextFragmentData *data = p->fragmentMap().fragment(n);-
1044 return
never executed: return p->formatCollection()->charFormat(data->format);
p->formatCollection()->charFormat(data->format);
never executed: return p->formatCollection()->charFormat(data->format);
0
1045}-
1046-
1047-
1048-
1049-
1050-
1051-
1052-
1053int QTextFragment::charFormatIndex() const-
1054{-
1055 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1056 return
never executed: return -1;
-1;
never executed: return -1;
0
1057 const QTextFragmentData *data = p->fragmentMap().fragment(n);-
1058 return
never executed: return data->format;
data->format;
never executed: return data->format;
0
1059}-
1060-
1061-
1062-
1063-
1064-
1065-
1066QString QTextFragment::text() const-
1067{-
1068 if (!p
!pDescription
TRUEnever evaluated
FALSEnever evaluated
|| !n
!nDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1069 return
never executed: return QString();
QString();
never executed: return QString();
0
1070-
1071 QString result;-
1072 QString buffer = p->buffer();-
1073 int f = n;-
1074 while (f != ne
f != neDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1075 const QTextFragmentData * const frag = p->fragmentMap().fragment(f);-
1076 result += QString(buffer.constData() + frag->stringPosition, frag->size_array[0]);-
1077 f = p->fragmentMap().next(f);-
1078 }
never executed: end of block
0
1079 return
never executed: return result;
result;
never executed: return result;
0
1080}-
1081-
1082-
Switch to Source codePreprocessed file

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