Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | QTextLength::operator QVariant() const | - |
5 | { | - |
6 | return QVariant(QVariant::TextLength, this); executed: return QVariant(QVariant::TextLength, this); Execution Count:294 | 294 |
7 | } | - |
8 | | - |
9 | | - |
10 | QDataStream &operator<<(QDataStream &stream, const QTextLength &length) | - |
11 | { | - |
12 | return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage); executed: return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage); Execution Count:1 | 1 |
13 | } | - |
14 | | - |
15 | QDataStream &operator>>(QDataStream &stream, QTextLength &length) | - |
16 | { | - |
17 | qint32 type; | - |
18 | double fixedValueOrPercentage; | - |
19 | stream >> type >> fixedValueOrPercentage; | - |
20 | length.fixedValueOrPercentage = fixedValueOrPercentage; | - |
21 | length.lengthType = QTextLength::Type(type); | - |
22 | return stream; executed: return stream; Execution Count:2 | 2 |
23 | } | - |
24 | | - |
25 | | - |
26 | class QTextFormatPrivate : public QSharedData | - |
27 | { | - |
28 | public: | - |
29 | QTextFormatPrivate() : hashDirty(true), fontDirty(true), hashValue(0) {} executed: } Execution Count:20951 | 20951 |
30 | | - |
31 | struct Property | - |
32 | { | - |
33 | inline Property(qint32 k, const QVariant &v) : key(k), value(v) {} executed: } Execution Count:260515 | 260515 |
34 | inline Property() {} | - |
35 | | - |
36 | qint32 key; | - |
37 | QVariant value; | - |
38 | | - |
39 | inline bool operator==(const Property &other) const | - |
40 | { return key == other.key && value == other.value; } executed: return key == other.key && value == other.value; Execution Count:3008 | 3008 |
41 | inline bool operator!=(const Property &other) const | - |
42 | { return key != other.key || value != other.value; } never executed: return key != other.key || value != other.value; | 0 |
43 | }; | - |
44 | | - |
45 | inline uint hash() const | - |
46 | { | - |
47 | if (!hashDirty) evaluated: !hashDirty yes Evaluation Count:63688 | yes Evaluation Count:7090 |
| 7090-63688 |
48 | return hashValue; executed: return hashValue; Execution Count:63688 | 63688 |
49 | return recalcHash(); executed: return recalcHash(); Execution Count:7090 | 7090 |
50 | } | - |
51 | | - |
52 | inline bool operator==(const QTextFormatPrivate &rhs) const { | - |
53 | if (hash() != rhs.hash()) evaluated: hash() != rhs.hash() yes Evaluation Count:28 | yes Evaluation Count:17801 |
| 28-17801 |
54 | return false; executed: return false; Execution Count:28 | 28 |
55 | | - |
56 | return props == rhs.props; executed: return props == rhs.props; Execution Count:17801 | 17801 |
57 | } | - |
58 | | - |
59 | inline void insertProperty(qint32 key, const QVariant &value) | - |
60 | { | - |
61 | hashDirty = true; | - |
62 | if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty) evaluated: key >= QTextFormat::FirstFontProperty yes Evaluation Count:248445 | yes Evaluation Count:36110 |
evaluated: key <= QTextFormat::LastFontProperty yes Evaluation Count:194421 | yes Evaluation Count:54024 |
| 36110-248445 |
63 | fontDirty = true; executed: fontDirty = true; Execution Count:194421 | 194421 |
64 | for (int i = 0; i < props.count(); ++i) evaluated: i < props.count() yes Evaluation Count:2572765 | yes Evaluation Count:260515 |
| 260515-2572765 |
65 | if (props.at(i).key == key) { evaluated: props.at(i).key == key yes Evaluation Count:24040 | yes Evaluation Count:2548725 |
| 24040-2548725 |
66 | props[i].value = value; | - |
67 | return; executed: return; Execution Count:24040 | 24040 |
68 | } | - |
69 | props.append(Property(key, value)); | - |
70 | } executed: } Execution Count:260515 | 260515 |
71 | | - |
72 | inline void clearProperty(qint32 key) | - |
73 | { | - |
74 | for (int i = 0; i < props.count(); ++i) evaluated: i < props.count() yes Evaluation Count:9336 | yes Evaluation Count:46321 |
| 9336-46321 |
75 | if (props.at(i).key == key) { evaluated: props.at(i).key == key yes Evaluation Count:950 | yes Evaluation Count:8386 |
| 950-8386 |
76 | hashDirty = true; | - |
77 | if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty) evaluated: key >= QTextFormat::FirstFontProperty yes Evaluation Count:547 | yes Evaluation Count:403 |
evaluated: key <= QTextFormat::LastFontProperty yes Evaluation Count:284 | yes Evaluation Count:263 |
| 263-547 |
78 | fontDirty = true; executed: fontDirty = true; Execution Count:284 | 284 |
79 | props.remove(i); | - |
80 | return; executed: return; Execution Count:950 | 950 |
81 | } | - |
82 | } executed: } Execution Count:46321 | 46321 |
83 | | - |
84 | inline int propertyIndex(qint32 key) const | - |
85 | { | - |
86 | for (int i = 0; i < props.count(); ++i) evaluated: i < props.count() yes Evaluation Count:335857 | yes Evaluation Count:130928 |
| 130928-335857 |
87 | if (props.at(i).key == key) evaluated: props.at(i).key == key yes Evaluation Count:39267 | yes Evaluation Count:296590 |
| 39267-296590 |
88 | return i; executed: return i; Execution Count:39267 | 39267 |
89 | return -1; executed: return -1; Execution Count:130928 | 130928 |
90 | } | - |
91 | | - |
92 | inline QVariant property(qint32 key) const | - |
93 | { | - |
94 | const int idx = propertyIndex(key); | - |
95 | if (idx < 0) evaluated: idx < 0 yes Evaluation Count:112534 | yes Evaluation Count:31798 |
| 31798-112534 |
96 | return QVariant(); executed: return QVariant(); Execution Count:112534 | 112534 |
97 | return props.at(idx).value; executed: return props.at(idx).value; Execution Count:31798 | 31798 |
98 | } | - |
99 | | - |
100 | inline bool hasProperty(qint32 key) const | - |
101 | { return propertyIndex(key) != -1; } executed: return propertyIndex(key) != -1; Execution Count:25863 | 25863 |
102 | | - |
103 | void resolveFont(const QFont &defaultFont); | - |
104 | | - |
105 | inline const QFont &font() const { | - |
106 | if (fontDirty) evaluated: fontDirty yes Evaluation Count:2737 | yes Evaluation Count:8121 |
| 2737-8121 |
107 | recalcFont(); executed: recalcFont(); Execution Count:2737 | 2737 |
108 | return fnt; executed: return fnt; Execution Count:10858 | 10858 |
109 | } | - |
110 | | - |
111 | QVector<Property> props; | - |
112 | private: | - |
113 | | - |
114 | uint recalcHash() const; | - |
115 | void recalcFont() const; | - |
116 | | - |
117 | mutable bool hashDirty; | - |
118 | mutable bool fontDirty; | - |
119 | mutable uint hashValue; | - |
120 | mutable QFont fnt; | - |
121 | | - |
122 | friend QDataStream &operator<<(QDataStream &, const QTextFormat &); | - |
123 | friend QDataStream &operator>>(QDataStream &, QTextFormat &); | - |
124 | }; | - |
125 | | - |
126 | | - |
127 | static inline uint hash(float d) | - |
128 | { | - |
129 | | - |
130 | | - |
131 | | - |
132 | union { float f; uint u; } cvt; | - |
133 | cvt.f = d; | - |
134 | return cvt.u; executed: return cvt.u; Execution Count:8815 | 8815 |
135 | | - |
136 | | - |
137 | | - |
138 | } | - |
139 | | - |
140 | static inline uint hash(const QColor &color) | - |
141 | { | - |
142 | return (color.isValid()) ? color.rgba() : 0x234109; executed: return (color.isValid()) ? color.rgba() : 0x234109; Execution Count:1748 | 1748 |
143 | } | - |
144 | | - |
145 | static inline uint hash(const QPen &pen) | - |
146 | { | - |
147 | return hash(pen.color()) + hash(pen.widthF()); never executed: return hash(pen.color()) + hash(pen.widthF()); | 0 |
148 | } | - |
149 | | - |
150 | static inline uint hash(const QBrush &brush) | - |
151 | { | - |
152 | return hash(brush.color()) + (brush.style() << 3); executed: return hash(brush.color()) + (brush.style() << 3); Execution Count:1747 | 1747 |
153 | } | - |
154 | | - |
155 | static inline uint variantHash(const QVariant &variant) | - |
156 | { | - |
157 | | - |
158 | switch (variant.userType()) { | - |
159 | case QVariant::String: return qHash(variant.toString()); executed: return qHash(variant.toString()); Execution Count:732 | 732 |
160 | case QVariant::Double: return hash(variant.toDouble()); executed: return hash(variant.toDouble()); Execution Count:8646 | 8646 |
161 | case QVariant::Int: return 0x811890 + variant.toInt(); executed: return 0x811890 + variant.toInt(); Execution Count:5229 | 5229 |
162 | case QVariant::Brush: | - |
163 | return 0x01010101 + hash(qvariant_cast<QBrush>(variant)); executed: return 0x01010101 + hash(qvariant_cast<QBrush>(variant)); Execution Count:1747 | 1747 |
164 | case QVariant::Bool: return 0x371818 + variant.toBool(); executed: return 0x371818 + variant.toBool(); Execution Count:985 | 985 |
165 | case QVariant::Pen: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); never executed: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); | 0 |
166 | case QVariant::List: | - |
167 | return 0x8377 + qvariant_cast<QVariantList>(variant).count(); executed: return 0x8377 + qvariant_cast<QVariantList>(variant).count(); Execution Count:85 | 85 |
168 | case QVariant::Color: return hash(qvariant_cast<QColor>(variant)); executed: return hash(qvariant_cast<QColor>(variant)); Execution Count:1 | 1 |
169 | case QVariant::TextLength: | - |
170 | return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); executed: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); Execution Count:169 | 169 |
171 | case QMetaType::Float: return hash(variant.toFloat()); never executed: return hash(variant.toFloat()); | 0 |
172 | case QVariant::Invalid: return 0; never executed: return 0; | 0 |
173 | default: break; executed: break; Execution Count:5 | 5 |
174 | } | - |
175 | return qHash(variant.typeName()); executed: return qHash(variant.typeName()); Execution Count:5 | 5 |
176 | } | - |
177 | | - |
178 | static inline int getHash(const QTextFormatPrivate *d, int format) | - |
179 | { | - |
180 | return (d ? d->hash() : 0) + format; executed: return (d ? d->hash() : 0) + format; Execution Count:43146 | 43146 |
181 | } | - |
182 | | - |
183 | uint QTextFormatPrivate::recalcHash() const | - |
184 | { | - |
185 | hashValue = 0; | - |
186 | for (QVector<Property>::ConstIterator it = props.constBegin(); it != props.constEnd(); ++it) evaluated: it != props.constEnd() yes Evaluation Count:17599 | yes Evaluation Count:7090 |
| 7090-17599 |
187 | hashValue += (it->key << 16) + variantHash(it->value); executed: hashValue += (it->key << 16) + variantHash(it->value); Execution Count:17599 | 17599 |
188 | | - |
189 | hashDirty = false; | - |
190 | | - |
191 | return hashValue; executed: return hashValue; Execution Count:7090 | 7090 |
192 | } | - |
193 | | - |
194 | void QTextFormatPrivate::resolveFont(const QFont &defaultFont) | - |
195 | { | - |
196 | recalcFont(); | - |
197 | const uint oldMask = fnt.resolve(); | - |
198 | fnt = fnt.resolve(defaultFont); | - |
199 | | - |
200 | if (hasProperty(QTextFormat::FontSizeAdjustment)) { evaluated: hasProperty(QTextFormat::FontSizeAdjustment) yes Evaluation Count:21 | yes Evaluation Count:9591 |
| 21-9591 |
201 | const qreal scaleFactors[7] = {qreal(0.7), qreal(0.8), qreal(1.0), qreal(1.2), qreal(1.5), qreal(2), qreal(2.4)}; | - |
202 | | - |
203 | const int htmlFontSize = qBound(0, property(QTextFormat::FontSizeAdjustment).toInt() + 3 - 1, 6); | - |
204 | | - |
205 | | - |
206 | if (defaultFont.pointSize() <= 0) { partially evaluated: defaultFont.pointSize() <= 0 no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
207 | qreal pixelSize = scaleFactors[htmlFontSize] * defaultFont.pixelSize(); | - |
208 | fnt.setPixelSize(qRound(pixelSize)); | - |
209 | } else { | 0 |
210 | qreal pointSize = scaleFactors[htmlFontSize] * defaultFont.pointSizeF(); | - |
211 | fnt.setPointSizeF(pointSize); | - |
212 | } executed: } Execution Count:21 | 21 |
213 | } | - |
214 | | - |
215 | fnt.resolve(oldMask); | - |
216 | } executed: } Execution Count:9612 | 9612 |
217 | | - |
218 | void QTextFormatPrivate::recalcFont() const | - |
219 | { | - |
220 | | - |
221 | QFont f; | - |
222 | | - |
223 | bool hasSpacingInformation = false; | - |
224 | QFont::SpacingType spacingType = QFont::PercentageSpacing; | - |
225 | qreal letterSpacing = 0.0; | - |
226 | | - |
227 | for (int i = 0; i < props.count(); ++i) { evaluated: i < props.count() yes Evaluation Count:70466 | yes Evaluation Count:12349 |
| 12349-70466 |
228 | switch (props.at(i).key) { | - |
229 | case QTextFormat::FontFamily: | - |
230 | f.setFamily(props.at(i).value.toString()); | - |
231 | break; executed: break; Execution Count:3313 | 3313 |
232 | case QTextFormat::FontPointSize: | - |
233 | f.setPointSizeF(props.at(i).value.toReal()); | - |
234 | break; executed: break; Execution Count:2760 | 2760 |
235 | case QTextFormat::FontPixelSize: | - |
236 | f.setPixelSize(props.at(i).value.toInt()); | - |
237 | break; executed: break; Execution Count:12 | 12 |
238 | case QTextFormat::FontWeight: { | - |
239 | int weight = props.at(i).value.toInt(); | - |
240 | if (weight == 0) weight = QFont::Normal; evaluated: weight == 0 yes Evaluation Count:2747 | yes Evaluation Count:87 |
executed: weight = QFont::Normal; Execution Count:2747 | 87-2747 |
241 | f.setWeight(weight); | - |
242 | break; } executed: break; Execution Count:2834 | 2834 |
243 | case QTextFormat::FontItalic: | - |
244 | f.setItalic(props.at(i).value.toBool()); | - |
245 | break; executed: break; Execution Count:2775 | 2775 |
246 | case QTextFormat::FontUnderline: | - |
247 | if (! hasProperty(QTextFormat::TextUnderlineStyle)) evaluated: ! hasProperty(QTextFormat::TextUnderlineStyle) yes Evaluation Count:1 | yes Evaluation Count:2768 |
| 1-2768 |
248 | f.setUnderline(props.at(i).value.toBool()); executed: f.setUnderline(props.at(i).value.toBool()); Execution Count:1 | 1 |
249 | break; executed: break; Execution Count:2769 | 2769 |
250 | case QTextFormat::TextUnderlineStyle: | - |
251 | f.setUnderline(static_cast<QTextCharFormat::UnderlineStyle>(props.at(i).value.toInt()) == QTextCharFormat::SingleUnderline); | - |
252 | break; executed: break; Execution Count:2778 | 2778 |
253 | case QTextFormat::FontOverline: | - |
254 | f.setOverline(props.at(i).value.toBool()); | - |
255 | break; executed: break; Execution Count:2740 | 2740 |
256 | case QTextFormat::FontStrikeOut: | - |
257 | f.setStrikeOut(props.at(i).value.toBool()); | - |
258 | break; executed: break; Execution Count:2736 | 2736 |
259 | case QTextFormat::FontLetterSpacingType: | - |
260 | spacingType = static_cast<QFont::SpacingType>(props.at(i).value.toInt()); | - |
261 | hasSpacingInformation = true; | - |
262 | break; executed: break; Execution Count:2731 | 2731 |
263 | case QTextFormat::FontLetterSpacing: | - |
264 | letterSpacing = props.at(i).value.toReal(); | - |
265 | hasSpacingInformation = true; | - |
266 | break; executed: break; Execution Count:2731 | 2731 |
267 | case QTextFormat::FontWordSpacing: | - |
268 | f.setWordSpacing(props.at(i).value.toReal()); | - |
269 | break; executed: break; Execution Count:2733 | 2733 |
270 | case QTextFormat::FontCapitalization: | - |
271 | f.setCapitalization(static_cast<QFont::Capitalization> (props.at(i).value.toInt())); | - |
272 | break; executed: break; Execution Count:2737 | 2737 |
273 | case QTextFormat::FontFixedPitch: { | - |
274 | const bool value = props.at(i).value.toBool(); | - |
275 | if (f.fixedPitch() != value) evaluated: f.fixedPitch() != value yes Evaluation Count:542 | yes Evaluation Count:2731 |
| 542-2731 |
276 | f.setFixedPitch(value); executed: f.setFixedPitch(value); Execution Count:542 | 542 |
277 | break; } executed: break; Execution Count:3273 | 3273 |
278 | case QTextFormat::FontStretch: | - |
279 | f.setStretch(props.at(i).value.toInt()); | - |
280 | break; executed: break; Execution Count:2731 | 2731 |
281 | case QTextFormat::FontStyleHint: | - |
282 | f.setStyleHint(static_cast<QFont::StyleHint>(props.at(i).value.toInt()), f.styleStrategy()); | - |
283 | break; executed: break; Execution Count:2733 | 2733 |
284 | case QTextFormat::FontHintingPreference: | - |
285 | f.setHintingPreference(static_cast<QFont::HintingPreference>(props.at(i).value.toInt())); | - |
286 | break; | 0 |
287 | case QTextFormat::FontStyleStrategy: | - |
288 | f.setStyleStrategy(static_cast<QFont::StyleStrategy>(props.at(i).value.toInt())); | - |
289 | break; executed: break; Execution Count:2733 | 2733 |
290 | case QTextFormat::FontKerning: | - |
291 | f.setKerning(props.at(i).value.toBool()); | - |
292 | break; executed: break; Execution Count:2731 | 2731 |
293 | default: | - |
294 | break; executed: break; Execution Count:22616 | 22616 |
295 | } | - |
296 | } executed: } Execution Count:70466 | 70466 |
297 | | - |
298 | if (hasSpacingInformation) evaluated: hasSpacingInformation yes Evaluation Count:2731 | yes Evaluation Count:9618 |
| 2731-9618 |
299 | f.setLetterSpacing(spacingType, letterSpacing); executed: f.setLetterSpacing(spacingType, letterSpacing); Execution Count:2731 | 2731 |
300 | | - |
301 | fnt = f; | - |
302 | fontDirty = false; | - |
303 | } executed: } Execution Count:12349 | 12349 |
304 | | - |
305 | | - |
306 | __attribute__((visibility("default"))) QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt) | - |
307 | { | - |
308 | stream << fmt.format_type << fmt.properties(); | - |
309 | return stream; never executed: return stream; | 0 |
310 | } | - |
311 | | - |
312 | __attribute__((visibility("default"))) QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) | - |
313 | { | - |
314 | QMap<qint32, QVariant> properties; | - |
315 | stream >> fmt.format_type >> properties; | - |
316 | | - |
317 | | - |
318 | | - |
319 | if(!fmt.d) | 0 |
320 | fmt.d = new QTextFormatPrivate(); never executed: fmt.d = new QTextFormatPrivate(); | 0 |
321 | | - |
322 | for (QMap<qint32, QVariant>::ConstIterator it = properties.constBegin(); | - |
323 | it != properties.constEnd(); ++it) never evaluated: it != properties.constEnd() | 0 |
324 | fmt.d->insertProperty(it.key(), it.value()); never executed: fmt.d->insertProperty(it.key(), it.value()); | 0 |
325 | | - |
326 | return stream; never executed: return stream; | 0 |
327 | } | - |
328 | QTextFormat::QTextFormat() | - |
329 | : format_type(InvalidFormat) | - |
330 | { | - |
331 | } executed: } Execution Count:3103 | 3103 |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | QTextFormat::QTextFormat(int type) | - |
339 | : format_type(type) | - |
340 | { | - |
341 | } executed: } Execution Count:67936 | 67936 |
342 | QTextFormat::QTextFormat(const QTextFormat &rhs) | - |
343 | : d(rhs.d), format_type(rhs.format_type) | - |
344 | { | - |
345 | } executed: } Execution Count:349402 | 349402 |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | QTextFormat &QTextFormat::operator=(const QTextFormat &rhs) | - |
354 | { | - |
355 | d = rhs.d; | - |
356 | format_type = rhs.format_type; | - |
357 | return *this; executed: return *this; Execution Count:13915 | 13915 |
358 | } | - |
359 | QTextFormat::~QTextFormat() | - |
360 | { | - |
361 | } | - |
362 | | - |
363 | | - |
364 | | - |
365 | | - |
366 | | - |
367 | QTextFormat::operator QVariant() const | - |
368 | { | - |
369 | return QVariant(QVariant::TextFormat, this); executed: return QVariant(QVariant::TextFormat, this); Execution Count:2 | 2 |
370 | } | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | void QTextFormat::merge(const QTextFormat &other) | - |
377 | { | - |
378 | if (format_type != other.format_type) partially evaluated: format_type != other.format_type no Evaluation Count:0 | yes Evaluation Count:16874 |
| 0-16874 |
379 | return; | 0 |
380 | | - |
381 | if (!d) { evaluated: !d yes Evaluation Count:112 | yes Evaluation Count:16762 |
| 112-16762 |
382 | d = other.d; | - |
383 | return; executed: return; Execution Count:112 | 112 |
384 | } | - |
385 | | - |
386 | if (!other.d) evaluated: !other.d yes Evaluation Count:12802 | yes Evaluation Count:3960 |
| 3960-12802 |
387 | return; executed: return; Execution Count:12802 | 12802 |
388 | | - |
389 | QTextFormatPrivate *d = this->d; | - |
390 | | - |
391 | const QVector<QTextFormatPrivate::Property> &otherProps = other.d->props; | - |
392 | d->props.reserve(d->props.size() + otherProps.size()); | - |
393 | for (int i = 0; i < otherProps.count(); ++i) { evaluated: i < otherProps.count() yes Evaluation Count:4370 | yes Evaluation Count:3960 |
| 3960-4370 |
394 | const QTextFormatPrivate::Property &p = otherProps.at(i); | - |
395 | d->insertProperty(p.key, p.value); | - |
396 | } executed: } Execution Count:4370 | 4370 |
397 | } executed: } Execution Count:3960 | 3960 |
398 | | - |
399 | | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | int QTextFormat::type() const | - |
405 | { | - |
406 | return format_type; executed: return format_type; Execution Count:4187 | 4187 |
407 | } | - |
408 | | - |
409 | | - |
410 | | - |
411 | | - |
412 | QTextBlockFormat QTextFormat::toBlockFormat() const | - |
413 | { | - |
414 | return QTextBlockFormat(*this); executed: return QTextBlockFormat(*this); Execution Count:28060 | 28060 |
415 | } | - |
416 | | - |
417 | | - |
418 | | - |
419 | | - |
420 | QTextCharFormat QTextFormat::toCharFormat() const | - |
421 | { | - |
422 | return QTextCharFormat(*this); executed: return QTextCharFormat(*this); Execution Count:50821 | 50821 |
423 | } | - |
424 | | - |
425 | | - |
426 | | - |
427 | | - |
428 | QTextListFormat QTextFormat::toListFormat() const | - |
429 | { | - |
430 | return QTextListFormat(*this); executed: return QTextListFormat(*this); Execution Count:85 | 85 |
431 | } | - |
432 | | - |
433 | | - |
434 | | - |
435 | | - |
436 | QTextTableFormat QTextFormat::toTableFormat() const | - |
437 | { | - |
438 | return QTextTableFormat(*this); executed: return QTextTableFormat(*this); Execution Count:411 | 411 |
439 | } | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | QTextFrameFormat QTextFormat::toFrameFormat() const | - |
445 | { | - |
446 | return QTextFrameFormat(*this); executed: return QTextFrameFormat(*this); Execution Count:1992 | 1992 |
447 | } | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | QTextImageFormat QTextFormat::toImageFormat() const | - |
453 | { | - |
454 | return QTextImageFormat(*this); executed: return QTextImageFormat(*this); Execution Count:26 | 26 |
455 | } | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | QTextTableCellFormat QTextFormat::toTableCellFormat() const | - |
463 | { | - |
464 | return QTextTableCellFormat(*this); executed: return QTextTableCellFormat(*this); Execution Count:217 | 217 |
465 | } | - |
466 | bool QTextFormat::boolProperty(int propertyId) const | - |
467 | { | - |
468 | if (!d) evaluated: !d yes Evaluation Count:56541 | yes Evaluation Count:3415 |
| 3415-56541 |
469 | return false; executed: return false; Execution Count:56541 | 56541 |
470 | const QVariant prop = d->property(propertyId); | - |
471 | if (prop.userType() != QVariant::Bool) evaluated: prop.userType() != QVariant::Bool yes Evaluation Count:3279 | yes Evaluation Count:136 |
| 136-3279 |
472 | return false; executed: return false; Execution Count:3279 | 3279 |
473 | return prop.toBool(); executed: return prop.toBool(); Execution Count:136 | 136 |
474 | } | - |
475 | int QTextFormat::intProperty(int propertyId) const | - |
476 | { | - |
477 | | - |
478 | int def = (propertyId == QTextFormat::LayoutDirection) ? int(Qt::LayoutDirectionAuto) : 0; evaluated: (propertyId == QTextFormat::LayoutDirection) yes Evaluation Count:5251 | yes Evaluation Count:33395 |
| 5251-33395 |
479 | | - |
480 | if (!d) evaluated: !d yes Evaluation Count:15 | yes Evaluation Count:38631 |
| 15-38631 |
481 | return def; executed: return def; Execution Count:15 | 15 |
482 | const QVariant prop = d->property(propertyId); | - |
483 | if (prop.userType() != QVariant::Int) evaluated: prop.userType() != QVariant::Int yes Evaluation Count:36646 | yes Evaluation Count:1985 |
| 1985-36646 |
484 | return def; executed: return def; Execution Count:36646 | 36646 |
485 | return prop.toInt(); executed: return prop.toInt(); Execution Count:1985 | 1985 |
486 | } | - |
487 | qreal QTextFormat::doubleProperty(int propertyId) const | - |
488 | { | - |
489 | if (!d) evaluated: !d yes Evaluation Count:219 | yes Evaluation Count:17052 |
| 219-17052 |
490 | return 0.; executed: return 0.; Execution Count:219 | 219 |
491 | const QVariant prop = d->property(propertyId); | - |
492 | if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float) evaluated: prop.userType() != QVariant::Double yes Evaluation Count:11505 | yes Evaluation Count:5547 |
partially evaluated: prop.userType() != QMetaType::Float yes Evaluation Count:11505 | no Evaluation Count:0 |
| 0-11505 |
493 | return 0.; executed: return 0.; Execution Count:11505 | 11505 |
494 | return qvariant_cast<qreal>(prop); executed: return qvariant_cast<qreal>(prop); Execution Count:5547 | 5547 |
495 | } | - |
496 | QString QTextFormat::stringProperty(int propertyId) const | - |
497 | { | - |
498 | if (!d) evaluated: !d yes Evaluation Count:1 | yes Evaluation Count:230 |
| 1-230 |
499 | return QString(); executed: return QString(); Execution Count:1 | 1 |
500 | const QVariant prop = d->property(propertyId); | - |
501 | if (prop.userType() != QVariant::String) evaluated: prop.userType() != QVariant::String yes Evaluation Count:99 | yes Evaluation Count:131 |
| 99-131 |
502 | return QString(); executed: return QString(); Execution Count:99 | 99 |
503 | return prop.toString(); executed: return prop.toString(); Execution Count:131 | 131 |
504 | } | - |
505 | QColor QTextFormat::colorProperty(int propertyId) const | - |
506 | { | - |
507 | if (!d) evaluated: !d yes Evaluation Count:447 | yes Evaluation Count:17 |
| 17-447 |
508 | return QColor(); executed: return QColor(); Execution Count:447 | 447 |
509 | const QVariant prop = d->property(propertyId); | - |
510 | if (prop.userType() != QVariant::Color) partially evaluated: prop.userType() != QVariant::Color yes Evaluation Count:17 | no Evaluation Count:0 |
| 0-17 |
511 | return QColor(); executed: return QColor(); Execution Count:17 | 17 |
512 | return qvariant_cast<QColor>(prop); never executed: return qvariant_cast<QColor>(prop); | 0 |
513 | } | - |
514 | QPen QTextFormat::penProperty(int propertyId) const | - |
515 | { | - |
516 | if (!d) evaluated: !d yes Evaluation Count:14825 | yes Evaluation Count:209 |
| 209-14825 |
517 | return QPen(Qt::NoPen); executed: return QPen(Qt::NoPen); Execution Count:14825 | 14825 |
518 | const QVariant prop = d->property(propertyId); | - |
519 | if (prop.userType() != QVariant::Pen) partially evaluated: prop.userType() != QVariant::Pen yes Evaluation Count:209 | no Evaluation Count:0 |
| 0-209 |
520 | return QPen(Qt::NoPen); executed: return QPen(Qt::NoPen); Execution Count:209 | 209 |
521 | return qvariant_cast<QPen>(prop); never executed: return qvariant_cast<QPen>(prop); | 0 |
522 | } | - |
523 | QBrush QTextFormat::brushProperty(int propertyId) const | - |
524 | { | - |
525 | if (!d) evaluated: !d yes Evaluation Count:632 | yes Evaluation Count:6905 |
| 632-6905 |
526 | return QBrush(Qt::NoBrush); executed: return QBrush(Qt::NoBrush); Execution Count:632 | 632 |
527 | const QVariant prop = d->property(propertyId); | - |
528 | if (prop.userType() != QVariant::Brush) evaluated: prop.userType() != QVariant::Brush yes Evaluation Count:1351 | yes Evaluation Count:5554 |
| 1351-5554 |
529 | return QBrush(Qt::NoBrush); executed: return QBrush(Qt::NoBrush); Execution Count:1351 | 1351 |
530 | return qvariant_cast<QBrush>(prop); executed: return qvariant_cast<QBrush>(prop); Execution Count:5554 | 5554 |
531 | } | - |
532 | | - |
533 | | - |
534 | | - |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | QTextLength QTextFormat::lengthProperty(int propertyId) const | - |
540 | { | - |
541 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:3200 |
| 0-3200 |
542 | return QTextLength(); never executed: return QTextLength(); | 0 |
543 | return qvariant_cast<QTextLength>(d->property(propertyId)); executed: return qvariant_cast<QTextLength>(d->property(propertyId)); Execution Count:3200 | 3200 |
544 | } | - |
545 | QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const | - |
546 | { | - |
547 | QVector<QTextLength> vector; | - |
548 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
549 | return vector; never executed: return vector; | 0 |
550 | const QVariant prop = d->property(propertyId); | - |
551 | if (prop.userType() != QVariant::List) evaluated: prop.userType() != QVariant::List yes Evaluation Count:33 | yes Evaluation Count:20 |
| 20-33 |
552 | return vector; executed: return vector; Execution Count:33 | 33 |
553 | | - |
554 | QList<QVariant> propertyList = prop.toList(); | - |
555 | for (int i=0; i<propertyList.size(); ++i) { evaluated: i<propertyList.size() yes Evaluation Count:24 | yes Evaluation Count:20 |
| 20-24 |
556 | QVariant var = propertyList.at(i); | - |
557 | if (var.userType() == QVariant::TextLength) partially evaluated: var.userType() == QVariant::TextLength yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
558 | vector.append(qvariant_cast<QTextLength>(var)); executed: vector.append(qvariant_cast<QTextLength>(var)); Execution Count:24 | 24 |
559 | } executed: } Execution Count:24 | 24 |
560 | | - |
561 | return vector; executed: return vector; Execution Count:20 | 20 |
562 | } | - |
563 | | - |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | QVariant QTextFormat::property(int propertyId) const | - |
570 | { | - |
571 | return d ? d->property(propertyId) : QVariant(); executed: return d ? d->property(propertyId) : QVariant(); Execution Count:4559 | 4559 |
572 | } | - |
573 | | - |
574 | | - |
575 | | - |
576 | | - |
577 | | - |
578 | | - |
579 | void QTextFormat::setProperty(int propertyId, const QVariant &value) | - |
580 | { | - |
581 | if (!d) evaluated: !d yes Evaluation Count:16044 | yes Evaluation Count:263202 |
| 16044-263202 |
582 | d = new QTextFormatPrivate; executed: d = new QTextFormatPrivate; Execution Count:16044 | 16044 |
583 | if (!value.isValid()) partially evaluated: !value.isValid() no Evaluation Count:0 | yes Evaluation Count:279246 |
| 0-279246 |
584 | clearProperty(propertyId); never executed: clearProperty(propertyId); | 0 |
585 | else | - |
586 | d->insertProperty(propertyId, value); executed: d->insertProperty(propertyId, value); Execution Count:279246 | 279246 |
587 | } | - |
588 | | - |
589 | | - |
590 | | - |
591 | | - |
592 | | - |
593 | | - |
594 | void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value) | - |
595 | { | - |
596 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:81 |
| 0-81 |
597 | d = new QTextFormatPrivate; never executed: d = new QTextFormatPrivate; | 0 |
598 | QVariantList list; | - |
599 | for (int i=0; i<value.size(); ++i) evaluated: i<value.size() yes Evaluation Count:126 | yes Evaluation Count:81 |
| 81-126 |
600 | list << value.at(i); executed: list << value.at(i); Execution Count:126 | 126 |
601 | d->insertProperty(propertyId, list); | - |
602 | } executed: } Execution Count:81 | 81 |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
608 | | - |
609 | void QTextFormat::clearProperty(int propertyId) | - |
610 | { | - |
611 | if (!d) evaluated: !d yes Evaluation Count:6197 | yes Evaluation Count:47269 |
| 6197-47269 |
612 | return; executed: return; Execution Count:6197 | 6197 |
613 | d->clearProperty(propertyId); | - |
614 | } executed: } Execution Count:47269 | 47269 |
615 | int QTextFormat::objectIndex() const | - |
616 | { | - |
617 | if (!d) evaluated: !d yes Evaluation Count:91 | yes Evaluation Count:70040 |
| 91-70040 |
618 | return -1; executed: return -1; Execution Count:91 | 91 |
619 | const QVariant prop = d->property(ObjectIndex); | - |
620 | if (prop.userType() != QVariant::Int) evaluated: prop.userType() != QVariant::Int yes Evaluation Count:51813 | yes Evaluation Count:18227 |
| 18227-51813 |
621 | return -1; executed: return -1; Execution Count:51813 | 51813 |
622 | return prop.toInt(); executed: return prop.toInt(); Execution Count:18227 | 18227 |
623 | } | - |
624 | void QTextFormat::setObjectIndex(int o) | - |
625 | { | - |
626 | if (o == -1) { evaluated: o == -1 yes Evaluation Count:2 | yes Evaluation Count:858 |
| 2-858 |
627 | if (d) partially evaluated: d yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
628 | d->clearProperty(ObjectIndex); executed: d->clearProperty(ObjectIndex); Execution Count:2 | 2 |
629 | } else { executed: } Execution Count:2 | 2 |
630 | if (!d) evaluated: !d yes Evaluation Count:225 | yes Evaluation Count:633 |
| 225-633 |
631 | d = new QTextFormatPrivate; executed: d = new QTextFormatPrivate; Execution Count:225 | 225 |
632 | | - |
633 | d->insertProperty(ObjectIndex, o); | - |
634 | } executed: } Execution Count:858 | 858 |
635 | } | - |
636 | | - |
637 | | - |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | bool QTextFormat::hasProperty(int propertyId) const | - |
644 | { | - |
645 | return d ? d->hasProperty(propertyId) : false; executed: return d ? d->hasProperty(propertyId) : false; Execution Count:35631 | 35631 |
646 | } | - |
647 | QMap<int, QVariant> QTextFormat::properties() const | - |
648 | { | - |
649 | QMap<int, QVariant> map; | - |
650 | if (d) { evaluated: d yes Evaluation Count:180 | yes Evaluation Count:83 |
| 83-180 |
651 | for (int i = 0; i < d->props.count(); ++i) evaluated: i < d->props.count() yes Evaluation Count:6 | yes Evaluation Count:180 |
| 6-180 |
652 | map.insert(d->props.at(i).key, d->props.at(i).value); executed: map.insert(d->props.at(i).key, d->props.at(i).value); Execution Count:6 | 6 |
653 | } executed: } Execution Count:180 | 180 |
654 | return map; executed: return map; Execution Count:263 | 263 |
655 | } | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | | - |
661 | int QTextFormat::propertyCount() const | - |
662 | { | - |
663 | return d ? d->props.count() : 0; executed: return d ? d->props.count() : 0; Execution Count:1562 | 1562 |
664 | } | - |
665 | bool QTextFormat::operator==(const QTextFormat &rhs) const | - |
666 | { | - |
667 | if (format_type != rhs.format_type) evaluated: format_type != rhs.format_type yes Evaluation Count:1823 | yes Evaluation Count:34945 |
| 1823-34945 |
668 | return false; executed: return false; Execution Count:1823 | 1823 |
669 | | - |
670 | if (d == rhs.d) evaluated: d == rhs.d yes Evaluation Count:13460 | yes Evaluation Count:21485 |
| 13460-21485 |
671 | return true; executed: return true; Execution Count:13460 | 13460 |
672 | | - |
673 | if (d && d->props.isEmpty() && !rhs.d) evaluated: d yes Evaluation Count:21459 | yes Evaluation Count:26 |
evaluated: d->props.isEmpty() yes Evaluation Count:19686 | yes Evaluation Count:1773 |
evaluated: !rhs.d yes Evaluation Count:3618 | yes Evaluation Count:16068 |
| 26-21459 |
674 | return true; executed: return true; Execution Count:3618 | 3618 |
675 | | - |
676 | if (!d && rhs.d && rhs.d->props.isEmpty()) evaluated: !d yes Evaluation Count:26 | yes Evaluation Count:17841 |
partially evaluated: rhs.d yes Evaluation Count:26 | no Evaluation Count:0 |
partially evaluated: rhs.d->props.isEmpty() no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-17841 |
677 | return true; never executed: return true; | 0 |
678 | | - |
679 | if (!d || !rhs.d) evaluated: !d yes Evaluation Count:26 | yes Evaluation Count:17841 |
evaluated: !rhs.d yes Evaluation Count:12 | yes Evaluation Count:17829 |
| 12-17841 |
680 | return false; executed: return false; Execution Count:38 | 38 |
681 | | - |
682 | return *d == *rhs.d; executed: return *d == *rhs.d; Execution Count:17829 | 17829 |
683 | } | - |
684 | QTextCharFormat::QTextCharFormat() : QTextFormat(CharFormat) {} executed: } Execution Count:60067 | 60067 |
685 | QTextCharFormat::QTextCharFormat(const QTextFormat &fmt) | - |
686 | : QTextFormat(fmt) | - |
687 | { | - |
688 | } executed: } Execution Count:51064 | 51064 |
689 | bool QTextCharFormat::fontUnderline() const | - |
690 | { | - |
691 | if (hasProperty(TextUnderlineStyle)) evaluated: hasProperty(TextUnderlineStyle) yes Evaluation Count:17 | yes Evaluation Count:8 |
| 8-17 |
692 | return underlineStyle() == SingleUnderline; executed: return underlineStyle() == SingleUnderline; Execution Count:17 | 17 |
693 | return boolProperty(FontUnderline); executed: return boolProperty(FontUnderline); Execution Count:8 | 8 |
694 | } | - |
695 | void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) | - |
696 | { | - |
697 | setProperty(TextUnderlineStyle, style); | - |
698 | | - |
699 | setProperty(FontUnderline, style == SingleUnderline); | - |
700 | } executed: } Execution Count:12898 | 12898 |
701 | QString QTextCharFormat::anchorName() const | - |
702 | { | - |
703 | QVariant prop = property(AnchorName); | - |
704 | if (prop.userType() == QVariant::StringList) evaluated: prop.userType() == QVariant::StringList yes Evaluation Count:12 | yes Evaluation Count:19 |
| 12-19 |
705 | return prop.toStringList().value(0); executed: return prop.toStringList().value(0); Execution Count:12 | 12 |
706 | else if (prop.userType() != QVariant::String) partially evaluated: prop.userType() != QVariant::String yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
707 | return QString(); executed: return QString(); Execution Count:19 | 19 |
708 | return prop.toString(); never executed: return prop.toString(); | 0 |
709 | } | - |
710 | QStringList QTextCharFormat::anchorNames() const | - |
711 | { | - |
712 | QVariant prop = property(AnchorName); | - |
713 | if (prop.userType() == QVariant::StringList) evaluated: prop.userType() == QVariant::StringList yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
714 | return prop.toStringList(); executed: return prop.toStringList(); Execution Count:2 | 2 |
715 | else if (prop.userType() != QVariant::String) partially evaluated: prop.userType() != QVariant::String yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
716 | return QStringList(); executed: return QStringList(); Execution Count:1 | 1 |
717 | return QStringList(prop.toString()); never executed: return QStringList(prop.toString()); | 0 |
718 | } | - |
719 | void QTextCharFormat::setFont(const QFont &font) | - |
720 | { | - |
721 | setFontFamily(font.family()); | - |
722 | | - |
723 | const qreal pointSize = font.pointSizeF(); | - |
724 | if (pointSize > 0) { evaluated: pointSize > 0 yes Evaluation Count:12867 | yes Evaluation Count:1 |
| 1-12867 |
725 | setFontPointSize(pointSize); | - |
726 | } else { executed: } Execution Count:12867 | 12867 |
727 | const int pixelSize = font.pixelSize(); | - |
728 | if (pixelSize > 0) partially evaluated: pixelSize > 0 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
729 | setProperty(QTextFormat::FontPixelSize, pixelSize); executed: setProperty(QTextFormat::FontPixelSize, pixelSize); Execution Count:1 | 1 |
730 | } executed: } Execution Count:1 | 1 |
731 | | - |
732 | setFontWeight(font.weight()); | - |
733 | setFontItalic(font.italic()); | - |
734 | setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline); | - |
735 | setFontOverline(font.overline()); | - |
736 | setFontStrikeOut(font.strikeOut()); | - |
737 | setFontFixedPitch(font.fixedPitch()); | - |
738 | setFontCapitalization(font.capitalization()); | - |
739 | setFontWordSpacing(font.wordSpacing()); | - |
740 | setFontLetterSpacingType(font.letterSpacingType()); | - |
741 | setFontLetterSpacing(font.letterSpacing()); | - |
742 | setFontStretch(font.stretch()); | - |
743 | setFontStyleHint(font.styleHint()); | - |
744 | setFontStyleStrategy(font.styleStrategy()); | - |
745 | setFontKerning(font.kerning()); | - |
746 | } executed: } Execution Count:12868 | 12868 |
747 | | - |
748 | | - |
749 | | - |
750 | | - |
751 | QFont QTextCharFormat::font() const | - |
752 | { | - |
753 | return d ? d->font() : QFont(); executed: return d ? d->font() : QFont(); Execution Count:10858 | 10858 |
754 | } | - |
755 | QTextBlockFormat::QTextBlockFormat() : QTextFormat(BlockFormat) {} executed: } Execution Count:6240 | 6240 |
756 | QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt) | - |
757 | : QTextFormat(fmt) | - |
758 | { | - |
759 | } executed: } Execution Count:28060 | 28060 |
760 | void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs) | - |
761 | { | - |
762 | QList<QVariant> list; | - |
763 | QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin(); | - |
764 | while (iter != tabs.constEnd()) { evaluated: iter != tabs.constEnd() yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
765 | QVariant v; | - |
766 | v.setValue<QTextOption::Tab>(*iter); | - |
767 | list.append(v); | - |
768 | ++iter; | - |
769 | } executed: } Execution Count:4 | 4 |
770 | setProperty(TabPositions, list); | - |
771 | } executed: } Execution Count:4 | 4 |
772 | | - |
773 | | - |
774 | | - |
775 | | - |
776 | | - |
777 | | - |
778 | | - |
779 | QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const | - |
780 | { | - |
781 | QVariant variant = property(TabPositions); | - |
782 | if(variant.isNull()) evaluated: variant.isNull() yes Evaluation Count:2020 | yes Evaluation Count:4 |
| 4-2020 |
783 | return QList<QTextOption::Tab>(); executed: return QList<QTextOption::Tab>(); Execution Count:2020 | 2020 |
784 | QList<QTextOption::Tab> answer; | - |
785 | QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant); | - |
786 | QList<QVariant>::Iterator iter = variantsList.begin(); | - |
787 | while(iter != variantsList.end()) { evaluated: iter != variantsList.end() yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
788 | answer.append( qvariant_cast<QTextOption::Tab>(*iter)); | - |
789 | ++iter; | - |
790 | } executed: } Execution Count:4 | 4 |
791 | return answer; executed: return answer; Execution Count:4 | 4 |
792 | } | - |
793 | QTextListFormat::QTextListFormat() | - |
794 | : QTextFormat(ListFormat) | - |
795 | { | - |
796 | setIndent(1); | - |
797 | } executed: } Execution Count:115 | 115 |
798 | QTextListFormat::QTextListFormat(const QTextFormat &fmt) | - |
799 | : QTextFormat(fmt) | - |
800 | { | - |
801 | } executed: } Execution Count:85 | 85 |
802 | QTextFrameFormat::QTextFrameFormat() : QTextFormat(FrameFormat) | - |
803 | { | - |
804 | setBorderStyle(BorderStyle_Outset); | - |
805 | setBorderBrush(Qt::darkGray); | - |
806 | } executed: } Execution Count:1512 | 1512 |
807 | QTextFrameFormat::QTextFrameFormat(const QTextFormat &fmt) | - |
808 | : QTextFormat(fmt) | - |
809 | { | - |
810 | } executed: } Execution Count:2403 | 2403 |
811 | void QTextFrameFormat::setMargin(qreal amargin) | - |
812 | { | - |
813 | setProperty(FrameMargin, amargin); | - |
814 | setProperty(FrameTopMargin, amargin); | - |
815 | setProperty(FrameBottomMargin, amargin); | - |
816 | setProperty(FrameLeftMargin, amargin); | - |
817 | setProperty(FrameRightMargin, amargin); | - |
818 | } executed: } Execution Count:1280 | 1280 |
819 | qreal QTextFrameFormat::topMargin() const | - |
820 | { | - |
821 | if (!hasProperty(FrameTopMargin)) evaluated: !hasProperty(FrameTopMargin) yes Evaluation Count:10 | yes Evaluation Count:868 |
| 10-868 |
822 | return margin(); executed: return margin(); Execution Count:10 | 10 |
823 | return doubleProperty(FrameTopMargin); executed: return doubleProperty(FrameTopMargin); Execution Count:868 | 868 |
824 | } | - |
825 | qreal QTextFrameFormat::bottomMargin() const | - |
826 | { | - |
827 | if (!hasProperty(FrameBottomMargin)) evaluated: !hasProperty(FrameBottomMargin) yes Evaluation Count:9 | yes Evaluation Count:867 |
| 9-867 |
828 | return margin(); executed: return margin(); Execution Count:9 | 9 |
829 | return doubleProperty(FrameBottomMargin); executed: return doubleProperty(FrameBottomMargin); Execution Count:867 | 867 |
830 | } | - |
831 | qreal QTextFrameFormat::leftMargin() const | - |
832 | { | - |
833 | if (!hasProperty(FrameLeftMargin)) evaluated: !hasProperty(FrameLeftMargin) yes Evaluation Count:9 | yes Evaluation Count:1085 |
| 9-1085 |
834 | return margin(); executed: return margin(); Execution Count:9 | 9 |
835 | return doubleProperty(FrameLeftMargin); executed: return doubleProperty(FrameLeftMargin); Execution Count:1085 | 1085 |
836 | } | - |
837 | qreal QTextFrameFormat::rightMargin() const | - |
838 | { | - |
839 | if (!hasProperty(FrameRightMargin)) evaluated: !hasProperty(FrameRightMargin) yes Evaluation Count:10 | yes Evaluation Count:869 |
| 10-869 |
840 | return margin(); executed: return margin(); Execution Count:10 | 10 |
841 | return doubleProperty(FrameRightMargin); executed: return doubleProperty(FrameRightMargin); Execution Count:869 | 869 |
842 | } | - |
843 | QTextTableFormat::QTextTableFormat() | - |
844 | : QTextFrameFormat() | - |
845 | { | - |
846 | setObjectType(TableObject); | - |
847 | setCellSpacing(2); | - |
848 | setBorder(1); | - |
849 | } executed: } Execution Count:148 | 148 |
850 | QTextTableFormat::QTextTableFormat(const QTextFormat &fmt) | - |
851 | : QTextFrameFormat(fmt) | - |
852 | { | - |
853 | } executed: } Execution Count:411 | 411 |
854 | QTextImageFormat::QTextImageFormat() : QTextCharFormat() { setObjectType(ImageObject); } executed: } Execution Count:30 | 30 |
855 | QTextImageFormat::QTextImageFormat(const QTextFormat &fmt) | - |
856 | : QTextCharFormat(fmt) | - |
857 | { | - |
858 | } executed: } Execution Count:26 | 26 |
859 | QTextTableCellFormat::QTextTableCellFormat() | - |
860 | : QTextCharFormat() | - |
861 | { | - |
862 | setObjectType(TableCellObject); | - |
863 | } | 0 |
864 | QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt) | - |
865 | : QTextCharFormat(fmt) | - |
866 | { | - |
867 | } executed: } Execution Count:217 | 217 |
868 | QTextFormatCollection::QTextFormatCollection(const QTextFormatCollection &rhs) | - |
869 | { | - |
870 | formats = rhs.formats; | - |
871 | objFormats = rhs.objFormats; | - |
872 | } | 0 |
873 | | - |
874 | QTextFormatCollection &QTextFormatCollection::operator=(const QTextFormatCollection &rhs) | - |
875 | { | - |
876 | formats = rhs.formats; | - |
877 | objFormats = rhs.objFormats; | - |
878 | return *this; executed: return *this; Execution Count:751 | 751 |
879 | } | - |
880 | | - |
881 | QTextFormatCollection::~QTextFormatCollection() | - |
882 | { | - |
883 | } | - |
884 | | - |
885 | int QTextFormatCollection::indexForFormat(const QTextFormat &format) | - |
886 | { | - |
887 | uint hash = getHash(format.d, format.format_type); | - |
888 | QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash); | - |
889 | while (i != hashes.constEnd() && i.key() == hash) { evaluated: i != hashes.constEnd() yes Evaluation Count:37131 | yes Evaluation Count:7978 |
evaluated: i.key() == hash yes Evaluation Count:35928 | yes Evaluation Count:1203 |
| 1203-37131 |
890 | if (formats.value(i.value()) == format) { evaluated: formats.value(i.value()) == format yes Evaluation Count:33965 | yes Evaluation Count:1963 |
| 1963-33965 |
891 | return i.value(); executed: return i.value(); Execution Count:33965 | 33965 |
892 | } | - |
893 | ++i; | - |
894 | } executed: } Execution Count:1963 | 1963 |
895 | | - |
896 | int idx = formats.size(); | - |
897 | formats.append(format); | - |
898 | | - |
899 | if (true){ partially evaluated: true yes Evaluation Count:9181 | no Evaluation Count:0 |
| 0-9181 |
900 | QTextFormat &f = formats.last(); | - |
901 | if (!f.d) evaluated: !f.d yes Evaluation Count:4682 | yes Evaluation Count:4499 |
| 4499-4682 |
902 | f.d = new QTextFormatPrivate; executed: f.d = new QTextFormatPrivate; Execution Count:4682 | 4682 |
903 | f.d->resolveFont(defaultFnt); | - |
904 | | - |
905 | if (!hashes.contains(hash, idx)) evaluated: !hashes.contains(hash, idx) yes Evaluation Count:7378 | yes Evaluation Count:1803 |
| 1803-7378 |
906 | hashes.insert(hash, idx); executed: hashes.insert(hash, idx); Execution Count:7378 | 7378 |
907 | | - |
908 | } else { executed: } Execution Count:9181 | 9181 |
909 | formats.pop_back(); | - |
910 | qt_noop(); | - |
911 | } | 0 |
912 | return idx; executed: return idx; Execution Count:9181 | 9181 |
913 | } | - |
914 | | - |
915 | bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const | - |
916 | { | - |
917 | uint hash = getHash(format.d, format.format_type); | - |
918 | QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash); | - |
919 | while (i != hashes.constEnd() && i.key() == hash) { never evaluated: i != hashes.constEnd() never evaluated: i.key() == hash | 0 |
920 | if (formats.value(i.value()) == format) { never evaluated: formats.value(i.value()) == format | 0 |
921 | return true; never executed: return true; | 0 |
922 | } | - |
923 | ++i; | - |
924 | } | 0 |
925 | return false; never executed: return false; | 0 |
926 | } | - |
927 | | - |
928 | QTextFormat QTextFormatCollection::objectFormat(int objectIndex) const | - |
929 | { | - |
930 | if (objectIndex == -1) evaluated: objectIndex == -1 yes Evaluation Count:1 | yes Evaluation Count:2692 |
| 1-2692 |
931 | return QTextFormat(); executed: return QTextFormat(); Execution Count:1 | 1 |
932 | return format(objFormats.at(objectIndex)); executed: return format(objFormats.at(objectIndex)); Execution Count:2692 | 2692 |
933 | } | - |
934 | | - |
935 | void QTextFormatCollection::setObjectFormat(int objectIndex, const QTextFormat &f) | - |
936 | { | - |
937 | const int formatIndex = indexForFormat(f); | - |
938 | objFormats[objectIndex] = formatIndex; | - |
939 | } | 0 |
940 | | - |
941 | int QTextFormatCollection::objectFormatIndex(int objectIndex) const | - |
942 | { | - |
943 | if (objectIndex == -1) evaluated: objectIndex == -1 yes Evaluation Count:1 | yes Evaluation Count:91 |
| 1-91 |
944 | return -1; executed: return -1; Execution Count:1 | 1 |
945 | return objFormats.at(objectIndex); executed: return objFormats.at(objectIndex); Execution Count:91 | 91 |
946 | } | - |
947 | | - |
948 | void QTextFormatCollection::setObjectFormatIndex(int objectIndex, int formatIndex) | - |
949 | { | - |
950 | objFormats[objectIndex] = formatIndex; | - |
951 | } executed: } Execution Count:90 | 90 |
952 | | - |
953 | int QTextFormatCollection::createObjectIndex(const QTextFormat &f) | - |
954 | { | - |
955 | const int objectIndex = objFormats.size(); | - |
956 | objFormats.append(indexForFormat(f)); | - |
957 | return objectIndex; executed: return objectIndex; Execution Count:1527 | 1527 |
958 | } | - |
959 | | - |
960 | QTextFormat QTextFormatCollection::format(int idx) const | - |
961 | { | - |
962 | if (idx < 0 || idx >= formats.count()) partially evaluated: idx < 0 no Evaluation Count:0 | yes Evaluation Count:125362 |
partially evaluated: idx >= formats.count() no Evaluation Count:0 | yes Evaluation Count:125362 |
| 0-125362 |
963 | return QTextFormat(); never executed: return QTextFormat(); | 0 |
964 | | - |
965 | return formats.at(idx); executed: return formats.at(idx); Execution Count:125362 | 125362 |
966 | } | - |
967 | | - |
968 | void QTextFormatCollection::setDefaultFont(const QFont &f) | - |
969 | { | - |
970 | defaultFnt = f; | - |
971 | for (int i = 0; i < formats.count(); ++i) evaluated: i < formats.count() yes Evaluation Count:431 | yes Evaluation Count:162 |
| 162-431 |
972 | if (formats[i].d) partially evaluated: formats[i].d yes Evaluation Count:431 | no Evaluation Count:0 |
| 0-431 |
973 | formats[i].d->resolveFont(defaultFnt); executed: formats[i].d->resolveFont(defaultFnt); Execution Count:431 | 431 |
974 | } executed: } Execution Count:162 | 162 |
975 | | - |
976 | | - |
977 | QDebug operator<<(QDebug dbg, const QTextLength &l) | - |
978 | { | - |
979 | dbg.nospace() << "QTextLength(QTextLength::Type(" << l.type() << "))"; | - |
980 | return dbg.space(); executed: return dbg.space(); Execution Count:1 | 1 |
981 | } | - |
982 | | - |
983 | QDebug operator<<(QDebug dbg, const QTextFormat &f) | - |
984 | { | - |
985 | dbg.nospace() << "QTextFormat(QTextFormat::FormatType(" << f.type() << "))"; | - |
986 | return dbg.space(); executed: return dbg.space(); Execution Count:1 | 1 |
987 | } | - |
988 | | - |
989 | | - |
990 | | - |
991 | | - |
992 | | - |
| | |