Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qtextlayout.h" | - |
41 | #include "qtextengine_p.h" | - |
42 | | - |
43 | #include <qthread.h> | - |
44 | #include <qfont.h> | - |
45 | #include <qmath.h> | - |
46 | #include <qpainter.h> | - |
47 | #include <qvarlengtharray.h> | - |
48 | #include <qtextformat.h> | - |
49 | #include <qabstracttextdocumentlayout.h> | - |
50 | #include "qtextdocument_p.h" | - |
51 | #include "qtextformat_p.h" | - |
52 | #include "qpainterpath.h" | - |
53 | #include "qglyphrun.h" | - |
54 | #include "qglyphrun_p.h" | - |
55 | #include "qrawfont.h" | - |
56 | #include "qrawfont_p.h" | - |
57 | #include <limits.h> | - |
58 | | - |
59 | #include <qdebug.h> | - |
60 | | - |
61 | #include "qfontengine_p.h" | - |
62 | #include <private/qpainter_p.h> | - |
63 | | - |
64 | QT_BEGIN_NAMESPACE | - |
65 | | - |
66 | #define ObjectSelectionBrush (QTextFormat::ForegroundBrush + 1) | - |
67 | #define SuppressText 0x5012 | - |
68 | #define SuppressBackground 0x513 | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | QRectF QTextInlineObject::rect() const | - |
158 | { | - |
159 | QScriptItem& si = eng->layoutData->items[itm]; | - |
160 | return QRectF(0, -si.ascent.toReal(), si.width.toReal(), si.height().toReal()); never executed: return QRectF(0, -si.ascent.toReal(), si.width.toReal(), si.height().toReal()); | 0 |
161 | } | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | qreal QTextInlineObject::width() const | - |
169 | { | - |
170 | return eng->layoutData->items[itm].width.toReal(); never executed: return eng->layoutData->items[itm].width.toReal(); | 0 |
171 | } | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | qreal QTextInlineObject::ascent() const | - |
179 | { | - |
180 | return eng->layoutData->items[itm].ascent.toReal(); never executed: return eng->layoutData->items[itm].ascent.toReal(); | 0 |
181 | } | - |
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | qreal QTextInlineObject::descent() const | - |
189 | { | - |
190 | return eng->layoutData->items[itm].descent.toReal(); never executed: return eng->layoutData->items[itm].descent.toReal(); | 0 |
191 | } | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | qreal QTextInlineObject::height() const | - |
200 | { | - |
201 | return eng->layoutData->items[itm].height().toReal(); never executed: return eng->layoutData->items[itm].height().toReal(); | 0 |
202 | } | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | void QTextInlineObject::setWidth(qreal w) | - |
210 | { | - |
211 | eng->layoutData->items[itm].width = QFixed::fromReal(w); | - |
212 | } never executed: end of block | 0 |
213 | | - |
214 | | - |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | void QTextInlineObject::setAscent(qreal a) | - |
220 | { | - |
221 | eng->layoutData->items[itm].ascent = QFixed::fromReal(a); | - |
222 | } never executed: end of block | 0 |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | void QTextInlineObject::setDescent(qreal d) | - |
230 | { | - |
231 | eng->layoutData->items[itm].descent = QFixed::fromReal(d); | - |
232 | } never executed: end of block | 0 |
233 | | - |
234 | | - |
235 | | - |
236 | | - |
237 | int QTextInlineObject::textPosition() const | - |
238 | { | - |
239 | return eng->layoutData->items[itm].position; never executed: return eng->layoutData->items[itm].position; | 0 |
240 | } | - |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | | - |
246 | int QTextInlineObject::formatIndex() const | - |
247 | { | - |
248 | return eng->formatIndex(&eng->layoutData->items[itm]); never executed: return eng->formatIndex(&eng->layoutData->items[itm]); | 0 |
249 | } | - |
250 | | - |
251 | | - |
252 | | - |
253 | | - |
254 | QTextFormat QTextInlineObject::format() const | - |
255 | { | - |
256 | return eng->format(&eng->layoutData->items[itm]); never executed: return eng->format(&eng->layoutData->items[itm]); | 0 |
257 | } | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | Qt::LayoutDirection QTextInlineObject::textDirection() const | - |
263 | { | - |
264 | return (eng->layoutData->items[itm].analysis.bidiLevel % 2 ? Qt::RightToLeft : Qt::LeftToRight); never executed: return (eng->layoutData->items[itm].analysis.bidiLevel % 2 ? Qt::RightToLeft : Qt::LeftToRight); | 0 |
265 | } | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | QTextLayout::QTextLayout() | - |
335 | { never executed: end of block d = new QTextEngine(); }never executed: end of block | 0 |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | QTextLayout::QTextLayout(const QString& text) | - |
341 | { | - |
342 | d = new QTextEngine(); | - |
343 | d->text = text; | - |
344 | } never executed: end of block | 0 |
345 | | - |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice) | - |
355 | { | - |
356 | QFont f(font); | - |
357 | if (paintdevice)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
358 | f = QFont(font, paintdevice); never executed: f = QFont(font, paintdevice); | 0 |
359 | d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f); | - |
360 | } never executed: end of block | 0 |
361 | | - |
362 | | - |
363 | | - |
364 | | - |
365 | | - |
366 | QTextLayout::QTextLayout(const QTextBlock &block) | - |
367 | { | - |
368 | d = new QTextEngine(); | - |
369 | d->block = block; | - |
370 | } never executed: end of block | 0 |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | QTextLayout::~QTextLayout() | - |
376 | { | - |
377 | if (!d->stackEngine)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
378 | delete d; never executed: delete d; | 0 |
379 | } never executed: end of block | 0 |
380 | | - |
381 | #ifndef QT_NO_RAWFONT | - |
382 | | - |
383 | | - |
384 | | - |
385 | | - |
386 | | - |
387 | | - |
388 | | - |
389 | void QTextLayout::setRawFont(const QRawFont &rawFont) | - |
390 | { | - |
391 | d->rawFont = rawFont; | - |
392 | d->useRawFont = true; | - |
393 | d->resetFontEngineCache(); | - |
394 | } never executed: end of block | 0 |
395 | #endif | - |
396 | | - |
397 | | - |
398 | | - |
399 | | - |
400 | | - |
401 | | - |
402 | | - |
403 | void QTextLayout::setFont(const QFont &font) | - |
404 | { | - |
405 | d->fnt = font; | - |
406 | #ifndef QT_NO_RAWFONT | - |
407 | d->useRawFont = false; | - |
408 | #endif | - |
409 | d->resetFontEngineCache(); | - |
410 | } never executed: end of block | 0 |
411 | | - |
412 | | - |
413 | | - |
414 | | - |
415 | | - |
416 | | - |
417 | | - |
418 | QFont QTextLayout::font() const | - |
419 | { | - |
420 | return d->font(); never executed: return d->font(); | 0 |
421 | } | - |
422 | | - |
423 | | - |
424 | | - |
425 | | - |
426 | | - |
427 | | - |
428 | | - |
429 | | - |
430 | | - |
431 | | - |
432 | void QTextLayout::setText(const QString& string) | - |
433 | { | - |
434 | d->invalidate(); | - |
435 | d->clearLineData(); | - |
436 | d->text = string; | - |
437 | } never executed: end of block | 0 |
438 | | - |
439 | | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | QString QTextLayout::text() const | - |
445 | { | - |
446 | return d->text; never executed: return d->text; | 0 |
447 | } | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | | - |
455 | void QTextLayout::setTextOption(const QTextOption &option) | - |
456 | { | - |
457 | d->option = option; | - |
458 | } never executed: end of block | 0 |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | | - |
465 | const QTextOption &QTextLayout::textOption() const | - |
466 | { | - |
467 | return d->option; never executed: return d->option; | 0 |
468 | } | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | void QTextLayout::setPreeditArea(int position, const QString &text) | - |
478 | { | - |
479 | if (d->preeditAreaPosition() == position && d->preeditAreaText() == text)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
480 | return; never executed: return; | 0 |
481 | d->setPreeditArea(position, text); | - |
482 | | - |
483 | if (d->block.docHandle())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
484 | d->block.docHandle()->documentChange(d->block.position(), d->block.length()); never executed: d->block.docHandle()->documentChange(d->block.position(), d->block.length()); | 0 |
485 | } never executed: end of block | 0 |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | int QTextLayout::preeditAreaPosition() const | - |
494 | { | - |
495 | return d->preeditAreaPosition(); never executed: return d->preeditAreaPosition(); | 0 |
496 | } | - |
497 | | - |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | QString QTextLayout::preeditAreaText() const | - |
504 | { | - |
505 | return d->preeditAreaText(); never executed: return d->preeditAreaText(); | 0 |
506 | } | - |
507 | | - |
508 | #if QT_DEPRECATED_SINCE(5, 6) | - |
509 | | - |
510 | | - |
511 | | - |
512 | void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList) | - |
513 | { | - |
514 | setFormats(formatList.toVector()); | - |
515 | } never executed: end of block | 0 |
516 | #endif // deprecated since 5.6 | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | | - |
526 | void QTextLayout::setFormats(const QVector<FormatRange> &formats) | - |
527 | { | - |
528 | d->setFormats(formats); | - |
529 | | - |
530 | if (d->block.docHandle())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
531 | d->block.docHandle()->documentChange(d->block.position(), d->block.length()); never executed: d->block.docHandle()->documentChange(d->block.position(), d->block.length()); | 0 |
532 | } never executed: end of block | 0 |
533 | | - |
534 | #if QT_DEPRECATED_SINCE(5, 6) | - |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | | - |
540 | QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const | - |
541 | { | - |
542 | return formats().toList(); never executed: return formats().toList(); | 0 |
543 | } | - |
544 | #endif // deprecated since 5.6 | - |
545 | | - |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | | - |
553 | QVector<QTextLayout::FormatRange> QTextLayout::formats() const | - |
554 | { | - |
555 | return d->formats(); never executed: return d->formats(); | 0 |
556 | } | - |
557 | | - |
558 | #if QT_DEPRECATED_SINCE(5, 6) | - |
559 | | - |
560 | | - |
561 | | - |
562 | void QTextLayout::clearAdditionalFormats() | - |
563 | { | - |
564 | clearFormats(); | - |
565 | } never executed: end of block | 0 |
566 | #endif // deprecated since 5.6 | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | | - |
573 | | - |
574 | | - |
575 | void QTextLayout::clearFormats() | - |
576 | { | - |
577 | setFormats(QVector<FormatRange>()); | - |
578 | } never executed: end of block | 0 |
579 | | - |
580 | | - |
581 | | - |
582 | | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | void QTextLayout::setCacheEnabled(bool enable) | - |
591 | { | - |
592 | d->cacheGlyphs = enable; | - |
593 | } never executed: end of block | 0 |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | | - |
600 | | - |
601 | bool QTextLayout::cacheEnabled() const | - |
602 | { | - |
603 | return d->cacheGlyphs; never executed: return d->cacheGlyphs; | 0 |
604 | } | - |
605 | | - |
606 | | - |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | | - |
612 | | - |
613 | | - |
614 | void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style) | - |
615 | { | - |
616 | d->visualMovement = style == Qt::VisualMoveStyle; | - |
617 | } never executed: end of block | 0 |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const | - |
626 | { | - |
627 | return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle; never executed: return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle; | 0 |
628 | } | - |
629 | | - |
630 | | - |
631 | | - |
632 | | - |
633 | | - |
634 | | - |
635 | void QTextLayout::beginLayout() | - |
636 | { | - |
637 | #ifndef QT_NO_DEBUG | - |
638 | if (d->layoutData && d->layoutData->layoutState == QTextEngine::InLayout) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
639 | qWarning("QTextLayout::beginLayout: Called while already doing layout"); | - |
640 | return; never executed: return; | 0 |
641 | } | - |
642 | #endif | - |
643 | d->invalidate(); | - |
644 | d->clearLineData(); | - |
645 | d->itemize(); | - |
646 | d->layoutData->layoutState = QTextEngine::InLayout; | - |
647 | } never executed: end of block | 0 |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | | - |
653 | | - |
654 | void QTextLayout::endLayout() | - |
655 | { | - |
656 | #ifndef QT_NO_DEBUG | - |
657 | if (!d->layoutData || d->layoutData->layoutState == QTextEngine::LayoutEmpty) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
658 | qWarning("QTextLayout::endLayout: Called without beginLayout()"); | - |
659 | return; never executed: return; | 0 |
660 | } | - |
661 | #endif | - |
662 | int l = d->lines.size(); | - |
663 | if (l && d->lines.at(l-1).length < 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
664 | QTextLine(l-1, d).setNumColumns(INT_MAX); | - |
665 | } never executed: end of block | 0 |
666 | d->layoutData->layoutState = QTextEngine::LayoutEmpty; | - |
667 | if (!d->cacheGlyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
668 | d->freeMemory(); never executed: d->freeMemory(); | 0 |
669 | } never executed: end of block | 0 |
670 | | - |
671 | | - |
672 | | - |
673 | | - |
674 | | - |
675 | | - |
676 | | - |
677 | void QTextLayout::clearLayout() | - |
678 | { | - |
679 | d->clearLineData(); | - |
680 | } never executed: end of block | 0 |
681 | | - |
682 | | - |
683 | | - |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const | - |
690 | { | - |
691 | const QCharAttributes *attributes = d->attributes(); | - |
692 | int len = d->block.isValid() ? d->block.length() - 1TRUE | never evaluated | FALSE | never evaluated |
| 0 |
693 | : d->layoutData->string.length(); | - |
694 | Q_ASSERT(len <= d->layoutData->string.length()); | - |
695 | if (!attributes || oldPos < 0 || oldPos >= len)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
696 | return oldPos; never executed: return oldPos; | 0 |
697 | | - |
698 | if (mode == SkipCharacters) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
699 | oldPos++; | - |
700 | while (oldPos < len && !attributes[oldPos].graphemeBoundary)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
701 | oldPos++; never executed: oldPos++; | 0 |
702 | } else { never executed: end of block | 0 |
703 | if (oldPos < len && d->atWordSeparator(oldPos)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
704 | oldPos++; | - |
705 | while (oldPos < len && d->atWordSeparator(oldPos))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
706 | oldPos++; never executed: oldPos++; | 0 |
707 | } else { never executed: end of block | 0 |
708 | while (oldPos < len && !attributes[oldPos].whiteSpace && !d->atWordSeparator(oldPos))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
709 | oldPos++; never executed: oldPos++; | 0 |
710 | } never executed: end of block | 0 |
711 | while (oldPos < len && attributes[oldPos].whiteSpace)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
712 | oldPos++; never executed: oldPos++; | 0 |
713 | } never executed: end of block | 0 |
714 | | - |
715 | return oldPos; never executed: return oldPos; | 0 |
716 | } | - |
717 | | - |
718 | | - |
719 | | - |
720 | | - |
721 | | - |
722 | | - |
723 | | - |
724 | | - |
725 | int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const | - |
726 | { | - |
727 | const QCharAttributes *attributes = d->attributes(); | - |
728 | int len = d->block.isValid() ? d->block.length() - 1TRUE | never evaluated | FALSE | never evaluated |
| 0 |
729 | : d->layoutData->string.length(); | - |
730 | Q_ASSERT(len <= d->layoutData->string.length()); | - |
731 | if (!attributes || oldPos <= 0 || oldPos > len)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
732 | return oldPos; never executed: return oldPos; | 0 |
733 | | - |
734 | if (mode == SkipCharacters) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
735 | oldPos--; | - |
736 | while (oldPos && !attributes[oldPos].graphemeBoundary)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
737 | oldPos--; never executed: oldPos--; | 0 |
738 | } else { never executed: end of block | 0 |
739 | while (oldPos > 0 && attributes[oldPos - 1].whiteSpace)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
740 | oldPos--; never executed: oldPos--; | 0 |
741 | | - |
742 | if (oldPos && d->atWordSeparator(oldPos-1)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
743 | oldPos--; | - |
744 | while (oldPos && d->atWordSeparator(oldPos-1))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
745 | oldPos--; never executed: oldPos--; | 0 |
746 | } else { never executed: end of block | 0 |
747 | while (oldPos > 0 && !attributes[oldPos - 1].whiteSpace && !d->atWordSeparator(oldPos-1))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
748 | oldPos--; never executed: oldPos--; | 0 |
749 | } never executed: end of block | 0 |
750 | } | - |
751 | | - |
752 | return oldPos; never executed: return oldPos; | 0 |
753 | } | - |
754 | | - |
755 | | - |
756 | | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | | - |
762 | int QTextLayout::rightCursorPosition(int oldPos) const | - |
763 | { | - |
764 | int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Right); | - |
765 | | - |
766 | return newPos; never executed: return newPos; | 0 |
767 | } | - |
768 | | - |
769 | | - |
770 | | - |
771 | | - |
772 | | - |
773 | | - |
774 | | - |
775 | | - |
776 | int QTextLayout::leftCursorPosition(int oldPos) const | - |
777 | { | - |
778 | int newPos = d->positionAfterVisualMovement(oldPos, QTextCursor::Left); | - |
779 | | - |
780 | return newPos; never executed: return newPos; | 0 |
781 | } | - |
782 | | - |
783 | | - |
784 | | - |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | bool QTextLayout::isValidCursorPosition(int pos) const | - |
799 | { | - |
800 | const QCharAttributes *attributes = d->attributes(); | - |
801 | if (!attributes || pos < 0 || pos > (int)d->layoutData->string.length())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
802 | return false; never executed: return false; | 0 |
803 | return attributes[pos].graphemeBoundary; never executed: return attributes[pos].graphemeBoundary; | 0 |
804 | } | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | | - |
814 | | - |
815 | | - |
816 | | - |
817 | | - |
818 | | - |
819 | | - |
820 | | - |
821 | | - |
822 | QTextLine QTextLayout::createLine() | - |
823 | { | - |
824 | #ifndef QT_NO_DEBUG | - |
825 | if (!d->layoutData || d->layoutData->layoutState == QTextEngine::LayoutEmpty) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
826 | qWarning("QTextLayout::createLine: Called without layouting"); | - |
827 | return QTextLine(); never executed: return QTextLine(); | 0 |
828 | } | - |
829 | #endif | - |
830 | if (d->layoutData->layoutState == QTextEngine::LayoutFailed)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
831 | return QTextLine(); never executed: return QTextLine(); | 0 |
832 | | - |
833 | int l = d->lines.size(); | - |
834 | if (l && d->lines.at(l-1).length < 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
835 | QTextLine(l-1, d).setNumColumns(INT_MAX); | - |
836 | } never executed: end of block | 0 |
837 | int from = l > 0 ? d->lines.at(l-1).from + d->lines.at(l-1).length + d->lines.at(l-1).trailingSpaces : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
838 | int strlen = d->layoutData->string.length(); | - |
839 | if (l && from >= strlen) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
840 | if (!d->lines.at(l-1).length || d->layoutData->string.at(strlen - 1) != QChar::LineSeparator)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
841 | return QTextLine(); never executed: return QTextLine(); | 0 |
842 | } never executed: end of block | 0 |
843 | | - |
844 | QScriptLine line; | - |
845 | line.from = from; | - |
846 | line.length = -1; | - |
847 | line.justified = false; | - |
848 | line.gridfitted = false; | - |
849 | | - |
850 | d->lines.append(line); | - |
851 | return QTextLine(l, d); never executed: return QTextLine(l, d); | 0 |
852 | } | - |
853 | | - |
854 | | - |
855 | | - |
856 | | - |
857 | | - |
858 | | - |
859 | int QTextLayout::lineCount() const | - |
860 | { | - |
861 | return d->lines.size(); never executed: return d->lines.size(); | 0 |
862 | } | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | QTextLine QTextLayout::lineAt(int i) const | - |
870 | { | - |
871 | return i < lineCount() ? QTextLine(i, d) : QTextLine(); never executed: return i < lineCount() ? QTextLine(i, d) : QTextLine(); | 0 |
872 | } | - |
873 | | - |
874 | | - |
875 | | - |
876 | | - |
877 | | - |
878 | | - |
879 | QTextLine QTextLayout::lineForTextPosition(int pos) const | - |
880 | { | - |
881 | int lineNum = d->lineNumberForTextPosition(pos); | - |
882 | return lineNum >= 0 ? lineAt(lineNum) : QTextLine(); never executed: return lineNum >= 0 ? lineAt(lineNum) : QTextLine(); | 0 |
883 | } | - |
884 | | - |
885 | | - |
886 | | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | | - |
892 | | - |
893 | QPointF QTextLayout::position() const | - |
894 | { | - |
895 | return d->position; never executed: return d->position; | 0 |
896 | } | - |
897 | | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | void QTextLayout::setPosition(const QPointF &p) | - |
904 | { | - |
905 | d->position = p; | - |
906 | } never executed: end of block | 0 |
907 | | - |
908 | | - |
909 | | - |
910 | | - |
911 | QRectF QTextLayout::boundingRect() const | - |
912 | { | - |
913 | if (d->lines.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
914 | return QRectF(); never executed: return QRectF(); | 0 |
915 | | - |
916 | QFixed xmax, ymax; | - |
917 | QFixed xmin = d->lines.at(0).x; | - |
918 | QFixed ymin = d->lines.at(0).y; | - |
919 | | - |
920 | for (int i = 0; i < d->lines.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
921 | const QScriptLine &si = d->lines[i]; | - |
922 | xmin = qMin(xmin, si.x); | - |
923 | ymin = qMin(ymin, si.y); | - |
924 | QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
925 | xmax = qMax(xmax, si.x+lineWidth); | - |
926 | | - |
927 | ymax = qMax(ymax, si.y+si.height().ceil()); | - |
928 | } never executed: end of block | 0 |
929 | return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal()); never executed: return QRectF(xmin.toReal(), ymin.toReal(), (xmax-xmin).toReal(), (ymax-ymin).toReal()); | 0 |
930 | } | - |
931 | | - |
932 | | - |
933 | | - |
934 | | - |
935 | | - |
936 | | - |
937 | | - |
938 | | - |
939 | | - |
940 | | - |
941 | qreal QTextLayout::minimumWidth() const | - |
942 | { | - |
943 | return d->minWidth.toReal(); never executed: return d->minWidth.toReal(); | 0 |
944 | } | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | | - |
950 | | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | qreal QTextLayout::maximumWidth() const | - |
956 | { | - |
957 | return d->maxWidth.toReal(); never executed: return d->maxWidth.toReal(); | 0 |
958 | } | - |
959 | | - |
960 | | - |
961 | | - |
962 | | - |
963 | | - |
964 | void QTextLayout::setFlags(int flags) | - |
965 | { | - |
966 | if (flags & Qt::TextJustificationForced) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
967 | d->option.setAlignment(Qt::AlignJustify); | - |
968 | d->forceJustification = true; | - |
969 | } never executed: end of block | 0 |
970 | | - |
971 | if (flags & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
972 | d->ignoreBidi = true; | - |
973 | d->option.setTextDirection((flags & Qt::TextForceLeftToRight) ? Qt::LeftToRight : Qt::RightToLeft); | - |
974 | } never executed: end of block | 0 |
975 | } never executed: end of block | 0 |
976 | | - |
977 | static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection, | - |
978 | QPainterPath *region, QRectF boundingRect) | - |
979 | { | - |
980 | const QScriptLine &line = eng->lines[lineNumber]; | - |
981 | | - |
982 | QTextLineItemIterator iterator(eng, lineNumber, pos, selection); | - |
983 | | - |
984 | | - |
985 | | - |
986 | const qreal selectionY = pos.y() + line.y.toReal(); | - |
987 | const qreal lineHeight = line.height().toReal(); | - |
988 | | - |
989 | QFixed lastSelectionX = iterator.x; | - |
990 | QFixed lastSelectionWidth; | - |
991 | | - |
992 | while (!iterator.atEnd()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
993 | iterator.next(); | - |
994 | | - |
995 | QFixed selectionX, selectionWidth; | - |
996 | if (iterator.getSelectionBounds(&selectionX, &selectionWidth)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
997 | if (selectionX == lastSelectionX + lastSelectionWidth) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
998 | lastSelectionWidth += selectionWidth; | - |
999 | continue; never executed: continue; | 0 |
1000 | } | - |
1001 | | - |
1002 | if (lastSelectionWidth > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1003 | QRectF rect = boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight); | - |
1004 | rect.moveLeft(qFloor(rect.left())); | - |
1005 | rect.moveTop(qFloor(rect.top())); | - |
1006 | region->addRect(rect); | - |
1007 | } never executed: end of block | 0 |
1008 | | - |
1009 | lastSelectionX = selectionX; | - |
1010 | lastSelectionWidth = selectionWidth; | - |
1011 | } never executed: end of block | 0 |
1012 | } never executed: end of block | 0 |
1013 | if (lastSelectionWidth > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1014 | QRectF rect = boundingRect & QRectF(lastSelectionX.toReal(), selectionY, lastSelectionWidth.toReal(), lineHeight); | - |
1015 | rect.moveLeft(qFloor(rect.left())); | - |
1016 | rect.moveTop(qFloor(rect.top())); | - |
1017 | region->addRect(rect); | - |
1018 | } never executed: end of block | 0 |
1019 | } never executed: end of block | 0 |
1020 | | - |
1021 | static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip) | - |
1022 | { | - |
1023 | return clip.isValid() ? (rect & clip) : rect; never executed: return clip.isValid() ? (rect & clip) : rect; | 0 |
1024 | } | - |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | | - |
1030 | | - |
1031 | | - |
1032 | | - |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | #if !defined(QT_NO_RAWFONT) | - |
1040 | QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const | - |
1041 | { | - |
1042 | if (from < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1043 | from = 0; never executed: from = 0; | 0 |
1044 | if (length < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1045 | length = text().length(); never executed: length = text().length(); | 0 |
1046 | | - |
1047 | QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphRunHash; | - |
1048 | for (int i=0; i<d->lines.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1049 | if (d->lines[i].from > from + length)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1050 | break; never executed: break; | 0 |
1051 | else if (d->lines[i].from + d->lines[i].length >= from) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1052 | QList<QGlyphRun> glyphRuns = QTextLine(i, d).glyphRuns(from, length); | - |
1053 | | - |
1054 | for (int j = 0; j < glyphRuns.size(); j++) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1055 | const QGlyphRun &glyphRun = glyphRuns.at(j); | - |
1056 | QRawFont rawFont = glyphRun.rawFont(); | - |
1057 | | - |
1058 | QFontEngine *fontEngine = rawFont.d->fontEngine; | - |
1059 | QGlyphRun::GlyphRunFlags flags = glyphRun.flags(); | - |
1060 | QPair<QFontEngine *, int> key(fontEngine, int(flags)); | - |
1061 | | - |
1062 | if (glyphRunHash.contains(key)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1063 | QGlyphRun &oldGlyphRun = glyphRunHash[key]; | - |
1064 | | - |
1065 | QVector<quint32> indexes = oldGlyphRun.glyphIndexes(); | - |
1066 | QVector<QPointF> positions = oldGlyphRun.positions(); | - |
1067 | QRectF boundingRect = oldGlyphRun.boundingRect(); | - |
1068 | | - |
1069 | indexes += glyphRun.glyphIndexes(); | - |
1070 | positions += glyphRun.positions(); | - |
1071 | boundingRect = boundingRect.united(glyphRun.boundingRect()); | - |
1072 | | - |
1073 | oldGlyphRun.setGlyphIndexes(indexes); | - |
1074 | oldGlyphRun.setPositions(positions); | - |
1075 | oldGlyphRun.setBoundingRect(boundingRect); | - |
1076 | } else { never executed: end of block | 0 |
1077 | glyphRunHash[key] = glyphRun; | - |
1078 | } never executed: end of block | 0 |
1079 | } | - |
1080 | } never executed: end of block | 0 |
1081 | } never executed: end of block | 0 |
1082 | | - |
1083 | return glyphRunHash.values(); never executed: return glyphRunHash.values(); | 0 |
1084 | } | - |
1085 | #endif // QT_NO_RAWFONT | - |
1086 | | - |
1087 | | - |
1088 | | - |
1089 | | - |
1090 | | - |
1091 | | - |
1092 | void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRange> &selections, const QRectF &clip) const | - |
1093 | { | - |
1094 | if (d->lines.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1095 | return; never executed: return; | 0 |
1096 | | - |
1097 | if (!d->layoutData)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1098 | d->itemize(); never executed: d->itemize(); | 0 |
1099 | | - |
1100 | QPointF position = pos + d->position; | - |
1101 | | - |
1102 | QFixed clipy = (INT_MIN/256); | - |
1103 | QFixed clipe = (INT_MAX/256); | - |
1104 | if (clip.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1105 | clipy = QFixed::fromReal(clip.y() - position.y()); | - |
1106 | clipe = clipy + QFixed::fromReal(clip.height()); | - |
1107 | } never executed: end of block | 0 |
1108 | | - |
1109 | int firstLine = 0; | - |
1110 | int lastLine = d->lines.size(); | - |
1111 | for (int i = 0; i < d->lines.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1112 | QTextLine l(i, d); | - |
1113 | const QScriptLine &sl = d->lines[i]; | - |
1114 | | - |
1115 | if (sl.y > clipe) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1116 | lastLine = i; | - |
1117 | break; never executed: break; | 0 |
1118 | } | - |
1119 | if ((sl.y + sl.height()) < clipy) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1120 | firstLine = i; | - |
1121 | continue; never executed: continue; | 0 |
1122 | } | - |
1123 | } never executed: end of block | 0 |
1124 | | - |
1125 | QPainterPath excludedRegion; | - |
1126 | QPainterPath textDoneRegion; | - |
1127 | for (int i = 0; i < selections.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1128 | FormatRange selection = selections.at(i); | - |
1129 | const QBrush bg = selection.format.background(); | - |
1130 | | - |
1131 | QPainterPath region; | - |
1132 | region.setFillRule(Qt::WindingFill); | - |
1133 | | - |
1134 | for (int line = firstLine; line < lastLine; ++line) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1135 | const QScriptLine &sl = d->lines[line]; | - |
1136 | QTextLine tl(line, d); | - |
1137 | | - |
1138 | QRectF lineRect(tl.naturalTextRect()); | - |
1139 | lineRect.translate(position); | - |
1140 | lineRect.adjust(0, 0, d->leadingSpaceWidth(sl).toReal(), 0); | - |
1141 | | - |
1142 | bool isLastLineInBlock = (line == d->lines.size()-1); | - |
1143 | int sl_length = sl.length + (isLastLineInBlock? 1 : 0); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1144 | | - |
1145 | | - |
1146 | if (sl.from > selection.start + selection.length || sl.from + sl_length <= selection.start)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1147 | continue; never executed: continue; | 0 |
1148 | | - |
1149 | const bool selectionStartInLine = sl.from <= selection.start; | - |
1150 | const bool selectionEndInLine = selection.start + selection.length < sl.from + sl_length; | - |
1151 | | - |
1152 | if (sl.length && (selectionStartInLine || selectionEndInLine)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1153 | addSelectedRegionsToPath(d, line, position, &selection, ®ion, clipIfValid(lineRect, clip)); | - |
1154 | } else { never executed: end of block | 0 |
1155 | region.addRect(clipIfValid(lineRect, clip)); | - |
1156 | } never executed: end of block | 0 |
1157 | | - |
1158 | if (selection.format.boolProperty(QTextFormat::FullWidthSelection)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1159 | QRectF fullLineRect(tl.rect()); | - |
1160 | fullLineRect.translate(position); | - |
1161 | fullLineRect.setRight(QFIXED_MAX); | - |
1162 | if (!selectionEndInLine)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1163 | region.addRect(clipIfValid(QRectF(lineRect.topRight(), fullLineRect.bottomRight()), clip)); never executed: region.addRect(clipIfValid(QRectF(lineRect.topRight(), fullLineRect.bottomRight()), clip)); | 0 |
1164 | if (!selectionStartInLine)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1165 | region.addRect(clipIfValid(QRectF(fullLineRect.topLeft(), lineRect.bottomLeft()), clip)); never executed: region.addRect(clipIfValid(QRectF(fullLineRect.topLeft(), lineRect.bottomLeft()), clip)); | 0 |
1166 | } else if (!selectionEndInLine never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1167 | && isLastLineInBlockTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1168 | &&!(d->option.flags() & QTextOption::ShowLineAndParagraphSeparators)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1169 | region.addRect(clipIfValid(QRectF(lineRect.right(), lineRect.top(), | - |
1170 | lineRect.height()/4, lineRect.height()), clip)); | - |
1171 | } never executed: end of block | 0 |
1172 | | - |
1173 | } never executed: end of block | 0 |
1174 | { | - |
1175 | const QPen oldPen = p->pen(); | - |
1176 | const QBrush oldBrush = p->brush(); | - |
1177 | | - |
1178 | p->setPen(selection.format.penProperty(QTextFormat::OutlinePen)); | - |
1179 | p->setBrush(selection.format.brushProperty(QTextFormat::BackgroundBrush)); | - |
1180 | p->drawPath(region); | - |
1181 | | - |
1182 | p->setPen(oldPen); | - |
1183 | p->setBrush(oldBrush); | - |
1184 | } | - |
1185 | | - |
1186 | | - |
1187 | | - |
1188 | bool hasText = (selection.format.foreground().style() != Qt::NoBrush); | - |
1189 | bool hasBackground= (selection.format.background().style() != Qt::NoBrush); | - |
1190 | | - |
1191 | if (hasBackground) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1192 | selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush)); | - |
1193 | | - |
1194 | | - |
1195 | selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush()); | - |
1196 | selection.format.clearProperty(QTextFormat::OutlinePen); | - |
1197 | } never executed: end of block | 0 |
1198 | | - |
1199 | selection.format.setProperty(SuppressText, !hasText); | - |
1200 | | - |
1201 | if (hasText && !hasBackground && !(textDoneRegion & region).isEmpty())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1202 | continue; never executed: continue; | 0 |
1203 | | - |
1204 | p->save(); | - |
1205 | p->setClipPath(region, Qt::IntersectClip); | - |
1206 | | - |
1207 | for (int line = firstLine; line < lastLine; ++line) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1208 | QTextLine l(line, d); | - |
1209 | l.draw(p, position, &selection); | - |
1210 | } never executed: end of block | 0 |
1211 | p->restore(); | - |
1212 | | - |
1213 | if (hasText) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1214 | textDoneRegion += region; | - |
1215 | } else { never executed: end of block | 0 |
1216 | if (hasBackground)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1217 | textDoneRegion -= region; never executed: textDoneRegion -= region; | 0 |
1218 | } never executed: end of block | 0 |
1219 | | - |
1220 | excludedRegion += region; | - |
1221 | } never executed: end of block | 0 |
1222 | | - |
1223 | QPainterPath needsTextButNoBackground = excludedRegion - textDoneRegion; | - |
1224 | if (!needsTextButNoBackground.isEmpty()){TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1225 | p->save(); | - |
1226 | p->setClipPath(needsTextButNoBackground, Qt::IntersectClip); | - |
1227 | FormatRange selection; | - |
1228 | selection.start = 0; | - |
1229 | selection.length = INT_MAX; | - |
1230 | selection.format.setProperty(SuppressBackground, true); | - |
1231 | for (int line = firstLine; line < lastLine; ++line) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1232 | QTextLine l(line, d); | - |
1233 | l.draw(p, position, &selection); | - |
1234 | } never executed: end of block | 0 |
1235 | p->restore(); | - |
1236 | } never executed: end of block | 0 |
1237 | | - |
1238 | if (!excludedRegion.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1239 | p->save(); | - |
1240 | QPainterPath path; | - |
1241 | QRectF br = boundingRect().translated(position); | - |
1242 | br.setRight(QFIXED_MAX); | - |
1243 | if (!clip.isNull())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1244 | br = br.intersected(clip); never executed: br = br.intersected(clip); | 0 |
1245 | path.addRect(br); | - |
1246 | path -= excludedRegion; | - |
1247 | p->setClipPath(path, Qt::IntersectClip); | - |
1248 | } never executed: end of block | 0 |
1249 | | - |
1250 | for (int i = firstLine; i < lastLine; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1251 | QTextLine l(i, d); | - |
1252 | l.draw(p, position); | - |
1253 | } never executed: end of block | 0 |
1254 | if (!excludedRegion.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1255 | p->restore(); never executed: p->restore(); | 0 |
1256 | | - |
1257 | | - |
1258 | if (!d->cacheGlyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1259 | d->freeMemory(); never executed: d->freeMemory(); | 0 |
1260 | } never executed: end of block | 0 |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | | - |
1267 | | - |
1268 | | - |
1269 | | - |
1270 | void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const | - |
1271 | { | - |
1272 | drawCursor(p, pos, cursorPosition, 1); | - |
1273 | } never executed: end of block | 0 |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | | - |
1278 | | - |
1279 | | - |
1280 | | - |
1281 | | - |
1282 | void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition, int width) const | - |
1283 | { | - |
1284 | if (d->lines.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1285 | return; never executed: return; | 0 |
1286 | | - |
1287 | if (!d->layoutData)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1288 | d->itemize(); never executed: d->itemize(); | 0 |
1289 | | - |
1290 | QPointF position = pos + d->position; | - |
1291 | | - |
1292 | cursorPosition = qBound(0, cursorPosition, d->layoutData->string.length()); | - |
1293 | int line = d->lineNumberForTextPosition(cursorPosition); | - |
1294 | if (line < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1295 | line = 0; never executed: line = 0; | 0 |
1296 | if (line >= d->lines.size())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1297 | return; never executed: return; | 0 |
1298 | | - |
1299 | QTextLine l(line, d); | - |
1300 | const QScriptLine &sl = d->lines[line]; | - |
1301 | | - |
1302 | qreal x = position.x() + l.cursorToX(cursorPosition); | - |
1303 | | - |
1304 | int itm; | - |
1305 | | - |
1306 | if (d->visualCursorMovement()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1307 | if (cursorPosition == sl.from + sl.length)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1308 | cursorPosition--; never executed: cursorPosition--; | 0 |
1309 | itm = d->findItem(cursorPosition); | - |
1310 | } else never executed: end of block | 0 |
1311 | itm = d->findItem(cursorPosition - 1); never executed: itm = d->findItem(cursorPosition - 1); | 0 |
1312 | | - |
1313 | QFixed base = sl.base(); | - |
1314 | QFixed descent = sl.descent; | - |
1315 | bool rightToLeft = d->isRightToLeft(); | - |
1316 | if (itm >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1317 | const QScriptItem &si = d->layoutData->items.at(itm); | - |
1318 | if (si.ascent > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1319 | base = si.ascent; never executed: base = si.ascent; | 0 |
1320 | if (si.descent > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1321 | descent = si.descent; never executed: descent = si.descent; | 0 |
1322 | rightToLeft = si.analysis.bidiLevel % 2; | - |
1323 | } never executed: end of block | 0 |
1324 | qreal y = position.y() + (sl.y + sl.base() - base).toReal(); | - |
1325 | bool toggleAntialiasing = !(p->renderHints() & QPainter::Antialiasing)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1326 | && (p->transform().type() > QTransform::TxTranslate);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1327 | if (toggleAntialiasing)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1328 | p->setRenderHint(QPainter::Antialiasing); never executed: p->setRenderHint(QPainter::Antialiasing); | 0 |
1329 | p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush()); | - |
1330 | if (toggleAntialiasing)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1331 | p->setRenderHint(QPainter::Antialiasing, false); never executed: p->setRenderHint(QPainter::Antialiasing, false); | 0 |
1332 | if (d->layoutData->hasBidi) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1333 | const int arrow_extent = 4; | - |
1334 | int sign = rightToLeft ? -1 : 1;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1335 | p->drawLine(QLineF(x, y, x + (sign * arrow_extent/2), y + arrow_extent/2)); | - |
1336 | p->drawLine(QLineF(x, y+arrow_extent, x + (sign * arrow_extent/2), y + arrow_extent/2)); | - |
1337 | } never executed: end of block | 0 |
1338 | return; never executed: return; | 0 |
1339 | } | - |
1340 | | - |
1341 | | - |
1342 | | - |
1343 | | - |
1344 | | - |
1345 | | - |
1346 | | - |
1347 | | - |
1348 | | - |
1349 | | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | | - |
1354 | | - |
1355 | | - |
1356 | | - |
1357 | | - |
1358 | | - |
1359 | | - |
1360 | | - |
1361 | | - |
1362 | | - |
1363 | | - |
1364 | | - |
1365 | | - |
1366 | | - |
1367 | | - |
1368 | | - |
1369 | | - |
1370 | | - |
1371 | | - |
1372 | | - |
1373 | | - |
1374 | | - |
1375 | | - |
1376 | | - |
1377 | | - |
1378 | | - |
1379 | | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | | - |
1386 | | - |
1387 | | - |
1388 | | - |
1389 | | - |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | | - |
1396 | | - |
1397 | | - |
1398 | | - |
1399 | | - |
1400 | | - |
1401 | | - |
1402 | | - |
1403 | | - |
1404 | | - |
1405 | | - |
1406 | | - |
1407 | QRectF QTextLine::rect() const | - |
1408 | { | - |
1409 | const QScriptLine& sl = eng->lines[index]; | - |
1410 | return QRectF(sl.x.toReal(), sl.y.toReal(), sl.width.toReal(), sl.height().toReal()); never executed: return QRectF(sl.x.toReal(), sl.y.toReal(), sl.width.toReal(), sl.height().toReal()); | 0 |
1411 | } | - |
1412 | | - |
1413 | | - |
1414 | | - |
1415 | | - |
1416 | QRectF QTextLine::naturalTextRect() const | - |
1417 | { | - |
1418 | const QScriptLine& sl = eng->lines[index]; | - |
1419 | QFixed x = sl.x + eng->alignLine(sl); | - |
1420 | | - |
1421 | QFixed width = sl.textWidth; | - |
1422 | if (sl.justified)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1423 | width = sl.width; never executed: width = sl.width; | 0 |
1424 | | - |
1425 | return QRectF(x.toReal(), sl.y.toReal(), width.toReal(), sl.height().toReal()); never executed: return QRectF(x.toReal(), sl.y.toReal(), width.toReal(), sl.height().toReal()); | 0 |
1426 | } | - |
1427 | | - |
1428 | | - |
1429 | | - |
1430 | | - |
1431 | | - |
1432 | | - |
1433 | qreal QTextLine::x() const | - |
1434 | { | - |
1435 | return eng->lines[index].x.toReal(); never executed: return eng->lines[index].x.toReal(); | 0 |
1436 | } | - |
1437 | | - |
1438 | | - |
1439 | | - |
1440 | | - |
1441 | | - |
1442 | | - |
1443 | qreal QTextLine::y() const | - |
1444 | { | - |
1445 | return eng->lines[index].y.toReal(); never executed: return eng->lines[index].y.toReal(); | 0 |
1446 | } | - |
1447 | | - |
1448 | | - |
1449 | | - |
1450 | | - |
1451 | | - |
1452 | | - |
1453 | qreal QTextLine::width() const | - |
1454 | { | - |
1455 | return eng->lines[index].width.toReal(); never executed: return eng->lines[index].width.toReal(); | 0 |
1456 | } | - |
1457 | | - |
1458 | | - |
1459 | | - |
1460 | | - |
1461 | | - |
1462 | | - |
1463 | | - |
1464 | qreal QTextLine::ascent() const | - |
1465 | { | - |
1466 | return eng->lines[index].ascent.toReal(); never executed: return eng->lines[index].ascent.toReal(); | 0 |
1467 | } | - |
1468 | | - |
1469 | | - |
1470 | | - |
1471 | | - |
1472 | | - |
1473 | | - |
1474 | qreal QTextLine::descent() const | - |
1475 | { | - |
1476 | return eng->lines[index].descent.toReal(); never executed: return eng->lines[index].descent.toReal(); | 0 |
1477 | } | - |
1478 | | - |
1479 | | - |
1480 | | - |
1481 | | - |
1482 | | - |
1483 | | - |
1484 | | - |
1485 | | - |
1486 | qreal QTextLine::height() const | - |
1487 | { | - |
1488 | return eng->lines[index].height().ceil().toReal(); never executed: return eng->lines[index].height().ceil().toReal(); | 0 |
1489 | } | - |
1490 | | - |
1491 | | - |
1492 | | - |
1493 | | - |
1494 | | - |
1495 | | - |
1496 | | - |
1497 | | - |
1498 | qreal QTextLine::leading() const | - |
1499 | { | - |
1500 | return eng->lines[index].leading.toReal(); never executed: return eng->lines[index].leading.toReal(); | 0 |
1501 | } | - |
1502 | | - |
1503 | | - |
1504 | | - |
1505 | | - |
1506 | | - |
1507 | | - |
1508 | | - |
1509 | | - |
1510 | | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | | - |
1515 | | - |
1516 | | - |
1517 | void QTextLine::setLeadingIncluded(bool included) | - |
1518 | { | - |
1519 | eng->lines[index].leadingIncluded= included; | - |
1520 | | - |
1521 | } never executed: end of block | 0 |
1522 | | - |
1523 | | - |
1524 | | - |
1525 | | - |
1526 | | - |
1527 | | - |
1528 | | - |
1529 | | - |
1530 | | - |
1531 | | - |
1532 | | - |
1533 | bool QTextLine::leadingIncluded() const | - |
1534 | { | - |
1535 | return eng->lines[index].leadingIncluded; never executed: return eng->lines[index].leadingIncluded; | 0 |
1536 | } | - |
1537 | | - |
1538 | | - |
1539 | | - |
1540 | | - |
1541 | | - |
1542 | | - |
1543 | qreal QTextLine::naturalTextWidth() const | - |
1544 | { | - |
1545 | return eng->lines[index].textWidth.toReal(); never executed: return eng->lines[index].textWidth.toReal(); | 0 |
1546 | } | - |
1547 | | - |
1548 | | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | | - |
1554 | | - |
1555 | | - |
1556 | | - |
1557 | | - |
1558 | qreal QTextLine::horizontalAdvance() const | - |
1559 | { | - |
1560 | return eng->lines[index].textAdvance.toReal(); never executed: return eng->lines[index].textAdvance.toReal(); | 0 |
1561 | } | - |
1562 | | - |
1563 | | - |
1564 | | - |
1565 | | - |
1566 | | - |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | void QTextLine::setLineWidth(qreal width) | - |
1571 | { | - |
1572 | QScriptLine &line = eng->lines[index]; | - |
1573 | if (!eng->layoutData) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1574 | qWarning("QTextLine: Can't set a line width while not layouting."); | - |
1575 | return; never executed: return; | 0 |
1576 | } | - |
1577 | | - |
1578 | if (width > QFIXED_MAX)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1579 | width = QFIXED_MAX; never executed: width = (2147483647/256); | 0 |
1580 | | - |
1581 | line.width = QFixed::fromReal(width); | - |
1582 | if (line.lengthTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1583 | && line.textWidth <= line.widthTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1584 | && line.from + line.length == eng->layoutData->string.length())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1585 | | - |
1586 | | - |
1587 | return; never executed: return; | 0 |
1588 | line.length = 0; | - |
1589 | line.textWidth = 0; | - |
1590 | | - |
1591 | layout_helper(INT_MAX); | - |
1592 | } never executed: end of block | 0 |
1593 | | - |
1594 | | - |
1595 | | - |
1596 | | - |
1597 | | - |
1598 | | - |
1599 | | - |
1600 | | - |
1601 | void QTextLine::setNumColumns(int numColumns) | - |
1602 | { | - |
1603 | QScriptLine &line = eng->lines[index]; | - |
1604 | line.width = QFIXED_MAX; | - |
1605 | line.length = 0; | - |
1606 | line.textWidth = 0; | - |
1607 | layout_helper(numColumns); | - |
1608 | } never executed: end of block | 0 |
1609 | | - |
1610 | | - |
1611 | | - |
1612 | | - |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | | - |
1618 | void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth) | - |
1619 | { | - |
1620 | QScriptLine &line = eng->lines[index]; | - |
1621 | line.width = QFixed::fromReal(alignmentWidth); | - |
1622 | line.length = 0; | - |
1623 | line.textWidth = 0; | - |
1624 | layout_helper(numColumns); | - |
1625 | } never executed: end of block | 0 |
1626 | | - |
1627 | #if 0 | - |
1628 | #define LB_DEBUG qDebug | - |
1629 | #else | - |
1630 | #define LB_DEBUG if (0) qDebug | - |
1631 | #endif | - |
1632 | | - |
1633 | namespace { | - |
1634 | | - |
1635 | struct LineBreakHelper | - |
1636 | { | - |
1637 | LineBreakHelper() | - |
1638 | : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0), | - |
1639 | manualWrap(false), whiteSpaceOrObject(true) | - |
1640 | { | - |
1641 | } never executed: end of block | 0 |
1642 | | - |
1643 | | - |
1644 | QScriptLine tmpData; | - |
1645 | QScriptLine spaceData; | - |
1646 | | - |
1647 | QGlyphLayout glyphs; | - |
1648 | | - |
1649 | int glyphCount; | - |
1650 | int maxGlyphs; | - |
1651 | int currentPosition; | - |
1652 | glyph_t previousGlyph; | - |
1653 | | - |
1654 | QFixed minw; | - |
1655 | QFixed softHyphenWidth; | - |
1656 | QFixed rightBearing; | - |
1657 | QFixed minimumRightBearing; | - |
1658 | | - |
1659 | QFontEngine *fontEngine; | - |
1660 | const unsigned short *logClusters; | - |
1661 | | - |
1662 | bool manualWrap; | - |
1663 | bool whiteSpaceOrObject; | - |
1664 | | - |
1665 | bool checkFullOtherwiseExtend(QScriptLine &line); | - |
1666 | | - |
1667 | QFixed calculateNewWidth(const QScriptLine &line) const { | - |
1668 | return line.textWidth + tmpData.textWidth + spaceData.textWidth never executed: return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + negativeRightBearing(); | 0 |
1669 | + softHyphenWidth + negativeRightBearing(); never executed: return line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + negativeRightBearing(); | 0 |
1670 | } | - |
1671 | | - |
1672 | inline glyph_t currentGlyph() const | - |
1673 | { | - |
1674 | Q_ASSERT(currentPosition > 0); | - |
1675 | Q_ASSERT(logClusters[currentPosition - 1] < glyphs.numGlyphs); | - |
1676 | | - |
1677 | return glyphs.glyphs[logClusters[currentPosition - 1]]; never executed: return glyphs.glyphs[logClusters[currentPosition - 1]]; | 0 |
1678 | } | - |
1679 | | - |
1680 | inline void saveCurrentGlyph() | - |
1681 | { | - |
1682 | previousGlyph = 0; | - |
1683 | if (currentPosition > 0 &&TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1684 | logClusters[currentPosition - 1] < glyphs.numGlyphs) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1685 | previousGlyph = currentGlyph(); | - |
1686 | } never executed: end of block | 0 |
1687 | } never executed: end of block | 0 |
1688 | | - |
1689 | inline void calculateRightBearing(glyph_t glyph) | - |
1690 | { | - |
1691 | qreal rb; | - |
1692 | fontEngine->getGlyphBearings(glyph, 0, &rb); | - |
1693 | | - |
1694 | | - |
1695 | | - |
1696 | | - |
1697 | | - |
1698 | rightBearing = qMin(QFixed::fromReal(rb), QFixed(0)); | - |
1699 | } never executed: end of block | 0 |
1700 | | - |
1701 | inline void calculateRightBearing() | - |
1702 | { | - |
1703 | if (currentPosition <= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1704 | return; never executed: return; | 0 |
1705 | calculateRightBearing(currentGlyph()); | - |
1706 | } never executed: end of block | 0 |
1707 | | - |
1708 | inline void calculateRightBearingForPreviousGlyph() | - |
1709 | { | - |
1710 | if (previousGlyph > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1711 | calculateRightBearing(previousGlyph); never executed: calculateRightBearing(previousGlyph); | 0 |
1712 | } never executed: end of block | 0 |
1713 | | - |
1714 | static const QFixed RightBearingNotCalculated; | - |
1715 | | - |
1716 | inline void resetRightBearing() | - |
1717 | { | - |
1718 | rightBearing = RightBearingNotCalculated; | - |
1719 | } never executed: end of block | 0 |
1720 | | - |
1721 | | - |
1722 | | - |
1723 | inline QFixed negativeRightBearing() const | - |
1724 | { | - |
1725 | if (rightBearing == RightBearingNotCalculated)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1726 | return QFixed(0); never executed: return QFixed(0); | 0 |
1727 | | - |
1728 | return qAbs(rightBearing); never executed: return qAbs(rightBearing); | 0 |
1729 | } | - |
1730 | }; | - |
1731 | | - |
1732 | const QFixed LineBreakHelper::RightBearingNotCalculated = QFixed(1); | - |
1733 | | - |
1734 | inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) | - |
1735 | { | - |
1736 | LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); dead code: QMessageLogger(__FILE__, 1736, __PRETTY_FUNCTION__).debug("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); | - |
1737 | | - |
1738 | QFixed newWidth = calculateNewWidth(line); | - |
1739 | if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1740 | return true; never executed: return true; | 0 |
1741 | | - |
1742 | minw = qMax(minw, tmpData.textWidth); | - |
1743 | line += tmpData; | - |
1744 | line.textWidth += spaceData.textWidth; | - |
1745 | | - |
1746 | line.length += spaceData.length; | - |
1747 | tmpData.textWidth = 0; | - |
1748 | tmpData.length = 0; | - |
1749 | spaceData.textWidth = 0; | - |
1750 | spaceData.length = 0; | - |
1751 | | - |
1752 | return false; never executed: return false; | 0 |
1753 | } | - |
1754 | | - |
1755 | } | - |
1756 | | - |
1757 | | - |
1758 | static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount, | - |
1759 | const QScriptItem ¤t, const unsigned short *logClusters, | - |
1760 | const QGlyphLayout &glyphs) | - |
1761 | { | - |
1762 | int glyphPosition = logClusters[pos]; | - |
1763 | do { | - |
1764 | ++pos; | - |
1765 | ++line.length; | - |
1766 | } while (pos < end && logClusters[pos] == glyphPosition); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1767 | do { | - |
1768 | if (!glyphs.attributes[glyphPosition].dontPrint)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1769 | line.textWidth += glyphs.advances[glyphPosition]; never executed: line.textWidth += glyphs.advances[glyphPosition]; | 0 |
1770 | ++glyphPosition; | - |
1771 | } while (glyphPosition < current.num_glyphs && !glyphs.attributes[glyphPosition].clusterStart); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1772 | | - |
1773 | Q_ASSERT((pos == end && glyphPosition == current.num_glyphs) || logClusters[pos] == glyphPosition); | - |
1774 | | - |
1775 | ++glyphCount; | - |
1776 | } never executed: end of block | 0 |
1777 | | - |
1778 | | - |
1779 | | - |
1780 | void QTextLine::layout_helper(int maxGlyphs) | - |
1781 | { | - |
1782 | QScriptLine &line = eng->lines[index]; | - |
1783 | line.length = 0; | - |
1784 | line.trailingSpaces = 0; | - |
1785 | line.textWidth = 0; | - |
1786 | line.hasTrailingSpaces = false; | - |
1787 | | - |
1788 | if (!eng->layoutData->items.size() || line.from >= eng->layoutData->string.length()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1789 | line.setDefaultHeight(eng); | - |
1790 | return; never executed: return; | 0 |
1791 | } | - |
1792 | | - |
1793 | Q_ASSERT(line.from < eng->layoutData->string.length()); | - |
1794 | | - |
1795 | LineBreakHelper lbh; | - |
1796 | | - |
1797 | lbh.maxGlyphs = maxGlyphs; | - |
1798 | | - |
1799 | QTextOption::WrapMode wrapMode = eng->option.wrapMode(); | - |
1800 | bool breakany = (wrapMode == QTextOption::WrapAnywhere); | - |
1801 | lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1802 | | - |
1803 | int item = -1; | - |
1804 | int newItem = eng->findItem(line.from); | - |
1805 | Q_ASSERT(newItem >= 0); | - |
1806 | | - |
1807 | LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); dead code: QMessageLogger(__FILE__, 1807, __PRETTY_FUNCTION__).debug("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); | - |
1808 | | - |
1809 | Qt::Alignment alignment = eng->option.alignment(); | - |
1810 | | - |
1811 | const QCharAttributes *attributes = eng->attributes(); | - |
1812 | if (!attributes)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1813 | return; never executed: return; | 0 |
1814 | lbh.currentPosition = line.from; | - |
1815 | int end = 0; | - |
1816 | lbh.logClusters = eng->layoutData->logClustersPtr; | - |
1817 | lbh.previousGlyph = 0; | - |
1818 | | - |
1819 | while (newItem < eng->layoutData->items.size()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1820 | lbh.resetRightBearing(); | - |
1821 | lbh.softHyphenWidth = 0; | - |
1822 | if (newItem != item) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1823 | item = newItem; | - |
1824 | const QScriptItem ¤t = eng->layoutData->items[item]; | - |
1825 | if (!current.num_glyphs) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1826 | eng->shape(item); | - |
1827 | attributes = eng->attributes(); | - |
1828 | if (!attributes)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1829 | return; never executed: return; | 0 |
1830 | lbh.logClusters = eng->layoutData->logClustersPtr; | - |
1831 | } never executed: end of block | 0 |
1832 | lbh.currentPosition = qMax(line.from, current.position); | - |
1833 | end = current.position + eng->length(item); | - |
1834 | lbh.glyphs = eng->shapedGlyphs(¤t); | - |
1835 | QFontEngine *fontEngine = eng->fontEngine(current); | - |
1836 | if (lbh.fontEngine != fontEngine) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1837 | lbh.fontEngine = fontEngine; | - |
1838 | lbh.minimumRightBearing = qMin(QFixed(), | - |
1839 | QFixed::fromReal(fontEngine->minRightBearing())); | - |
1840 | } never executed: end of block | 0 |
1841 | } never executed: end of block | 0 |
1842 | const QScriptItem ¤t = eng->layoutData->items[item]; | - |
1843 | | - |
1844 | lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent, | - |
1845 | current.leading + current.ascent) - qMax(lbh.tmpData.ascent, | - |
1846 | current.ascent); | - |
1847 | lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent); | - |
1848 | lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent); | - |
1849 | | - |
1850 | if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1851 | lbh.whiteSpaceOrObject = true; | - |
1852 | if (lbh.checkFullOtherwiseExtend(line))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1853 | goto found; never executed: goto found; | 0 |
1854 | | - |
1855 | QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; | - |
1856 | QFixed tabWidth = eng->calculateTabWidth(item, x); | - |
1857 | attributes = eng->attributes(); | - |
1858 | if (!attributes)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1859 | return; never executed: return; | 0 |
1860 | lbh.logClusters = eng->layoutData->logClustersPtr; | - |
1861 | lbh.glyphs = eng->shapedGlyphs(¤t); | - |
1862 | | - |
1863 | lbh.spaceData.textWidth += tabWidth; | - |
1864 | lbh.spaceData.length++; | - |
1865 | newItem = item + 1; | - |
1866 | | - |
1867 | QFixed averageCharWidth = eng->fontEngine(current)->averageCharWidth(); | - |
1868 | lbh.glyphCount += qRound(tabWidth / averageCharWidth); | - |
1869 | | - |
1870 | if (lbh.checkFullOtherwiseExtend(line))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1871 | goto found; never executed: goto found; | 0 |
1872 | } else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1873 | lbh.whiteSpaceOrObject = true; | - |
1874 | | - |
1875 | | - |
1876 | if (!line.length && !lbh.tmpData.length)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1877 | line.setDefaultHeight(eng); never executed: line.setDefaultHeight(eng); | 0 |
1878 | if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1879 | if (lbh.checkFullOtherwiseExtend(line))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1880 | goto found; never executed: goto found; | 0 |
1881 | | - |
1882 | addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, | - |
1883 | current, lbh.logClusters, lbh.glyphs); | - |
1884 | } else { never executed: end of block | 0 |
1885 | lbh.tmpData.length++; | - |
1886 | lbh.calculateRightBearingForPreviousGlyph(); | - |
1887 | } never executed: end of block | 0 |
1888 | line += lbh.tmpData; | - |
1889 | goto found; never executed: goto found; | 0 |
1890 | } else if (current.analysis.flags == QScriptAnalysis::Object) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1891 | lbh.whiteSpaceOrObject = true; | - |
1892 | lbh.tmpData.length++; | - |
1893 | | - |
1894 | if (eng->block.docHandle()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1895 | QTextInlineObject inlineObject(item, eng); | - |
1896 | eng->docLayout()->positionInlineObject(inlineObject, eng->block.position() + current.position, inlineObject.format()); | - |
1897 | } never executed: end of block | 0 |
1898 | | - |
1899 | lbh.tmpData.textWidth += current.width; | - |
1900 | | - |
1901 | newItem = item + 1; | - |
1902 | ++lbh.glyphCount; | - |
1903 | if (lbh.checkFullOtherwiseExtend(line))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1904 | goto found; never executed: goto found; | 0 |
1905 | } else if (attributes[lbh.currentPosition].whiteSpace never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1906 | && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1907 | lbh.whiteSpaceOrObject = true; | - |
1908 | while (lbh.currentPosition < endTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1909 | && attributes[lbh.currentPosition].whiteSpaceTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1910 | && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1911 | addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount, | - |
1912 | current, lbh.logClusters, lbh.glyphs); | - |
1913 | } never executed: end of block | 0 |
1914 | | - |
1915 | if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1916 | lbh.spaceData.textWidth = line.width; | - |
1917 | goto found; never executed: goto found; | 0 |
1918 | } | - |
1919 | } else { never executed: end of block | 0 |
1920 | lbh.whiteSpaceOrObject = false; | - |
1921 | bool sb_or_ws = false; | - |
1922 | lbh.saveCurrentGlyph(); | - |
1923 | do { | - |
1924 | addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount, | - |
1925 | current, lbh.logClusters, lbh.glyphs); | - |
1926 | | - |
1927 | | - |
1928 | | - |
1929 | | - |
1930 | | - |
1931 | | - |
1932 | bool isBreakableSpace = lbh.currentPosition < eng->layoutData->string.length()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1933 | && attributes[lbh.currentPosition].whiteSpaceTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1934 | && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1935 | | - |
1936 | if (lbh.currentPosition >= eng->layoutData->string.length()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1937 | || isBreakableSpaceTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1938 | || attributes[lbh.currentPosition].lineBreak) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1939 | sb_or_ws = true; | - |
1940 | break; never executed: break; | 0 |
1941 | } else if (breakany && attributes[lbh.currentPosition].graphemeBoundary) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1942 | break; never executed: break; | 0 |
1943 | } | - |
1944 | } while (lbh.currentPosition < end); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1945 | lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw); | - |
1946 | | - |
1947 | if (lbh.currentPosition > 0 && lbh.currentPosition < endTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1948 | && attributes[lbh.currentPosition].lineBreakTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1949 | && eng->layoutData->string.at(lbh.currentPosition - 1).unicode() == QChar::SoftHyphen) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1950 | | - |
1951 | | - |
1952 | | - |
1953 | | - |
1954 | | - |
1955 | | - |
1956 | | - |
1957 | | - |
1958 | | - |
1959 | | - |
1960 | | - |
1961 | | - |
1962 | | - |
1963 | | - |
1964 | | - |
1965 | | - |
1966 | if (line.length)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1967 | lbh.softHyphenWidth = lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; never executed: lbh.softHyphenWidth = lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; | 0 |
1968 | else if (breakany)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1969 | lbh.tmpData.textWidth += lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; never executed: lbh.tmpData.textWidth += lbh.glyphs.advances[lbh.logClusters[lbh.currentPosition - 1]]; | 0 |
1970 | } never executed: end of block | 0 |
1971 | | - |
1972 | if (sb_or_ws|breakany) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1973 | | - |
1974 | | - |
1975 | | - |
1976 | | - |
1977 | | - |
1978 | | - |
1979 | | - |
1980 | QFixed previousRightBearing = lbh.rightBearing; | - |
1981 | | - |
1982 | | - |
1983 | | - |
1984 | | - |
1985 | | - |
1986 | | - |
1987 | | - |
1988 | | - |
1989 | | - |
1990 | | - |
1991 | if ((lbh.calculateNewWidth(line) + qAbs(lbh.minimumRightBearing)) > line.width)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1992 | lbh.calculateRightBearing(); never executed: lbh.calculateRightBearing(); | 0 |
1993 | | - |
1994 | if (lbh.checkFullOtherwiseExtend(line)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1995 | | - |
1996 | | - |
1997 | | - |
1998 | if (previousRightBearing != LineBreakHelper::RightBearingNotCalculated)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1999 | lbh.rightBearing = previousRightBearing; never executed: lbh.rightBearing = previousRightBearing; | 0 |
2000 | else | - |
2001 | lbh.calculateRightBearingForPreviousGlyph(); never executed: lbh.calculateRightBearingForPreviousGlyph(); | 0 |
2002 | | - |
2003 | if (!breakany) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2004 | line.textWidth += lbh.softHyphenWidth; | - |
2005 | } never executed: end of block | 0 |
2006 | | - |
2007 | goto found; never executed: goto found; | 0 |
2008 | } | - |
2009 | } never executed: end of block | 0 |
2010 | lbh.saveCurrentGlyph(); | - |
2011 | } never executed: end of block | 0 |
2012 | if (lbh.currentPosition == end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2013 | newItem = item + 1; never executed: newItem = item + 1; | 0 |
2014 | } never executed: end of block | 0 |
2015 | LB_DEBUG("reached end of line"); dead code: QMessageLogger(__FILE__, 2015, __PRETTY_FUNCTION__).debug("reached end of line"); | - |
2016 | lbh.checkFullOtherwiseExtend(line); | - |
2017 | found: code before this statement never executed: found: | 0 |
2018 | line.textAdvance = line.textWidth; | - |
2019 | | - |
2020 | | - |
2021 | if (lbh.rightBearing == LineBreakHelper::RightBearingNotCalculated && !lbh.whiteSpaceOrObject)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2022 | lbh.calculateRightBearing(); never executed: lbh.calculateRightBearing(); | 0 |
2023 | | - |
2024 | | - |
2025 | line.textWidth += lbh.negativeRightBearing(); | - |
2026 | | - |
2027 | if (line.length == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2028 | LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", dead code: QMessageLogger(__FILE__, 2028, __PRETTY_FUNCTION__).debug("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); | - |
2029 | lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), dead code: QMessageLogger(__FILE__, 2028, __PRETTY_FUNCTION__).debug("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); | - |
2030 | lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); dead code: QMessageLogger(__FILE__, 2028, __PRETTY_FUNCTION__).debug("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); | - |
2031 | line += lbh.tmpData; | - |
2032 | } never executed: end of block | 0 |
2033 | | - |
2034 | LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(), dead code: QMessageLogger(__FILE__, 2034, __PRETTY_FUNCTION__).debug("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(), line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal()); | - |
2035 | line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal()); dead code: QMessageLogger(__FILE__, 2034, __PRETTY_FUNCTION__).debug("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(), line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal()); | - |
2036 | LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data()); dead code: QMessageLogger(__FILE__, 2036, __PRETTY_FUNCTION__).debug(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data()); | - |
2037 | | - |
2038 | if (lbh.manualWrap) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2039 | eng->minWidth = qMax(eng->minWidth, line.textWidth); | - |
2040 | eng->maxWidth = qMax(eng->maxWidth, line.textWidth); | - |
2041 | } else { never executed: end of block | 0 |
2042 | eng->minWidth = qMax(eng->minWidth, lbh.minw); | - |
2043 | eng->maxWidth += line.textWidth; | - |
2044 | } never executed: end of block | 0 |
2045 | | - |
2046 | if (line.textWidth > 0 && item < eng->layoutData->items.size())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2047 | eng->maxWidth += lbh.spaceData.textWidth; never executed: eng->maxWidth += lbh.spaceData.textWidth; | 0 |
2048 | if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2049 | line.textWidth += lbh.spaceData.textWidth; never executed: line.textWidth += lbh.spaceData.textWidth; | 0 |
2050 | if (lbh.spaceData.length) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2051 | line.trailingSpaces = lbh.spaceData.length; | - |
2052 | line.hasTrailingSpaces = true; | - |
2053 | } never executed: end of block | 0 |
2054 | | - |
2055 | line.justified = false; | - |
2056 | line.gridfitted = false; | - |
2057 | | - |
2058 | if (eng->option.wrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2059 | if ((lbh.maxGlyphs != INT_MAX && lbh.glyphCount > lbh.maxGlyphs)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2060 | || (lbh.maxGlyphs == INT_MAX && line.textWidth > line.width)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2061 | | - |
2062 | eng->option.setWrapMode(QTextOption::WrapAnywhere); | - |
2063 | line.length = 0; | - |
2064 | line.textWidth = 0; | - |
2065 | layout_helper(lbh.maxGlyphs); | - |
2066 | eng->option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); | - |
2067 | } never executed: end of block | 0 |
2068 | } never executed: end of block | 0 |
2069 | } never executed: end of block | 0 |
2070 | | - |
2071 | | - |
2072 | | - |
2073 | | - |
2074 | void QTextLine::setPosition(const QPointF &pos) | - |
2075 | { | - |
2076 | eng->lines[index].x = QFixed::fromReal(pos.x()); | - |
2077 | eng->lines[index].y = QFixed::fromReal(pos.y()); | - |
2078 | } never executed: end of block | 0 |
2079 | | - |
2080 | | - |
2081 | | - |
2082 | | - |
2083 | QPointF QTextLine::position() const | - |
2084 | { | - |
2085 | return QPointF(eng->lines[index].x.toReal(), eng->lines[index].y.toReal()); never executed: return QPointF(eng->lines[index].x.toReal(), eng->lines[index].y.toReal()); | 0 |
2086 | } | - |
2087 | | - |
2088 | | - |
2089 | | - |
2090 | | - |
2091 | | - |
2092 | | - |
2093 | | - |
2094 | | - |
2095 | | - |
2096 | | - |
2097 | | - |
2098 | | - |
2099 | int QTextLine::textStart() const | - |
2100 | { | - |
2101 | return eng->lines[index].from; never executed: return eng->lines[index].from; | 0 |
2102 | } | - |
2103 | | - |
2104 | | - |
2105 | | - |
2106 | | - |
2107 | | - |
2108 | | - |
2109 | int QTextLine::textLength() const | - |
2110 | { | - |
2111 | if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparatorsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2112 | && eng->block.isValid() && index == eng->lines.count()-1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2113 | return eng->lines[index].length - 1; never executed: return eng->lines[index].length - 1; | 0 |
2114 | } | - |
2115 | return eng->lines[index].length + eng->lines[index].trailingSpaces; never executed: return eng->lines[index].length + eng->lines[index].trailingSpaces; | 0 |
2116 | } | - |
2117 | | - |
2118 | static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const QTextCharFormat &chf, const QRectF &r) | - |
2119 | { | - |
2120 | QBrush c = chf.foreground(); | - |
2121 | if (c.style() == Qt::NoBrush) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2122 | p->setPen(defaultPen); | - |
2123 | } never executed: end of block | 0 |
2124 | | - |
2125 | QBrush bg = chf.background(); | - |
2126 | if (bg.style() != Qt::NoBrush && !chf.property(SuppressBackground).toBool())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2127 | p->fillRect(QRectF(qFloor(r.x()), qFloor(r.y()), r.width(), r.height()), bg); never executed: p->fillRect(QRectF(qFloor(r.x()), qFloor(r.y()), r.width(), r.height()), bg); | 0 |
2128 | if (c.style() != Qt::NoBrush) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2129 | p->setPen(QPen(c, 0)); | - |
2130 | } never executed: end of block | 0 |
2131 | | - |
2132 | } never executed: end of block | 0 |
2133 | | - |
2134 | #if !defined(QT_NO_RAWFONT) | - |
2135 | static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, | - |
2136 | const QGlyphLayout &glyphLayout, | - |
2137 | const QPointF &pos, | - |
2138 | const QGlyphRun::GlyphRunFlags &flags, | - |
2139 | const QFixed &selectionX, | - |
2140 | const QFixed &selectionWidth, | - |
2141 | int glyphsStart, | - |
2142 | int glyphsEnd, | - |
2143 | unsigned short *logClusters, | - |
2144 | int textPosition, | - |
2145 | int textLength) | - |
2146 | { | - |
2147 | Q_ASSERT(logClusters != 0); | - |
2148 | | - |
2149 | QGlyphRun glyphRun; | - |
2150 | | - |
2151 | QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun); | - |
2152 | | - |
2153 | int rangeStart = textPosition; | - |
2154 | while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2155 | ++logClusters; | - |
2156 | ++rangeStart; | - |
2157 | } never executed: end of block | 0 |
2158 | | - |
2159 | int rangeEnd = rangeStart; | - |
2160 | while (*logClusters != glyphsEnd && rangeEnd < textPosition + textLength) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2161 | ++logClusters; | - |
2162 | ++rangeEnd; | - |
2163 | } never executed: end of block | 0 |
2164 | | - |
2165 | d->textRangeStart = rangeStart; | - |
2166 | d->textRangeEnd = rangeEnd; | - |
2167 | | - |
2168 | | - |
2169 | QRawFont font; | - |
2170 | QRawFontPrivate *fontD = QRawFontPrivate::get(font); | - |
2171 | fontD->setFontEngine(fontEngine); | - |
2172 | | - |
2173 | QVarLengthArray<glyph_t> glyphsArray; | - |
2174 | QVarLengthArray<QFixedPoint> positionsArray; | - |
2175 | | - |
2176 | QTextItem::RenderFlags renderFlags; | - |
2177 | if (flags.testFlag(QGlyphRun::Overline))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2178 | renderFlags |= QTextItem::Overline; never executed: renderFlags |= QTextItem::Overline; | 0 |
2179 | if (flags.testFlag(QGlyphRun::Underline))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2180 | renderFlags |= QTextItem::Underline; never executed: renderFlags |= QTextItem::Underline; | 0 |
2181 | if (flags.testFlag(QGlyphRun::StrikeOut))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2182 | renderFlags |= QTextItem::StrikeOut; never executed: renderFlags |= QTextItem::StrikeOut; | 0 |
2183 | if (flags.testFlag(QGlyphRun::RightToLeft))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2184 | renderFlags |= QTextItem::RightToLeft; never executed: renderFlags |= QTextItem::RightToLeft; | 0 |
2185 | | - |
2186 | fontEngine->getGlyphPositions(glyphLayout, QTransform(), renderFlags, glyphsArray, | - |
2187 | positionsArray); | - |
2188 | Q_ASSERT(glyphsArray.size() == positionsArray.size()); | - |
2189 | | - |
2190 | qreal fontHeight = font.ascent() + font.descent(); | - |
2191 | qreal minY = 0; | - |
2192 | qreal maxY = 0; | - |
2193 | QVector<quint32> glyphs; | - |
2194 | glyphs.reserve(glyphsArray.size()); | - |
2195 | QVector<QPointF> positions; | - |
2196 | positions.reserve(glyphsArray.size()); | - |
2197 | for (int i=0; i<glyphsArray.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2198 | glyphs.append(glyphsArray.at(i) & 0xffffff); | - |
2199 | | - |
2200 | QPointF position = positionsArray.at(i).toPointF() + pos; | - |
2201 | positions.append(position); | - |
2202 | | - |
2203 | if (i == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2204 | maxY = minY = position.y(); | - |
2205 | } else { never executed: end of block | 0 |
2206 | minY = qMin(minY, position.y()); | - |
2207 | maxY = qMax(maxY, position.y()); | - |
2208 | } never executed: end of block | 0 |
2209 | } | - |
2210 | | - |
2211 | qreal height = maxY + fontHeight - minY; | - |
2212 | | - |
2213 | glyphRun.setGlyphIndexes(glyphs); | - |
2214 | glyphRun.setPositions(positions); | - |
2215 | glyphRun.setFlags(flags); | - |
2216 | glyphRun.setRawFont(font); | - |
2217 | | - |
2218 | glyphRun.setBoundingRect(QRectF(selectionX.toReal(), minY - font.ascent(), | - |
2219 | selectionWidth.toReal(), height)); | - |
2220 | | - |
2221 | return glyphRun; never executed: return glyphRun; | 0 |
2222 | } | - |
2223 | | - |
2224 | | - |
2225 | | - |
2226 | | - |
2227 | | - |
2228 | | - |
2229 | | - |
2230 | | - |
2231 | | - |
2232 | | - |
2233 | | - |
2234 | | - |
2235 | | - |
2236 | | - |
2237 | QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const | - |
2238 | { | - |
2239 | const QScriptLine &line = eng->lines[index]; | - |
2240 | | - |
2241 | if (line.length == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2242 | return QList<QGlyphRun>(); never executed: return QList<QGlyphRun>(); | 0 |
2243 | | - |
2244 | if (from < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2245 | from = textStart(); never executed: from = textStart(); | 0 |
2246 | | - |
2247 | if (length < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2248 | length = textLength(); never executed: length = textLength(); | 0 |
2249 | | - |
2250 | if (length == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2251 | return QList<QGlyphRun>(); never executed: return QList<QGlyphRun>(); | 0 |
2252 | | - |
2253 | QTextLayout::FormatRange selection; | - |
2254 | selection.start = from; | - |
2255 | selection.length = length; | - |
2256 | | - |
2257 | QTextLineItemIterator iterator(eng, index, QPointF(), &selection); | - |
2258 | qreal y = line.y.toReal() + line.base().toReal(); | - |
2259 | QList<QGlyphRun> glyphRuns; | - |
2260 | while (!iterator.atEnd()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2261 | QScriptItem &si = iterator.next(); | - |
2262 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2263 | continue; never executed: continue; | 0 |
2264 | | - |
2265 | if (from >= 0 && length >= 0 && (from >= iterator.itemEnd || from + length <= iterator.itemStart))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2266 | continue; never executed: continue; | 0 |
2267 | | - |
2268 | QPointF pos(iterator.x.toReal(), y); | - |
2269 | | - |
2270 | QFont font; | - |
2271 | QGlyphRun::GlyphRunFlags flags; | - |
2272 | if (!eng->useRawFont) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2273 | font = eng->font(si); | - |
2274 | if (font.overline())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2275 | flags |= QGlyphRun::Overline; never executed: flags |= QGlyphRun::Overline; | 0 |
2276 | if (font.underline())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2277 | flags |= QGlyphRun::Underline; never executed: flags |= QGlyphRun::Underline; | 0 |
2278 | if (font.strikeOut())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2279 | flags |= QGlyphRun::StrikeOut; never executed: flags |= QGlyphRun::StrikeOut; | 0 |
2280 | } never executed: end of block | 0 |
2281 | | - |
2282 | bool rtl = false; | - |
2283 | if (si.analysis.bidiLevel % 2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2284 | flags |= QGlyphRun::RightToLeft; | - |
2285 | rtl = true; | - |
2286 | } never executed: end of block | 0 |
2287 | | - |
2288 | int relativeFrom = qMax(iterator.itemStart, from) - si.position; | - |
2289 | int relativeTo = qMin(iterator.itemEnd, from + length) - 1 - si.position; | - |
2290 | | - |
2291 | unsigned short *logClusters = eng->logClusters(&si); | - |
2292 | int glyphsStart = logClusters[relativeFrom]; | - |
2293 | int glyphsEnd = (relativeTo == iterator.itemLength) ? si.num_glyphs - 1 : logClusters[relativeTo];TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2294 | | - |
2295 | int nextGlyphIndex = (relativeTo < iterator.itemLength - 1) ? logClusters[relativeTo + 1] : si.num_glyphs;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2296 | if (nextGlyphIndex - 1 > glyphsEnd)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2297 | glyphsEnd = nextGlyphIndex - 1; never executed: glyphsEnd = nextGlyphIndex - 1; | 0 |
2298 | bool startsInsideLigature = relativeFrom > 0 && logClusters[relativeFrom - 1] == glyphsStart;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2299 | bool endsInsideLigature = nextGlyphIndex == glyphsEnd; | - |
2300 | | - |
2301 | int itemGlyphsStart = logClusters[iterator.itemStart - si.position]; | - |
2302 | int itemGlyphsEnd = logClusters[iterator.itemEnd - 1 - si.position]; | - |
2303 | | - |
2304 | QGlyphLayout glyphLayout = eng->shapedGlyphs(&si); | - |
2305 | | - |
2306 | | - |
2307 | | - |
2308 | | - |
2309 | if (relativeFrom != (iterator.itemStart - si.position) && !rtl) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2310 | for (int i=itemGlyphsStart; i<glyphsStart; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2311 | QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); | - |
2312 | pos.rx() += (glyphLayout.advances[i] + justification).toReal(); | - |
2313 | } never executed: end of block | 0 |
2314 | } else if (relativeTo != (iterator.itemEnd - si.position - 1) && rtl) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2315 | for (int i=itemGlyphsEnd; i>glyphsEnd; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2316 | QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6); | - |
2317 | pos.rx() += (glyphLayout.advances[i] + justification).toReal(); | - |
2318 | } never executed: end of block | 0 |
2319 | } never executed: end of block | 0 |
2320 | | - |
2321 | glyphLayout = glyphLayout.mid(glyphsStart, glyphsEnd - glyphsStart + 1); | - |
2322 | | - |
2323 | QFixed x; | - |
2324 | QFixed width; | - |
2325 | iterator.getSelectionBounds(&x, &width); | - |
2326 | | - |
2327 | if (glyphLayout.numGlyphs > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2328 | QFontEngine *mainFontEngine; | - |
2329 | #ifndef QT_NO_RAWFONT | - |
2330 | if (eng->useRawFont && eng->rawFont.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2331 | mainFontEngine= eng->fontEngine(si); never executed: mainFontEngine= eng->fontEngine(si); | 0 |
2332 | else | - |
2333 | #endif | - |
2334 | mainFontEngine = font.d->engineForScript(si.analysis.script); never executed: mainFontEngine = font.d->engineForScript(si.analysis.script); | 0 |
2335 | | - |
2336 | if (mainFontEngine->type() == QFontEngine::Multi) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2337 | QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine); | - |
2338 | int start = rtl ? glyphLayout.numGlyphs : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2339 | int end = start - 1; | - |
2340 | int which = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24; | - |
2341 | for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs - 1);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2342 | rtl ? --start : ++end) { | - |
2343 | const int e = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24; | - |
2344 | if (e == which)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2345 | continue; never executed: continue; | 0 |
2346 | | - |
2347 | QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1); | - |
2348 | multiFontEngine->ensureEngineAt(which); | - |
2349 | | - |
2350 | QGlyphRun::GlyphRunFlags subFlags = flags; | - |
2351 | if (start == 0 && startsInsideLigature)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2352 | subFlags |= QGlyphRun::SplitLigature; never executed: subFlags |= QGlyphRun::SplitLigature; | 0 |
2353 | | - |
2354 | glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which), | - |
2355 | subLayout, | - |
2356 | pos, | - |
2357 | subFlags, | - |
2358 | x, | - |
2359 | width, | - |
2360 | glyphsStart + start, | - |
2361 | glyphsStart + end, | - |
2362 | logClusters + relativeFrom, | - |
2363 | relativeFrom + si.position, | - |
2364 | relativeTo - relativeFrom + 1)); | - |
2365 | for (int i = 0; i < subLayout.numGlyphs; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2366 | QFixed justification = QFixed::fromFixed(subLayout.justifications[i].space_18d6); | - |
2367 | pos.rx() += (subLayout.advances[i] + justification).toReal(); | - |
2368 | } never executed: end of block | 0 |
2369 | | - |
2370 | if (rtl)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2371 | end = start - 1; never executed: end = start - 1; | 0 |
2372 | else | - |
2373 | start = end + 1; never executed: start = end + 1; | 0 |
2374 | which = e; | - |
2375 | } never executed: end of block | 0 |
2376 | | - |
2377 | QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1); | - |
2378 | multiFontEngine->ensureEngineAt(which); | - |
2379 | | - |
2380 | QGlyphRun::GlyphRunFlags subFlags = flags; | - |
2381 | if ((start == 0 && startsInsideLigature) || endsInsideLigature)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2382 | subFlags |= QGlyphRun::SplitLigature; never executed: subFlags |= QGlyphRun::SplitLigature; | 0 |
2383 | | - |
2384 | QGlyphRun glyphRun = glyphRunWithInfo(multiFontEngine->engine(which), | - |
2385 | subLayout, | - |
2386 | pos, | - |
2387 | subFlags, | - |
2388 | x, | - |
2389 | width, | - |
2390 | glyphsStart + start, | - |
2391 | glyphsStart + end, | - |
2392 | logClusters + relativeFrom, | - |
2393 | relativeFrom + si.position, | - |
2394 | relativeTo - relativeFrom + 1); | - |
2395 | if (!glyphRun.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2396 | glyphRuns.append(glyphRun); never executed: glyphRuns.append(glyphRun); | 0 |
2397 | } else { never executed: end of block | 0 |
2398 | if (startsInsideLigature || endsInsideLigature)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2399 | flags |= QGlyphRun::SplitLigature; never executed: flags |= QGlyphRun::SplitLigature; | 0 |
2400 | QGlyphRun glyphRun = glyphRunWithInfo(mainFontEngine, | - |
2401 | glyphLayout, | - |
2402 | pos, | - |
2403 | flags, | - |
2404 | x, | - |
2405 | width, | - |
2406 | glyphsStart, | - |
2407 | glyphsEnd, | - |
2408 | logClusters + relativeFrom, | - |
2409 | relativeFrom + si.position, | - |
2410 | relativeTo - relativeFrom + 1); | - |
2411 | if (!glyphRun.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2412 | glyphRuns.append(glyphRun); never executed: glyphRuns.append(glyphRun); | 0 |
2413 | } never executed: end of block | 0 |
2414 | } | - |
2415 | } never executed: end of block | 0 |
2416 | | - |
2417 | return glyphRuns; never executed: return glyphRuns; | 0 |
2418 | } | - |
2419 | #endif // QT_NO_RAWFONT | - |
2420 | | - |
2421 | | - |
2422 | | - |
2423 | | - |
2424 | | - |
2425 | | - |
2426 | | - |
2427 | void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatRange *selection) const | - |
2428 | { | - |
2429 | #ifndef QT_NO_RAWFONT | - |
2430 | | - |
2431 | Q_ASSERT(!eng->useRawFont); | - |
2432 | #endif | - |
2433 | const QScriptLine &line = eng->lines[index]; | - |
2434 | QPen pen = p->pen(); | - |
2435 | | - |
2436 | bool noText = (selection && selection->format.property(SuppressText).toBool());TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2437 | | - |
2438 | if (!line.length) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2439 | if (selectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2440 | && selection->start <= line.fromTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2441 | && selection->start + selection->length > line.from) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2442 | | - |
2443 | const qreal lineHeight = line.height().toReal(); | - |
2444 | QRectF r(pos.x() + line.x.toReal(), pos.y() + line.y.toReal(), | - |
2445 | lineHeight / 2, QFontMetrics(eng->font()).width(QLatin1Char(' '))); | - |
2446 | setPenAndDrawBackground(p, QPen(), selection->format, r); | - |
2447 | p->setPen(pen); | - |
2448 | } never executed: end of block | 0 |
2449 | return; never executed: return; | 0 |
2450 | } | - |
2451 | | - |
2452 | | - |
2453 | QTextLineItemIterator iterator(eng, index, pos, selection); | - |
2454 | QFixed lineBase = line.base(); | - |
2455 | eng->clearDecorations(); | - |
2456 | eng->enableDelayDecorations(); | - |
2457 | | - |
2458 | const QFixed y = QFixed::fromReal(pos.y()) + line.y + lineBase; | - |
2459 | | - |
2460 | bool suppressColors = (eng->option.flags() & QTextOption::SuppressColors); | - |
2461 | while (!iterator.atEnd()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2462 | QScriptItem &si = iterator.next(); | - |
2463 | | - |
2464 | if (selection && selection->start >= 0 && iterator.isOutsideSelection())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2465 | continue; never executed: continue; | 0 |
2466 | | - |
2467 | if (si.analysis.flags == QScriptAnalysis::LineOrParagraphSeparatorTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2468 | && !(eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2469 | continue; never executed: continue; | 0 |
2470 | | - |
2471 | QFixed itemBaseLine = y; | - |
2472 | QFont f = eng->font(si); | - |
2473 | QTextCharFormat format; | - |
2474 | | - |
2475 | if (eng->hasFormats() || selection) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2476 | format = eng->format(&si); | - |
2477 | if (suppressColors) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2478 | format.clearForeground(); | - |
2479 | format.clearBackground(); | - |
2480 | format.clearProperty(QTextFormat::TextUnderlineColor); | - |
2481 | } never executed: end of block | 0 |
2482 | if (selection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2483 | format.merge(selection->format); never executed: format.merge(selection->format); | 0 |
2484 | | - |
2485 | setPenAndDrawBackground(p, pen, format, QRectF(iterator.x.toReal(), (y - lineBase).toReal(), | - |
2486 | iterator.itemWidth.toReal(), line.height().toReal())); | - |
2487 | | - |
2488 | QTextCharFormat::VerticalAlignment valign = format.verticalAlignment(); | - |
2489 | if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2490 | QFontEngine *fe = f.d->engineForScript(si.analysis.script); | - |
2491 | QFixed height = fe->ascent() + fe->descent(); | - |
2492 | if (valign == QTextCharFormat::AlignSubScript)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2493 | itemBaseLine += height / 6; never executed: itemBaseLine += height / 6; | 0 |
2494 | else if (valign == QTextCharFormat::AlignSuperScript)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2495 | itemBaseLine -= height / 2; never executed: itemBaseLine -= height / 2; | 0 |
2496 | } never executed: end of block | 0 |
2497 | } never executed: end of block | 0 |
2498 | | - |
2499 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2500 | | - |
2501 | if (eng->hasFormats()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2502 | p->save(); | - |
2503 | if (si.analysis.flags == QScriptAnalysis::Object && eng->block.docHandle()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2504 | QFixed itemY = y - si.ascent; | - |
2505 | if (format.verticalAlignment() == QTextCharFormat::AlignTop) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2506 | itemY = y - lineBase; | - |
2507 | } never executed: end of block | 0 |
2508 | | - |
2509 | QRectF itemRect(iterator.x.toReal(), itemY.toReal(), iterator.itemWidth.toReal(), si.height().toReal()); | - |
2510 | | - |
2511 | eng->docLayout()->drawInlineObject(p, itemRect, | - |
2512 | QTextInlineObject(iterator.item, eng), | - |
2513 | si.position + eng->block.position(), | - |
2514 | format); | - |
2515 | if (selection) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2516 | QBrush bg = format.brushProperty(ObjectSelectionBrush); | - |
2517 | if (bg.style() != Qt::NoBrush) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2518 | QColor c = bg.color(); | - |
2519 | c.setAlpha(128); | - |
2520 | p->fillRect(itemRect, c); | - |
2521 | } never executed: end of block | 0 |
2522 | } never executed: end of block | 0 |
2523 | } else { never executed: end of block | 0 |
2524 | QFont f = eng->font(si); | - |
2525 | QTextItemInt gf(si, &f, format); | - |
2526 | gf.chars = 0; | - |
2527 | gf.num_chars = 0; | - |
2528 | gf.width = iterator.itemWidth; | - |
2529 | QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng); | - |
2530 | if (eng->option.flags() & QTextOption::ShowTabsAndSpaces) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2531 | QChar visualTab(0x2192); | - |
2532 | int w = QFontMetrics(f).width(visualTab); | - |
2533 | qreal x = iterator.itemWidth.toReal() - w; | - |
2534 | if (x < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2535 | p->setClipRect(QRectF(iterator.x.toReal(), line.y.toReal(), never executed: p->setClipRect(QRectF(iterator.x.toReal(), line.y.toReal(), iterator.itemWidth.toReal(), line.height().toReal()), Qt::IntersectClip); | 0 |
2536 | iterator.itemWidth.toReal(), line.height().toReal()), never executed: p->setClipRect(QRectF(iterator.x.toReal(), line.y.toReal(), iterator.itemWidth.toReal(), line.height().toReal()), Qt::IntersectClip); | 0 |
2537 | Qt::IntersectClip); never executed: p->setClipRect(QRectF(iterator.x.toReal(), line.y.toReal(), iterator.itemWidth.toReal(), line.height().toReal()), Qt::IntersectClip); | 0 |
2538 | else | - |
2539 | x /= 2; never executed: x /= 2; | 0 |
2540 | p->drawText(QPointF(iterator.x.toReal() + x, | - |
2541 | y.toReal()), visualTab); | - |
2542 | } never executed: end of block | 0 |
2543 | | - |
2544 | } never executed: end of block | 0 |
2545 | p->restore(); | - |
2546 | } never executed: end of block | 0 |
2547 | | - |
2548 | continue; never executed: continue; | 0 |
2549 | } | - |
2550 | | - |
2551 | unsigned short *logClusters = eng->logClusters(&si); | - |
2552 | QGlyphLayout glyphs = eng->shapedGlyphs(&si); | - |
2553 | | - |
2554 | QTextItemInt gf(glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart), | - |
2555 | &f, eng->layoutData->string.unicode() + iterator.itemStart, | - |
2556 | iterator.itemEnd - iterator.itemStart, eng->fontEngine(si), format); | - |
2557 | gf.logClusters = logClusters + iterator.itemStart - si.position; | - |
2558 | gf.width = iterator.itemWidth; | - |
2559 | gf.justified = line.justified; | - |
2560 | gf.initWithScriptItem(si); | - |
2561 | | - |
2562 | Q_ASSERT(gf.fontEngine); | - |
2563 | | - |
2564 | QPointF pos(iterator.x.toReal(), itemBaseLine.toReal()); | - |
2565 | if (format.penProperty(QTextFormat::TextOutline).style() != Qt::NoPen) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2566 | QPainterPath path; | - |
2567 | path.setFillRule(Qt::WindingFill); | - |
2568 | | - |
2569 | if (gf.glyphs.numGlyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2570 | gf.fontEngine->addOutlineToPath(pos.x(), pos.y(), gf.glyphs, &path, gf.flags); never executed: gf.fontEngine->addOutlineToPath(pos.x(), pos.y(), gf.glyphs, &path, gf.flags); | 0 |
2571 | if (gf.flags) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2572 | const QFontEngine *fe = gf.fontEngine; | - |
2573 | const qreal lw = fe->lineThickness().toReal(); | - |
2574 | if (gf.flags & QTextItem::Underline) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2575 | qreal offs = fe->underlinePosition().toReal(); | - |
2576 | path.addRect(pos.x(), pos.y() + offs, gf.width.toReal(), lw); | - |
2577 | } never executed: end of block | 0 |
2578 | if (gf.flags & QTextItem::Overline) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2579 | qreal offs = fe->ascent().toReal() + 1; | - |
2580 | path.addRect(pos.x(), pos.y() - offs, gf.width.toReal(), lw); | - |
2581 | } never executed: end of block | 0 |
2582 | if (gf.flags & QTextItem::StrikeOut) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2583 | qreal offs = fe->ascent().toReal() / 3; | - |
2584 | path.addRect(pos.x(), pos.y() - offs, gf.width.toReal(), lw); | - |
2585 | } never executed: end of block | 0 |
2586 | } never executed: end of block | 0 |
2587 | | - |
2588 | p->save(); | - |
2589 | p->setRenderHint(QPainter::Antialiasing); | - |
2590 | | - |
2591 | | - |
2592 | if (p->pen().style() == Qt::NoPen)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2593 | p->setBrush(Qt::NoBrush); never executed: p->setBrush(Qt::NoBrush); | 0 |
2594 | else | - |
2595 | p->setBrush(p->pen().brush()); never executed: p->setBrush(p->pen().brush()); | 0 |
2596 | | - |
2597 | p->setPen(format.textOutline()); | - |
2598 | p->drawPath(path); | - |
2599 | p->restore(); | - |
2600 | } else { never executed: end of block | 0 |
2601 | if (noText)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2602 | gf.glyphs.numGlyphs = 0; never executed: gf.glyphs.numGlyphs = 0; | 0 |
2603 | QPainterPrivate::get(p)->drawTextItem(pos, gf, eng); | - |
2604 | } never executed: end of block | 0 |
2605 | | - |
2606 | if (si.analysis.flags == QScriptAnalysis::SpaceTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2607 | && (eng->option.flags() & QTextOption::ShowTabsAndSpaces)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2608 | QBrush c = format.foreground(); | - |
2609 | if (c.style() != Qt::NoBrush)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2610 | p->setPen(c.color()); never executed: p->setPen(c.color()); | 0 |
2611 | QChar visualSpace((ushort)0xb7); | - |
2612 | p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace); | - |
2613 | p->setPen(pen); | - |
2614 | } never executed: end of block | 0 |
2615 | } never executed: end of block | 0 |
2616 | eng->drawDecorations(p); | - |
2617 | | - |
2618 | if (eng->hasFormats())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2619 | p->setPen(pen); never executed: p->setPen(pen); | 0 |
2620 | } never executed: end of block | 0 |
2621 | | - |
2622 | | - |
2623 | | - |
2624 | | - |
2625 | | - |
2626 | | - |
2627 | | - |
2628 | | - |
2629 | | - |
2630 | | - |
2631 | | - |
2632 | | - |
2633 | | - |
2634 | | - |
2635 | | - |
2636 | | - |
2637 | | - |
2638 | qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const | - |
2639 | { | - |
2640 | const QScriptLine &line = eng->lines[index]; | - |
2641 | bool lastLine = index >= eng->lines.size() - 1; | - |
2642 | | - |
2643 | QFixed x = line.x + eng->alignLine(line) - eng->leadingSpaceWidth(line); | - |
2644 | | - |
2645 | if (!eng->layoutData)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2646 | eng->itemize(); never executed: eng->itemize(); | 0 |
2647 | if (!eng->layoutData->items.size()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2648 | *cursorPos = line.from; | - |
2649 | return x.toReal(); never executed: return x.toReal(); | 0 |
2650 | } | - |
2651 | | - |
2652 | int lineEnd = line.from + line.length + line.trailingSpaces; | - |
2653 | int pos = qBound(line.from, *cursorPos, lineEnd); | - |
2654 | int itm; | - |
2655 | const QCharAttributes *attributes = eng->attributes(); | - |
2656 | if (!attributes) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2657 | *cursorPos = line.from; | - |
2658 | return x.toReal(); never executed: return x.toReal(); | 0 |
2659 | } | - |
2660 | while (pos < lineEnd && !attributes[pos].graphemeBoundary)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2661 | pos++; never executed: pos++; | 0 |
2662 | if (pos == lineEnd) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2663 | | - |
2664 | itm = eng->findItem(pos-1); | - |
2665 | } never executed: end of block | 0 |
2666 | else | - |
2667 | itm = eng->findItem(pos); never executed: itm = eng->findItem(pos); | 0 |
2668 | if (itm < 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2669 | *cursorPos = line.from; | - |
2670 | return x.toReal(); never executed: return x.toReal(); | 0 |
2671 | } | - |
2672 | eng->shapeLine(line); | - |
2673 | | - |
2674 | const QScriptItem *si = &eng->layoutData->items[itm]; | - |
2675 | if (!si->num_glyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2676 | eng->shape(itm); never executed: eng->shape(itm); | 0 |
2677 | | - |
2678 | const int l = eng->length(itm); | - |
2679 | pos = qBound(0, pos - si->position, l); | - |
2680 | | - |
2681 | QGlyphLayout glyphs = eng->shapedGlyphs(si); | - |
2682 | unsigned short *logClusters = eng->logClusters(si); | - |
2683 | Q_ASSERT(logClusters); | - |
2684 | | - |
2685 | int glyph_pos = pos == l ? si->num_glyphs : logClusters[pos];TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2686 | if (edge == Trailing && glyph_pos < si->num_glyphs) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2687 | | - |
2688 | glyph_pos++; | - |
2689 | while (glyph_pos < si->num_glyphs && !glyphs.attributes[glyph_pos].clusterStart)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2690 | glyph_pos++; never executed: glyph_pos++; | 0 |
2691 | } never executed: end of block | 0 |
2692 | | - |
2693 | bool reverse = si->analysis.bidiLevel % 2; | - |
2694 | | - |
2695 | | - |
2696 | | - |
2697 | | - |
2698 | int firstItem = eng->findItem(line.from); | - |
2699 | int lastItem = eng->findItem(lineEnd - 1, itm); | - |
2700 | int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2701 | | - |
2702 | QVarLengthArray<int> visualOrder(nItems); | - |
2703 | QVarLengthArray<uchar> levels(nItems); | - |
2704 | for (int i = 0; i < nItems; ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2705 | levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; never executed: levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; | 0 |
2706 | QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); | - |
2707 | | - |
2708 | for (int i = 0; i < nItems; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2709 | int item = visualOrder[i]+firstItem; | - |
2710 | if (item == itm)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2711 | break; never executed: break; | 0 |
2712 | QScriptItem &si = eng->layoutData->items[item]; | - |
2713 | if (!si.num_glyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2714 | eng->shape(item); never executed: eng->shape(item); | 0 |
2715 | | - |
2716 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2717 | x += si.width; | - |
2718 | continue; never executed: continue; | 0 |
2719 | } | - |
2720 | | - |
2721 | const int itemLength = eng->length(item); | - |
2722 | int start = qMax(line.from, si.position); | - |
2723 | int end = qMin(lineEnd, si.position + itemLength); | - |
2724 | | - |
2725 | logClusters = eng->logClusters(&si); | - |
2726 | | - |
2727 | int gs = logClusters[start-si.position]; | - |
2728 | int ge = (end == si.position + itemLength) ? si.num_glyphs-1 : logClusters[end-si.position-1];TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2729 | | - |
2730 | QGlyphLayout glyphs = eng->shapedGlyphs(&si); | - |
2731 | | - |
2732 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2733 | x += glyphs.effectiveAdvance(gs); | - |
2734 | ++gs; | - |
2735 | } never executed: end of block | 0 |
2736 | } never executed: end of block | 0 |
2737 | | - |
2738 | logClusters = eng->logClusters(si); | - |
2739 | glyphs = eng->shapedGlyphs(si); | - |
2740 | if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2741 | if (pos == (reverse ? 0 : l))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2742 | x += si->width; never executed: x += si->width; | 0 |
2743 | } else { never executed: end of block | 0 |
2744 | bool rtl = eng->isRightToLeft(); | - |
2745 | bool visual = eng->visualCursorMovement(); | - |
2746 | int end = qMin(lineEnd, si->position + l) - si->position; | - |
2747 | if (reverse) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2748 | int glyph_end = end == l ? si->num_glyphs : logClusters[end];TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2749 | int glyph_start = glyph_pos; | - |
2750 | if (visual && !rtl && !(lastLine && itm == (visualOrder[nItems - 1] + firstItem)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2751 | glyph_start++; never executed: glyph_start++; | 0 |
2752 | for (int i = glyph_end - 1; i >= glyph_start; i--)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2753 | x += glyphs.effectiveAdvance(i); never executed: x += glyphs.effectiveAdvance(i); | 0 |
2754 | } else { never executed: end of block | 0 |
2755 | int start = qMax(line.from - si->position, 0); | - |
2756 | int glyph_start = logClusters[start]; | - |
2757 | int glyph_end = glyph_pos; | - |
2758 | if (!visual || !rtl || (lastLine && itm == visualOrder[0] + firstItem))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2759 | glyph_end--; never executed: glyph_end--; | 0 |
2760 | for (int i = glyph_start; i <= glyph_end; i++)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2761 | x += glyphs.effectiveAdvance(i); never executed: x += glyphs.effectiveAdvance(i); | 0 |
2762 | } never executed: end of block | 0 |
2763 | x += eng->offsetInLigature(si, pos, end, glyph_pos); | - |
2764 | } never executed: end of block | 0 |
2765 | | - |
2766 | if (eng->option.wrapMode() != QTextOption::NoWrap && x > line.x + line.width)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2767 | x = line.x + line.width; never executed: x = line.x + line.width; | 0 |
2768 | if (eng->option.wrapMode() != QTextOption::NoWrap && x < 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2769 | x = 0; never executed: x = 0; | 0 |
2770 | | - |
2771 | *cursorPos = pos + si->position; | - |
2772 | return x.toReal(); never executed: return x.toReal(); | 0 |
2773 | } | - |
2774 | | - |
2775 | | - |
2776 | | - |
2777 | | - |
2778 | | - |
2779 | | - |
2780 | | - |
2781 | | - |
2782 | | - |
2783 | | - |
2784 | int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const | - |
2785 | { | - |
2786 | QFixed x = QFixed::fromReal(_x); | - |
2787 | const QScriptLine &line = eng->lines[index]; | - |
2788 | bool lastLine = index >= eng->lines.size() - 1; | - |
2789 | int lineNum = index; | - |
2790 | | - |
2791 | if (!eng->layoutData)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2792 | eng->itemize(); never executed: eng->itemize(); | 0 |
2793 | | - |
2794 | int line_length = textLength(); | - |
2795 | | - |
2796 | if (!line_length)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2797 | return line.from; never executed: return line.from; | 0 |
2798 | | - |
2799 | int firstItem = eng->findItem(line.from); | - |
2800 | int lastItem = eng->findItem(line.from + line_length - 1, firstItem); | - |
2801 | int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2802 | | - |
2803 | if (!nItems)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2804 | return 0; never executed: return 0; | 0 |
2805 | | - |
2806 | x -= line.x; | - |
2807 | x -= eng->alignLine(line); | - |
2808 | | - |
2809 | | - |
2810 | QVarLengthArray<int> visualOrder(nItems); | - |
2811 | QVarLengthArray<unsigned char> levels(nItems); | - |
2812 | for (int i = 0; i < nItems; ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2813 | levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; never executed: levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; | 0 |
2814 | QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); | - |
2815 | | - |
2816 | bool visual = eng->visualCursorMovement(); | - |
2817 | if (x <= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2818 | | - |
2819 | int item = visualOrder[0]+firstItem; | - |
2820 | QScriptItem &si = eng->layoutData->items[item]; | - |
2821 | if (!si.num_glyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2822 | eng->shape(item); never executed: eng->shape(item); | 0 |
2823 | int pos = si.position; | - |
2824 | if (si.analysis.bidiLevel % 2)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2825 | pos += eng->length(item); never executed: pos += eng->length(item); | 0 |
2826 | pos = qMax(line.from, pos); | - |
2827 | pos = qMin(line.from + line_length, pos); | - |
2828 | return pos; never executed: return pos; | 0 |
2829 | } else if (x < line.textWidthTRUE | never evaluated | FALSE | never evaluated |
| 0 |
2830 | || (line.justified && x < line.width)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2831 | | - |
2832 | QFixed pos; | - |
2833 | bool rtl = eng->isRightToLeft(); | - |
2834 | | - |
2835 | eng->shapeLine(line); | - |
2836 | QVector<int> insertionPoints; | - |
2837 | if (visual && rtl)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2838 | eng->insertionPointsForLine(lineNum, insertionPoints); never executed: eng->insertionPointsForLine(lineNum, insertionPoints); | 0 |
2839 | int nchars = 0; | - |
2840 | for (int i = 0; i < nItems; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2841 | int item = visualOrder[i]+firstItem; | - |
2842 | QScriptItem &si = eng->layoutData->items[item]; | - |
2843 | int item_length = eng->length(item); | - |
2844 | | - |
2845 | | - |
2846 | int start = qMax(line.from - si.position, 0); | - |
2847 | int end = qMin(line.from + line_length - si.position, item_length); | - |
2848 | | - |
2849 | unsigned short *logClusters = eng->logClusters(&si); | - |
2850 | | - |
2851 | int gs = logClusters[start]; | - |
2852 | int ge = (end == item_length ? si.num_glyphs : logClusters[end]) - 1;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2853 | QGlyphLayout glyphs = eng->shapedGlyphs(&si); | - |
2854 | | - |
2855 | QFixed item_width = 0; | - |
2856 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2857 | item_width = si.width; | - |
2858 | } else { never executed: end of block | 0 |
2859 | int g = gs; | - |
2860 | while (g <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2861 | item_width += glyphs.effectiveAdvance(g); | - |
2862 | ++g; | - |
2863 | } never executed: end of block | 0 |
2864 | } never executed: end of block | 0 |
2865 | | - |
2866 | | - |
2867 | if (pos + item_width < x) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2868 | pos += item_width; | - |
2869 | nchars += end; | - |
2870 | continue; never executed: continue; | 0 |
2871 | } | - |
2872 | | - |
2873 | if (si.analysis.flags >= QScriptAnalysis::TabOrObject) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2874 | if (cpos == QTextLine::CursorOnCharacter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2875 | return si.position; never executed: return si.position; | 0 |
2876 | bool left_half = (x - pos) < item_width/2; | - |
2877 | | - |
2878 | if (bool(si.analysis.bidiLevel % 2) != left_half)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2879 | return si.position; never executed: return si.position; | 0 |
2880 | return si.position + 1; never executed: return si.position + 1; | 0 |
2881 | } | - |
2882 | | - |
2883 | int glyph_pos = -1; | - |
2884 | QFixed edge; | - |
2885 | | - |
2886 | if (cpos == QTextLine::CursorOnCharacter) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2887 | if (si.analysis.bidiLevel % 2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2888 | pos += item_width; | - |
2889 | glyph_pos = gs; | - |
2890 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2891 | if (glyphs.attributes[gs].clusterStart) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2892 | if (pos < x)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2893 | break; never executed: break; | 0 |
2894 | glyph_pos = gs; | - |
2895 | edge = pos; | - |
2896 | } never executed: end of block | 0 |
2897 | pos -= glyphs.effectiveAdvance(gs); | - |
2898 | ++gs; | - |
2899 | } never executed: end of block | 0 |
2900 | } else { never executed: end of block | 0 |
2901 | glyph_pos = gs; | - |
2902 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2903 | if (glyphs.attributes[gs].clusterStart) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2904 | if (pos > x)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2905 | break; never executed: break; | 0 |
2906 | glyph_pos = gs; | - |
2907 | edge = pos; | - |
2908 | } never executed: end of block | 0 |
2909 | pos += glyphs.effectiveAdvance(gs); | - |
2910 | ++gs; | - |
2911 | } never executed: end of block | 0 |
2912 | } never executed: end of block | 0 |
2913 | } else { | - |
2914 | QFixed dist = INT_MAX/256; | - |
2915 | if (si.analysis.bidiLevel % 2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2916 | if (!visual || rtl || (lastLine && i == nItems - 1)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2917 | pos += item_width; | - |
2918 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2919 | if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2920 | glyph_pos = gs; | - |
2921 | edge = pos; | - |
2922 | dist = qAbs(x-pos); | - |
2923 | } never executed: end of block | 0 |
2924 | pos -= glyphs.effectiveAdvance(gs); | - |
2925 | ++gs; | - |
2926 | } never executed: end of block | 0 |
2927 | } else { never executed: end of block | 0 |
2928 | while (ge >= gs) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2929 | if (glyphs.attributes[ge].clusterStart && qAbs(x-pos) < dist) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2930 | glyph_pos = ge; | - |
2931 | edge = pos; | - |
2932 | dist = qAbs(x-pos); | - |
2933 | } never executed: end of block | 0 |
2934 | pos += glyphs.effectiveAdvance(ge); | - |
2935 | --ge; | - |
2936 | } never executed: end of block | 0 |
2937 | } never executed: end of block | 0 |
2938 | } else { | - |
2939 | if (!visual || !rtl || (lastLine && i == 0)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2940 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2941 | if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2942 | glyph_pos = gs; | - |
2943 | edge = pos; | - |
2944 | dist = qAbs(x-pos); | - |
2945 | } never executed: end of block | 0 |
2946 | pos += glyphs.effectiveAdvance(gs); | - |
2947 | ++gs; | - |
2948 | } never executed: end of block | 0 |
2949 | } else { never executed: end of block | 0 |
2950 | QFixed oldPos = pos; | - |
2951 | while (gs <= ge) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2952 | pos += glyphs.effectiveAdvance(gs); | - |
2953 | if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2954 | glyph_pos = gs; | - |
2955 | edge = pos; | - |
2956 | dist = qAbs(x-pos); | - |
2957 | } never executed: end of block | 0 |
2958 | ++gs; | - |
2959 | } never executed: end of block | 0 |
2960 | pos = oldPos; | - |
2961 | } never executed: end of block | 0 |
2962 | } | - |
2963 | if (qAbs(x-pos) < dist) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2964 | if (visual) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2965 | if (!rtl && i < nItems - 1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2966 | nchars += end; | - |
2967 | continue; never executed: continue; | 0 |
2968 | } | - |
2969 | if (rtl && nchars > 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2970 | return insertionPoints[lastLine ? nchars : nchars - 1]; never executed: return insertionPoints[lastLine ? nchars : nchars - 1]; | 0 |
2971 | } never executed: end of block | 0 |
2972 | return eng->positionInLigature(&si, end, x, pos, -1, never executed: return eng->positionInLigature(&si, end, x, pos, -1, cpos == QTextLine::CursorOnCharacter); | 0 |
2973 | cpos == QTextLine::CursorOnCharacter); never executed: return eng->positionInLigature(&si, end, x, pos, -1, cpos == QTextLine::CursorOnCharacter); | 0 |
2974 | } | - |
2975 | } never executed: end of block | 0 |
2976 | Q_ASSERT(glyph_pos != -1); | - |
2977 | return eng->positionInLigature(&si, end, x, edge, glyph_pos, never executed: return eng->positionInLigature(&si, end, x, edge, glyph_pos, cpos == QTextLine::CursorOnCharacter); | 0 |
2978 | cpos == QTextLine::CursorOnCharacter); never executed: return eng->positionInLigature(&si, end, x, edge, glyph_pos, cpos == QTextLine::CursorOnCharacter); | 0 |
2979 | } | - |
2980 | } never executed: end of block | 0 |
2981 | | - |
2982 | | - |
2983 | int item = visualOrder[nItems-1]+firstItem; | - |
2984 | QScriptItem &si = eng->layoutData->items[item]; | - |
2985 | if (!si.num_glyphs)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2986 | eng->shape(item); never executed: eng->shape(item); | 0 |
2987 | int pos = si.position; | - |
2988 | if (!(si.analysis.bidiLevel % 2))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2989 | pos += eng->length(item); never executed: pos += eng->length(item); | 0 |
2990 | pos = qMax(line.from, pos); | - |
2991 | | - |
2992 | int maxPos = line.from + line_length; | - |
2993 | | - |
2994 | | - |
2995 | | - |
2996 | | - |
2997 | | - |
2998 | | - |
2999 | if (this->index < eng->lines.count() - 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3000 | --maxPos; never executed: --maxPos; | 0 |
3001 | | - |
3002 | pos = qMin(pos, maxPos); | - |
3003 | return pos; never executed: return pos; | 0 |
3004 | } | - |
3005 | | - |
3006 | QT_END_NAMESPACE | - |
| | |