| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickstyledtext.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | __attribute__((visibility("default"))) int qt_defaultDpi(); | - | ||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | class QQuickStyledTextPrivate | - | ||||||||||||||||||||||||||||||
| 6 | { | - | ||||||||||||||||||||||||||||||
| 7 | public: | - | ||||||||||||||||||||||||||||||
| 8 | enum ListType { Ordered, Unordered }; | - | ||||||||||||||||||||||||||||||
| 9 | enum ListFormat { Bullet, Disc, Square, Decimal, LowerAlpha, UpperAlpha, LowerRoman, UpperRoman }; | - | ||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | struct List { | - | ||||||||||||||||||||||||||||||
| 12 | int level; | - | ||||||||||||||||||||||||||||||
| 13 | ListType type; | - | ||||||||||||||||||||||||||||||
| 14 | ListFormat format; | - | ||||||||||||||||||||||||||||||
| 15 | }; | - | ||||||||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||||||||
| 17 | QQuickStyledTextPrivate(const QString &t, QTextLayout &l, | - | ||||||||||||||||||||||||||||||
| 18 | QList<QQuickStyledTextImgTag*> &imgTags, | - | ||||||||||||||||||||||||||||||
| 19 | const QUrl &baseUrl, | - | ||||||||||||||||||||||||||||||
| 20 | QQmlContext *context, | - | ||||||||||||||||||||||||||||||
| 21 | bool preloadImages, | - | ||||||||||||||||||||||||||||||
| 22 | bool *fontSizeModified) | - | ||||||||||||||||||||||||||||||
| 23 | : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(true), nbImages(0), updateImagePositions(false) | - | ||||||||||||||||||||||||||||||
| 24 | , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), fontSizeModified(fontSizeModified), context(context) | - | ||||||||||||||||||||||||||||||
| 25 | { | - | ||||||||||||||||||||||||||||||
| 26 | } executed 2146 times by 7 tests: end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||||||||
| 28 | void parse(); | - | ||||||||||||||||||||||||||||||
| 29 | void appendText(const QString &textIn, int start, int length, QString &textOut); | - | ||||||||||||||||||||||||||||||
| 30 | bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format); | - | ||||||||||||||||||||||||||||||
| 31 | bool parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut); | - | ||||||||||||||||||||||||||||||
| 32 | void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut); | - | ||||||||||||||||||||||||||||||
| 33 | bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format); | - | ||||||||||||||||||||||||||||||
| 34 | bool parseOrderedListAttributes(const QChar *&ch, const QString &textIn); | - | ||||||||||||||||||||||||||||||
| 35 | bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn); | - | ||||||||||||||||||||||||||||||
| 36 | bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format); | - | ||||||||||||||||||||||||||||||
| 37 | void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut); | - | ||||||||||||||||||||||||||||||
| 38 | QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn); | - | ||||||||||||||||||||||||||||||
| 39 | QStringRef parseValue(const QChar *&ch, const QString &textIn); | - | ||||||||||||||||||||||||||||||
| 40 | void setFontSize(int size, QTextCharFormat &format); | - | ||||||||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||||||||
| 42 | inline void skipSpace(const QChar *&ch) { | - | ||||||||||||||||||||||||||||||
| 43 | while (ch->isSpace()
| 0-6806 | ||||||||||||||||||||||||||||||
| 44 | ++ executed 1046 times by 3 tests: ch;++ch;Executed by:
executed 1046 times by 3 tests: ++ch;Executed by:
| 1046 | ||||||||||||||||||||||||||||||
| 45 | } executed 6806 times by 7 tests: end of blockExecuted by:
| 6806 | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | static QString toAlpha(int value, bool upper); | - | ||||||||||||||||||||||||||||||
| 48 | static QString toRoman(int value, bool upper); | - | ||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||
| 50 | QString text; | - | ||||||||||||||||||||||||||||||
| 51 | QTextLayout &layout; | - | ||||||||||||||||||||||||||||||
| 52 | QList<QQuickStyledTextImgTag*> *imgTags; | - | ||||||||||||||||||||||||||||||
| 53 | QFont baseFont; | - | ||||||||||||||||||||||||||||||
| 54 | QStack<List> listStack; | - | ||||||||||||||||||||||||||||||
| 55 | QUrl baseUrl; | - | ||||||||||||||||||||||||||||||
| 56 | bool hasNewLine; | - | ||||||||||||||||||||||||||||||
| 57 | int nbImages; | - | ||||||||||||||||||||||||||||||
| 58 | bool updateImagePositions; | - | ||||||||||||||||||||||||||||||
| 59 | bool preFormat; | - | ||||||||||||||||||||||||||||||
| 60 | bool prependSpace; | - | ||||||||||||||||||||||||||||||
| 61 | bool hasSpace; | - | ||||||||||||||||||||||||||||||
| 62 | bool preloadImages; | - | ||||||||||||||||||||||||||||||
| 63 | bool *fontSizeModified; | - | ||||||||||||||||||||||||||||||
| 64 | QQmlContext *context; | - | ||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||
| 66 | static const QChar lessThan; | - | ||||||||||||||||||||||||||||||
| 67 | static const QChar greaterThan; | - | ||||||||||||||||||||||||||||||
| 68 | static const QChar equals; | - | ||||||||||||||||||||||||||||||
| 69 | static const QChar singleQuote; | - | ||||||||||||||||||||||||||||||
| 70 | static const QChar doubleQuote; | - | ||||||||||||||||||||||||||||||
| 71 | static const QChar slash; | - | ||||||||||||||||||||||||||||||
| 72 | static const QChar ampersand; | - | ||||||||||||||||||||||||||||||
| 73 | static const QChar bullet; | - | ||||||||||||||||||||||||||||||
| 74 | static const QChar disc; | - | ||||||||||||||||||||||||||||||
| 75 | static const QChar square; | - | ||||||||||||||||||||||||||||||
| 76 | static const QChar lineFeed; | - | ||||||||||||||||||||||||||||||
| 77 | static const QChar space; | - | ||||||||||||||||||||||||||||||
| 78 | static const int tabsize = 6; | - | ||||||||||||||||||||||||||||||
| 79 | }; | - | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | const QChar QQuickStyledTextPrivate::lessThan(QLatin1Char('<')); | - | ||||||||||||||||||||||||||||||
| 82 | const QChar QQuickStyledTextPrivate::greaterThan(QLatin1Char('>')); | - | ||||||||||||||||||||||||||||||
| 83 | const QChar QQuickStyledTextPrivate::equals(QLatin1Char('=')); | - | ||||||||||||||||||||||||||||||
| 84 | const QChar QQuickStyledTextPrivate::singleQuote(QLatin1Char('\'')); | - | ||||||||||||||||||||||||||||||
| 85 | const QChar QQuickStyledTextPrivate::doubleQuote(QLatin1Char('\"')); | - | ||||||||||||||||||||||||||||||
| 86 | const QChar QQuickStyledTextPrivate::slash(QLatin1Char('/')); | - | ||||||||||||||||||||||||||||||
| 87 | const QChar QQuickStyledTextPrivate::ampersand(QLatin1Char('&')); | - | ||||||||||||||||||||||||||||||
| 88 | const QChar QQuickStyledTextPrivate::bullet(0x2022); | - | ||||||||||||||||||||||||||||||
| 89 | const QChar QQuickStyledTextPrivate::disc(0x25e6); | - | ||||||||||||||||||||||||||||||
| 90 | const QChar QQuickStyledTextPrivate::square(0x25a1); | - | ||||||||||||||||||||||||||||||
| 91 | const QChar QQuickStyledTextPrivate::lineFeed(QLatin1Char('\n')); | - | ||||||||||||||||||||||||||||||
| 92 | const QChar QQuickStyledTextPrivate::space(QLatin1Char(' ')); | - | ||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||
| 94 | QQuickStyledText::QQuickStyledText(const QString &string, QTextLayout &layout, | - | ||||||||||||||||||||||||||||||
| 95 | QList<QQuickStyledTextImgTag*> &imgTags, | - | ||||||||||||||||||||||||||||||
| 96 | const QUrl &baseUrl, | - | ||||||||||||||||||||||||||||||
| 97 | QQmlContext *context, | - | ||||||||||||||||||||||||||||||
| 98 | bool preloadImages, | - | ||||||||||||||||||||||||||||||
| 99 | bool *fontSizeModified) | - | ||||||||||||||||||||||||||||||
| 100 | : d(new QQuickStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified)) | - | ||||||||||||||||||||||||||||||
| 101 | { | - | ||||||||||||||||||||||||||||||
| 102 | } executed 2146 times by 7 tests: end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | QQuickStyledText::~QQuickStyledText() | - | ||||||||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||||||||
| 106 | delete d; | - | ||||||||||||||||||||||||||||||
| 107 | } executed 2146 times by 7 tests: end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | void QQuickStyledText::parse(const QString &string, QTextLayout &layout, | - | ||||||||||||||||||||||||||||||
| 110 | QList<QQuickStyledTextImgTag*> &imgTags, | - | ||||||||||||||||||||||||||||||
| 111 | const QUrl &baseUrl, | - | ||||||||||||||||||||||||||||||
| 112 | QQmlContext *context, | - | ||||||||||||||||||||||||||||||
| 113 | bool preloadImages, | - | ||||||||||||||||||||||||||||||
| 114 | bool *fontSizeModified) | - | ||||||||||||||||||||||||||||||
| 115 | { | - | ||||||||||||||||||||||||||||||
| 116 | if (string.isEmpty()
| 2-2146 | ||||||||||||||||||||||||||||||
| 117 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 118 | QQuickStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified); | - | ||||||||||||||||||||||||||||||
| 119 | styledText.d->parse(); | - | ||||||||||||||||||||||||||||||
| 120 | } executed 2146 times by 7 tests: end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||||||||
| 122 | void QQuickStyledTextPrivate::parse() | - | ||||||||||||||||||||||||||||||
| 123 | { | - | ||||||||||||||||||||||||||||||
| 124 | QVector<QTextLayout::FormatRange> ranges; | - | ||||||||||||||||||||||||||||||
| 125 | QStack<QTextCharFormat> formatStack; | - | ||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||
| 127 | QString drawText; | - | ||||||||||||||||||||||||||||||
| 128 | drawText.reserve(text.count()); | - | ||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | updateImagePositions = !imgTags->isEmpty(); | - | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | int textStart = 0; | - | ||||||||||||||||||||||||||||||
| 133 | int textLength = 0; | - | ||||||||||||||||||||||||||||||
| 134 | int rangeStart = 0; | - | ||||||||||||||||||||||||||||||
| 135 | bool formatChanged = false; | - | ||||||||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||||||||
| 137 | const QChar *ch = text.constData(); | - | ||||||||||||||||||||||||||||||
| 138 | while (!ch->isNull()
| 2146-20051504 | ||||||||||||||||||||||||||||||
| 139 | if (*
| 4844-20046660 | ||||||||||||||||||||||||||||||
| 140 | if (textLength
| 2356-2488 | ||||||||||||||||||||||||||||||
| 141 | appendText(text, textStart, textLength, drawText); | - | ||||||||||||||||||||||||||||||
| 142 | } executed 2356 times by 7 tests: else if (prependSpaceend of blockExecuted by:
| 812-2356 | ||||||||||||||||||||||||||||||
| 143 | drawText.append(space); | - | ||||||||||||||||||||||||||||||
| 144 | prependSpace = false; | - | ||||||||||||||||||||||||||||||
| 145 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 146 | } executed 1676 times by 3 tests: end of blockExecuted by:
| 1676 | ||||||||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||||||||
| 148 | if (rangeStart != drawText.length()
| 778-4066 | ||||||||||||||||||||||||||||||
| 149 | if (formatChanged
| 18-2298 | ||||||||||||||||||||||||||||||
| 150 | QTextLayout::FormatRange formatRange; | - | ||||||||||||||||||||||||||||||
| 151 | formatRange.format = formatStack.top(); | - | ||||||||||||||||||||||||||||||
| 152 | formatRange.start = rangeStart; | - | ||||||||||||||||||||||||||||||
| 153 | formatRange.length = drawText.length() - rangeStart; | - | ||||||||||||||||||||||||||||||
| 154 | ranges.append(formatRange); | - | ||||||||||||||||||||||||||||||
| 155 | formatChanged = false; | - | ||||||||||||||||||||||||||||||
| 156 | } executed 2298 times by 7 tests: else if (ranges.count()end of blockExecuted by:
| 0-2298 | ||||||||||||||||||||||||||||||
| 157 | ranges.last().length += drawText.length() - rangeStart; | - | ||||||||||||||||||||||||||||||
| 158 | } executed 18 times by 3 tests: end of blockExecuted by:
| 18 | ||||||||||||||||||||||||||||||
| 159 | } executed 2316 times by 7 tests: end of blockExecuted by:
| 2316 | ||||||||||||||||||||||||||||||
| 160 | rangeStart = drawText.length(); | - | ||||||||||||||||||||||||||||||
| 161 | ++ch; | - | ||||||||||||||||||||||||||||||
| 162 | if (*
| 2220-2624 | ||||||||||||||||||||||||||||||
| 163 | ++ch; | - | ||||||||||||||||||||||||||||||
| 164 | if (parseCloseTag(ch, text, drawText)
| 114-2106 | ||||||||||||||||||||||||||||||
| 165 | if (formatStack.count()
| 16-2090 | ||||||||||||||||||||||||||||||
| 166 | formatChanged = true; | - | ||||||||||||||||||||||||||||||
| 167 | formatStack.pop(); | - | ||||||||||||||||||||||||||||||
| 168 | } executed 2090 times by 6 tests: end of blockExecuted by:
| 2090 | ||||||||||||||||||||||||||||||
| 169 | } executed 2106 times by 6 tests: end of blockExecuted by:
| 2106 | ||||||||||||||||||||||||||||||
| 170 | } executed 2220 times by 6 tests: else {end of blockExecuted by:
| 2220 | ||||||||||||||||||||||||||||||
| 171 | QTextCharFormat format; | - | ||||||||||||||||||||||||||||||
| 172 | if (formatStack.count()
| 256-2368 | ||||||||||||||||||||||||||||||
| 173 | format = formatStack.top(); executed 256 times by 4 tests: format = formatStack.top();Executed by:
| 256 | ||||||||||||||||||||||||||||||
| 174 | if (parseTag(ch, text, drawText, format)
| 504-2120 | ||||||||||||||||||||||||||||||
| 175 | formatChanged = true; | - | ||||||||||||||||||||||||||||||
| 176 | formatStack.push(format); | - | ||||||||||||||||||||||||||||||
| 177 | } executed 2120 times by 7 tests: end of blockExecuted by:
| 2120 | ||||||||||||||||||||||||||||||
| 178 | } executed 2624 times by 7 tests: end of blockExecuted by:
| 2624 | ||||||||||||||||||||||||||||||
| 179 | textStart = ch - text.constData() + 1; | - | ||||||||||||||||||||||||||||||
| 180 | textLength = 0; | - | ||||||||||||||||||||||||||||||
| 181 | } executed 4844 times by 7 tests: else if (*end of blockExecuted by:
| 30-20046630 | ||||||||||||||||||||||||||||||
| 182 | ++ch; | - | ||||||||||||||||||||||||||||||
| 183 | appendText(text, textStart, textLength, drawText); | - | ||||||||||||||||||||||||||||||
| 184 | parseEntity(ch, text, drawText); | - | ||||||||||||||||||||||||||||||
| 185 | textStart = ch - text.constData() + 1; | - | ||||||||||||||||||||||||||||||
| 186 | textLength = 0; | - | ||||||||||||||||||||||||||||||
| 187 | } executed 30 times by 1 test: else if (ch->isSpace()end of blockExecuted by:
| 30-20039182 | ||||||||||||||||||||||||||||||
| 188 | if (textLength
| 1436-6012 | ||||||||||||||||||||||||||||||
| 189 | appendText(text, textStart, textLength, drawText); executed 6012 times by 6 tests: appendText(text, textStart, textLength, drawText);Executed by:
| 6012 | ||||||||||||||||||||||||||||||
| 190 | if (!preFormat
| 6-7442 | ||||||||||||||||||||||||||||||
| 191 | prependSpace = !hasSpace; | - | ||||||||||||||||||||||||||||||
| 192 | for (const QChar *n = ch + 1; !n->isNull()
| 6-20009776 | ||||||||||||||||||||||||||||||
| 193 | ch = n; executed 20002340 times by 3 tests: ch = n;Executed by:
| 20002340 | ||||||||||||||||||||||||||||||
| 194 | hasNewLine = false; | - | ||||||||||||||||||||||||||||||
| 195 | } executed 7442 times by 6 tests: else if (*end of blockExecuted by:
| 2-7442 | ||||||||||||||||||||||||||||||
| 196 | drawText.append(QChar(QChar::LineSeparator)); | - | ||||||||||||||||||||||||||||||
| 197 | hasNewLine = true; | - | ||||||||||||||||||||||||||||||
| 198 | } executed 2 times by 1 test: else {end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 199 | drawText.append(QChar(QChar::Nbsp)); | - | ||||||||||||||||||||||||||||||
| 200 | hasNewLine = false; | - | ||||||||||||||||||||||||||||||
| 201 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 202 | textStart = ch - text.constData() + 1; | - | ||||||||||||||||||||||||||||||
| 203 | textLength = 0; | - | ||||||||||||||||||||||||||||||
| 204 | } executed 7448 times by 6 tests: else {end of blockExecuted by:
| 7448 | ||||||||||||||||||||||||||||||
| 205 | ++textLength; | - | ||||||||||||||||||||||||||||||
| 206 | } executed 20039182 times by 7 tests: end of blockExecuted by:
| 20039182 | ||||||||||||||||||||||||||||||
| 207 | if (!ch->isNull()
| 10-20051494 | ||||||||||||||||||||||||||||||
| 208 | ++ executed 20051494 times by 7 tests: ch;++ch;Executed by:
executed 20051494 times by 7 tests: ++ch;Executed by:
| 20051494 | ||||||||||||||||||||||||||||||
| 209 | } executed 20051504 times by 7 tests: end of blockExecuted by:
| 20051504 | ||||||||||||||||||||||||||||||
| 210 | if (textLength
| 244-1902 | ||||||||||||||||||||||||||||||
| 211 | appendText(text, textStart, textLength, drawText); executed 1902 times by 6 tests: appendText(text, textStart, textLength, drawText);Executed by:
| 1902 | ||||||||||||||||||||||||||||||
| 212 | if (rangeStart != drawText.length()
| 20-1958 | ||||||||||||||||||||||||||||||
| 213 | if (formatChanged
| 4-16 | ||||||||||||||||||||||||||||||
| 214 | QTextLayout::FormatRange formatRange; | - | ||||||||||||||||||||||||||||||
| 215 | formatRange.format = formatStack.top(); | - | ||||||||||||||||||||||||||||||
| 216 | formatRange.start = rangeStart; | - | ||||||||||||||||||||||||||||||
| 217 | formatRange.length = drawText.length() - rangeStart; | - | ||||||||||||||||||||||||||||||
| 218 | ranges.append(formatRange); | - | ||||||||||||||||||||||||||||||
| 219 | } executed 16 times by 1 test: else if (ranges.count()end of blockExecuted by:
| 0-16 | ||||||||||||||||||||||||||||||
| 220 | ranges.last().length += drawText.length() - rangeStart; | - | ||||||||||||||||||||||||||||||
| 221 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 222 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||||||||
| 224 | layout.setText(drawText); | - | ||||||||||||||||||||||||||||||
| 225 | layout.setFormats(ranges); | - | ||||||||||||||||||||||||||||||
| 226 | } executed 2146 times by 7 tests: end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | void QQuickStyledTextPrivate::appendText(const QString &textIn, int start, int length, QString &textOut) | - | ||||||||||||||||||||||||||||||
| 229 | { | - | ||||||||||||||||||||||||||||||
| 230 | if (prependSpace
| 4940-5360 | ||||||||||||||||||||||||||||||
| 231 | textOut.append(space); executed 4940 times by 6 tests: textOut.append(space);Executed by:
| 4940 | ||||||||||||||||||||||||||||||
| 232 | textOut.append(QStringRef(&textIn, start, length)); | - | ||||||||||||||||||||||||||||||
| 233 | prependSpace = false; | - | ||||||||||||||||||||||||||||||
| 234 | hasSpace = false; | - | ||||||||||||||||||||||||||||||
| 235 | hasNewLine = false; | - | ||||||||||||||||||||||||||||||
| 236 | } executed 10300 times by 7 tests: end of blockExecuted by:
| 10300 | ||||||||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | void QQuickStyledTextPrivate::setFontSize(int size, QTextCharFormat &format) | - | ||||||||||||||||||||||||||||||
| 243 | { | - | ||||||||||||||||||||||||||||||
| 244 | static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 }; | - | ||||||||||||||||||||||||||||||
| 245 | if (baseFont.pointSizeF() != -1
| 648-666 | ||||||||||||||||||||||||||||||
| 246 | format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]); executed 666 times by 2 tests: format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]);Executed by:
| 666 | ||||||||||||||||||||||||||||||
| 247 | else | - | ||||||||||||||||||||||||||||||
| 248 | format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]); executed 648 times by 1 test: format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]);Executed by:
| 648 | ||||||||||||||||||||||||||||||
| 249 | *fontSizeModified = true; | - | ||||||||||||||||||||||||||||||
| 250 | } executed 1314 times by 2 tests: end of blockExecuted by:
| 1314 | ||||||||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||||||||
| 252 | bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) | - | ||||||||||||||||||||||||||||||
| 253 | { | - | ||||||||||||||||||||||||||||||
| 254 | skipSpace(ch); | - | ||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||
| 256 | int tagStart = ch - textIn.constData(); | - | ||||||||||||||||||||||||||||||
| 257 | int tagLength = 0; | - | ||||||||||||||||||||||||||||||
| 258 | while (!ch->isNull()
| 4-8732 | ||||||||||||||||||||||||||||||
| 259 | if (*
| 1684-7048 | ||||||||||||||||||||||||||||||
| 260 | if (tagLength == 0
| 6-1678 | ||||||||||||||||||||||||||||||
| 261 | return executed 6 times by 2 tests: false;return false;Executed by:
executed 6 times by 2 tests: return false;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 262 | QStringRef tag(&textIn, tagStart, tagLength); | - | ||||||||||||||||||||||||||||||
| 263 | const QChar char0 = tag.at(0); | - | ||||||||||||||||||||||||||||||
| 264 | if (char0 == QLatin1Char('b')
| 760-918 | ||||||||||||||||||||||||||||||
| 265 | if (tagLength == 1
| 174-586 | ||||||||||||||||||||||||||||||
| 266 | format.setFontWeight(QFont::Bold); | - | ||||||||||||||||||||||||||||||
| 267 | return executed 586 times by 7 tests: true;return true;Executed by:
executed 586 times by 7 tests: return true;Executed by:
| 586 | ||||||||||||||||||||||||||||||
| 268 | } else if (tagLength == 2
| 2-168 | ||||||||||||||||||||||||||||||
| 269 | textOut.append(QChar(QChar::LineSeparator)); | - | ||||||||||||||||||||||||||||||
| 270 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 271 | prependSpace = false; | - | ||||||||||||||||||||||||||||||
| 272 | return executed 166 times by 2 tests: false;return false;Executed by:
executed 166 times by 2 tests: return false;Executed by:
| 166 | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | } executed 8 times by 1 test: else if (char0 == QLatin1Char('i')end of blockExecuted by:
| 8-846 | ||||||||||||||||||||||||||||||
| 275 | if (tagLength == 1
| 2-70 | ||||||||||||||||||||||||||||||
| 276 | format.setFontItalic(true); | - | ||||||||||||||||||||||||||||||
| 277 | return executed 70 times by 2 tests: true;return true;Executed by:
executed 70 times by 2 tests: return true;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 278 | } | - | ||||||||||||||||||||||||||||||
| 279 | } executed 2 times by 1 test: else if (char0 == QLatin1Char('p')end of blockExecuted by:
| 2-824 | ||||||||||||||||||||||||||||||
| 280 | if (tagLength == 1
| 10-12 | ||||||||||||||||||||||||||||||
| 281 | if (!hasNewLine
| 0-12 | ||||||||||||||||||||||||||||||
| 282 | textOut.append(QChar::LineSeparator); executed 12 times by 2 tests: textOut.append(QChar::LineSeparator);Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 283 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 284 | prependSpace = false; | - | ||||||||||||||||||||||||||||||
| 285 | } executed 12 times by 2 tests: else if (tag == QLatin1String("pre")end of blockExecuted by:
| 4-12 | ||||||||||||||||||||||||||||||
| 286 | preFormat = true; | - | ||||||||||||||||||||||||||||||
| 287 | if (!hasNewLine
| 0-4 | ||||||||||||||||||||||||||||||
| 288 | textOut.append(QChar::LineSeparator); executed 4 times by 1 test: textOut.append(QChar::LineSeparator);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 289 | format.setFontFamily(QString::fromLatin1("Courier New,courier")); | - | ||||||||||||||||||||||||||||||
| 290 | format.setFontFixedPitch(true); | - | ||||||||||||||||||||||||||||||
| 291 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 292 | } | - | ||||||||||||||||||||||||||||||
| 293 | } executed 18 times by 2 tests: else if (char0 == QLatin1Char('u')end of blockExecuted by:
| 18-806 | ||||||||||||||||||||||||||||||
| 294 | if (tagLength == 1
| 4-14 | ||||||||||||||||||||||||||||||
| 295 | format.setFontUnderline(true); | - | ||||||||||||||||||||||||||||||
| 296 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 297 | } else if (tag == QLatin1String("ul")
| 2-12 | ||||||||||||||||||||||||||||||
| 298 | List listItem; | - | ||||||||||||||||||||||||||||||
| 299 | listItem.level = 0; | - | ||||||||||||||||||||||||||||||
| 300 | listItem.type = Unordered; | - | ||||||||||||||||||||||||||||||
| 301 | listItem.format = Bullet; | - | ||||||||||||||||||||||||||||||
| 302 | listStack.push(listItem); | - | ||||||||||||||||||||||||||||||
| 303 | } executed 12 times by 2 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 304 | } executed 14 times by 2 tests: else if (char0 == QLatin1Char('h')end of blockExecuted by:
| 14-660 | ||||||||||||||||||||||||||||||
| 305 | int level = tag.at(1).digitValue(); | - | ||||||||||||||||||||||||||||||
| 306 | if (level >= 1
| 2-642 | ||||||||||||||||||||||||||||||
| 307 | if (!hasNewLine
| 16-624 | ||||||||||||||||||||||||||||||
| 308 | textOut.append(QChar::LineSeparator); executed 624 times by 1 test: textOut.append(QChar::LineSeparator);Executed by:
| 624 | ||||||||||||||||||||||||||||||
| 309 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 310 | prependSpace = false; | - | ||||||||||||||||||||||||||||||
| 311 | setFontSize(7 - level, format); | - | ||||||||||||||||||||||||||||||
| 312 | format.setFontWeight(QFont::Bold); | - | ||||||||||||||||||||||||||||||
| 313 | return executed 640 times by 2 tests: true;return true;Executed by:
executed 640 times by 2 tests: return true;Executed by:
| 640 | ||||||||||||||||||||||||||||||
| 314 | } | - | ||||||||||||||||||||||||||||||
| 315 | } executed 4 times by 1 test: else if (tag == QLatin1String("strong")end of blockExecuted by:
| 2-160 | ||||||||||||||||||||||||||||||
| 316 | format.setFontWeight(QFont::Bold); | - | ||||||||||||||||||||||||||||||
| 317 | return executed 2 times by 1 test: true;return true;Executed by:
executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 318 | } else if (tag == QLatin1String("ol")
| 12-148 | ||||||||||||||||||||||||||||||
| 319 | List listItem; | - | ||||||||||||||||||||||||||||||
| 320 | listItem.level = 0; | - | ||||||||||||||||||||||||||||||
| 321 | listItem.type = Ordered; | - | ||||||||||||||||||||||||||||||
| 322 | listItem.format = Decimal; | - | ||||||||||||||||||||||||||||||
| 323 | listStack.push(listItem); | - | ||||||||||||||||||||||||||||||
| 324 | } executed 12 times by 2 tests: else if (tag == QLatin1String("li")end of blockExecuted by:
| 12-110 | ||||||||||||||||||||||||||||||
| 325 | if (!hasNewLine
| 24-86 | ||||||||||||||||||||||||||||||
| 326 | textOut.append(QChar(QChar::LineSeparator)); executed 86 times by 2 tests: textOut.append(QChar(QChar::LineSeparator));Executed by:
| 86 | ||||||||||||||||||||||||||||||
| 327 | if (!listStack.isEmpty()
| 0-110 | ||||||||||||||||||||||||||||||
| 328 | int count = ++listStack.top().level; | - | ||||||||||||||||||||||||||||||
| 329 | for (int i = 0; i < listStack.size()
| 110 | ||||||||||||||||||||||||||||||
| 330 | textOut += QString(tabsize, QChar::Nbsp); executed 110 times by 2 tests: textOut += QString(tabsize, QChar::Nbsp);Executed by:
| 110 | ||||||||||||||||||||||||||||||
| 331 | switch (listStack.top().format) { | - | ||||||||||||||||||||||||||||||
| 332 | case executed 40 times by 2 tests: Decimal:case Decimal:Executed by:
executed 40 times by 2 tests: case Decimal:Executed by:
| 40 | ||||||||||||||||||||||||||||||
| 333 | textOut += QString::number(count) % QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 334 | break; executed 40 times by 2 tests: break;Executed by:
| 40 | ||||||||||||||||||||||||||||||
| 335 | case executed 4 times by 1 test: LowerAlpha:case LowerAlpha:Executed by:
executed 4 times by 1 test: case LowerAlpha:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 336 | textOut += toAlpha(count, false) % QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 337 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 338 | case executed 4 times by 1 test: UpperAlpha:case UpperAlpha:Executed by:
executed 4 times by 1 test: case UpperAlpha:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 339 | textOut += toAlpha(count, true) % QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 340 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 341 | case executed 4 times by 1 test: LowerRoman:case LowerRoman:Executed by:
executed 4 times by 1 test: case LowerRoman:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 342 | textOut += toRoman(count, false) % QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 343 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 344 | case executed 4 times by 1 test: UpperRoman:case UpperRoman:Executed by:
executed 4 times by 1 test: case UpperRoman:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 345 | textOut += toRoman(count, true) % QLatin1Char('.'); | - | ||||||||||||||||||||||||||||||
| 346 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 347 | case executed 46 times by 2 tests: Bullet:case Bullet:Executed by:
executed 46 times by 2 tests: case Bullet:Executed by:
| 46 | ||||||||||||||||||||||||||||||
| 348 | textOut += bullet; | - | ||||||||||||||||||||||||||||||
| 349 | break; executed 46 times by 2 tests: break;Executed by:
| 46 | ||||||||||||||||||||||||||||||
| 350 | case executed 4 times by 1 test: Disc:case Disc:Executed by:
executed 4 times by 1 test: case Disc:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 351 | textOut += disc; | - | ||||||||||||||||||||||||||||||
| 352 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 353 | case executed 4 times by 1 test: Square:case Square:Executed by:
executed 4 times by 1 test: case Square:Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 354 | textOut += square; | - | ||||||||||||||||||||||||||||||
| 355 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 356 | } | - | ||||||||||||||||||||||||||||||
| 357 | textOut += QString(2, QChar::Nbsp); | - | ||||||||||||||||||||||||||||||
| 358 | } executed 110 times by 2 tests: end of blockExecuted by:
| 110 | ||||||||||||||||||||||||||||||
| 359 | } executed 110 times by 2 tests: end of blockExecuted by:
| 110 | ||||||||||||||||||||||||||||||
| 360 | return executed 206 times by 3 tests: false;return false;Executed by:
executed 206 times by 3 tests: return false;Executed by:
| 206 | ||||||||||||||||||||||||||||||
| 361 | } else if (ch->isSpace()
| 938-6110 | ||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||
| 363 | QStringRef tag(&textIn, tagStart, tagLength); | - | ||||||||||||||||||||||||||||||
| 364 | if (tag == QLatin1String("font")
| 244-694 | ||||||||||||||||||||||||||||||
| 365 | return executed 694 times by 3 tests: parseFontAttributes(ch, textIn, format);return parseFontAttributes(ch, textIn, format);Executed by:
executed 694 times by 3 tests: return parseFontAttributes(ch, textIn, format);Executed by:
| 694 | ||||||||||||||||||||||||||||||
| 366 | if (tag == QLatin1String("ol")
| 10-234 | ||||||||||||||||||||||||||||||
| 367 | parseOrderedListAttributes(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 368 | return executed 10 times by 1 test: false;return false;Executed by:
executed 10 times by 1 test: return false;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 369 | } | - | ||||||||||||||||||||||||||||||
| 370 | if (tag == QLatin1String("ul")
| 6-228 | ||||||||||||||||||||||||||||||
| 371 | parseUnorderedListAttributes(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 372 | return executed 6 times by 1 test: false;return false;Executed by:
executed 6 times by 1 test: return false;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 373 | } | - | ||||||||||||||||||||||||||||||
| 374 | if (tag == QLatin1String("a")
| 98-130 | ||||||||||||||||||||||||||||||
| 375 | return executed 130 times by 2 tests: parseAnchorAttributes(ch, textIn, format);return parseAnchorAttributes(ch, textIn, format);Executed by:
executed 130 times by 2 tests: return parseAnchorAttributes(ch, textIn, format);Executed by:
| 130 | ||||||||||||||||||||||||||||||
| 376 | } | - | ||||||||||||||||||||||||||||||
| 377 | if (tag == QLatin1String("img")
| 2-96 | ||||||||||||||||||||||||||||||
| 378 | parseImageAttributes(ch, textIn, textOut); | - | ||||||||||||||||||||||||||||||
| 379 | return executed 96 times by 3 tests: false;return false;Executed by:
executed 96 times by 3 tests: return false;Executed by:
| 96 | ||||||||||||||||||||||||||||||
| 380 | } | - | ||||||||||||||||||||||||||||||
| 381 | if (*
| 0-2 | ||||||||||||||||||||||||||||||
| 382 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 383 | } executed 2 times by 1 test: else if (*end of blockExecuted by:
| 2-5974 | ||||||||||||||||||||||||||||||
| 384 | tagLength++; | - | ||||||||||||||||||||||||||||||
| 385 | } executed 5974 times by 7 tests: end of blockExecuted by:
| 5974 | ||||||||||||||||||||||||||||||
| 386 | ++ch; | - | ||||||||||||||||||||||||||||||
| 387 | } executed 6112 times by 7 tests: end of blockExecuted by:
| 6112 | ||||||||||||||||||||||||||||||
| 388 | return executed 4 times by 2 tests: false;return false;Executed by:
executed 4 times by 2 tests: return false;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 389 | } | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn, QString &textOut) | - | ||||||||||||||||||||||||||||||
| 392 | { | - | ||||||||||||||||||||||||||||||
| 393 | skipSpace(ch); | - | ||||||||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||||||||
| 395 | int tagStart = ch - textIn.constData(); | - | ||||||||||||||||||||||||||||||
| 396 | int tagLength = 0; | - | ||||||||||||||||||||||||||||||
| 397 | while (!ch->isNull()
| 4-7304 | ||||||||||||||||||||||||||||||
| 398 | if (*
| 2216-5088 | ||||||||||||||||||||||||||||||
| 399 | if (tagLength == 0
| 2-2214 | ||||||||||||||||||||||||||||||
| 400 | return executed 2 times by 1 test: false;return false;Executed by:
executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 401 | QStringRef tag(&textIn, tagStart, tagLength); | - | ||||||||||||||||||||||||||||||
| 402 | const QChar char0 = tag.at(0); | - | ||||||||||||||||||||||||||||||
| 403 | hasNewLine = false; | - | ||||||||||||||||||||||||||||||
| 404 | if (char0 == QLatin1Char('b')
| 576-1638 | ||||||||||||||||||||||||||||||
| 405 | if (tagLength == 1
| 0-576 | ||||||||||||||||||||||||||||||
| 406 | return executed 576 times by 6 tests: true;return true;Executed by:
executed 576 times by 6 tests: return true;Executed by:
| 576 | ||||||||||||||||||||||||||||||
| 407 | else if (tag.at(1) == QLatin1Char('r')
| 0 | ||||||||||||||||||||||||||||||
| 408 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 409 | } never executed: else if (char0 == QLatin1Char('i')end of block
| 0-1566 | ||||||||||||||||||||||||||||||
| 410 | if (tagLength == 1
| 2-70 | ||||||||||||||||||||||||||||||
| 411 | return executed 70 times by 2 tests: true;return true;Executed by:
executed 70 times by 2 tests: return true;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 412 | } executed 2 times by 1 test: else if (char0 == QLatin1Char('a')end of blockExecuted by:
| 2-1436 | ||||||||||||||||||||||||||||||
| 413 | if (tagLength == 1
| 2-128 | ||||||||||||||||||||||||||||||
| 414 | return executed 128 times by 2 tests: true;return true;Executed by:
executed 128 times by 2 tests: return true;Executed by:
| 128 | ||||||||||||||||||||||||||||||
| 415 | } executed 2 times by 1 test: else if (char0 == QLatin1Char('p')end of blockExecuted by:
| 2-1426 | ||||||||||||||||||||||||||||||
| 416 | if (tagLength == 1
| 4-6 | ||||||||||||||||||||||||||||||
| 417 | textOut.append(QChar::LineSeparator); | - | ||||||||||||||||||||||||||||||
| 418 | hasNewLine = true; | - | ||||||||||||||||||||||||||||||
| 419 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 420 | return executed 6 times by 1 test: false;return false;Executed by:
executed 6 times by 1 test: return false;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 421 | } else if (tag == QLatin1String("pre")
| 0-4 | ||||||||||||||||||||||||||||||
| 422 | preFormat = false; | - | ||||||||||||||||||||||||||||||
| 423 | if (!hasNewLine
| 0-4 | ||||||||||||||||||||||||||||||
| 424 | textOut.append(QChar::LineSeparator); executed 4 times by 1 test: textOut.append(QChar::LineSeparator);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 425 | hasNewLine = true; | - | ||||||||||||||||||||||||||||||
| 426 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 427 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 428 | } | - | ||||||||||||||||||||||||||||||
| 429 | } never executed: else if (char0 == QLatin1Char('u')end of block
| 0-1406 | ||||||||||||||||||||||||||||||
| 430 | if (tagLength == 1
| 4-16 | ||||||||||||||||||||||||||||||
| 431 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 432 | else if (tag == QLatin1String("ul")
| 0-16 | ||||||||||||||||||||||||||||||
| 433 | if (!listStack.isEmpty()
| 0-16 | ||||||||||||||||||||||||||||||
| 434 | listStack.pop(); | - | ||||||||||||||||||||||||||||||
| 435 | if (!listStack.count()
| 0-16 | ||||||||||||||||||||||||||||||
| 436 | textOut.append(QChar::LineSeparator); executed 16 times by 2 tests: textOut.append(QChar::LineSeparator);Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 437 | } executed 16 times by 2 tests: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 438 | return executed 16 times by 2 tests: false;return false;Executed by:
executed 16 times by 2 tests: return false;Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 439 | } | - | ||||||||||||||||||||||||||||||
| 440 | } never executed: else if (char0 == QLatin1Char('h')end of block
| 0-762 | ||||||||||||||||||||||||||||||
| 441 | textOut.append(QChar::LineSeparator); | - | ||||||||||||||||||||||||||||||
| 442 | hasNewLine = true; | - | ||||||||||||||||||||||||||||||
| 443 | hasSpace = true; | - | ||||||||||||||||||||||||||||||
| 444 | return executed 628 times by 2 tests: true;return true;Executed by:
executed 628 times by 2 tests: return true;Executed by:
| 628 | ||||||||||||||||||||||||||||||
| 445 | } else if (tag == QLatin1String("font")
| 84-694 | ||||||||||||||||||||||||||||||
| 446 | return executed 694 times by 3 tests: true;return true;Executed by:
executed 694 times by 3 tests: return true;Executed by:
| 694 | ||||||||||||||||||||||||||||||
| 447 | } else if (tag == QLatin1String("strong")
| 2-82 | ||||||||||||||||||||||||||||||
| 448 | return executed 2 times by 1 test: true;return true;Executed by:
executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 449 | } else if (tag == QLatin1String("ol")
| 20-62 | ||||||||||||||||||||||||||||||
| 450 | if (!listStack.isEmpty()
| 0-20 | ||||||||||||||||||||||||||||||
| 451 | listStack.pop(); | - | ||||||||||||||||||||||||||||||
| 452 | if (!listStack.count()
| 0-20 | ||||||||||||||||||||||||||||||
| 453 | textOut.append(QChar::LineSeparator); executed 20 times by 2 tests: textOut.append(QChar::LineSeparator);Executed by:
| 20 | ||||||||||||||||||||||||||||||
| 454 | } executed 20 times by 2 tests: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||||||||
| 455 | return executed 20 times by 2 tests: false;return false;Executed by:
executed 20 times by 2 tests: return false;Executed by:
| 20 | ||||||||||||||||||||||||||||||
| 456 | } else if (tag == QLatin1String("li")
| 22-40 | ||||||||||||||||||||||||||||||
| 457 | return executed 40 times by 1 test: false;return false;Executed by:
executed 40 times by 1 test: return false;Executed by:
| 40 | ||||||||||||||||||||||||||||||
| 458 | } | - | ||||||||||||||||||||||||||||||
| 459 | return executed 26 times by 2 tests: false;return false;Executed by:
executed 26 times by 2 tests: return false;Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 460 | } else if (!ch->isSpace()
| 0-5088 | ||||||||||||||||||||||||||||||
| 461 | tagLength++; | - | ||||||||||||||||||||||||||||||
| 462 | } executed 5088 times by 6 tests: end of blockExecuted by:
| 5088 | ||||||||||||||||||||||||||||||
| 463 | ++ch; | - | ||||||||||||||||||||||||||||||
| 464 | } executed 5088 times by 6 tests: end of blockExecuted by:
| 5088 | ||||||||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||||||||
| 466 | return executed 4 times by 1 test: false;return false;Executed by:
executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 467 | } | - | ||||||||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||||||||
| 469 | void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut) | - | ||||||||||||||||||||||||||||||
| 470 | { | - | ||||||||||||||||||||||||||||||
| 471 | int entityStart = ch - textIn.constData(); | - | ||||||||||||||||||||||||||||||
| 472 | int entityLength = 0; | - | ||||||||||||||||||||||||||||||
| 473 | while (!ch->isNull()
| 0-122 | ||||||||||||||||||||||||||||||
| 474 | if (*
| 26-96 | ||||||||||||||||||||||||||||||
| 475 | QStringRef entity(&textIn, entityStart, entityLength); | - | ||||||||||||||||||||||||||||||
| 476 | if (entity == QLatin1String("gt")
| 6-20 | ||||||||||||||||||||||||||||||
| 477 | textOut += QChar(62); executed 6 times by 1 test: textOut += QChar(62);Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 478 | else if (entity == QLatin1String("lt")
| 6-14 | ||||||||||||||||||||||||||||||
| 479 | textOut += QChar(60); executed 6 times by 1 test: textOut += QChar(60);Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 480 | else if (entity == QLatin1String("amp")
| 4-10 | ||||||||||||||||||||||||||||||
| 481 | textOut += QChar(38); executed 4 times by 1 test: textOut += QChar(38);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 482 | else if (entity == QLatin1String("quot")
| 4-6 | ||||||||||||||||||||||||||||||
| 483 | textOut += QChar(34); executed 6 times by 1 test: textOut += QChar(34);Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 484 | else if (entity == QLatin1String("nbsp")
| 2 | ||||||||||||||||||||||||||||||
| 485 | textOut += QChar(QChar::Nbsp); executed 2 times by 1 test: textOut += QChar(QChar::Nbsp);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 486 | return; executed 26 times by 1 test: return;Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 487 | } else if (*
| 4-92 | ||||||||||||||||||||||||||||||
| 488 | QStringRef entity(&textIn, entityStart - 1, entityLength + 1); | - | ||||||||||||||||||||||||||||||
| 489 | textOut += entity + *ch; | - | ||||||||||||||||||||||||||||||
| 490 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 491 | } | - | ||||||||||||||||||||||||||||||
| 492 | ++entityLength; | - | ||||||||||||||||||||||||||||||
| 493 | ++ch; | - | ||||||||||||||||||||||||||||||
| 494 | } executed 92 times by 1 test: end of blockExecuted by:
| 92 | ||||||||||||||||||||||||||||||
| 495 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||||||||
| 497 | bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) | - | ||||||||||||||||||||||||||||||
| 498 | { | - | ||||||||||||||||||||||||||||||
| 499 | bool valid = false; | - | ||||||||||||||||||||||||||||||
| 500 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 501 | do { | - | ||||||||||||||||||||||||||||||
| 502 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 503 | if (attr.first == QLatin1String("color")
| 16-1370 | ||||||||||||||||||||||||||||||
| 504 | valid = true; | - | ||||||||||||||||||||||||||||||
| 505 | format.setForeground(QColor(attr.second.toString())); | - | ||||||||||||||||||||||||||||||
| 506 | } executed 16 times by 2 tests: else if (attr.first == QLatin1String("size")end of blockExecuted by:
| 16-696 | ||||||||||||||||||||||||||||||
| 507 | valid = true; | - | ||||||||||||||||||||||||||||||
| 508 | int size = attr.second.toString().toInt(); | - | ||||||||||||||||||||||||||||||
| 509 | if (attr.second.at(0) == QLatin1Char('-')
| 0-674 | ||||||||||||||||||||||||||||||
| 510 | size += 3; never executed: size += 3; | 0 | ||||||||||||||||||||||||||||||
| 511 | if (size >= 1
| 0-674 | ||||||||||||||||||||||||||||||
| 512 | setFontSize(size, format); executed 674 times by 2 tests: setFontSize(size, format);Executed by:
| 674 | ||||||||||||||||||||||||||||||
| 513 | } executed 674 times by 2 tests: end of blockExecuted by:
| 674 | ||||||||||||||||||||||||||||||
| 514 | } executed 1386 times by 3 tests: while (!ch->isNull()end of blockExecuted by:
| 2-1386 | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | return executed 694 times by 3 tests: valid;return valid;Executed by:
executed 694 times by 3 tests: return valid;Executed by:
| 694 | ||||||||||||||||||||||||||||||
| 517 | } | - | ||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const QString &textIn) | - | ||||||||||||||||||||||||||||||
| 520 | { | - | ||||||||||||||||||||||||||||||
| 521 | bool valid = false; | - | ||||||||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||||||||
| 523 | List listItem; | - | ||||||||||||||||||||||||||||||
| 524 | listItem.level = 0; | - | ||||||||||||||||||||||||||||||
| 525 | listItem.type = Ordered; | - | ||||||||||||||||||||||||||||||
| 526 | listItem.format = Decimal; | - | ||||||||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||||||||
| 528 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 529 | do { | - | ||||||||||||||||||||||||||||||
| 530 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 531 | if (attr.first == QLatin1String("type")
| 10 | ||||||||||||||||||||||||||||||
| 532 | valid = true; | - | ||||||||||||||||||||||||||||||
| 533 | if (attr.second == QLatin1String("a")
| 2-8 | ||||||||||||||||||||||||||||||
| 534 | listItem.format = LowerAlpha; executed 2 times by 1 test: listItem.format = LowerAlpha;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 535 | else if (attr.second == QLatin1String("A")
| 2-6 | ||||||||||||||||||||||||||||||
| 536 | listItem.format = UpperAlpha; executed 2 times by 1 test: listItem.format = UpperAlpha;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 537 | else if (attr.second == QLatin1String("i")
| 2-4 | ||||||||||||||||||||||||||||||
| 538 | listItem.format = LowerRoman; executed 2 times by 1 test: listItem.format = LowerRoman;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 539 | else if (attr.second == QLatin1String("I")
| 2 | ||||||||||||||||||||||||||||||
| 540 | listItem.format = UpperRoman; executed 2 times by 1 test: listItem.format = UpperRoman;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 541 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 542 | } executed 20 times by 1 test: while (!ch->isNull()end of blockExecuted by:
| 0-20 | ||||||||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||||||||
| 544 | listStack.push(listItem); | - | ||||||||||||||||||||||||||||||
| 545 | return executed 10 times by 1 test: valid;return valid;Executed by:
executed 10 times by 1 test: return valid;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 546 | } | - | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | bool QQuickStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, const QString &textIn) | - | ||||||||||||||||||||||||||||||
| 549 | { | - | ||||||||||||||||||||||||||||||
| 550 | bool valid = false; | - | ||||||||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||||||||
| 552 | List listItem; | - | ||||||||||||||||||||||||||||||
| 553 | listItem.level = 0; | - | ||||||||||||||||||||||||||||||
| 554 | listItem.type = Unordered; | - | ||||||||||||||||||||||||||||||
| 555 | listItem.format = Bullet; | - | ||||||||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||||||||
| 557 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 558 | do { | - | ||||||||||||||||||||||||||||||
| 559 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 560 | if (attr.first == QLatin1String("type")
| 6 | ||||||||||||||||||||||||||||||
| 561 | valid = true; | - | ||||||||||||||||||||||||||||||
| 562 | if (attr.second == QLatin1String("disc")
| 2-4 | ||||||||||||||||||||||||||||||
| 563 | listItem.format = Disc; executed 2 times by 1 test: listItem.format = Disc;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 564 | else if (attr.second == QLatin1String("square")
| 2 | ||||||||||||||||||||||||||||||
| 565 | listItem.format = Square; executed 2 times by 1 test: listItem.format = Square;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 566 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 567 | } executed 12 times by 1 test: while (!ch->isNull()end of blockExecuted by:
| 0-12 | ||||||||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||||||||
| 569 | listStack.push(listItem); | - | ||||||||||||||||||||||||||||||
| 570 | return executed 6 times by 1 test: valid;return valid;Executed by:
executed 6 times by 1 test: return valid;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 571 | } | - | ||||||||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||||||||
| 573 | bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) | - | ||||||||||||||||||||||||||||||
| 574 | { | - | ||||||||||||||||||||||||||||||
| 575 | bool valid = false; | - | ||||||||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||||||||
| 577 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 578 | do { | - | ||||||||||||||||||||||||||||||
| 579 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 580 | if (attr.first == QLatin1String("href")
| 124-132 | ||||||||||||||||||||||||||||||
| 581 | format.setAnchorHref(attr.second.toString()); | - | ||||||||||||||||||||||||||||||
| 582 | format.setAnchor(true); | - | ||||||||||||||||||||||||||||||
| 583 | format.setFontUnderline(true); | - | ||||||||||||||||||||||||||||||
| 584 | valid = true; | - | ||||||||||||||||||||||||||||||
| 585 | } executed 124 times by 2 tests: end of blockExecuted by:
| 124 | ||||||||||||||||||||||||||||||
| 586 | } executed 256 times by 2 tests: while (!ch->isNull()end of blockExecuted by:
| 0-256 | ||||||||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||||||||
| 588 | return executed 130 times by 2 tests: valid;return valid;Executed by:
executed 130 times by 2 tests: return valid;Executed by:
| 130 | ||||||||||||||||||||||||||||||
| 589 | } | - | ||||||||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||||||||
| 591 | void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut) | - | ||||||||||||||||||||||||||||||
| 592 | { | - | ||||||||||||||||||||||||||||||
| 593 | qreal imgWidth = 0.0; | - | ||||||||||||||||||||||||||||||
| 594 | QFontMetricsF fm(layout.font()); | - | ||||||||||||||||||||||||||||||
| 595 | const qreal spaceWidth = fm.width(QChar::Nbsp); | - | ||||||||||||||||||||||||||||||
| 596 | const bool trailingSpace = textOut.endsWith(space); | - | ||||||||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||||||||
| 598 | if (!updateImagePositions
| 10-86 | ||||||||||||||||||||||||||||||
| 599 | QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag; | - | ||||||||||||||||||||||||||||||
| 600 | image->position = textOut.length() + (trailingSpace
| 34-52 | ||||||||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||||||||
| 602 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 603 | do { | - | ||||||||||||||||||||||||||||||
| 604 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 605 | if (attr.first == QLatin1String("src")
| 86-180 | ||||||||||||||||||||||||||||||
| 606 | image->url = QUrl(attr.second.toString()); | - | ||||||||||||||||||||||||||||||
| 607 | } executed 86 times by 3 tests: else if (attr.first == QLatin1String("width")end of blockExecuted by:
| 30-150 | ||||||||||||||||||||||||||||||
| 608 | image->size.setWidth(attr.second.toString().toInt()); | - | ||||||||||||||||||||||||||||||
| 609 | } executed 30 times by 2 tests: else if (attr.first == QLatin1String("height")end of blockExecuted by:
| 30-120 | ||||||||||||||||||||||||||||||
| 610 | image->size.setHeight(attr.second.toString().toInt()); | - | ||||||||||||||||||||||||||||||
| 611 | } executed 30 times by 2 tests: else if (attr.first == QLatin1String("align")end of blockExecuted by:
| 30-86 | ||||||||||||||||||||||||||||||
| 612 | if (attr.second.toString() == QLatin1String("top")
| 8-26 | ||||||||||||||||||||||||||||||
| 613 | image->align = QQuickStyledTextImgTag::Top; | - | ||||||||||||||||||||||||||||||
| 614 | } executed 8 times by 2 tests: else if (attr.second.toString() == QLatin1String("middle")end of blockExecuted by:
| 8-16 | ||||||||||||||||||||||||||||||
| 615 | image->align = QQuickStyledTextImgTag::Middle; | - | ||||||||||||||||||||||||||||||
| 616 | } executed 16 times by 2 tests: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 617 | } executed 34 times by 2 tests: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 618 | } executed 266 times by 3 tests: while (!ch->isNull()end of blockExecuted by:
| 0-266 | ||||||||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||||||||
| 620 | if (preloadImages
| 6-80 | ||||||||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||||||||
| 624 | QUrl url = baseUrl.resolved(image->url); | - | ||||||||||||||||||||||||||||||
| 625 | if (url.isLocalFile()
| 8-44 | ||||||||||||||||||||||||||||||
| 626 | image->pix = new QQuickPixmap(context->engine(), url, image->size); | - | ||||||||||||||||||||||||||||||
| 627 | if (image->pix
| 0-44 | ||||||||||||||||||||||||||||||
| 628 | image->size = image->pix->implicitSize(); | - | ||||||||||||||||||||||||||||||
| 629 | } executed 44 times by 2 tests: else {end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 630 | delete image->pix; | - | ||||||||||||||||||||||||||||||
| 631 | image->pix = nullptr; | - | ||||||||||||||||||||||||||||||
| 632 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 633 | } | - | ||||||||||||||||||||||||||||||
| 634 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||||||||
| 636 | imgWidth = image->size.width(); | - | ||||||||||||||||||||||||||||||
| 637 | image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0; | - | ||||||||||||||||||||||||||||||
| 638 | imgTags->append(image); | - | ||||||||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||||||||
| 640 | } executed 86 times by 3 tests: else {end of blockExecuted by:
| 86 | ||||||||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||||||||
| 643 | QQuickStyledTextImgTag *image = imgTags->value(nbImages); | - | ||||||||||||||||||||||||||||||
| 644 | image->position = textOut.length() + (trailingSpace
| 4-6 | ||||||||||||||||||||||||||||||
| 645 | imgWidth = image->size.width(); | - | ||||||||||||||||||||||||||||||
| 646 | image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0; | - | ||||||||||||||||||||||||||||||
| 647 | QPair<QStringRef,QStringRef> attr; | - | ||||||||||||||||||||||||||||||
| 648 | do { | - | ||||||||||||||||||||||||||||||
| 649 | attr = parseAttribute(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 650 | } executed 22 times by 2 tests: while (!ch->isNull()end of blockExecuted by:
| 0-22 | ||||||||||||||||||||||||||||||
| 651 | nbImages++; | - | ||||||||||||||||||||||||||||||
| 652 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||||||||
| 654 | QString padding(qFloor(imgWidth / spaceWidth), QChar::Nbsp); | - | ||||||||||||||||||||||||||||||
| 655 | if (!trailingSpace
| 38-58 | ||||||||||||||||||||||||||||||
| 656 | textOut += QLatin1Char(' '); executed 38 times by 3 tests: textOut += QLatin1Char(' ');Executed by:
| 38 | ||||||||||||||||||||||||||||||
| 657 | textOut += padding + QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 658 | } executed 96 times by 3 tests: end of blockExecuted by:
| 96 | ||||||||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||||||||
| 660 | QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn) | - | ||||||||||||||||||||||||||||||
| 661 | { | - | ||||||||||||||||||||||||||||||
| 662 | skipSpace(ch); | - | ||||||||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||||||||
| 664 | int attrStart = ch - textIn.constData(); | - | ||||||||||||||||||||||||||||||
| 665 | int attrLength = 0; | - | ||||||||||||||||||||||||||||||
| 666 | while (!ch->isNull()
| 0-6186 | ||||||||||||||||||||||||||||||
| 667 | if (*
| 930-5256 | ||||||||||||||||||||||||||||||
| 668 | break; executed 930 times by 3 tests: break;Executed by:
| 930 | ||||||||||||||||||||||||||||||
| 669 | } else if (*
| 1032-4224 | ||||||||||||||||||||||||||||||
| 670 | ++ch; | - | ||||||||||||||||||||||||||||||
| 671 | if (*
| 4-1028 | ||||||||||||||||||||||||||||||
| 672 | while (*
| 0-4 | ||||||||||||||||||||||||||||||
| 673 | ++ never executed: ch;++ch;never executed: ++ch; | 0 | ||||||||||||||||||||||||||||||
| 674 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 675 | } | - | ||||||||||||||||||||||||||||||
| 676 | ++ch; | - | ||||||||||||||||||||||||||||||
| 677 | if (!attrLength
| 0-1028 | ||||||||||||||||||||||||||||||
| 678 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 679 | QStringRef attr(&textIn, attrStart, attrLength); | - | ||||||||||||||||||||||||||||||
| 680 | QStringRef val = parseValue(ch, textIn); | - | ||||||||||||||||||||||||||||||
| 681 | if (!val.isEmpty()
| 2-1026 | ||||||||||||||||||||||||||||||
| 682 | return executed 1026 times by 3 tests: QPair<QStringRef,QStringRef>(attr,val);return QPair<QStringRef,QStringRef>(attr,val);Executed by:
executed 1026 times by 3 tests: return QPair<QStringRef,QStringRef>(attr,val);Executed by:
| 1026 | ||||||||||||||||||||||||||||||
| 683 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 684 | } else { | - | ||||||||||||||||||||||||||||||
| 685 | ++attrLength; | - | ||||||||||||||||||||||||||||||
| 686 | } executed 4224 times by 3 tests: end of blockExecuted by:
| 4224 | ||||||||||||||||||||||||||||||
| 687 | ++ch; | - | ||||||||||||||||||||||||||||||
| 688 | } executed 4224 times by 3 tests: end of blockExecuted by:
| 4224 | ||||||||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||||||||
| 690 | return executed 936 times by 3 tests: QPair<QStringRef,QStringRef>();return QPair<QStringRef,QStringRef>();Executed by:
executed 936 times by 3 tests: return QPair<QStringRef,QStringRef>();Executed by:
| 936 | ||||||||||||||||||||||||||||||
| 691 | } | - | ||||||||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||||||||
| 693 | QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn) | - | ||||||||||||||||||||||||||||||
| 694 | { | - | ||||||||||||||||||||||||||||||
| 695 | int valStart = ch - textIn.constData(); | - | ||||||||||||||||||||||||||||||
| 696 | int valLength = 0; | - | ||||||||||||||||||||||||||||||
| 697 | while (*
| 2-7680 | ||||||||||||||||||||||||||||||
| 698 | ++valLength; | - | ||||||||||||||||||||||||||||||
| 699 | ++ch; | - | ||||||||||||||||||||||||||||||
| 700 | } executed 6658 times by 3 tests: end of blockExecuted by:
| 6658 | ||||||||||||||||||||||||||||||
| 701 | if (ch->isNull()
| 2-1026 | ||||||||||||||||||||||||||||||
| 702 | return executed 2 times by 1 test: QStringRef();return QStringRef();Executed by:
executed 2 times by 1 test: return QStringRef();Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 703 | ++ch; | - | ||||||||||||||||||||||||||||||
| 704 | - | |||||||||||||||||||||||||||||||
| 705 | return executed 1026 times by 3 tests: QStringRef(&textIn, valStart, valLength);return QStringRef(&textIn, valStart, valLength);Executed by:
executed 1026 times by 3 tests: return QStringRef(&textIn, valStart, valLength);Executed by:
| 1026 | ||||||||||||||||||||||||||||||
| 706 | } | - | ||||||||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||||||||
| 708 | QString QQuickStyledTextPrivate::toAlpha(int value, bool upper) | - | ||||||||||||||||||||||||||||||
| 709 | { | - | ||||||||||||||||||||||||||||||
| 710 | const char baseChar = upper
| 4 | ||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 | QString result; | - | ||||||||||||||||||||||||||||||
| 713 | int c = value; | - | ||||||||||||||||||||||||||||||
| 714 | while (c > 0
| 8 | ||||||||||||||||||||||||||||||
| 715 | c--; | - | ||||||||||||||||||||||||||||||
| 716 | result.prepend(QChar(baseChar + (c % 26))); | - | ||||||||||||||||||||||||||||||
| 717 | c /= 26; | - | ||||||||||||||||||||||||||||||
| 718 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 719 | return executed 8 times by 1 test: result;return result;Executed by:
executed 8 times by 1 test: return result;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 720 | } | - | ||||||||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||||||||
| 722 | QString QQuickStyledTextPrivate::toRoman(int value, bool upper) | - | ||||||||||||||||||||||||||||||
| 723 | { | - | ||||||||||||||||||||||||||||||
| 724 | QString result = QLatin1String("?"); | - | ||||||||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||||||||
| 726 | if (value < 5000
| 0-8 | ||||||||||||||||||||||||||||||
| 727 | QByteArray romanNumeral; | - | ||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm"; | - | ||||||||||||||||||||||||||||||
| 730 | static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM"; | - | ||||||||||||||||||||||||||||||
| 731 | QByteArray romanSymbols; | - | ||||||||||||||||||||||||||||||
| 732 | if (!upper
| 4 | ||||||||||||||||||||||||||||||
| 733 | romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); executed 4 times by 1 test: romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower));Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 734 | else | - | ||||||||||||||||||||||||||||||
| 735 | romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); executed 4 times by 1 test: romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper));Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||||||||
| 737 | int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 }; | - | ||||||||||||||||||||||||||||||
| 738 | int n = value; | - | ||||||||||||||||||||||||||||||
| 739 | for (int i = 12; i >= 0
| 8-104 | ||||||||||||||||||||||||||||||
| 740 | int q = n / c[i]; | - | ||||||||||||||||||||||||||||||
| 741 | if (q > 0
| 8-96 | ||||||||||||||||||||||||||||||
| 742 | int startDigit = i + (i + 3) / 4; | - | ||||||||||||||||||||||||||||||
| 743 | int numDigits; | - | ||||||||||||||||||||||||||||||
| 744 | if (i % 4
| 0-8 | ||||||||||||||||||||||||||||||
| 745 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 746 | numDigits = 2; never executed: numDigits = 2; | 0 | ||||||||||||||||||||||||||||||
| 747 | else | - | ||||||||||||||||||||||||||||||
| 748 | numDigits = 1; never executed: numDigits = 1; | 0 | ||||||||||||||||||||||||||||||
| 749 | } | - | ||||||||||||||||||||||||||||||
| 750 | else | - | ||||||||||||||||||||||||||||||
| 751 | numDigits = q; executed 8 times by 1 test: numDigits = q;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 752 | romanNumeral.append(romanSymbols.mid(startDigit, numDigits)); | - | ||||||||||||||||||||||||||||||
| 753 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 754 | } executed 104 times by 1 test: end of blockExecuted by:
| 104 | ||||||||||||||||||||||||||||||
| 755 | result = QString::fromLatin1(romanNumeral); | - | ||||||||||||||||||||||||||||||
| 756 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 757 | return executed 8 times by 1 test: result;return result;Executed by:
executed 8 times by 1 test: return result;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 758 | } | - | ||||||||||||||||||||||||||||||
| 759 | - | |||||||||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |