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