| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextengine.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | static const float smallCapsFraction = 0.7f; | - | ||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | namespace { | - | ||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | class Itemizer { | - | ||||||||||||||||||||||||
| 12 | public: | - | ||||||||||||||||||||||||
| 13 | Itemizer(const QString &string, const QScriptAnalysis *analysis, QScriptItemArray &items) | - | ||||||||||||||||||||||||
| 14 | : m_string(string), | - | ||||||||||||||||||||||||
| 15 | m_analysis(analysis), | - | ||||||||||||||||||||||||
| 16 | m_items(items), | - | ||||||||||||||||||||||||
| 17 | m_splitter(0) | - | ||||||||||||||||||||||||
| 18 | { | - | ||||||||||||||||||||||||
| 19 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 20 | ~Itemizer() | - | ||||||||||||||||||||||||
| 21 | { | - | ||||||||||||||||||||||||
| 22 | delete m_splitter; | - | ||||||||||||||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | void generate(int start, int length, QFont::Capitalization caps) | - | ||||||||||||||||||||||||
| 28 | { | - | ||||||||||||||||||||||||
| 29 | if (caps == QFont::SmallCaps
| 0 | ||||||||||||||||||||||||
| 30 | generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length); never executed: generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length); | 0 | ||||||||||||||||||||||||
| 31 | else if(caps == QFont::Capitalize
| 0 | ||||||||||||||||||||||||
| 32 | generateScriptItemsCapitalize(start, length); never executed: generateScriptItemsCapitalize(start, length); | 0 | ||||||||||||||||||||||||
| 33 | else if(caps != QFont::MixedCase
| 0 | ||||||||||||||||||||||||
| 34 | generateScriptItemsAndChangeCase(start, length, | - | ||||||||||||||||||||||||
| 35 | caps == QFont::AllLowercase ? QScriptAnalysis::Lowercase : QScriptAnalysis::Uppercase); | - | ||||||||||||||||||||||||
| 36 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 37 | else | - | ||||||||||||||||||||||||
| 38 | generateScriptItems(start, length); never executed: generateScriptItems(start, length); | 0 | ||||||||||||||||||||||||
| 39 | } | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | private: | - | ||||||||||||||||||||||||
| 42 | enum { MaxItemLength = 4096 }; | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | void generateScriptItemsAndChangeCase(int start, int length, QScriptAnalysis::Flags flags) | - | ||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||
| 46 | generateScriptItems(start, length); | - | ||||||||||||||||||||||||
| 47 | if (m_items.isEmpty()
| 0 | ||||||||||||||||||||||||
| 48 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 49 | QScriptItemArray::Iterator iter = m_items.end(); | - | ||||||||||||||||||||||||
| 50 | do { | - | ||||||||||||||||||||||||
| 51 | iter--; | - | ||||||||||||||||||||||||
| 52 | if (iter->analysis.flags < QScriptAnalysis::LineOrParagraphSeparator
| 0 | ||||||||||||||||||||||||
| 53 | iter->analysis.flags = flags; never executed: iter->analysis.flags = flags; | 0 | ||||||||||||||||||||||||
| 54 | } never executed: while (iter->position > startend of block
| 0 | ||||||||||||||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | void generateScriptItems(int start, int length) | - | ||||||||||||||||||||||||
| 58 | { | - | ||||||||||||||||||||||||
| 59 | if (!length
| 0 | ||||||||||||||||||||||||
| 60 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 61 | const int end = start + length; | - | ||||||||||||||||||||||||
| 62 | for (int i = start + 1; i < end
| 0 | ||||||||||||||||||||||||
| 63 | if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
| 0 | ||||||||||||||||||||||||
| 64 | && m_analysis[i].flags == m_analysis[start].flags
| 0 | ||||||||||||||||||||||||
| 65 | && (m_analysis[i].script == m_analysis[start].script
| 0 | ||||||||||||||||||||||||
| 66 | && m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
| 0 | ||||||||||||||||||||||||
| 67 | && i - start < MaxItemLength
| 0 | ||||||||||||||||||||||||
| 68 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 69 | m_items.append(QScriptItem(start, m_analysis[start])); | - | ||||||||||||||||||||||||
| 70 | start = i; | - | ||||||||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 72 | m_items.append(QScriptItem(start, m_analysis[start])); | - | ||||||||||||||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | void generateScriptItemsCapitalize(int start, int length) | - | ||||||||||||||||||||||||
| 76 | { | - | ||||||||||||||||||||||||
| 77 | if (!length
| 0 | ||||||||||||||||||||||||
| 78 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | if (!m_splitter
| 0 | ||||||||||||||||||||||||
| 81 | m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0); | 0 | ||||||||||||||||||||||||
| 82 | m_string.constData(), m_string.length(), never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0); | 0 | ||||||||||||||||||||||||
| 83 | 0, 0); never executed: m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), 0, 0); | 0 | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | m_splitter->setPosition(start); | - | ||||||||||||||||||||||||
| 86 | QScriptAnalysis itemAnalysis = m_analysis[start]; | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem
| 0 | ||||||||||||||||||||||||
| 89 | itemAnalysis.flags = QScriptAnalysis::Uppercase; never executed: itemAnalysis.flags = QScriptAnalysis::Uppercase; | 0 | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | m_splitter->toNextBoundary(); | - | ||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||
| 93 | const int end = start + length; | - | ||||||||||||||||||||||||
| 94 | for (int i = start + 1; i < end
| 0 | ||||||||||||||||||||||||
| 95 | bool atWordStart = false; | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | if (i == m_splitter->position()
| 0 | ||||||||||||||||||||||||
| 98 | if (m_splitter->boundaryReasons() & QTextBoundaryFinder::StartOfItem
| 0 | ||||||||||||||||||||||||
| 99 | ((!(m_analysis[i].flags < QScriptAnalysis::TabOrObject)) ? qt_assert("m_analysis[i].flags < QScriptAnalysis::TabOrObject",__FILE__,155) : qt_noop()); | - | ||||||||||||||||||||||||
| 100 | atWordStart = true; | - | ||||||||||||||||||||||||
| 101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | m_splitter->toNextBoundary(); | - | ||||||||||||||||||||||||
| 104 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | if (m_analysis[i] == itemAnalysis
| 0 | ||||||||||||||||||||||||
| 107 | && m_analysis[i].flags < QScriptAnalysis::TabOrObject
| 0 | ||||||||||||||||||||||||
| 108 | && !atWordStart
| 0 | ||||||||||||||||||||||||
| 109 | && i - start < MaxItemLength
| 0 | ||||||||||||||||||||||||
| 110 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | m_items.append(QScriptItem(start, itemAnalysis)); | - | ||||||||||||||||||||||||
| 113 | start = i; | - | ||||||||||||||||||||||||
| 114 | itemAnalysis = m_analysis[start]; | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | if (atWordStart
| 0 | ||||||||||||||||||||||||
| 117 | itemAnalysis.flags = QScriptAnalysis::Uppercase; never executed: itemAnalysis.flags = QScriptAnalysis::Uppercase; | 0 | ||||||||||||||||||||||||
| 118 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 119 | m_items.append(QScriptItem(start, itemAnalysis)); | - | ||||||||||||||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | void generateScriptItemsSmallCaps(const ushort *uc, int start, int length) | - | ||||||||||||||||||||||||
| 123 | { | - | ||||||||||||||||||||||||
| 124 | if (!length
| 0 | ||||||||||||||||||||||||
| 125 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 126 | bool lower = (QChar::category(uc[start]) == QChar::Letter_Lowercase); | - | ||||||||||||||||||||||||
| 127 | const int end = start + length; | - | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | for (int i = start + 1; i < end
| 0 | ||||||||||||||||||||||||
| 130 | bool l = (QChar::category(uc[i]) == QChar::Letter_Lowercase); | - | ||||||||||||||||||||||||
| 131 | if ((
| 0 | ||||||||||||||||||||||||
| 132 | && m_analysis[i].flags < QScriptAnalysis::TabOrObject
| 0 | ||||||||||||||||||||||||
| 133 | && l == lower
| 0 | ||||||||||||||||||||||||
| 134 | && i - start < MaxItemLength
| 0 | ||||||||||||||||||||||||
| 135 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 136 | m_items.append(QScriptItem(start, m_analysis[start])); | - | ||||||||||||||||||||||||
| 137 | if (lower
| 0 | ||||||||||||||||||||||||
| 138 | m_items.last().analysis.flags = QScriptAnalysis::SmallCaps; never executed: m_items.last().analysis.flags = QScriptAnalysis::SmallCaps; | 0 | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | start = i; | - | ||||||||||||||||||||||||
| 141 | lower = l; | - | ||||||||||||||||||||||||
| 142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 143 | m_items.append(QScriptItem(start, m_analysis[start])); | - | ||||||||||||||||||||||||
| 144 | if (lower
| 0 | ||||||||||||||||||||||||
| 145 | m_items.last().analysis.flags = QScriptAnalysis::SmallCaps; never executed: m_items.last().analysis.flags = QScriptAnalysis::SmallCaps; | 0 | ||||||||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | const QString &m_string; | - | ||||||||||||||||||||||||
| 149 | const QScriptAnalysis * const m_analysis; | - | ||||||||||||||||||||||||
| 150 | QScriptItemArray &m_items; | - | ||||||||||||||||||||||||
| 151 | QTextBoundaryFinder *m_splitter; | - | ||||||||||||||||||||||||
| 152 | }; | - | ||||||||||||||||||||||||
| 153 | } | - | ||||||||||||||||||||||||
| 154 | struct QBidiStatus { | - | ||||||||||||||||||||||||
| 155 | QBidiStatus() { | - | ||||||||||||||||||||||||
| 156 | eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 157 | lastStrong = QChar::DirON; | - | ||||||||||||||||||||||||
| 158 | last = QChar:: DirON; | - | ||||||||||||||||||||||||
| 159 | dir = QChar::DirON; | - | ||||||||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 161 | QChar::Direction eor; | - | ||||||||||||||||||||||||
| 162 | QChar::Direction lastStrong; | - | ||||||||||||||||||||||||
| 163 | QChar::Direction last; | - | ||||||||||||||||||||||||
| 164 | QChar::Direction dir; | - | ||||||||||||||||||||||||
| 165 | }; | - | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | enum { MaxBidiLevel = 61 }; | - | ||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | struct QBidiControl { | - | ||||||||||||||||||||||||
| 170 | inline QBidiControl(bool rtl) | - | ||||||||||||||||||||||||
| 171 | : cCtx(0), base(rtl ? 1 : 0), level(rtl ? 1 : 0), override(false) {} never executed: end of block | 0 | ||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | inline void embed(bool rtl, bool o = false) { | - | ||||||||||||||||||||||||
| 174 | unsigned int toAdd = 1; | - | ||||||||||||||||||||||||
| 175 | if((
| 0 | ||||||||||||||||||||||||
| 176 | ++toAdd; | - | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | if (level + toAdd <= MaxBidiLevel
| 0 | ||||||||||||||||||||||||
| 179 | ctx[cCtx].level = level; | - | ||||||||||||||||||||||||
| 180 | ctx[cCtx].override = override; | - | ||||||||||||||||||||||||
| 181 | cCtx++; | - | ||||||||||||||||||||||||
| 182 | override = o; | - | ||||||||||||||||||||||||
| 183 | level += toAdd; | - | ||||||||||||||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 186 | inline bool canPop() const { return never executed: cCtx != 0;return cCtx != 0;never executed: }return cCtx != 0; | 0 | ||||||||||||||||||||||||
| 187 | inline void pdf() { | - | ||||||||||||||||||||||||
| 188 | ((!(cCtx)) ? qt_assert("cCtx",__FILE__,267) : qt_noop()); | - | ||||||||||||||||||||||||
| 189 | --cCtx; | - | ||||||||||||||||||||||||
| 190 | level = ctx[cCtx].level; | - | ||||||||||||||||||||||||
| 191 | override = ctx[cCtx].override; | - | ||||||||||||||||||||||||
| 192 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||
| 194 | inline QChar::Direction basicDirection() const { | - | ||||||||||||||||||||||||
| 195 | return never executed: (base ? QChar::DirR : QChar:: DirL);return (base ? QChar::DirR : QChar:: DirL);never executed: return (base ? QChar::DirR : QChar:: DirL); | 0 | ||||||||||||||||||||||||
| 196 | } | - | ||||||||||||||||||||||||
| 197 | inline unsigned int baseLevel() const { | - | ||||||||||||||||||||||||
| 198 | return never executed: base;return base;never executed: return base; | 0 | ||||||||||||||||||||||||
| 199 | } | - | ||||||||||||||||||||||||
| 200 | inline QChar::Direction direction() const { | - | ||||||||||||||||||||||||
| 201 | return never executed: ((level%2) ? QChar::DirR : QChar:: DirL);return ((level%2) ? QChar::DirR : QChar:: DirL);never executed: return ((level%2) ? QChar::DirR : QChar:: DirL); | 0 | ||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | struct { | - | ||||||||||||||||||||||||
| 205 | unsigned int level; | - | ||||||||||||||||||||||||
| 206 | bool override; | - | ||||||||||||||||||||||||
| 207 | } ctx[MaxBidiLevel]; | - | ||||||||||||||||||||||||
| 208 | unsigned int cCtx; | - | ||||||||||||||||||||||||
| 209 | const unsigned int base; | - | ||||||||||||||||||||||||
| 210 | unsigned int level; | - | ||||||||||||||||||||||||
| 211 | bool override; | - | ||||||||||||||||||||||||
| 212 | }; | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | static void appendItems(QScriptAnalysis *analysis, int &start, int &stop, const QBidiControl &control, QChar::Direction dir) | - | ||||||||||||||||||||||||
| 216 | { | - | ||||||||||||||||||||||||
| 217 | if (start > stop
| 0 | ||||||||||||||||||||||||
| 218 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | int level = control.level; | - | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | if(dir != QChar::DirON
| 0 | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | if(level % 2
| 0 | ||||||||||||||||||||||||
| 225 | if(dir == QChar::DirL
| 0 | ||||||||||||||||||||||||
| 226 | level++; never executed: level++; | 0 | ||||||||||||||||||||||||
| 227 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 228 | if(dir == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 229 | level++; never executed: level++; | 0 | ||||||||||||||||||||||||
| 230 | else if(dir == QChar::DirAN
| 0 | ||||||||||||||||||||||||
| 231 | level += 2; never executed: level += 2; | 0 | ||||||||||||||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | QScriptAnalysis *s = analysis + start; | - | ||||||||||||||||||||||||
| 239 | const QScriptAnalysis *e = analysis + stop; | - | ||||||||||||||||||||||||
| 240 | while (s <= e
| 0 | ||||||||||||||||||||||||
| 241 | s->bidiLevel = level; | - | ||||||||||||||||||||||||
| 242 | ++s; | - | ||||||||||||||||||||||||
| 243 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 244 | ++stop; | - | ||||||||||||||||||||||||
| 245 | start = stop; | - | ||||||||||||||||||||||||
| 246 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | static QChar::Direction skipBoundryNeutrals(QScriptAnalysis *analysis, | - | ||||||||||||||||||||||||
| 249 | const ushort *unicode, int length, | - | ||||||||||||||||||||||||
| 250 | int &sor, int &eor, QBidiControl &control) | - | ||||||||||||||||||||||||
| 251 | { | - | ||||||||||||||||||||||||
| 252 | QChar::Direction dir = control.basicDirection(); | - | ||||||||||||||||||||||||
| 253 | int level = sor > 0
| 0 | ||||||||||||||||||||||||
| 254 | while (sor < length
| 0 | ||||||||||||||||||||||||
| 255 | dir = QChar::direction(unicode[sor]); | - | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | if (dir != QChar::DirBN
| 0 | ||||||||||||||||||||||||
| 258 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 259 | analysis[sor++].bidiLevel = level; | - | ||||||||||||||||||||||||
| 260 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | eor = sor; | - | ||||||||||||||||||||||||
| 263 | if (eor == length
| 0 | ||||||||||||||||||||||||
| 264 | dir = control.basicDirection(); never executed: dir = control.basicDirection(); | 0 | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | return never executed: dir;return dir;never executed: return dir; | 0 | ||||||||||||||||||||||||
| 267 | } | - | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiControl &control) | - | ||||||||||||||||||||||||
| 271 | { | - | ||||||||||||||||||||||||
| 272 | bool rightToLeft = (control.basicDirection() == 1); | - | ||||||||||||||||||||||||
| 273 | bool hasBidi = rightToLeft; | - | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | int sor = 0; | - | ||||||||||||||||||||||||
| 279 | int eor = -1; | - | ||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | int length = engine->layoutData->string.length(); | - | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | const ushort *unicode = (const ushort *)engine->layoutData->string.unicode(); | - | ||||||||||||||||||||||||
| 285 | int current = 0; | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | QChar::Direction dir = rightToLeft
| 0 | ||||||||||||||||||||||||
| 288 | QBidiStatus status; | - | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | QChar::Direction sdir = QChar::direction(*unicode); | - | ||||||||||||||||||||||||
| 291 | if (sdir != QChar::DirL
| 0 | ||||||||||||||||||||||||
| 292 | sdir = QChar::DirON; never executed: sdir = QChar::DirON; | 0 | ||||||||||||||||||||||||
| 293 | else | - | ||||||||||||||||||||||||
| 294 | dir = QChar::DirON; never executed: dir = QChar::DirON; | 0 | ||||||||||||||||||||||||
| 295 | status.eor = sdir; | - | ||||||||||||||||||||||||
| 296 | status.lastStrong = rightToLeft
| 0 | ||||||||||||||||||||||||
| 297 | status.last = status.lastStrong; | - | ||||||||||||||||||||||||
| 298 | status.dir = sdir; | - | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | while (current <= length
| 0 | ||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | QChar::Direction dirCurrent; | - | ||||||||||||||||||||||||
| 304 | if (current == (int)length
| 0 | ||||||||||||||||||||||||
| 305 | dirCurrent = control.basicDirection(); never executed: dirCurrent = control.basicDirection(); | 0 | ||||||||||||||||||||||||
| 306 | else | - | ||||||||||||||||||||||||
| 307 | dirCurrent = QChar::direction(unicode[current]); never executed: dirCurrent = QChar::direction(unicode[current]); | 0 | ||||||||||||||||||||||||
| 308 | switch(dirCurrent) { | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | case never executed: QChar::DirRLE:case QChar::DirRLE:never executed: case QChar::DirRLE: | 0 | ||||||||||||||||||||||||
| 312 | case never executed: QChar::DirRLO:case QChar::DirRLO:never executed: case QChar::DirRLO: | 0 | ||||||||||||||||||||||||
| 313 | case never executed: QChar::DirLRE:case QChar::DirLRE:never executed: case QChar::DirLRE: | 0 | ||||||||||||||||||||||||
| 314 | case never executed: QChar::DirLRO:case QChar::DirLRO:never executed: case QChar::DirLRO: | 0 | ||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||
| 316 | bool rtl = (dirCurrent == QChar::DirRLE
| 0 | ||||||||||||||||||||||||
| 317 | hasBidi |= rtl; | - | ||||||||||||||||||||||||
| 318 | bool override = (dirCurrent == QChar::DirLRO
| 0 | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | unsigned int level = control.level+1; | - | ||||||||||||||||||||||||
| 321 | if ((
never executed: level;++level;never executed: ++level; | 0 | ||||||||||||||||||||||||
| 322 | if(level < MaxBidiLevel
| 0 | ||||||||||||||||||||||||
| 323 | eor = current-1; | - | ||||||||||||||||||||||||
| 324 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 325 | eor = current; | - | ||||||||||||||||||||||||
| 326 | control.embed(rtl, override); | - | ||||||||||||||||||||||||
| 327 | QChar::Direction edir = (rtl
| 0 | ||||||||||||||||||||||||
| 328 | dir = status.eor = edir; | - | ||||||||||||||||||||||||
| 329 | status.lastStrong = edir; | - | ||||||||||||||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 331 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 332 | } | - | ||||||||||||||||||||||||
| 333 | case never executed: QChar::DirPDF:case QChar::DirPDF:never executed: case QChar::DirPDF: | 0 | ||||||||||||||||||||||||
| 334 | { | - | ||||||||||||||||||||||||
| 335 | if (control.canPop()
| 0 | ||||||||||||||||||||||||
| 336 | if (dir != control.direction()
| 0 | ||||||||||||||||||||||||
| 337 | eor = current-1; | - | ||||||||||||||||||||||||
| 338 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 339 | dir = control.direction(); | - | ||||||||||||||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 341 | eor = current; | - | ||||||||||||||||||||||||
| 342 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 343 | control.pdf(); | - | ||||||||||||||||||||||||
| 344 | dir = QChar::DirON; status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 345 | status.last = control.direction(); | - | ||||||||||||||||||||||||
| 346 | if (control.override
| 0 | ||||||||||||||||||||||||
| 347 | dir = control.direction(); never executed: dir = control.direction(); | 0 | ||||||||||||||||||||||||
| 348 | else | - | ||||||||||||||||||||||||
| 349 | dir = QChar::DirON; never executed: dir = QChar::DirON; | 0 | ||||||||||||||||||||||||
| 350 | status.lastStrong = control.direction(); | - | ||||||||||||||||||||||||
| 351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 352 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 353 | } | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||
| 356 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 357 | if(dir == QChar::DirON
| 0 | ||||||||||||||||||||||||
| 358 | dir = QChar::DirL; never executed: dir = QChar::DirL; | 0 | ||||||||||||||||||||||||
| 359 | switch(status.last) | - | ||||||||||||||||||||||||
| 360 | { | - | ||||||||||||||||||||||||
| 361 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 362 | eor = current; status.eor = QChar::DirL; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 363 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 364 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 365 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 366 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 367 | if (eor >= 0
| 0 | ||||||||||||||||||||||||
| 368 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 369 | status.eor = dir = skipBoundryNeutrals(analysis, unicode, length, sor, eor, control); | - | ||||||||||||||||||||||||
| 370 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 371 | eor = current; status.eor = dir; | - | ||||||||||||||||||||||||
| 372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 373 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 374 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 375 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 376 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 377 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 378 | case never executed: QChar::DirB:case QChar::DirB:never executed: case QChar::DirB: | 0 | ||||||||||||||||||||||||
| 379 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 380 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 381 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 382 | if(dir != QChar::DirL
| 0 | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | if(control.direction() == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 385 | if(status.eor != QChar::DirR
| 0 | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 388 | status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 389 | dir = QChar::DirR; | - | ||||||||||||||||||||||||
| 390 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 391 | eor = current - 1; | - | ||||||||||||||||||||||||
| 392 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 393 | status.eor = dir = skipBoundryNeutrals(analysis, unicode, length, sor, eor, control); | - | ||||||||||||||||||||||||
| 394 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 395 | if(status.eor != QChar::DirL
| 0 | ||||||||||||||||||||||||
| 396 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 397 | status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 398 | dir = QChar::DirL; | - | ||||||||||||||||||||||||
| 399 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 400 | eor = current; status.eor = QChar::DirL; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 401 | } | - | ||||||||||||||||||||||||
| 402 | } | - | ||||||||||||||||||||||||
| 403 | } else { | - | ||||||||||||||||||||||||
| 404 | eor = current; status.eor = QChar::DirL; | - | ||||||||||||||||||||||||
| 405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 406 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 407 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 408 | } | - | ||||||||||||||||||||||||
| 409 | status.lastStrong = QChar::DirL; | - | ||||||||||||||||||||||||
| 410 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 411 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 412 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 413 | hasBidi = true; | - | ||||||||||||||||||||||||
| 414 | if(dir == QChar::DirON
never executed: dir = QChar::DirR; | 0 | ||||||||||||||||||||||||
| 415 | switch(status.last) | - | ||||||||||||||||||||||||
| 416 | { | - | ||||||||||||||||||||||||
| 417 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 418 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 419 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 420 | if (eor >= 0
| 0 | ||||||||||||||||||||||||
| 421 | appendItems(analysis, sor, eor, control, dir); never executed: appendItems(analysis, sor, eor, control, dir); | 0 | ||||||||||||||||||||||||
| 422 | - | |||||||||||||||||||||||||
| 423 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR:code before this statement never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 424 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 425 | dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 426 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 427 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 428 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 429 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 430 | case never executed: QChar::DirB:case QChar::DirB:never executed: case QChar::DirB: | 0 | ||||||||||||||||||||||||
| 431 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 432 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 433 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 434 | if(status.eor != QChar::DirR
| 0 | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | if(control.direction() == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 437 | || status.lastStrong == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 438 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 439 | dir = QChar::DirR; status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 440 | eor = current; | - | ||||||||||||||||||||||||
| 441 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 442 | eor = current - 1; | - | ||||||||||||||||||||||||
| 443 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 444 | dir = QChar::DirR; status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 445 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 446 | } else { | - | ||||||||||||||||||||||||
| 447 | eor = current; status.eor = QChar::DirR; | - | ||||||||||||||||||||||||
| 448 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 449 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 450 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 451 | } | - | ||||||||||||||||||||||||
| 452 | status.lastStrong = dirCurrent; | - | ||||||||||||||||||||||||
| 453 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | case never executed: QChar::DirNSM:case QChar::DirNSM:never executed: case QChar::DirNSM: | 0 | ||||||||||||||||||||||||
| 458 | if (eor == current-1
| 0 | ||||||||||||||||||||||||
| 459 | eor = current; never executed: eor = current; | 0 | ||||||||||||||||||||||||
| 460 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 461 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | if(status.lastStrong != QChar::DirAL
| 0 | ||||||||||||||||||||||||
| 464 | if(dir == QChar::DirON
| 0 | ||||||||||||||||||||||||
| 465 | if(status.lastStrong == QChar::DirL
| 0 | ||||||||||||||||||||||||
| 466 | dir = QChar::DirL; never executed: dir = QChar::DirL; | 0 | ||||||||||||||||||||||||
| 467 | else | - | ||||||||||||||||||||||||
| 468 | dir = QChar::DirEN; never executed: dir = QChar::DirEN; | 0 | ||||||||||||||||||||||||
| 469 | } | - | ||||||||||||||||||||||||
| 470 | switch(status.last) | - | ||||||||||||||||||||||||
| 471 | { | - | ||||||||||||||||||||||||
| 472 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 473 | if (status.lastStrong == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 474 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 475 | status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 476 | dir = QChar::DirAN; | - | ||||||||||||||||||||||||
| 477 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN:code before this statement never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 480 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 481 | eor = current; | - | ||||||||||||||||||||||||
| 482 | status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 483 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 484 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 485 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 486 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 487 | if (eor >= 0
| 0 | ||||||||||||||||||||||||
| 488 | appendItems(analysis, sor, eor, control, dir); never executed: appendItems(analysis, sor, eor, control, dir); | 0 | ||||||||||||||||||||||||
| 489 | else | - | ||||||||||||||||||||||||
| 490 | eor = current; never executed: eor = current; | 0 | ||||||||||||||||||||||||
| 491 | status.eor = QChar::DirEN; | - | ||||||||||||||||||||||||
| 492 | dir = QChar::DirAN; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 493 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 494 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 495 | if(status.eor == QChar::DirEN
| 0 | ||||||||||||||||||||||||
| 496 | eor = current; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 497 | } | - | ||||||||||||||||||||||||
| 498 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN:code before this statement never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 499 | case never executed: QChar::DirB:case QChar::DirB:never executed: case QChar::DirB: | 0 | ||||||||||||||||||||||||
| 500 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 501 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 502 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 503 | if(status.eor == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | eor = current - 1; | - | ||||||||||||||||||||||||
| 506 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 507 | dir = QChar::DirON; status.eor = QChar::DirEN; | - | ||||||||||||||||||||||||
| 508 | dir = QChar::DirAN; | - | ||||||||||||||||||||||||
| 509 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 510 | else if(status.eor == QChar::DirL
| 0 | ||||||||||||||||||||||||
| 511 | (status.eor == QChar::DirEN
| 0 | ||||||||||||||||||||||||
| 512 | eor = current; status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 513 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | if(dir != QChar::DirL
| 0 | ||||||||||||||||||||||||
| 516 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 517 | dir = QChar::DirON; status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 518 | eor = current - 1; | - | ||||||||||||||||||||||||
| 519 | dir = QChar::DirR; | - | ||||||||||||||||||||||||
| 520 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 521 | dir = QChar::DirON; status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 522 | dir = QChar::DirAN; | - | ||||||||||||||||||||||||
| 523 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 524 | eor = current; status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 525 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 526 | } | - | ||||||||||||||||||||||||
| 527 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 528 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 529 | } | - | ||||||||||||||||||||||||
| 530 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 531 | } | - | ||||||||||||||||||||||||
| 532 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN:code before this statement never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 533 | hasBidi = true; | - | ||||||||||||||||||||||||
| 534 | dirCurrent = QChar::DirAN; | - | ||||||||||||||||||||||||
| 535 | if(dir == QChar::DirON
never executed: dir = QChar::DirAN; | 0 | ||||||||||||||||||||||||
| 536 | switch(status.last) | - | ||||||||||||||||||||||||
| 537 | { | - | ||||||||||||||||||||||||
| 538 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 539 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 540 | eor = current; status.eor = QChar::DirAN; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 541 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 542 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 543 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 544 | if (eor >= 0
| 0 | ||||||||||||||||||||||||
| 545 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 546 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 547 | eor = current; | - | ||||||||||||||||||||||||
| 548 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 549 | dir = QChar::DirAN; status.eor = QChar::DirAN; | - | ||||||||||||||||||||||||
| 550 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 551 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 552 | if(status.eor == QChar::DirAN
| 0 | ||||||||||||||||||||||||
| 553 | eor = current; break; never executed: break; | 0 | ||||||||||||||||||||||||
| 554 | } | - | ||||||||||||||||||||||||
| 555 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES:code before this statement never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 556 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 557 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 558 | case never executed: QChar::DirB:case QChar::DirB:never executed: case QChar::DirB: | 0 | ||||||||||||||||||||||||
| 559 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 560 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 561 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 562 | if(status.eor == QChar::DirR
| 0 | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | eor = current - 1; | - | ||||||||||||||||||||||||
| 565 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 566 | status.eor = QChar::DirAN; | - | ||||||||||||||||||||||||
| 567 | dir = QChar::DirAN; | - | ||||||||||||||||||||||||
| 568 | } never executed: else if(status.eor == QChar::DirLend of block
| 0 | ||||||||||||||||||||||||
| 569 | (status.eor == QChar::DirEN
| 0 | ||||||||||||||||||||||||
| 570 | eor = current; status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 571 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||
| 573 | if(dir != QChar::DirL
| 0 | ||||||||||||||||||||||||
| 574 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 575 | status.eor = QChar::DirON; | - | ||||||||||||||||||||||||
| 576 | eor = current - 1; | - | ||||||||||||||||||||||||
| 577 | dir = QChar::DirR; | - | ||||||||||||||||||||||||
| 578 | appendItems(analysis, sor, eor, control, dir); | - | ||||||||||||||||||||||||
| 579 | status.eor = QChar::DirAN; | - | ||||||||||||||||||||||||
| 580 | dir = QChar::DirAN; | - | ||||||||||||||||||||||||
| 581 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 582 | eor = current; status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 584 | } | - | ||||||||||||||||||||||||
| 585 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 586 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 587 | } | - | ||||||||||||||||||||||||
| 588 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 589 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 590 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 591 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 592 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 593 | if(status.last == QChar::DirEN
| 0 | ||||||||||||||||||||||||
| 594 | dirCurrent = QChar::DirEN; | - | ||||||||||||||||||||||||
| 595 | eor = current; status.eor = dirCurrent; | - | ||||||||||||||||||||||||
| 596 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 597 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | - | |||||||||||||||||||||||||
| 600 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 601 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | case never executed: QChar::DirB:case QChar::DirB:never executed: case QChar::DirB: | 0 | ||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||
| 605 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 606 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 607 | - | |||||||||||||||||||||||||
| 608 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 609 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 610 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 611 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 612 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 613 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 614 | } | - | ||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | if(current >= (int)length
never executed: break; | 0 | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||
| 621 | switch(dirCurrent) { | - | ||||||||||||||||||||||||
| 622 | case never executed: QChar::DirET:case QChar::DirET:never executed: case QChar::DirET: | 0 | ||||||||||||||||||||||||
| 623 | case never executed: QChar::DirES:case QChar::DirES:never executed: case QChar::DirES: | 0 | ||||||||||||||||||||||||
| 624 | case never executed: QChar::DirCS:case QChar::DirCS:never executed: case QChar::DirCS: | 0 | ||||||||||||||||||||||||
| 625 | case never executed: QChar::DirS:case QChar::DirS:never executed: case QChar::DirS: | 0 | ||||||||||||||||||||||||
| 626 | case never executed: QChar::DirWS:case QChar::DirWS:never executed: case QChar::DirWS: | 0 | ||||||||||||||||||||||||
| 627 | case never executed: QChar::DirON:case QChar::DirON:never executed: case QChar::DirON: | 0 | ||||||||||||||||||||||||
| 628 | switch(status.last) | - | ||||||||||||||||||||||||
| 629 | { | - | ||||||||||||||||||||||||
| 630 | case never executed: QChar::DirL:case QChar::DirL:never executed: case QChar::DirL: | 0 | ||||||||||||||||||||||||
| 631 | case never executed: QChar::DirR:case QChar::DirR:never executed: case QChar::DirR: | 0 | ||||||||||||||||||||||||
| 632 | case never executed: QChar::DirAL:case QChar::DirAL:never executed: case QChar::DirAL: | 0 | ||||||||||||||||||||||||
| 633 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 634 | case never executed: QChar::DirAN:case QChar::DirAN:never executed: case QChar::DirAN: | 0 | ||||||||||||||||||||||||
| 635 | status.last = dirCurrent; | - | ||||||||||||||||||||||||
| 636 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 637 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 638 | status.last = QChar::DirON; | - | ||||||||||||||||||||||||
| 639 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 640 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 641 | case never executed: QChar::DirNSM:case QChar::DirNSM:never executed: case QChar::DirNSM: | 0 | ||||||||||||||||||||||||
| 642 | case never executed: QChar::DirBN:case QChar::DirBN:never executed: case QChar::DirBN: | 0 | ||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||
| 644 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 645 | case never executed: QChar::DirLRO:case QChar::DirLRO:never executed: case QChar::DirLRO: | 0 | ||||||||||||||||||||||||
| 646 | case never executed: QChar::DirLRE:case QChar::DirLRE:never executed: case QChar::DirLRE: | 0 | ||||||||||||||||||||||||
| 647 | status.last = QChar::DirL; | - | ||||||||||||||||||||||||
| 648 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 649 | case never executed: QChar::DirRLO:case QChar::DirRLO:never executed: case QChar::DirRLO: | 0 | ||||||||||||||||||||||||
| 650 | case never executed: QChar::DirRLE:case QChar::DirRLE:never executed: case QChar::DirRLE: | 0 | ||||||||||||||||||||||||
| 651 | status.last = QChar::DirR; | - | ||||||||||||||||||||||||
| 652 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 653 | case never executed: QChar::DirEN:case QChar::DirEN:never executed: case QChar::DirEN: | 0 | ||||||||||||||||||||||||
| 654 | if (status.last == QChar::DirL
| 0 | ||||||||||||||||||||||||
| 655 | status.last = QChar::DirL; | - | ||||||||||||||||||||||||
| 656 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 657 | } | - | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 660 | status.last = dirCurrent; | - | ||||||||||||||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | ++current; | - | ||||||||||||||||||||||||
| 664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | - | |||||||||||||||||||||||||
| 669 | eor = current - 1; | - | ||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||
| 671 | if (sor <= eor
| 0 | ||||||||||||||||||||||||
| 672 | appendItems(analysis, sor, eor, control, dir); never executed: appendItems(analysis, sor, eor, control, dir); | 0 | ||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||
| 674 | return never executed: hasBidi;return hasBidi;never executed: return hasBidi; | 0 | ||||||||||||||||||||||||
| 675 | } | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | void QTextEngine::bidiReorder(int numItems, const quint8 *levels, int *visualOrder) | - | ||||||||||||||||||||||||
| 678 | { | - | ||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | quint8 levelLow = 128; | - | ||||||||||||||||||||||||
| 682 | quint8 levelHigh = 0; | - | ||||||||||||||||||||||||
| 683 | int i = 0; | - | ||||||||||||||||||||||||
| 684 | while (i < numItems
| 0 | ||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||
| 686 | if (levels[i] > levelHigh
| 0 | ||||||||||||||||||||||||
| 687 | levelHigh = levels[i]; never executed: levelHigh = levels[i]; | 0 | ||||||||||||||||||||||||
| 688 | if (levels[i] < levelLow
| 0 | ||||||||||||||||||||||||
| 689 | levelLow = levels[i]; never executed: levelLow = levels[i]; | 0 | ||||||||||||||||||||||||
| 690 | i++; | - | ||||||||||||||||||||||||
| 691 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | if(!(levelLow%2)
never executed: levelLow++; | 0 | ||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||
| 704 | int count = numItems - 1; | - | ||||||||||||||||||||||||
| 705 | for (i = 0; i < numItems
| 0 | ||||||||||||||||||||||||
| 706 | visualOrder[i] = i; never executed: visualOrder[i] = i; | 0 | ||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | while(levelHigh >= levelLow
| 0 | ||||||||||||||||||||||||
| 709 | int i = 0; | - | ||||||||||||||||||||||||
| 710 | while (i < count
| 0 | ||||||||||||||||||||||||
| 711 | while(i < count
never executed: i++; | 0 | ||||||||||||||||||||||||
| 712 | int start = i; | - | ||||||||||||||||||||||||
| 713 | while(i <= count
never executed: i++; | 0 | ||||||||||||||||||||||||
| 714 | int end = i-1; | - | ||||||||||||||||||||||||
| 715 | - | |||||||||||||||||||||||||
| 716 | if(start != end
| 0 | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | for(int j = 0; j < (end-start+1)/2
| 0 | ||||||||||||||||||||||||
| 719 | int tmp = visualOrder[start+j]; | - | ||||||||||||||||||||||||
| 720 | visualOrder[start+j] = visualOrder[end-j]; | - | ||||||||||||||||||||||||
| 721 | visualOrder[end-j] = tmp; | - | ||||||||||||||||||||||||
| 722 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 723 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 724 | i++; | - | ||||||||||||||||||||||||
| 725 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 726 | levelHigh--; | - | ||||||||||||||||||||||||
| 727 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | - | |||||||||||||||||||||||||
| 734 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 735 | - | |||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||
| 737 | enum JustificationClass { | - | ||||||||||||||||||||||||
| 738 | Justification_Prohibited = 0, | - | ||||||||||||||||||||||||
| 739 | Justification_Arabic_Space = 1, | - | ||||||||||||||||||||||||
| 740 | Justification_Character = 2, | - | ||||||||||||||||||||||||
| 741 | Justification_Space = 4, | - | ||||||||||||||||||||||||
| 742 | Justification_Arabic_Normal = 7, | - | ||||||||||||||||||||||||
| 743 | Justification_Arabic_Waw = 8, | - | ||||||||||||||||||||||||
| 744 | Justification_Arabic_BaRa = 9, | - | ||||||||||||||||||||||||
| 745 | Justification_Arabic_Alef = 10, | - | ||||||||||||||||||||||||
| 746 | Justification_Arabic_HahDal = 11, | - | ||||||||||||||||||||||||
| 747 | Justification_Arabic_Seen = 12, | - | ||||||||||||||||||||||||
| 748 | Justification_Arabic_Kashida = 13 | - | ||||||||||||||||||||||||
| 749 | }; | - | ||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, QGlyphLayout g, ushort *log_clusters, int spaceAs) | - | ||||||||||||||||||||||||
| 758 | { | - | ||||||||||||||||||||||||
| 759 | int str_pos = 0; | - | ||||||||||||||||||||||||
| 760 | while (str_pos < length
| 0 | ||||||||||||||||||||||||
| 761 | int glyph_pos = log_clusters[str_pos]; | - | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | ((!(glyph_pos < g.numGlyphs && g.attributes[glyph_pos].clusterStart)) ? qt_assert("glyph_pos < g.numGlyphs && g.attributes[glyph_pos].clusterStart",__FILE__,852) : qt_noop()); | - | ||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||
| 765 | uint ucs4 = string[str_pos]; | - | ||||||||||||||||||||||||
| 766 | if (QChar::isHighSurrogate(ucs4)
| 0 | ||||||||||||||||||||||||
| 767 | ushort low = string[str_pos + 1]; | - | ||||||||||||||||||||||||
| 768 | if (QChar::isLowSurrogate(low)
| 0 | ||||||||||||||||||||||||
| 769 | ++str_pos; | - | ||||||||||||||||||||||||
| 770 | ucs4 = QChar::surrogateToUcs4(ucs4, low); | - | ||||||||||||||||||||||||
| 771 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 772 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 773 | - | |||||||||||||||||||||||||
| 774 | - | |||||||||||||||||||||||||
| 775 | do { | - | ||||||||||||||||||||||||
| 776 | ++str_pos; | - | ||||||||||||||||||||||||
| 777 | } never executed: while (str_pos < lengthend of block
| 0 | ||||||||||||||||||||||||
| 778 | do { | - | ||||||||||||||||||||||||
| 779 | ++glyph_pos; | - | ||||||||||||||||||||||||
| 780 | } never executed: while (glyph_pos < g.numGlyphsend of block
| 0 | ||||||||||||||||||||||||
| 781 | --glyph_pos; | - | ||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | if (__builtin_expect(!!(QChar::isLetterOrNumber(ucs4)), true)
| 0 | ||||||||||||||||||||||||
| 785 | g.attributes[glyph_pos].justification = Justification_Character; never executed: g.attributes[glyph_pos].justification = Justification_Character; | 0 | ||||||||||||||||||||||||
| 786 | else if (__builtin_expect(!!(QChar::isSpace(ucs4)), true)
| 0 | ||||||||||||||||||||||||
| 787 | g.attributes[glyph_pos].justification = spaceAs; never executed: g.attributes[glyph_pos].justification = spaceAs; | 0 | ||||||||||||||||||||||||
| 788 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, QGlyphLayout g, ushort *log_clusters) | - | ||||||||||||||||||||||||
| 792 | { | - | ||||||||||||||||||||||||
| 793 | ((!(length > 0 && g.numGlyphs > 0)) ? qt_assert("length > 0 && g.numGlyphs > 0",__FILE__,882) : qt_noop()); | - | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | for (int glyph_pos = 0; glyph_pos < g.numGlyphs
| 0 | ||||||||||||||||||||||||
| 796 | g.attributes[glyph_pos].justification = Justification_Prohibited; never executed: g.attributes[glyph_pos].justification = Justification_Prohibited; | 0 | ||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | int spaceAs; | - | ||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | switch (si.analysis.script) { | - | ||||||||||||||||||||||||
| 801 | case never executed: QChar::Script_Arabic:case QChar::Script_Arabic:never executed: case QChar::Script_Arabic: | 0 | ||||||||||||||||||||||||
| 802 | case never executed: QChar::Script_Syriac:case QChar::Script_Syriac:never executed: case QChar::Script_Syriac: | 0 | ||||||||||||||||||||||||
| 803 | case never executed: QChar::Script_Nko:case QChar::Script_Nko:never executed: case QChar::Script_Nko: | 0 | ||||||||||||||||||||||||
| 804 | case never executed: QChar::Script_Mandaic:case QChar::Script_Mandaic:never executed: case QChar::Script_Mandaic: | 0 | ||||||||||||||||||||||||
| 805 | case never executed: QChar::Script_Mongolian:case QChar::Script_Mongolian:never executed: case QChar::Script_Mongolian: | 0 | ||||||||||||||||||||||||
| 806 | case never executed: QChar::Script_PhagsPa:case QChar::Script_PhagsPa:never executed: case QChar::Script_PhagsPa: | 0 | ||||||||||||||||||||||||
| 807 | case never executed: QChar::Script_Manichaean:case QChar::Script_Manichaean:never executed: case QChar::Script_Manichaean: | 0 | ||||||||||||||||||||||||
| 808 | case never executed: QChar::Script_PsalterPahlavi:case QChar::Script_PsalterPahlavi:never executed: case QChar::Script_PsalterPahlavi: | 0 | ||||||||||||||||||||||||
| 809 | - | |||||||||||||||||||||||||
| 810 | spaceAs = Justification_Arabic_Space; | - | ||||||||||||||||||||||||
| 811 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||
| 813 | case never executed: QChar::Script_Tibetan:case QChar::Script_Tibetan:never executed: case QChar::Script_Tibetan: | 0 | ||||||||||||||||||||||||
| 814 | case never executed: QChar::Script_Hiragana:case QChar::Script_Hiragana:never executed: case QChar::Script_Hiragana: | 0 | ||||||||||||||||||||||||
| 815 | case never executed: QChar::Script_Katakana:case QChar::Script_Katakana:never executed: case QChar::Script_Katakana: | 0 | ||||||||||||||||||||||||
| 816 | case never executed: QChar::Script_Bopomofo:case QChar::Script_Bopomofo:never executed: case QChar::Script_Bopomofo: | 0 | ||||||||||||||||||||||||
| 817 | case never executed: QChar::Script_Han:case QChar::Script_Han:never executed: case QChar::Script_Han: | 0 | ||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | spaceAs = Justification_Character; | - | ||||||||||||||||||||||||
| 820 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||
| 822 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 823 | spaceAs = Justification_Space; | - | ||||||||||||||||||||||||
| 824 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 825 | } | - | ||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | qt_getDefaultJustificationOpportunities(string, length, g, log_clusters, spaceAs); | - | ||||||||||||||||||||||||
| 828 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||
| 834 | void QTextEngine::shapeLine(const QScriptLine &line) | - | ||||||||||||||||||||||||
| 835 | { | - | ||||||||||||||||||||||||
| 836 | QFixed x; | - | ||||||||||||||||||||||||
| 837 | bool first = true; | - | ||||||||||||||||||||||||
| 838 | int item = findItem(line.from); | - | ||||||||||||||||||||||||
| 839 | if (item == -1
| 0 | ||||||||||||||||||||||||
| 840 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | const int end = findItem(line.from + line.length + line.trailingSpaces - 1, item); | - | ||||||||||||||||||||||||
| 843 | for ( ; item <= end
| 0 | ||||||||||||||||||||||||
| 844 | QScriptItem &si = layoutData->items[item]; | - | ||||||||||||||||||||||||
| 845 | if (si.analysis.flags == QScriptAnalysis::Tab
| 0 | ||||||||||||||||||||||||
| 846 | ensureSpace(1); | - | ||||||||||||||||||||||||
| 847 | si.width = calculateTabWidth(item, x); | - | ||||||||||||||||||||||||
| 848 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 849 | shape(item); | - | ||||||||||||||||||||||||
| 850 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 851 | if (first
| 0 | ||||||||||||||||||||||||
| 852 | QGlyphLayout glyphs = shapedGlyphs(&si); | - | ||||||||||||||||||||||||
| 853 | ((!(line.from > si.position)) ? qt_assert("line.from > si.position",__FILE__,942) : qt_noop()); | - | ||||||||||||||||||||||||
| 854 | for (int i = line.from - si.position - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 855 | x -= glyphs.effectiveAdvance(i); | - | ||||||||||||||||||||||||
| 856 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 857 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 858 | first = false; | - | ||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||
| 860 | x += si.width; | - | ||||||||||||||||||||||||
| 861 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 862 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | extern bool qt_useHarfbuzzNG(); | - | ||||||||||||||||||||||||
| 866 | - | |||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | void QTextEngine::shapeText(int item) const | - | ||||||||||||||||||||||||
| 869 | { | - | ||||||||||||||||||||||||
| 870 | ((!(item < layoutData->items.size())) ? qt_assert("item < layoutData->items.size()",__FILE__,959) : qt_noop()); | - | ||||||||||||||||||||||||
| 871 | QScriptItem &si = layoutData->items[item]; | - | ||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | if (si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 874 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||
| 876 | si.width = 0; | - | ||||||||||||||||||||||||
| 877 | si.glyph_data_offset = layoutData->used; | - | ||||||||||||||||||||||||
| 878 | - | |||||||||||||||||||||||||
| 879 | const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.constData()) + si.position; | - | ||||||||||||||||||||||||
| 880 | const int itemLength = length(item); | - | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | QString casedString; | - | ||||||||||||||||||||||||
| 883 | if (si.analysis.flags
| 0 | ||||||||||||||||||||||||
| 884 | casedString.resize(itemLength); | - | ||||||||||||||||||||||||
| 885 | ushort *uc = reinterpret_cast<ushort *>(casedString.data()); | - | ||||||||||||||||||||||||
| 886 | for (int i = 0; i < itemLength
| 0 | ||||||||||||||||||||||||
| 887 | uint ucs4 = string[i]; | - | ||||||||||||||||||||||||
| 888 | if (QChar::isHighSurrogate(ucs4)
| 0 | ||||||||||||||||||||||||
| 889 | uint low = string[i + 1]; | - | ||||||||||||||||||||||||
| 890 | if (QChar::isLowSurrogate(low)
| 0 | ||||||||||||||||||||||||
| 891 | ++i; | - | ||||||||||||||||||||||||
| 892 | ucs4 = QChar::surrogateToUcs4(ucs4, low); | - | ||||||||||||||||||||||||
| 893 | ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase
| 0 | ||||||||||||||||||||||||
| 894 | : QChar::toUpper(ucs4); | - | ||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | uc[i] = QChar::lowSurrogate(ucs4); | - | ||||||||||||||||||||||||
| 897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 898 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 899 | uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase
| 0 | ||||||||||||||||||||||||
| 900 | : QChar::toUpper(ucs4); | - | ||||||||||||||||||||||||
| 901 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 902 | } | - | ||||||||||||||||||||||||
| 903 | string = reinterpret_cast<const ushort *>(casedString.constData()); | - | ||||||||||||||||||||||||
| 904 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 905 | - | |||||||||||||||||||||||||
| 906 | if (__builtin_expect(!!(!ensureSpace(itemLength)), false)
| 0 | ||||||||||||||||||||||||
| 907 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,996) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||
| 908 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 909 | } | - | ||||||||||||||||||||||||
| 910 | - | |||||||||||||||||||||||||
| 911 | QFontEngine *fontEngine = this->fontEngine(si, &si.ascent, &si.descent, &si.leading); | - | ||||||||||||||||||||||||
| 912 | - | |||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | QVector<uint> itemBoundaries; | - | ||||||||||||||||||||||||
| 916 | itemBoundaries.reserve(24); | - | ||||||||||||||||||||||||
| 917 | if (fontEngine->type() == QFontEngine::Multi
| 0 | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | QGlyphLayout initialGlyphs = availableGlyphs(&si); | - | ||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | int nGlyphs = initialGlyphs.numGlyphs; | - | ||||||||||||||||||||||||
| 923 | QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly); | - | ||||||||||||||||||||||||
| 924 | if (!fontEngine->stringToCMap(reinterpret_cast<const QChar *>(string), itemLength, &initialGlyphs, &nGlyphs, shaperFlags)
| 0 | ||||||||||||||||||||||||
| 925 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1014) : qt_noop()); __builtin_unreachable(); } never executed: while (0);end of block | 0 | ||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||
| 927 | uint lastEngine = ~0u; | - | ||||||||||||||||||||||||
| 928 | for (int i = 0, glyph_pos = 0; i < itemLength
| 0 | ||||||||||||||||||||||||
| 929 | const uint engineIdx = initialGlyphs.glyphs[glyph_pos] >> 24; | - | ||||||||||||||||||||||||
| 930 | if (lastEngine != engineIdx
| 0 | ||||||||||||||||||||||||
| 931 | itemBoundaries.append(i); | - | ||||||||||||||||||||||||
| 932 | itemBoundaries.append(glyph_pos); | - | ||||||||||||||||||||||||
| 933 | itemBoundaries.append(engineIdx); | - | ||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | if (engineIdx != 0
| 0 | ||||||||||||||||||||||||
| 936 | QFontEngine *actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx); | - | ||||||||||||||||||||||||
| 937 | si.ascent = qMax(actualFontEngine->ascent(), si.ascent); | - | ||||||||||||||||||||||||
| 938 | si.descent = qMax(actualFontEngine->descent(), si.descent); | - | ||||||||||||||||||||||||
| 939 | si.leading = qMax(actualFontEngine->leading(), si.leading); | - | ||||||||||||||||||||||||
| 940 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||
| 942 | lastEngine = engineIdx; | - | ||||||||||||||||||||||||
| 943 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 944 | - | |||||||||||||||||||||||||
| 945 | if (QChar::isHighSurrogate(string[i])
| 0 | ||||||||||||||||||||||||
| 946 | ++ never executed: i;++i;never executed: ++i; | 0 | ||||||||||||||||||||||||
| 947 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 948 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 949 | itemBoundaries.append(0); | - | ||||||||||||||||||||||||
| 950 | itemBoundaries.append(0); | - | ||||||||||||||||||||||||
| 951 | itemBoundaries.append(0); | - | ||||||||||||||||||||||||
| 952 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 953 | - | |||||||||||||||||||||||||
| 954 | bool kerningEnabled; | - | ||||||||||||||||||||||||
| 955 | bool letterSpacingIsAbsolute; | - | ||||||||||||||||||||||||
| 956 | QFixed letterSpacing, wordSpacing; | - | ||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||
| 958 | if (useRawFont
| 0 | ||||||||||||||||||||||||
| 959 | QTextCharFormat f = format(&si); | - | ||||||||||||||||||||||||
| 960 | kerningEnabled = f.fontKerning(); | - | ||||||||||||||||||||||||
| 961 | wordSpacing = QFixed::fromReal(f.fontWordSpacing()); | - | ||||||||||||||||||||||||
| 962 | letterSpacing = QFixed::fromReal(f.fontLetterSpacing()); | - | ||||||||||||||||||||||||
| 963 | letterSpacingIsAbsolute = true; | - | ||||||||||||||||||||||||
| 964 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||
| 966 | { | - | ||||||||||||||||||||||||
| 967 | QFont font = this->font(si); | - | ||||||||||||||||||||||||
| 968 | kerningEnabled = font.d->kerning; | - | ||||||||||||||||||||||||
| 969 | letterSpacingIsAbsolute = font.d->letterSpacingIsAbsolute; | - | ||||||||||||||||||||||||
| 970 | letterSpacing = font.d->letterSpacing; | - | ||||||||||||||||||||||||
| 971 | wordSpacing = font.d->wordSpacing; | - | ||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | if (letterSpacingIsAbsolute
| 0 | ||||||||||||||||||||||||
| 974 | letterSpacing *= font.d->dpi / qt_defaultDpiY(); never executed: letterSpacing *= font.d->dpi / qt_defaultDpiY(); | 0 | ||||||||||||||||||||||||
| 975 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 976 | - | |||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||
| 978 | if (__builtin_expect(!!(qt_useHarfbuzzNG()), true)
| 0 | ||||||||||||||||||||||||
| 979 | si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0); never executed: si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0); | 0 | ||||||||||||||||||||||||
| 980 | else | - | ||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); never executed: si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled); | 0 | ||||||||||||||||||||||||
| 983 | if (__builtin_expect(!!(si.num_glyphs == 0), false)
| 0 | ||||||||||||||||||||||||
| 984 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1073) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||
| 985 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 986 | } | - | ||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||
| 989 | layoutData->used += si.num_glyphs; | - | ||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||
| 991 | QGlyphLayout glyphs = shapedGlyphs(&si); | - | ||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| 993 | - | |||||||||||||||||||||||||
| 994 | if (__builtin_expect(!!(qt_useHarfbuzzNG()), true)
| 0 | ||||||||||||||||||||||||
| 995 | qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si)); never executed: qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si)); | 0 | ||||||||||||||||||||||||
| 996 | - | |||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||
| 998 | if (letterSpacing != 0
| 0 | ||||||||||||||||||||||||
| 999 | for (int i = 1; i < si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1000 | if (glyphs.attributes[i].clusterStart
| 0 | ||||||||||||||||||||||||
| 1001 | if (letterSpacingIsAbsolute
| 0 | ||||||||||||||||||||||||
| 1002 | glyphs.advances[i - 1] += letterSpacing; never executed: glyphs.advances[i - 1] += letterSpacing; | 0 | ||||||||||||||||||||||||
| 1003 | else { | - | ||||||||||||||||||||||||
| 1004 | QFixed &advance = glyphs.advances[i - 1]; | - | ||||||||||||||||||||||||
| 1005 | advance += (letterSpacing - 100) * advance / 100; | - | ||||||||||||||||||||||||
| 1006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | } | - | ||||||||||||||||||||||||
| 1008 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1009 | if (letterSpacingIsAbsolute
| 0 | ||||||||||||||||||||||||
| 1010 | glyphs.advances[si.num_glyphs - 1] += letterSpacing; never executed: glyphs.advances[si.num_glyphs - 1] += letterSpacing; | 0 | ||||||||||||||||||||||||
| 1011 | else { | - | ||||||||||||||||||||||||
| 1012 | QFixed &advance = glyphs.advances[si.num_glyphs - 1]; | - | ||||||||||||||||||||||||
| 1013 | advance += (letterSpacing - 100) * advance / 100; | - | ||||||||||||||||||||||||
| 1014 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||||||||
| 1016 | if (wordSpacing != 0
| 0 | ||||||||||||||||||||||||
| 1017 | for (int i = 0; i < si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1018 | if (glyphs.attributes[i].justification == Justification_Space
| 0 | ||||||||||||||||||||||||
| 1019 | || glyphs.attributes[i].justification == Justification_Arabic_Space
| 0 | ||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | if (i + 1 == si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1022 | ||(glyphs.attributes[i+1].justification != Justification_Space
| 0 | ||||||||||||||||||||||||
| 1023 | && glyphs.attributes[i+1].justification != Justification_Arabic_Space
| 0 | ||||||||||||||||||||||||
| 1024 | glyphs.advances[i] += wordSpacing; never executed: glyphs.advances[i] += wordSpacing; | 0 | ||||||||||||||||||||||||
| 1025 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1026 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1027 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | for (int i = 0; i < si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1030 | si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; never executed: si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; | 0 | ||||||||||||||||||||||||
| 1031 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||
| 1040 | int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, | - | ||||||||||||||||||||||||
| 1041 | const ushort *string, | - | ||||||||||||||||||||||||
| 1042 | int itemLength, | - | ||||||||||||||||||||||||
| 1043 | QFontEngine *fontEngine, | - | ||||||||||||||||||||||||
| 1044 | const QVector<uint> &itemBoundaries, | - | ||||||||||||||||||||||||
| 1045 | bool kerningEnabled, | - | ||||||||||||||||||||||||
| 1046 | bool hasLetterSpacing) const | - | ||||||||||||||||||||||||
| 1047 | { | - | ||||||||||||||||||||||||
| 1048 | uint glyphs_shaped = 0; | - | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | hb_buffer_t *buffer = hb_buffer_create(); | - | ||||||||||||||||||||||||
| 1051 | hb_buffer_set_unicode_funcs(buffer, hb_qt_get_unicode_funcs()); | - | ||||||||||||||||||||||||
| 1052 | hb_buffer_pre_allocate(buffer, itemLength); | - | ||||||||||||||||||||||||
| 1053 | if (__builtin_expect(!!(!hb_buffer_allocation_successful(buffer)), false)
| 0 | ||||||||||||||||||||||||
| 1054 | hb_buffer_destroy(buffer); | - | ||||||||||||||||||||||||
| 1055 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1056 | } | - | ||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||
| 1058 | hb_segment_properties_t props = {HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, ((hb_language_t) __null), __null, __null}; | - | ||||||||||||||||||||||||
| 1059 | props.direction = si.analysis.bidiLevel % 2
| 0 | ||||||||||||||||||||||||
| 1060 | QChar::Script script = QChar::Script(si.analysis.script); | - | ||||||||||||||||||||||||
| 1061 | props.script = hb_qt_script_to_script(script); | - | ||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | for (int k = 0; k < itemBoundaries.size()
| 0 | ||||||||||||||||||||||||
| 1065 | const uint item_pos = itemBoundaries[k]; | - | ||||||||||||||||||||||||
| 1066 | const uint item_length = (k + 4 < itemBoundaries.size()
| 0 | ||||||||||||||||||||||||
| 1067 | const uint engineIdx = itemBoundaries[k + 2]; | - | ||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | QFontEngine *actualFontEngine = fontEngine->type() != QFontEngine::Multi
| 0 | ||||||||||||||||||||||||
| 1070 | : static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx); | - | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | hb_buffer_clear_contents(buffer); | - | ||||||||||||||||||||||||
| 1075 | hb_buffer_add_utf16(buffer, reinterpret_cast<const uint16_t *>(string) + item_pos, item_length, 0, item_length); | - | ||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | hb_buffer_set_segment_properties(buffer, &props); | - | ||||||||||||||||||||||||
| 1078 | hb_buffer_guess_segment_properties(buffer); | - | ||||||||||||||||||||||||
| 1079 | - | |||||||||||||||||||||||||
| 1080 | uint buffer_flags = HB_BUFFER_FLAG_DEFAULT; | - | ||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||
| 1082 | - | |||||||||||||||||||||||||
| 1083 | if (__builtin_expect(!!(actualFontEngine->symbol), false)
| 0 | ||||||||||||||||||||||||
| 1084 | buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES; never executed: buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES; | 0 | ||||||||||||||||||||||||
| 1085 | hb_buffer_set_flags(buffer, hb_buffer_flags_t(buffer_flags)); | - | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | - | |||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | { | - | ||||||||||||||||||||||||
| 1090 | hb_font_t *hb_font = hb_qt_font_get_for_engine(actualFontEngine); | - | ||||||||||||||||||||||||
| 1091 | ((!(hb_font)) ? qt_assert("hb_font",__FILE__,1181) : qt_noop()); | - | ||||||||||||||||||||||||
| 1092 | hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); | - | ||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | - | |||||||||||||||||||||||||
| 1096 | bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac
| 0 | ||||||||||||||||||||||||
| 1097 | || script == QChar::Script_Khmer
| 0 | ||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||
| 1099 | bool dontLigate = hasLetterSpacing
| 0 | ||||||||||||||||||||||||
| 1100 | const hb_feature_t features[5] = { | - | ||||||||||||||||||||||||
| 1101 | { ((hb_tag_t)((((uint8_t)('k'))<<24)|(((uint8_t)('e'))<<16)|(((uint8_t)('r'))<<8)|((uint8_t)('n')))), !!kerningEnabled, 0, uint(-1) }, | - | ||||||||||||||||||||||||
| 1102 | { ((hb_tag_t)((((uint8_t)('l'))<<24)|(((uint8_t)('i'))<<16)|(((uint8_t)('g'))<<8)|((uint8_t)('a')))), !dontLigate, 0, uint(-1) }, | - | ||||||||||||||||||||||||
| 1103 | { ((hb_tag_t)((((uint8_t)('c'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) }, | - | ||||||||||||||||||||||||
| 1104 | { ((hb_tag_t)((((uint8_t)('d'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) }, | - | ||||||||||||||||||||||||
| 1105 | { ((hb_tag_t)((((uint8_t)('h'))<<24)|(((uint8_t)('l'))<<16)|(((uint8_t)('i'))<<8)|((uint8_t)('g')))), !dontLigate, 0, uint(-1) } }; | - | ||||||||||||||||||||||||
| 1106 | const int num_features = dontLigate
| 0 | ||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | const char *const *shaper_list = nullptr; | - | ||||||||||||||||||||||||
| 1109 | bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, shaper_list); | - | ||||||||||||||||||||||||
| 1110 | if (__builtin_expect(!!(!shapedOk), false)
| 0 | ||||||||||||||||||||||||
| 1111 | hb_buffer_destroy(buffer); | - | ||||||||||||||||||||||||
| 1112 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1113 | } | - | ||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | if (__builtin_expect(!!(((((unsigned int) (props.direction)) & ~2U) == 5)), false)
| 0 | ||||||||||||||||||||||||
| 1116 | hb_buffer_reverse(buffer); never executed: hb_buffer_reverse(buffer); | 0 | ||||||||||||||||||||||||
| 1117 | } | - | ||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | const uint num_glyphs = hb_buffer_get_length(buffer); | - | ||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||
| 1121 | if (__builtin_expect(!!(num_glyphs == 0 || !ensureSpace(glyphs_shaped + num_glyphs)), false)
| 0 | ||||||||||||||||||||||||
| 1122 | hb_buffer_destroy(buffer); | - | ||||||||||||||||||||||||
| 1123 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1124 | } | - | ||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | QGlyphLayout g = availableGlyphs(&si).mid(glyphs_shaped, num_glyphs); | - | ||||||||||||||||||||||||
| 1128 | ushort *log_clusters = logClusters(&si) + item_pos; | - | ||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||
| 1130 | hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, 0); | - | ||||||||||||||||||||||||
| 1131 | hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, 0); | - | ||||||||||||||||||||||||
| 1132 | uint str_pos = 0; | - | ||||||||||||||||||||||||
| 1133 | uint last_cluster = ~0u; | - | ||||||||||||||||||||||||
| 1134 | uint last_glyph_pos = glyphs_shaped; | - | ||||||||||||||||||||||||
| 1135 | for (uint i = 0; i < num_glyphs
| 0 | ||||||||||||||||||||||||
| 1136 | g.glyphs[i] = infos->codepoint; | - | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | g.advances[i] = QFixed::fromFixed(positions->x_advance); | - | ||||||||||||||||||||||||
| 1139 | g.offsets[i].x = QFixed::fromFixed(positions->x_offset); | - | ||||||||||||||||||||||||
| 1140 | g.offsets[i].y = QFixed::fromFixed(positions->y_offset); | - | ||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||
| 1142 | uint cluster = infos->cluster; | - | ||||||||||||||||||||||||
| 1143 | if (__builtin_expect(!!(last_cluster != cluster), true)
| 0 | ||||||||||||||||||||||||
| 1144 | g.attributes[i].clusterStart = true; | - | ||||||||||||||||||||||||
| 1145 | - | |||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | - | |||||||||||||||||||||||||
| 1148 | while (last_cluster++ < cluster
| 0 | ||||||||||||||||||||||||
| 1149 | log_clusters[str_pos++] = last_glyph_pos; never executed: log_clusters[str_pos++] = last_glyph_pos; | 0 | ||||||||||||||||||||||||
| 1150 | last_glyph_pos = i + glyphs_shaped; | - | ||||||||||||||||||||||||
| 1151 | last_cluster = cluster; | - | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||
| 1154 | switch (string[item_pos + str_pos]) { | - | ||||||||||||||||||||||||
| 1155 | case never executed: QChar::LineFeed:case QChar::LineFeed:never executed: case QChar::LineFeed: | 0 | ||||||||||||||||||||||||
| 1156 | case never executed: 0x000c:case 0x000c:never executed: case 0x000c: | 0 | ||||||||||||||||||||||||
| 1157 | case never executed: QChar::CarriageReturn:case QChar::CarriageReturn:never executed: case QChar::CarriageReturn: | 0 | ||||||||||||||||||||||||
| 1158 | case never executed: QChar::LineSeparator:case QChar::LineSeparator:never executed: case QChar::LineSeparator: | 0 | ||||||||||||||||||||||||
| 1159 | case never executed: QChar::ParagraphSeparator:case QChar::ParagraphSeparator:never executed: case QChar::ParagraphSeparator: | 0 | ||||||||||||||||||||||||
| 1160 | g.attributes[i].dontPrint = true; | - | ||||||||||||||||||||||||
| 1161 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1162 | case never executed: QChar::SoftHyphen:case QChar::SoftHyphen:never executed: case QChar::SoftHyphen: | 0 | ||||||||||||||||||||||||
| 1163 | if (!actualFontEngine->symbol
| 0 | ||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | g.glyphs[i] = actualFontEngine->glyphIndex('-'); | - | ||||||||||||||||||||||||
| 1168 | if (__builtin_expect(!!(g.glyphs[i] != 0), true)
| 0 | ||||||||||||||||||||||||
| 1169 | QGlyphLayout tmp = g.mid(i, 1); | - | ||||||||||||||||||||||||
| 1170 | actualFontEngine->recalcAdvances(&tmp, 0); | - | ||||||||||||||||||||||||
| 1171 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1172 | g.attributes[i].dontPrint = true; | - | ||||||||||||||||||||||||
| 1173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1174 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1175 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1176 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1177 | } | - | ||||||||||||||||||||||||
| 1178 | } | - | ||||||||||||||||||||||||
| 1179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1180 | while (str_pos < item_length
| 0 | ||||||||||||||||||||||||
| 1181 | log_clusters[str_pos++] = last_glyph_pos; never executed: log_clusters[str_pos++] = last_glyph_pos; | 0 | ||||||||||||||||||||||||
| 1182 | - | |||||||||||||||||||||||||
| 1183 | if (__builtin_expect(!!(engineIdx != 0), false)
| 0 | ||||||||||||||||||||||||
| 1184 | for (quint32 i = 0; i < num_glyphs
| 0 | ||||||||||||||||||||||||
| 1185 | g.glyphs[i] |= (engineIdx << 24); never executed: g.glyphs[i] |= (engineIdx << 24); | 0 | ||||||||||||||||||||||||
| 1186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1187 | if (!actualFontEngine->supportsSubPixelPositions()
| 0 | ||||||||||||||||||||||||
| 1188 | for (uint i = 0; i < num_glyphs
| 0 | ||||||||||||||||||||||||
| 1189 | g.advances[i] = g.advances[i].round(); never executed: g.advances[i] = g.advances[i].round(); | 0 | ||||||||||||||||||||||||
| 1190 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | glyphs_shaped += num_glyphs; | - | ||||||||||||||||||||||||
| 1193 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||
| 1195 | hb_buffer_destroy(buffer); | - | ||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | return never executed: glyphs_shaped;return glyphs_shaped;never executed: return glyphs_shaped; | 0 | ||||||||||||||||||||||||
| 1198 | } | - | ||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | static_assert(bool(sizeof(HB_Glyph) == sizeof(glyph_t)), "sizeof(HB_Glyph) == sizeof(glyph_t)"); | - | ||||||||||||||||||||||||
| 1209 | static_assert(bool(sizeof(HB_Fixed) == sizeof(QFixed)), "sizeof(HB_Fixed) == sizeof(QFixed)"); | - | ||||||||||||||||||||||||
| 1210 | static_assert(bool(sizeof(HB_FixedPoint) == sizeof(QFixedPoint)), "sizeof(HB_FixedPoint) == sizeof(QFixedPoint)"); | - | ||||||||||||||||||||||||
| 1211 | - | |||||||||||||||||||||||||
| 1212 | static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num) | - | ||||||||||||||||||||||||
| 1213 | { | - | ||||||||||||||||||||||||
| 1214 | if (num > 0
| 0 | ||||||||||||||||||||||||
| 1215 | memmove(destination.glyphs, source.glyphs, num * sizeof(glyph_t)); never executed: memmove(destination.glyphs, source.glyphs, num * sizeof(glyph_t)); | 0 | ||||||||||||||||||||||||
| 1216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const | - | ||||||||||||||||||||||||
| 1219 | { | - | ||||||||||||||||||||||||
| 1220 | HB_ShaperItem entire_shaper_item; | - | ||||||||||||||||||||||||
| 1221 | memset(&entire_shaper_item, 0, sizeof(entire_shaper_item)); | - | ||||||||||||||||||||||||
| 1222 | entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(string); | - | ||||||||||||||||||||||||
| 1223 | entire_shaper_item.stringLength = itemLength; | - | ||||||||||||||||||||||||
| 1224 | entire_shaper_item.item.script = script_to_hbscript(si.analysis.script); | - | ||||||||||||||||||||||||
| 1225 | entire_shaper_item.item.pos = 0; | - | ||||||||||||||||||||||||
| 1226 | entire_shaper_item.item.length = itemLength; | - | ||||||||||||||||||||||||
| 1227 | entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel; | - | ||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||
| 1229 | entire_shaper_item.shaperFlags = 0; | - | ||||||||||||||||||||||||
| 1230 | if (!kerningEnabled
| 0 | ||||||||||||||||||||||||
| 1231 | entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning; never executed: entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning; | 0 | ||||||||||||||||||||||||
| 1232 | if (option.useDesignMetrics()
| 0 | ||||||||||||||||||||||||
| 1233 | entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics; never executed: entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics; | 0 | ||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||
| 1236 | entire_shaper_item.num_glyphs = 0; | - | ||||||||||||||||||||||||
| 1237 | for (int i = 0; i < itemLength
| 0 | ||||||||||||||||||||||||
| 1238 | if (QChar::isHighSurrogate(string[i])
| 0 | ||||||||||||||||||||||||
| 1239 | ++ never executed: i;++i;never executed: ++i; | 0 | ||||||||||||||||||||||||
| 1240 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | int remaining_glyphs = entire_shaper_item.num_glyphs; | - | ||||||||||||||||||||||||
| 1244 | int glyph_pos = 0; | - | ||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | for (int k = 0; k < itemBoundaries.size()
| 0 | ||||||||||||||||||||||||
| 1247 | HB_ShaperItem shaper_item = entire_shaper_item; | - | ||||||||||||||||||||||||
| 1248 | shaper_item.item.pos = itemBoundaries[k]; | - | ||||||||||||||||||||||||
| 1249 | if (k + 4 < itemBoundaries.size()
| 0 | ||||||||||||||||||||||||
| 1250 | shaper_item.item.length = itemBoundaries[k + 3] - shaper_item.item.pos; | - | ||||||||||||||||||||||||
| 1251 | shaper_item.num_glyphs = itemBoundaries[k + 4] - itemBoundaries[k + 1]; | - | ||||||||||||||||||||||||
| 1252 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1253 | shaper_item.item.length -= shaper_item.item.pos - entire_shaper_item.item.pos; | - | ||||||||||||||||||||||||
| 1254 | shaper_item.num_glyphs -= itemBoundaries[k + 1]; | - | ||||||||||||||||||||||||
| 1255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1256 | shaper_item.initialGlyphCount = shaper_item.num_glyphs; | - | ||||||||||||||||||||||||
| 1257 | if (shaper_item.num_glyphs < shaper_item.item.length
| 0 | ||||||||||||||||||||||||
| 1258 | shaper_item.num_glyphs = shaper_item.item.length; never executed: shaper_item.num_glyphs = shaper_item.item.length; | 0 | ||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||
| 1260 | uint engineIdx = itemBoundaries[k + 2]; | - | ||||||||||||||||||||||||
| 1261 | QFontEngine *actualFontEngine = fontEngine; | - | ||||||||||||||||||||||||
| 1262 | if (fontEngine->type() == QFontEngine::Multi
| 0 | ||||||||||||||||||||||||
| 1263 | actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx); | - | ||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||
| 1265 | if ((
| 0 | ||||||||||||||||||||||||
| 1266 | shaper_item.glyphIndicesPresent = true; never executed: shaper_item.glyphIndicesPresent = true; | 0 | ||||||||||||||||||||||||
| 1267 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1268 | - | |||||||||||||||||||||||||
| 1269 | shaper_item.font = (HB_Font)actualFontEngine->harfbuzzFont(); | - | ||||||||||||||||||||||||
| 1270 | shaper_item.face = (HB_Face)actualFontEngine->harfbuzzFace(); | - | ||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||
| 1272 | remaining_glyphs -= shaper_item.initialGlyphCount; | - | ||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | QVarLengthArray<HB_GlyphAttributes, 128> hbGlyphAttributes; | - | ||||||||||||||||||||||||
| 1275 | do { | - | ||||||||||||||||||||||||
| 1276 | if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs)
| 0 | ||||||||||||||||||||||||
| 1277 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1278 | if (hbGlyphAttributes.size() < int(shaper_item.num_glyphs)
| 0 | ||||||||||||||||||||||||
| 1279 | hbGlyphAttributes.resize(shaper_item.num_glyphs); | - | ||||||||||||||||||||||||
| 1280 | memset(hbGlyphAttributes.data(), 0, hbGlyphAttributes.size() * sizeof(HB_GlyphAttributes)); | - | ||||||||||||||||||||||||
| 1281 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos); | - | ||||||||||||||||||||||||
| 1284 | if (fontEngine->type() == QFontEngine::Multi
| 0 | ||||||||||||||||||||||||
| 1285 | moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); never executed: moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); | 0 | ||||||||||||||||||||||||
| 1286 | - | |||||||||||||||||||||||||
| 1287 | shaper_item.glyphs = reinterpret_cast<HB_Glyph *>(g.glyphs); | - | ||||||||||||||||||||||||
| 1288 | shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances); | - | ||||||||||||||||||||||||
| 1289 | shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets); | - | ||||||||||||||||||||||||
| 1290 | shaper_item.attributes = hbGlyphAttributes.data(); | - | ||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | if (engineIdx != 0
| 0 | ||||||||||||||||||||||||
| 1293 | for (quint32 i = 0; i < shaper_item.initialGlyphCount
| 0 | ||||||||||||||||||||||||
| 1294 | shaper_item.glyphs[i] &= 0x00ffffff; never executed: shaper_item.glyphs[i] &= 0x00ffffff; | 0 | ||||||||||||||||||||||||
| 1295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | shaper_item.log_clusters = logClusters(&si) + shaper_item.item.pos - entire_shaper_item.item.pos; | - | ||||||||||||||||||||||||
| 1298 | } never executed: while (!qShapeItem(&shaper_item)end of block
| 0 | ||||||||||||||||||||||||
| 1299 | - | |||||||||||||||||||||||||
| 1300 | QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs); | - | ||||||||||||||||||||||||
| 1301 | if (fontEngine->type() == QFontEngine::Multi
| 0 | ||||||||||||||||||||||||
| 1302 | moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); never executed: moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); | 0 | ||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||
| 1304 | for (quint32 i = 0; i < shaper_item.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1305 | HB_GlyphAttributes hbAttrs = hbGlyphAttributes.at(i); | - | ||||||||||||||||||||||||
| 1306 | QGlyphAttributes &attrs = g.attributes[i]; | - | ||||||||||||||||||||||||
| 1307 | attrs.clusterStart = hbAttrs.clusterStart; | - | ||||||||||||||||||||||||
| 1308 | attrs.dontPrint = hbAttrs.dontPrint; | - | ||||||||||||||||||||||||
| 1309 | attrs.justification = hbAttrs.justification; | - | ||||||||||||||||||||||||
| 1310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | for (quint32 i = 0; i < shaper_item.item.length
| 0 | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | if (shaper_item.log_clusters[i] >= shaper_item.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1315 | shaper_item.log_clusters[i] = shaper_item.num_glyphs - 1; never executed: shaper_item.log_clusters[i] = shaper_item.num_glyphs - 1; | 0 | ||||||||||||||||||||||||
| 1316 | shaper_item.log_clusters[i] += glyph_pos; | - | ||||||||||||||||||||||||
| 1317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1318 | - | |||||||||||||||||||||||||
| 1319 | if (kerningEnabled
| 0 | ||||||||||||||||||||||||
| 1320 | actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); never executed: actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); | 0 | ||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||
| 1322 | if (engineIdx != 0
| 0 | ||||||||||||||||||||||||
| 1323 | for (quint32 i = 0; i < shaper_item.num_glyphs
| 0 | ||||||||||||||||||||||||
| 1324 | g.glyphs[i] |= (engineIdx << 24); never executed: g.glyphs[i] |= (engineIdx << 24); | 0 | ||||||||||||||||||||||||
| 1325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1326 | - | |||||||||||||||||||||||||
| 1327 | glyph_pos += shaper_item.num_glyphs; | - | ||||||||||||||||||||||||
| 1328 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||
| 1330 | return never executed: glyph_pos;return glyph_pos;never executed: return glyph_pos; | 0 | ||||||||||||||||||||||||
| 1331 | } | - | ||||||||||||||||||||||||
| 1332 | - | |||||||||||||||||||||||||
| 1333 | void QTextEngine::init(QTextEngine *e) | - | ||||||||||||||||||||||||
| 1334 | { | - | ||||||||||||||||||||||||
| 1335 | e->ignoreBidi = false; | - | ||||||||||||||||||||||||
| 1336 | e->cacheGlyphs = false; | - | ||||||||||||||||||||||||
| 1337 | e->forceJustification = false; | - | ||||||||||||||||||||||||
| 1338 | e->visualMovement = false; | - | ||||||||||||||||||||||||
| 1339 | e->delayDecorations = false; | - | ||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||
| 1341 | e->layoutData = 0; | - | ||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | e->minWidth = 0; | - | ||||||||||||||||||||||||
| 1344 | e->maxWidth = 0; | - | ||||||||||||||||||||||||
| 1345 | - | |||||||||||||||||||||||||
| 1346 | e->specialData = 0; | - | ||||||||||||||||||||||||
| 1347 | e->stackEngine = false; | - | ||||||||||||||||||||||||
| 1348 | - | |||||||||||||||||||||||||
| 1349 | e->useRawFont = false; | - | ||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||
| 1351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | QTextEngine::QTextEngine() | - | ||||||||||||||||||||||||
| 1354 | { | - | ||||||||||||||||||||||||
| 1355 | init(this); | - | ||||||||||||||||||||||||
| 1356 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1357 | - | |||||||||||||||||||||||||
| 1358 | QTextEngine::QTextEngine(const QString &str, const QFont &f) | - | ||||||||||||||||||||||||
| 1359 | : text(str), | - | ||||||||||||||||||||||||
| 1360 | fnt(f) | - | ||||||||||||||||||||||||
| 1361 | { | - | ||||||||||||||||||||||||
| 1362 | init(this); | - | ||||||||||||||||||||||||
| 1363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | QTextEngine::~QTextEngine() | - | ||||||||||||||||||||||||
| 1366 | { | - | ||||||||||||||||||||||||
| 1367 | if (!stackEngine
| 0 | ||||||||||||||||||||||||
| 1368 | delete layoutData; never executed: delete layoutData; | 0 | ||||||||||||||||||||||||
| 1369 | delete specialData; | - | ||||||||||||||||||||||||
| 1370 | resetFontEngineCache(); | - | ||||||||||||||||||||||||
| 1371 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||
| 1373 | const QCharAttributes *QTextEngine::attributes() const | - | ||||||||||||||||||||||||
| 1374 | { | - | ||||||||||||||||||||||||
| 1375 | if (layoutData
| 0 | ||||||||||||||||||||||||
| 1376 | return never executed: (QCharAttributes *) layoutData->memory;return (QCharAttributes *) layoutData->memory;never executed: return (QCharAttributes *) layoutData->memory; | 0 | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | itemize(); | - | ||||||||||||||||||||||||
| 1379 | if (! ensureSpace(layoutData->string.length())
| 0 | ||||||||||||||||||||||||
| 1380 | return never executed: __null;return __null;never executed: return __null; | 0 | ||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||
| 1382 | QVarLengthArray<QUnicodeTools::ScriptItem> scriptItems(layoutData->items.size()); | - | ||||||||||||||||||||||||
| 1383 | for (int i = 0; i < layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 1384 | const QScriptItem &si = layoutData->items[i]; | - | ||||||||||||||||||||||||
| 1385 | scriptItems[i].position = si.position; | - | ||||||||||||||||||||||||
| 1386 | scriptItems[i].script = si.analysis.script; | - | ||||||||||||||||||||||||
| 1387 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||
| 1389 | QUnicodeTools::initCharAttributes(reinterpret_cast<const ushort *>(layoutData->string.constData()), | - | ||||||||||||||||||||||||
| 1390 | layoutData->string.length(), | - | ||||||||||||||||||||||||
| 1391 | scriptItems.data(), scriptItems.size(), | - | ||||||||||||||||||||||||
| 1392 | (QCharAttributes *)layoutData->memory); | - | ||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||
| 1395 | layoutData->haveCharAttributes = true; | - | ||||||||||||||||||||||||
| 1396 | return never executed: (QCharAttributes *) layoutData->memory;return (QCharAttributes *) layoutData->memory;never executed: return (QCharAttributes *) layoutData->memory; | 0 | ||||||||||||||||||||||||
| 1397 | } | - | ||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||
| 1399 | void QTextEngine::shape(int item) const | - | ||||||||||||||||||||||||
| 1400 | { | - | ||||||||||||||||||||||||
| 1401 | if (layoutData->items[item].analysis.flags == QScriptAnalysis::Object
| 0 | ||||||||||||||||||||||||
| 1402 | ensureSpace(1); | - | ||||||||||||||||||||||||
| 1403 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 1404 | docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)), | - | ||||||||||||||||||||||||
| 1405 | layoutData->items[item].position + block.position(), | - | ||||||||||||||||||||||||
| 1406 | format(&layoutData->items[item])); | - | ||||||||||||||||||||||||
| 1407 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1408 | } never executed: else if (layoutData->items[item].analysis.flags == QScriptAnalysis::Tabend of block
| 0 | ||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | fontEngine(layoutData->items[item], | - | ||||||||||||||||||||||||
| 1411 | &layoutData->items[item].ascent, | - | ||||||||||||||||||||||||
| 1412 | &layoutData->items[item].descent, | - | ||||||||||||||||||||||||
| 1413 | &layoutData->items[item].leading); | - | ||||||||||||||||||||||||
| 1414 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1415 | shapeText(item); | - | ||||||||||||||||||||||||
| 1416 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1417 | } | - | ||||||||||||||||||||||||
| 1418 | - | |||||||||||||||||||||||||
| 1419 | static inline void releaseCachedFontEngine(QFontEngine *fontEngine) | - | ||||||||||||||||||||||||
| 1420 | { | - | ||||||||||||||||||||||||
| 1421 | if (fontEngine
| 0 | ||||||||||||||||||||||||
| 1422 | delete fontEngine; never executed: delete fontEngine; | 0 | ||||||||||||||||||||||||
| 1423 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||
| 1425 | void QTextEngine::resetFontEngineCache() | - | ||||||||||||||||||||||||
| 1426 | { | - | ||||||||||||||||||||||||
| 1427 | releaseCachedFontEngine(feCache.prevFontEngine); | - | ||||||||||||||||||||||||
| 1428 | releaseCachedFontEngine(feCache.prevScaledFontEngine); | - | ||||||||||||||||||||||||
| 1429 | feCache.reset(); | - | ||||||||||||||||||||||||
| 1430 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||
| 1432 | void QTextEngine::invalidate() | - | ||||||||||||||||||||||||
| 1433 | { | - | ||||||||||||||||||||||||
| 1434 | freeMemory(); | - | ||||||||||||||||||||||||
| 1435 | minWidth = 0; | - | ||||||||||||||||||||||||
| 1436 | maxWidth = 0; | - | ||||||||||||||||||||||||
| 1437 | - | |||||||||||||||||||||||||
| 1438 | resetFontEngineCache(); | - | ||||||||||||||||||||||||
| 1439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | void QTextEngine::clearLineData() | - | ||||||||||||||||||||||||
| 1442 | { | - | ||||||||||||||||||||||||
| 1443 | lines.clear(); | - | ||||||||||||||||||||||||
| 1444 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||
| 1446 | void QTextEngine::validate() const | - | ||||||||||||||||||||||||
| 1447 | { | - | ||||||||||||||||||||||||
| 1448 | if (layoutData
| 0 | ||||||||||||||||||||||||
| 1449 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1450 | layoutData = new LayoutData(); | - | ||||||||||||||||||||||||
| 1451 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 1452 | layoutData->string = block.text(); | - | ||||||||||||||||||||||||
| 1453 | const bool nextBlockValid = block.next().isValid(); | - | ||||||||||||||||||||||||
| 1454 | if (!nextBlockValid
| 0 | ||||||||||||||||||||||||
| 1455 | layoutData->string += QChar(0xA7); | - | ||||||||||||||||||||||||
| 1456 | } never executed: else if (option.flags() & QTextOption::ShowLineAndParagraphSeparatorsend of block
| 0 | ||||||||||||||||||||||||
| 1457 | layoutData->string += QLatin1Char(nextBlockValid ? 0xb6 : 0x20); | - | ||||||||||||||||||||||||
| 1458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1459 | - | |||||||||||||||||||||||||
| 1460 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1461 | layoutData->string = text; | - | ||||||||||||||||||||||||
| 1462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1463 | if (specialData
| 0 | ||||||||||||||||||||||||
| 1464 | layoutData->string.insert(specialData->preeditPosition, specialData->preeditText); never executed: layoutData->string.insert(specialData->preeditPosition, specialData->preeditText); | 0 | ||||||||||||||||||||||||
| 1465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||
| 1467 | void QTextEngine::itemize() const | - | ||||||||||||||||||||||||
| 1468 | { | - | ||||||||||||||||||||||||
| 1469 | validate(); | - | ||||||||||||||||||||||||
| 1470 | if (layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 1471 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||
| 1473 | int length = layoutData->string.length(); | - | ||||||||||||||||||||||||
| 1474 | if (!length
| 0 | ||||||||||||||||||||||||
| 1475 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1476 | - | |||||||||||||||||||||||||
| 1477 | const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.unicode()); | - | ||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||
| 1479 | bool ignore = ignoreBidi; | - | ||||||||||||||||||||||||
| 1480 | - | |||||||||||||||||||||||||
| 1481 | bool rtl = isRightToLeft(); | - | ||||||||||||||||||||||||
| 1482 | - | |||||||||||||||||||||||||
| 1483 | if (!ignore
| 0 | ||||||||||||||||||||||||
| 1484 | ignore = true; | - | ||||||||||||||||||||||||
| 1485 | const QChar *start = layoutData->string.unicode(); | - | ||||||||||||||||||||||||
| 1486 | const QChar * const end = start + length; | - | ||||||||||||||||||||||||
| 1487 | while (start < end
| 0 | ||||||||||||||||||||||||
| 1488 | if (start->unicode() >= 0x590
| 0 | ||||||||||||||||||||||||
| 1489 | ignore = false; | - | ||||||||||||||||||||||||
| 1490 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1491 | } | - | ||||||||||||||||||||||||
| 1492 | ++start; | - | ||||||||||||||||||||||||
| 1493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1495 | - | |||||||||||||||||||||||||
| 1496 | QVarLengthArray<QScriptAnalysis, 4096> scriptAnalysis(length); | - | ||||||||||||||||||||||||
| 1497 | QScriptAnalysis *analysis = scriptAnalysis.data(); | - | ||||||||||||||||||||||||
| 1498 | - | |||||||||||||||||||||||||
| 1499 | QBidiControl control(rtl); | - | ||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | if (ignore
| 0 | ||||||||||||||||||||||||
| 1502 | memset(analysis, 0, length*sizeof(QScriptAnalysis)); | - | ||||||||||||||||||||||||
| 1503 | if (option.textDirection() == Qt::RightToLeft
| 0 | ||||||||||||||||||||||||
| 1504 | for (int i = 0; i < length
| 0 | ||||||||||||||||||||||||
| 1505 | analysis[i].bidiLevel = 1; never executed: analysis[i].bidiLevel = 1; | 0 | ||||||||||||||||||||||||
| 1506 | layoutData->hasBidi = true; | - | ||||||||||||||||||||||||
| 1507 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1508 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1509 | layoutData->hasBidi = bidiItemize(const_cast<QTextEngine *>(this), analysis, control); | - | ||||||||||||||||||||||||
| 1510 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1511 | - | |||||||||||||||||||||||||
| 1512 | { | - | ||||||||||||||||||||||||
| 1513 | QVarLengthArray<uchar> scripts(length); | - | ||||||||||||||||||||||||
| 1514 | QUnicodeTools::initScripts(string, length, scripts.data()); | - | ||||||||||||||||||||||||
| 1515 | for (int i = 0; i < length
| 0 | ||||||||||||||||||||||||
| 1516 | analysis[i].script = scripts.at(i); never executed: analysis[i].script = scripts.at(i); | 0 | ||||||||||||||||||||||||
| 1517 | } | - | ||||||||||||||||||||||||
| 1518 | - | |||||||||||||||||||||||||
| 1519 | const ushort *uc = string; | - | ||||||||||||||||||||||||
| 1520 | const ushort *e = uc + length; | - | ||||||||||||||||||||||||
| 1521 | while (uc < e
| 0 | ||||||||||||||||||||||||
| 1522 | switch (*uc) { | - | ||||||||||||||||||||||||
| 1523 | case never executed: QChar::ObjectReplacementCharacter:case QChar::ObjectReplacementCharacter:never executed: case QChar::ObjectReplacementCharacter: | 0 | ||||||||||||||||||||||||
| 1524 | analysis->flags = QScriptAnalysis::Object; | - | ||||||||||||||||||||||||
| 1525 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1526 | case never executed: QChar::LineSeparator:case QChar::LineSeparator:never executed: case QChar::LineSeparator: | 0 | ||||||||||||||||||||||||
| 1527 | if (analysis->bidiLevel % 2
| 0 | ||||||||||||||||||||||||
| 1528 | -- never executed: analysis->bidiLevel;--analysis->bidiLevel;never executed: --analysis->bidiLevel; | 0 | ||||||||||||||||||||||||
| 1529 | analysis->flags = QScriptAnalysis::LineOrParagraphSeparator; | - | ||||||||||||||||||||||||
| 1530 | if (option.flags() & QTextOption::ShowLineAndParagraphSeparators
| 0 | ||||||||||||||||||||||||
| 1531 | const int offset = uc - string; | - | ||||||||||||||||||||||||
| 1532 | layoutData->string.detach(); | - | ||||||||||||||||||||||||
| 1533 | string = reinterpret_cast<const ushort *>(layoutData->string.unicode()); | - | ||||||||||||||||||||||||
| 1534 | uc = string + offset; | - | ||||||||||||||||||||||||
| 1535 | e = uc + length; | - | ||||||||||||||||||||||||
| 1536 | *const_cast<ushort*>(uc) = 0x21B5; | - | ||||||||||||||||||||||||
| 1537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1538 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1539 | case never executed: QChar::Tabulation:case QChar::Tabulation:never executed: case QChar::Tabulation: | 0 | ||||||||||||||||||||||||
| 1540 | analysis->flags = QScriptAnalysis::Tab; | - | ||||||||||||||||||||||||
| 1541 | analysis->bidiLevel = control.baseLevel(); | - | ||||||||||||||||||||||||
| 1542 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1543 | case never executed: QChar::Space:case QChar::Space:never executed: case QChar::Space: | 0 | ||||||||||||||||||||||||
| 1544 | case never executed: QChar::Nbsp:case QChar::Nbsp:never executed: case QChar::Nbsp: | 0 | ||||||||||||||||||||||||
| 1545 | if (option.flags() & QTextOption::ShowTabsAndSpaces
| 0 | ||||||||||||||||||||||||
| 1546 | analysis->flags = QScriptAnalysis::Space; | - | ||||||||||||||||||||||||
| 1547 | analysis->bidiLevel = control.baseLevel(); | - | ||||||||||||||||||||||||
| 1548 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1549 | } | - | ||||||||||||||||||||||||
| 1550 | - | |||||||||||||||||||||||||
| 1551 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 1552 | analysis->flags = QScriptAnalysis::None; | - | ||||||||||||||||||||||||
| 1553 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1554 | } | - | ||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||
| 1556 | - | |||||||||||||||||||||||||
| 1557 | - | |||||||||||||||||||||||||
| 1558 | ++uc; | - | ||||||||||||||||||||||||
| 1559 | ++analysis; | - | ||||||||||||||||||||||||
| 1560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1561 | if (option.flags() & QTextOption::ShowLineAndParagraphSeparators
| 0 | ||||||||||||||||||||||||
| 1562 | (analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; | - | ||||||||||||||||||||||||
| 1563 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||
| 1565 | analysis = scriptAnalysis.data(); | - | ||||||||||||||||||||||||
| 1566 | if (qt_useHarfbuzzNG()
| 0 | ||||||||||||||||||||||||
| 1567 | - | |||||||||||||||||||||||||
| 1568 | for (int i = 0; i < length
| 0 | ||||||||||||||||||||||||
| 1569 | switch (analysis[i].script) { | - | ||||||||||||||||||||||||
| 1570 | case never executed: QChar::Script_Latin:case QChar::Script_Latin:never executed: case QChar::Script_Latin: | 0 | ||||||||||||||||||||||||
| 1571 | case never executed: QChar::Script_Hiragana:case QChar::Script_Hiragana:never executed: case QChar::Script_Hiragana: | 0 | ||||||||||||||||||||||||
| 1572 | case never executed: QChar::Script_Katakana:case QChar::Script_Katakana:never executed: case QChar::Script_Katakana: | 0 | ||||||||||||||||||||||||
| 1573 | case never executed: QChar::Script_Bopomofo:case QChar::Script_Bopomofo:never executed: case QChar::Script_Bopomofo: | 0 | ||||||||||||||||||||||||
| 1574 | case never executed: QChar::Script_Han:case QChar::Script_Han:never executed: case QChar::Script_Han: | 0 | ||||||||||||||||||||||||
| 1575 | analysis[i].script = QChar::Script_Common; | - | ||||||||||||||||||||||||
| 1576 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1577 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1578 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1579 | } | - | ||||||||||||||||||||||||
| 1580 | } | - | ||||||||||||||||||||||||
| 1581 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1582 | for (int i = 0; i < length
| 0 | ||||||||||||||||||||||||
| 1583 | analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script)); never executed: analysis[i].script = hbscript_to_script(script_to_hbscript(analysis[i].script)); | 0 | ||||||||||||||||||||||||
| 1584 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1585 | - | |||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||
| 1587 | Itemizer itemizer(layoutData->string, scriptAnalysis.data(), layoutData->items); | - | ||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||
| 1589 | const QTextDocumentPrivate *p = block.docHandle(); | - | ||||||||||||||||||||||||
| 1590 | if (p
| 0 | ||||||||||||||||||||||||
| 1591 | SpecialData *s = specialData; | - | ||||||||||||||||||||||||
| 1592 | - | |||||||||||||||||||||||||
| 1593 | QTextDocumentPrivate::FragmentIterator it = p->find(block.position()); | - | ||||||||||||||||||||||||
| 1594 | QTextDocumentPrivate::FragmentIterator end = p->find(block.position() + block.length() - 1); | - | ||||||||||||||||||||||||
| 1595 | int format = it.value()->format; | - | ||||||||||||||||||||||||
| 1596 | - | |||||||||||||||||||||||||
| 1597 | int prevPosition = 0; | - | ||||||||||||||||||||||||
| 1598 | int position = prevPosition; | - | ||||||||||||||||||||||||
| 1599 | while (1) { | - | ||||||||||||||||||||||||
| 1600 | const QTextFragmentData * const frag = it.value(); | - | ||||||||||||||||||||||||
| 1601 | if (it == end
| 0 | ||||||||||||||||||||||||
| 1602 | if (s
| 0 | ||||||||||||||||||||||||
| 1603 | position += s->preeditText.length(); | - | ||||||||||||||||||||||||
| 1604 | s = 0; | - | ||||||||||||||||||||||||
| 1605 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1606 | ((!(position <= length)) ? qt_assert("position <= length",__FILE__,1725) : qt_noop()); | - | ||||||||||||||||||||||||
| 1607 | QFont::Capitalization capitalization = | - | ||||||||||||||||||||||||
| 1608 | formatCollection()->charFormat(format).hasProperty(QTextFormat::FontCapitalization)
| 0 | ||||||||||||||||||||||||
| 1609 | ? formatCollection()->charFormat(format).fontCapitalization() | - | ||||||||||||||||||||||||
| 1610 | : formatCollection()->defaultFont().capitalization(); | - | ||||||||||||||||||||||||
| 1611 | itemizer.generate(prevPosition, position - prevPosition, capitalization); | - | ||||||||||||||||||||||||
| 1612 | if (it == end
| 0 | ||||||||||||||||||||||||
| 1613 | if (position < length
| 0 | ||||||||||||||||||||||||
| 1614 | itemizer.generate(position, length - position, capitalization); never executed: itemizer.generate(position, length - position, capitalization); | 0 | ||||||||||||||||||||||||
| 1615 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1616 | } | - | ||||||||||||||||||||||||
| 1617 | format = frag->format; | - | ||||||||||||||||||||||||
| 1618 | prevPosition = position; | - | ||||||||||||||||||||||||
| 1619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1620 | position += frag->size_array[0]; | - | ||||||||||||||||||||||||
| 1621 | ++it; | - | ||||||||||||||||||||||||
| 1622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1623 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1624 | - | |||||||||||||||||||||||||
| 1625 | if (useRawFont
| 0 | ||||||||||||||||||||||||
| 1626 | int lastIndex = 0; | - | ||||||||||||||||||||||||
| 1627 | for (int i = 0; i < specialData->formats.size()
| 0 | ||||||||||||||||||||||||
| 1628 | const QTextLayout::FormatRange &range = specialData->formats.at(i); | - | ||||||||||||||||||||||||
| 1629 | const QTextCharFormat &format = range.format; | - | ||||||||||||||||||||||||
| 1630 | if (format.hasProperty(QTextFormat::FontCapitalization)
| 0 | ||||||||||||||||||||||||
| 1631 | itemizer.generate(lastIndex, range.start - lastIndex, QFont::MixedCase); | - | ||||||||||||||||||||||||
| 1632 | itemizer.generate(range.start, range.length, format.fontCapitalization()); | - | ||||||||||||||||||||||||
| 1633 | lastIndex = range.start + range.length; | - | ||||||||||||||||||||||||
| 1634 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1635 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1636 | itemizer.generate(lastIndex, length - lastIndex, QFont::MixedCase); | - | ||||||||||||||||||||||||
| 1637 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 1638 | - | |||||||||||||||||||||||||
| 1639 | itemizer.generate(0, length, static_cast<QFont::Capitalization> (fnt.d->capital)); never executed: itemizer.generate(0, length, static_cast<QFont::Capitalization> (fnt.d->capital)); | 0 | ||||||||||||||||||||||||
| 1640 | } | - | ||||||||||||||||||||||||
| 1641 | - | |||||||||||||||||||||||||
| 1642 | addRequiredBoundaries(); | - | ||||||||||||||||||||||||
| 1643 | resolveFormats(); | - | ||||||||||||||||||||||||
| 1644 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||
| 1646 | bool QTextEngine::isRightToLeft() const | - | ||||||||||||||||||||||||
| 1647 | { | - | ||||||||||||||||||||||||
| 1648 | switch (option.textDirection()) { | - | ||||||||||||||||||||||||
| 1649 | case never executed: Qt::LeftToRight:case Qt::LeftToRight:never executed: case Qt::LeftToRight: | 0 | ||||||||||||||||||||||||
| 1650 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1651 | case never executed: Qt::RightToLeft:case Qt::RightToLeft:never executed: case Qt::RightToLeft: | 0 | ||||||||||||||||||||||||
| 1652 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1653 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1654 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1655 | } | - | ||||||||||||||||||||||||
| 1656 | if (!layoutData
| 0 | ||||||||||||||||||||||||
| 1657 | itemize(); never executed: itemize(); | 0 | ||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||
| 1659 | if (layoutData->string.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1660 | return never executed: QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;never executed: return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft; | 0 | ||||||||||||||||||||||||
| 1661 | return never executed: layoutData->string.isRightToLeft();return layoutData->string.isRightToLeft();never executed: return layoutData->string.isRightToLeft(); | 0 | ||||||||||||||||||||||||
| 1662 | } | - | ||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||
| 1664 | - | |||||||||||||||||||||||||
| 1665 | int QTextEngine::findItem(int strPos, int firstItem) const | - | ||||||||||||||||||||||||
| 1666 | { | - | ||||||||||||||||||||||||
| 1667 | itemize(); | - | ||||||||||||||||||||||||
| 1668 | if (strPos < 0
| 0 | ||||||||||||||||||||||||
| 1669 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||
| 1671 | int left = firstItem + 1; | - | ||||||||||||||||||||||||
| 1672 | int right = layoutData->items.size()-1; | - | ||||||||||||||||||||||||
| 1673 | while(left <= right
| 0 | ||||||||||||||||||||||||
| 1674 | int middle = ((right-left)/2)+left; | - | ||||||||||||||||||||||||
| 1675 | if (strPos > layoutData->items[middle].position
| 0 | ||||||||||||||||||||||||
| 1676 | left = middle+1; never executed: left = middle+1; | 0 | ||||||||||||||||||||||||
| 1677 | else if(strPos < layoutData->items[middle].position
| 0 | ||||||||||||||||||||||||
| 1678 | right = middle-1; never executed: right = middle-1; | 0 | ||||||||||||||||||||||||
| 1679 | else { | - | ||||||||||||||||||||||||
| 1680 | return never executed: middle;return middle;never executed: return middle; | 0 | ||||||||||||||||||||||||
| 1681 | } | - | ||||||||||||||||||||||||
| 1682 | } | - | ||||||||||||||||||||||||
| 1683 | return never executed: right;return right;never executed: return right; | 0 | ||||||||||||||||||||||||
| 1684 | } | - | ||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||
| 1686 | QFixed QTextEngine::width(int from, int len) const | - | ||||||||||||||||||||||||
| 1687 | { | - | ||||||||||||||||||||||||
| 1688 | itemize(); | - | ||||||||||||||||||||||||
| 1689 | - | |||||||||||||||||||||||||
| 1690 | QFixed w = 0; | - | ||||||||||||||||||||||||
| 1691 | - | |||||||||||||||||||||||||
| 1692 | - | |||||||||||||||||||||||||
| 1693 | for (int i = 0; i < layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 1694 | const QScriptItem *si = layoutData->items.constData() + i; | - | ||||||||||||||||||||||||
| 1695 | int pos = si->position; | - | ||||||||||||||||||||||||
| 1696 | int ilen = length(i); | - | ||||||||||||||||||||||||
| 1697 | - | |||||||||||||||||||||||||
| 1698 | if (pos >= from + len
| 0 | ||||||||||||||||||||||||
| 1699 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1700 | if (pos + ilen > from
| 0 | ||||||||||||||||||||||||
| 1701 | if (!si->num_glyphs
| 0 | ||||||||||||||||||||||||
| 1702 | shape(i); never executed: shape(i); | 0 | ||||||||||||||||||||||||
| 1703 | - | |||||||||||||||||||||||||
| 1704 | if (si->analysis.flags == QScriptAnalysis::Object
| 0 | ||||||||||||||||||||||||
| 1705 | w += si->width; | - | ||||||||||||||||||||||||
| 1706 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1707 | } else if (si->analysis.flags == QScriptAnalysis::Tab
| 0 | ||||||||||||||||||||||||
| 1708 | w += calculateTabWidth(i, w); | - | ||||||||||||||||||||||||
| 1709 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1710 | } | - | ||||||||||||||||||||||||
| 1711 | - | |||||||||||||||||||||||||
| 1712 | - | |||||||||||||||||||||||||
| 1713 | QGlyphLayout glyphs = shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 1714 | unsigned short *logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 1715 | - | |||||||||||||||||||||||||
| 1716 | - | |||||||||||||||||||||||||
| 1717 | - | |||||||||||||||||||||||||
| 1718 | - | |||||||||||||||||||||||||
| 1719 | - | |||||||||||||||||||||||||
| 1720 | - | |||||||||||||||||||||||||
| 1721 | int charFrom = from - pos; | - | ||||||||||||||||||||||||
| 1722 | if (charFrom < 0
| 0 | ||||||||||||||||||||||||
| 1723 | charFrom = 0; never executed: charFrom = 0; | 0 | ||||||||||||||||||||||||
| 1724 | int glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1725 | if (charFrom > 0
| 0 | ||||||||||||||||||||||||
| 1726 | while (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1727 | charFrom++; never executed: charFrom++; | 0 | ||||||||||||||||||||||||
| 1728 | if (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1729 | glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1730 | int charEnd = from + len - 1 - pos; | - | ||||||||||||||||||||||||
| 1731 | if (charEnd >= ilen
| 0 | ||||||||||||||||||||||||
| 1732 | charEnd = ilen-1; never executed: charEnd = ilen-1; | 0 | ||||||||||||||||||||||||
| 1733 | int glyphEnd = logClusters[charEnd]; | - | ||||||||||||||||||||||||
| 1734 | while (charEnd < ilen
| 0 | ||||||||||||||||||||||||
| 1735 | charEnd++; never executed: charEnd++; | 0 | ||||||||||||||||||||||||
| 1736 | glyphEnd = (
| 0 | ||||||||||||||||||||||||
| 1737 | - | |||||||||||||||||||||||||
| 1738 | - | |||||||||||||||||||||||||
| 1739 | for (int i = glyphStart; i < glyphEnd
| 0 | ||||||||||||||||||||||||
| 1740 | w += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; never executed: w += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; | 0 | ||||||||||||||||||||||||
| 1741 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||
| 1745 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||||||||||||||
| 1746 | } | - | ||||||||||||||||||||||||
| 1747 | - | |||||||||||||||||||||||||
| 1748 | glyph_metrics_t QTextEngine::boundingBox(int from, int len) const | - | ||||||||||||||||||||||||
| 1749 | { | - | ||||||||||||||||||||||||
| 1750 | itemize(); | - | ||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||
| 1752 | glyph_metrics_t gm; | - | ||||||||||||||||||||||||
| 1753 | - | |||||||||||||||||||||||||
| 1754 | for (int i = 0; i < layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 1755 | const QScriptItem *si = layoutData->items.constData() + i; | - | ||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||
| 1757 | int pos = si->position; | - | ||||||||||||||||||||||||
| 1758 | int ilen = length(i); | - | ||||||||||||||||||||||||
| 1759 | if (pos > from + len
| 0 | ||||||||||||||||||||||||
| 1760 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1761 | if (pos + ilen > from
| 0 | ||||||||||||||||||||||||
| 1762 | if (!si->num_glyphs
| 0 | ||||||||||||||||||||||||
| 1763 | shape(i); never executed: shape(i); | 0 | ||||||||||||||||||||||||
| 1764 | - | |||||||||||||||||||||||||
| 1765 | if (si->analysis.flags == QScriptAnalysis::Object
| 0 | ||||||||||||||||||||||||
| 1766 | gm.width += si->width; | - | ||||||||||||||||||||||||
| 1767 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1768 | } else if (si->analysis.flags == QScriptAnalysis::Tab
| 0 | ||||||||||||||||||||||||
| 1769 | gm.width += calculateTabWidth(i, gm.width); | - | ||||||||||||||||||||||||
| 1770 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1771 | } | - | ||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||
| 1773 | unsigned short *logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 1774 | QGlyphLayout glyphs = shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||
| 1776 | - | |||||||||||||||||||||||||
| 1777 | int charFrom = from - pos; | - | ||||||||||||||||||||||||
| 1778 | if (charFrom < 0
| 0 | ||||||||||||||||||||||||
| 1779 | charFrom = 0; never executed: charFrom = 0; | 0 | ||||||||||||||||||||||||
| 1780 | int glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1781 | if (charFrom > 0
| 0 | ||||||||||||||||||||||||
| 1782 | while (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1783 | charFrom++; never executed: charFrom++; | 0 | ||||||||||||||||||||||||
| 1784 | if (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1785 | QFontEngine *fe = fontEngine(*si); | - | ||||||||||||||||||||||||
| 1786 | glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1787 | int charEnd = from + len - 1 - pos; | - | ||||||||||||||||||||||||
| 1788 | if (charEnd >= ilen
| 0 | ||||||||||||||||||||||||
| 1789 | charEnd = ilen-1; never executed: charEnd = ilen-1; | 0 | ||||||||||||||||||||||||
| 1790 | int glyphEnd = logClusters[charEnd]; | - | ||||||||||||||||||||||||
| 1791 | while (charEnd < ilen
| 0 | ||||||||||||||||||||||||
| 1792 | charEnd++; never executed: charEnd++; | 0 | ||||||||||||||||||||||||
| 1793 | glyphEnd = (
| 0 | ||||||||||||||||||||||||
| 1794 | if (glyphStart <= glyphEnd
| 0 | ||||||||||||||||||||||||
| 1795 | glyph_metrics_t m = fe->boundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart)); | - | ||||||||||||||||||||||||
| 1796 | gm.x = qMin(gm.x, m.x + gm.xoff); | - | ||||||||||||||||||||||||
| 1797 | gm.y = qMin(gm.y, m.y + gm.yoff); | - | ||||||||||||||||||||||||
| 1798 | gm.width = qMax(gm.width, m.width+gm.xoff); | - | ||||||||||||||||||||||||
| 1799 | gm.height = qMax(gm.height, m.height+gm.yoff); | - | ||||||||||||||||||||||||
| 1800 | gm.xoff += m.xoff; | - | ||||||||||||||||||||||||
| 1801 | gm.yoff += m.yoff; | - | ||||||||||||||||||||||||
| 1802 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1803 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1804 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1805 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1806 | return never executed: gm;return gm;never executed: return gm; | 0 | ||||||||||||||||||||||||
| 1807 | } | - | ||||||||||||||||||||||||
| 1808 | - | |||||||||||||||||||||||||
| 1809 | glyph_metrics_t QTextEngine::tightBoundingBox(int from, int len) const | - | ||||||||||||||||||||||||
| 1810 | { | - | ||||||||||||||||||||||||
| 1811 | itemize(); | - | ||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||
| 1813 | glyph_metrics_t gm; | - | ||||||||||||||||||||||||
| 1814 | - | |||||||||||||||||||||||||
| 1815 | for (int i = 0; i < layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 1816 | const QScriptItem *si = layoutData->items.constData() + i; | - | ||||||||||||||||||||||||
| 1817 | int pos = si->position; | - | ||||||||||||||||||||||||
| 1818 | int ilen = length(i); | - | ||||||||||||||||||||||||
| 1819 | if (pos > from + len
| 0 | ||||||||||||||||||||||||
| 1820 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1821 | if (pos + len > from
| 0 | ||||||||||||||||||||||||
| 1822 | if (!si->num_glyphs
| 0 | ||||||||||||||||||||||||
| 1823 | shape(i); never executed: shape(i); | 0 | ||||||||||||||||||||||||
| 1824 | unsigned short *logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 1825 | QGlyphLayout glyphs = shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 1826 | - | |||||||||||||||||||||||||
| 1827 | - | |||||||||||||||||||||||||
| 1828 | int charFrom = from - pos; | - | ||||||||||||||||||||||||
| 1829 | if (charFrom < 0
| 0 | ||||||||||||||||||||||||
| 1830 | charFrom = 0; never executed: charFrom = 0; | 0 | ||||||||||||||||||||||||
| 1831 | int glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1832 | if (charFrom > 0
| 0 | ||||||||||||||||||||||||
| 1833 | while (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1834 | charFrom++; never executed: charFrom++; | 0 | ||||||||||||||||||||||||
| 1835 | if (charFrom < ilen
| 0 | ||||||||||||||||||||||||
| 1836 | glyphStart = logClusters[charFrom]; | - | ||||||||||||||||||||||||
| 1837 | int charEnd = from + len - 1 - pos; | - | ||||||||||||||||||||||||
| 1838 | if (charEnd >= ilen
| 0 | ||||||||||||||||||||||||
| 1839 | charEnd = ilen-1; never executed: charEnd = ilen-1; | 0 | ||||||||||||||||||||||||
| 1840 | int glyphEnd = logClusters[charEnd]; | - | ||||||||||||||||||||||||
| 1841 | while (charEnd < ilen
| 0 | ||||||||||||||||||||||||
| 1842 | charEnd++; never executed: charEnd++; | 0 | ||||||||||||||||||||||||
| 1843 | glyphEnd = (
| 0 | ||||||||||||||||||||||||
| 1844 | if (glyphStart <= glyphEnd
| 0 | ||||||||||||||||||||||||
| 1845 | QFontEngine *fe = fontEngine(*si); | - | ||||||||||||||||||||||||
| 1846 | glyph_metrics_t m = fe->tightBoundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart)); | - | ||||||||||||||||||||||||
| 1847 | gm.x = qMin(gm.x, m.x + gm.xoff); | - | ||||||||||||||||||||||||
| 1848 | gm.y = qMin(gm.y, m.y + gm.yoff); | - | ||||||||||||||||||||||||
| 1849 | gm.width = qMax(gm.width, m.width+gm.xoff); | - | ||||||||||||||||||||||||
| 1850 | gm.height = qMax(gm.height, m.height+gm.yoff); | - | ||||||||||||||||||||||||
| 1851 | gm.xoff += m.xoff; | - | ||||||||||||||||||||||||
| 1852 | gm.yoff += m.yoff; | - | ||||||||||||||||||||||||
| 1853 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1854 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1856 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1857 | return never executed: gm;return gm;never executed: return gm; | 0 | ||||||||||||||||||||||||
| 1858 | } | - | ||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||
| 1860 | QFont QTextEngine::font(const QScriptItem &si) const | - | ||||||||||||||||||||||||
| 1861 | { | - | ||||||||||||||||||||||||
| 1862 | QFont font = fnt; | - | ||||||||||||||||||||||||
| 1863 | if (hasFormats()
| 0 | ||||||||||||||||||||||||
| 1864 | QTextCharFormat f = format(&si); | - | ||||||||||||||||||||||||
| 1865 | font = f.font(); | - | ||||||||||||||||||||||||
| 1866 | - | |||||||||||||||||||||||||
| 1867 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 1868 | - | |||||||||||||||||||||||||
| 1869 | QPaintDevice *pdev = block.docHandle()->layout()->paintDevice(); | - | ||||||||||||||||||||||||
| 1870 | if (pdev
| 0 | ||||||||||||||||||||||||
| 1871 | font = QFont(font, pdev); never executed: font = QFont(font, pdev); | 0 | ||||||||||||||||||||||||
| 1872 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1873 | font = font.resolve(fnt); | - | ||||||||||||||||||||||||
| 1874 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1875 | QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); | - | ||||||||||||||||||||||||
| 1876 | if (valign == QTextCharFormat::AlignSuperScript
| 0 | ||||||||||||||||||||||||
| 1877 | if (font.pointSize() != -1
| 0 | ||||||||||||||||||||||||
| 1878 | font.setPointSize((font.pointSize() * 2) / 3); never executed: font.setPointSize((font.pointSize() * 2) / 3); | 0 | ||||||||||||||||||||||||
| 1879 | else | - | ||||||||||||||||||||||||
| 1880 | font.setPixelSize((font.pixelSize() * 2) / 3); never executed: font.setPixelSize((font.pixelSize() * 2) / 3); | 0 | ||||||||||||||||||||||||
| 1881 | } | - | ||||||||||||||||||||||||
| 1882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||
| 1884 | if (si.analysis.flags == QScriptAnalysis::SmallCaps
| 0 | ||||||||||||||||||||||||
| 1885 | font = font.d->smallCapsFont(); never executed: font = font.d->smallCapsFont(); | 0 | ||||||||||||||||||||||||
| 1886 | - | |||||||||||||||||||||||||
| 1887 | return never executed: font;return font;never executed: return font; | 0 | ||||||||||||||||||||||||
| 1888 | } | - | ||||||||||||||||||||||||
| 1889 | - | |||||||||||||||||||||||||
| 1890 | QTextEngine::FontEngineCache::FontEngineCache() | - | ||||||||||||||||||||||||
| 1891 | { | - | ||||||||||||||||||||||||
| 1892 | reset(); | - | ||||||||||||||||||||||||
| 1893 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1894 | - | |||||||||||||||||||||||||
| 1895 | - | |||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||
| 1897 | QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const | - | ||||||||||||||||||||||||
| 1898 | { | - | ||||||||||||||||||||||||
| 1899 | QFontEngine *engine = 0; | - | ||||||||||||||||||||||||
| 1900 | QFontEngine *scaledEngine = 0; | - | ||||||||||||||||||||||||
| 1901 | int script = si.analysis.script; | - | ||||||||||||||||||||||||
| 1902 | - | |||||||||||||||||||||||||
| 1903 | QFont font = fnt; | - | ||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||
| 1905 | if (useRawFont
| 0 | ||||||||||||||||||||||||
| 1906 | if (feCache.prevFontEngine
| 0 | ||||||||||||||||||||||||
| 1907 | engine = feCache.prevFontEngine; | - | ||||||||||||||||||||||||
| 1908 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1909 | engine = QFontEngineMulti::createMultiFontEngine(rawFont.d->fontEngine, script); | - | ||||||||||||||||||||||||
| 1910 | feCache.prevFontEngine = engine; | - | ||||||||||||||||||||||||
| 1911 | feCache.prevScript = script; | - | ||||||||||||||||||||||||
| 1912 | engine->ref.ref(); | - | ||||||||||||||||||||||||
| 1913 | if (feCache.prevScaledFontEngine
| 0 | ||||||||||||||||||||||||
| 1914 | releaseCachedFontEngine(feCache.prevScaledFontEngine); | - | ||||||||||||||||||||||||
| 1915 | feCache.prevScaledFontEngine = 0; | - | ||||||||||||||||||||||||
| 1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1917 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1918 | if (si.analysis.flags == QScriptAnalysis::SmallCaps
| 0 | ||||||||||||||||||||||||
| 1919 | if (feCache.prevScaledFontEngine
| 0 | ||||||||||||||||||||||||
| 1920 | scaledEngine = feCache.prevScaledFontEngine; | - | ||||||||||||||||||||||||
| 1921 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1922 | QFontEngine *scEngine = rawFont.d->fontEngine->cloneWithSize(smallCapsFraction * rawFont.pixelSize()); | - | ||||||||||||||||||||||||
| 1923 | scEngine->ref.ref(); | - | ||||||||||||||||||||||||
| 1924 | scaledEngine = QFontEngineMulti::createMultiFontEngine(scEngine, script); | - | ||||||||||||||||||||||||
| 1925 | scaledEngine->ref.ref(); | - | ||||||||||||||||||||||||
| 1926 | feCache.prevScaledFontEngine = scaledEngine; | - | ||||||||||||||||||||||||
| 1927 | - | |||||||||||||||||||||||||
| 1928 | if (!scEngine->ref.deref()
| 0 | ||||||||||||||||||||||||
| 1929 | delete scEngine; never executed: delete scEngine; | 0 | ||||||||||||||||||||||||
| 1930 | - | |||||||||||||||||||||||||
| 1931 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1932 | } | - | ||||||||||||||||||||||||
| 1933 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 1934 | - | |||||||||||||||||||||||||
| 1935 | { | - | ||||||||||||||||||||||||
| 1936 | if (hasFormats()
| 0 | ||||||||||||||||||||||||
| 1937 | if (feCache.prevFontEngine
| 0 | ||||||||||||||||||||||||
| 1938 | engine = feCache.prevFontEngine; | - | ||||||||||||||||||||||||
| 1939 | scaledEngine = feCache.prevScaledFontEngine; | - | ||||||||||||||||||||||||
| 1940 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1941 | QTextCharFormat f = format(&si); | - | ||||||||||||||||||||||||
| 1942 | font = f.font(); | - | ||||||||||||||||||||||||
| 1943 | - | |||||||||||||||||||||||||
| 1944 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 1945 | - | |||||||||||||||||||||||||
| 1946 | QPaintDevice *pdev = block.docHandle()->layout()->paintDevice(); | - | ||||||||||||||||||||||||
| 1947 | if (pdev
| 0 | ||||||||||||||||||||||||
| 1948 | font = QFont(font, pdev); never executed: font = QFont(font, pdev); | 0 | ||||||||||||||||||||||||
| 1949 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1950 | font = font.resolve(fnt); | - | ||||||||||||||||||||||||
| 1951 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1952 | engine = font.d->engineForScript(script); | - | ||||||||||||||||||||||||
| 1953 | if (engine
| 0 | ||||||||||||||||||||||||
| 1954 | engine->ref.ref(); never executed: engine->ref.ref(); | 0 | ||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||
| 1956 | QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); | - | ||||||||||||||||||||||||
| 1957 | if (valign == QTextCharFormat::AlignSuperScript
| 0 | ||||||||||||||||||||||||
| 1958 | if (font.pointSize() != -1
| 0 | ||||||||||||||||||||||||
| 1959 | font.setPointSize((font.pointSize() * 2) / 3); never executed: font.setPointSize((font.pointSize() * 2) / 3); | 0 | ||||||||||||||||||||||||
| 1960 | else | - | ||||||||||||||||||||||||
| 1961 | font.setPixelSize((font.pixelSize() * 2) / 3); never executed: font.setPixelSize((font.pixelSize() * 2) / 3); | 0 | ||||||||||||||||||||||||
| 1962 | scaledEngine = font.d->engineForScript(script); | - | ||||||||||||||||||||||||
| 1963 | if (scaledEngine
| 0 | ||||||||||||||||||||||||
| 1964 | scaledEngine->ref.ref(); never executed: scaledEngine->ref.ref(); | 0 | ||||||||||||||||||||||||
| 1965 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||
| 1967 | if (feCache.prevFontEngine
| 0 | ||||||||||||||||||||||||
| 1968 | releaseCachedFontEngine(feCache.prevFontEngine); never executed: releaseCachedFontEngine(feCache.prevFontEngine); | 0 | ||||||||||||||||||||||||
| 1969 | feCache.prevFontEngine = engine; | - | ||||||||||||||||||||||||
| 1970 | - | |||||||||||||||||||||||||
| 1971 | if (feCache.prevScaledFontEngine
| 0 | ||||||||||||||||||||||||
| 1972 | releaseCachedFontEngine(feCache.prevScaledFontEngine); never executed: releaseCachedFontEngine(feCache.prevScaledFontEngine); | 0 | ||||||||||||||||||||||||
| 1973 | feCache.prevScaledFontEngine = scaledEngine; | - | ||||||||||||||||||||||||
| 1974 | - | |||||||||||||||||||||||||
| 1975 | feCache.prevScript = script; | - | ||||||||||||||||||||||||
| 1976 | feCache.prevPosition = si.position; | - | ||||||||||||||||||||||||
| 1977 | feCache.prevLength = length(&si); | - | ||||||||||||||||||||||||
| 1978 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1979 | } else { | - | ||||||||||||||||||||||||
| 1980 | if (feCache.prevFontEngine
| 0 | ||||||||||||||||||||||||
| 1981 | engine = feCache.prevFontEngine; never executed: engine = feCache.prevFontEngine; | 0 | ||||||||||||||||||||||||
| 1982 | else { | - | ||||||||||||||||||||||||
| 1983 | engine = font.d->engineForScript(script); | - | ||||||||||||||||||||||||
| 1984 | - | |||||||||||||||||||||||||
| 1985 | if (engine
| 0 | ||||||||||||||||||||||||
| 1986 | engine->ref.ref(); never executed: engine->ref.ref(); | 0 | ||||||||||||||||||||||||
| 1987 | if (feCache.prevFontEngine
| 0 | ||||||||||||||||||||||||
| 1988 | releaseCachedFontEngine(feCache.prevFontEngine); never executed: releaseCachedFontEngine(feCache.prevFontEngine); | 0 | ||||||||||||||||||||||||
| 1989 | feCache.prevFontEngine = engine; | - | ||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||
| 1991 | feCache.prevScript = script; | - | ||||||||||||||||||||||||
| 1992 | feCache.prevPosition = -1; | - | ||||||||||||||||||||||||
| 1993 | feCache.prevLength = -1; | - | ||||||||||||||||||||||||
| 1994 | feCache.prevScaledFontEngine = 0; | - | ||||||||||||||||||||||||
| 1995 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1996 | } | - | ||||||||||||||||||||||||
| 1997 | - | |||||||||||||||||||||||||
| 1998 | if (si.analysis.flags == QScriptAnalysis::SmallCaps
| 0 | ||||||||||||||||||||||||
| 1999 | QFontPrivate *p = font.d->smallCapsFontPrivate(); | - | ||||||||||||||||||||||||
| 2000 | scaledEngine = p->engineForScript(script); | - | ||||||||||||||||||||||||
| 2001 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2002 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2003 | - | |||||||||||||||||||||||||
| 2004 | if (ascent
| 0 | ||||||||||||||||||||||||
| 2005 | *ascent = engine->ascent(); | - | ||||||||||||||||||||||||
| 2006 | *descent = engine->descent(); | - | ||||||||||||||||||||||||
| 2007 | *leading = engine->leading(); | - | ||||||||||||||||||||||||
| 2008 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2009 | - | |||||||||||||||||||||||||
| 2010 | if (scaledEngine
| 0 | ||||||||||||||||||||||||
| 2011 | return never executed: scaledEngine;return scaledEngine;never executed: return scaledEngine; | 0 | ||||||||||||||||||||||||
| 2012 | return never executed: engine;return engine;never executed: return engine; | 0 | ||||||||||||||||||||||||
| 2013 | } | - | ||||||||||||||||||||||||
| 2014 | - | |||||||||||||||||||||||||
| 2015 | struct QJustificationPoint { | - | ||||||||||||||||||||||||
| 2016 | int type; | - | ||||||||||||||||||||||||
| 2017 | QFixed kashidaWidth; | - | ||||||||||||||||||||||||
| 2018 | QGlyphLayout glyph; | - | ||||||||||||||||||||||||
| 2019 | }; | - | ||||||||||||||||||||||||
| 2020 | - | |||||||||||||||||||||||||
| 2021 | template<> class QTypeInfo<QJustificationPoint > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QJustificationPoint)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QJustificationPoint >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QJustificationPoint) }; static inline const char *name() { return "QJustificationPoint"; } }; | - | ||||||||||||||||||||||||
| 2022 | - | |||||||||||||||||||||||||
| 2023 | static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe) | - | ||||||||||||||||||||||||
| 2024 | { | - | ||||||||||||||||||||||||
| 2025 | point->type = type; | - | ||||||||||||||||||||||||
| 2026 | point->glyph = glyph; | - | ||||||||||||||||||||||||
| 2027 | - | |||||||||||||||||||||||||
| 2028 | if (type >= Justification_Arabic_Normal
| 0 | ||||||||||||||||||||||||
| 2029 | QChar ch(0x640); | - | ||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | glyph_t kashidaGlyph = fe->glyphIndex(ch.unicode()); | - | ||||||||||||||||||||||||
| 2032 | if (kashidaGlyph != 0
| 0 | ||||||||||||||||||||||||
| 2033 | QGlyphLayout g; | - | ||||||||||||||||||||||||
| 2034 | g.numGlyphs = 1; | - | ||||||||||||||||||||||||
| 2035 | g.glyphs = &kashidaGlyph; | - | ||||||||||||||||||||||||
| 2036 | g.advances = &point->kashidaWidth; | - | ||||||||||||||||||||||||
| 2037 | fe->recalcAdvances(&g, 0); | - | ||||||||||||||||||||||||
| 2038 | - | |||||||||||||||||||||||||
| 2039 | if (point->kashidaWidth == 0
| 0 | ||||||||||||||||||||||||
| 2040 | point->type = Justification_Prohibited; never executed: point->type = Justification_Prohibited; | 0 | ||||||||||||||||||||||||
| 2041 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2042 | point->type = Justification_Prohibited; | - | ||||||||||||||||||||||||
| 2043 | point->kashidaWidth = 0; | - | ||||||||||||||||||||||||
| 2044 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2045 | } | - | ||||||||||||||||||||||||
| 2046 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2047 | - | |||||||||||||||||||||||||
| 2048 | - | |||||||||||||||||||||||||
| 2049 | void QTextEngine::justify(const QScriptLine &line) | - | ||||||||||||||||||||||||
| 2050 | { | - | ||||||||||||||||||||||||
| 2051 | - | |||||||||||||||||||||||||
| 2052 | if (line.gridfitted
| 0 | ||||||||||||||||||||||||
| 2053 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||
| 2055 | if (!line.gridfitted
| 0 | ||||||||||||||||||||||||
| 2056 | - | |||||||||||||||||||||||||
| 2057 | const_cast<QScriptLine &>(line).gridfitted = true; | - | ||||||||||||||||||||||||
| 2058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2059 | - | |||||||||||||||||||||||||
| 2060 | if ((
| 0 | ||||||||||||||||||||||||
| 2061 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||
| 2063 | itemize(); | - | ||||||||||||||||||||||||
| 2064 | - | |||||||||||||||||||||||||
| 2065 | if (!forceJustification
| 0 | ||||||||||||||||||||||||
| 2066 | int end = line.from + (int)line.length + line.trailingSpaces; | - | ||||||||||||||||||||||||
| 2067 | if (end == layoutData->string.length()
| 0 | ||||||||||||||||||||||||
| 2068 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2069 | if (end
| 0 | ||||||||||||||||||||||||
| 2070 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2071 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2072 | - | |||||||||||||||||||||||||
| 2073 | - | |||||||||||||||||||||||||
| 2074 | int maxJustify = 0; | - | ||||||||||||||||||||||||
| 2075 | - | |||||||||||||||||||||||||
| 2076 | - | |||||||||||||||||||||||||
| 2077 | int line_length = line.length; | - | ||||||||||||||||||||||||
| 2078 | const QCharAttributes *a = attributes(); | - | ||||||||||||||||||||||||
| 2079 | if (! a
| 0 | ||||||||||||||||||||||||
| 2080 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2081 | a += line.from; | - | ||||||||||||||||||||||||
| 2082 | while (line_length
| 0 | ||||||||||||||||||||||||
| 2083 | -- never executed: line_length;--line_length;never executed: --line_length; | 0 | ||||||||||||||||||||||||
| 2084 | - | |||||||||||||||||||||||||
| 2085 | --line_length; | - | ||||||||||||||||||||||||
| 2086 | - | |||||||||||||||||||||||||
| 2087 | if (line_length <= 0
| 0 | ||||||||||||||||||||||||
| 2088 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2089 | - | |||||||||||||||||||||||||
| 2090 | int firstItem = findItem(line.from); | - | ||||||||||||||||||||||||
| 2091 | int lastItem = findItem(line.from + line_length - 1, firstItem); | - | ||||||||||||||||||||||||
| 2092 | int nItems = (firstItem >= 0
| 0 | ||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||
| 2094 | QVarLengthArray<QJustificationPoint> justificationPoints; | - | ||||||||||||||||||||||||
| 2095 | int nPoints = 0; | - | ||||||||||||||||||||||||
| 2096 | - | |||||||||||||||||||||||||
| 2097 | QFixed minKashida = 0x100000; | - | ||||||||||||||||||||||||
| 2098 | - | |||||||||||||||||||||||||
| 2099 | - | |||||||||||||||||||||||||
| 2100 | - | |||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||
| 2102 | for (int i = 0; i < nItems
| 0 | ||||||||||||||||||||||||
| 2103 | QScriptItem &si = layoutData->items[firstItem + i]; | - | ||||||||||||||||||||||||
| 2104 | if (!si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 2105 | shape(firstItem + i); never executed: shape(firstItem + i); | 0 | ||||||||||||||||||||||||
| 2106 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | for (int i = 0; i < nItems
| 0 | ||||||||||||||||||||||||
| 2109 | QScriptItem &si = layoutData->items[firstItem + i]; | - | ||||||||||||||||||||||||
| 2110 | - | |||||||||||||||||||||||||
| 2111 | int kashida_type = Justification_Arabic_Normal; | - | ||||||||||||||||||||||||
| 2112 | int kashida_pos = -1; | - | ||||||||||||||||||||||||
| 2113 | - | |||||||||||||||||||||||||
| 2114 | int start = qMax(line.from - si.position, 0); | - | ||||||||||||||||||||||||
| 2115 | int end = qMin(line.from + line_length - (int)si.position, length(firstItem+i)); | - | ||||||||||||||||||||||||
| 2116 | - | |||||||||||||||||||||||||
| 2117 | unsigned short *log_clusters = logClusters(&si); | - | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | int gs = log_clusters[start]; | - | ||||||||||||||||||||||||
| 2120 | int ge = (end == length(firstItem+i)
| 0 | ||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | ((!(ge <= si.num_glyphs)) ? qt_assert("ge <= si.num_glyphs",__FILE__,2241) : qt_noop()); | - | ||||||||||||||||||||||||
| 2123 | - | |||||||||||||||||||||||||
| 2124 | const QGlyphLayout g = shapedGlyphs(&si); | - | ||||||||||||||||||||||||
| 2125 | - | |||||||||||||||||||||||||
| 2126 | for (int i = gs; i < ge
| 0 | ||||||||||||||||||||||||
| 2127 | g.justifications[i].type = QGlyphJustification::JustifyNone; | - | ||||||||||||||||||||||||
| 2128 | g.justifications[i].nKashidas = 0; | - | ||||||||||||||||||||||||
| 2129 | g.justifications[i].space_18d6 = 0; | - | ||||||||||||||||||||||||
| 2130 | - | |||||||||||||||||||||||||
| 2131 | justificationPoints.resize(nPoints+3); | - | ||||||||||||||||||||||||
| 2132 | int justification = g.attributes[i].justification; | - | ||||||||||||||||||||||||
| 2133 | - | |||||||||||||||||||||||||
| 2134 | switch(justification) { | - | ||||||||||||||||||||||||
| 2135 | case never executed: Justification_Prohibited:case Justification_Prohibited:never executed: case Justification_Prohibited: | 0 | ||||||||||||||||||||||||
| 2136 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2137 | case never executed: Justification_Space:case Justification_Space:never executed: case Justification_Space: | 0 | ||||||||||||||||||||||||
| 2138 | - | |||||||||||||||||||||||||
| 2139 | case never executed: Justification_Arabic_Space:case Justification_Arabic_Space:never executed: case Justification_Arabic_Space: | 0 | ||||||||||||||||||||||||
| 2140 | if (kashida_pos >= 0
| 0 | ||||||||||||||||||||||||
| 2141 | - | |||||||||||||||||||||||||
| 2142 | set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si)); | - | ||||||||||||||||||||||||
| 2143 | if (justificationPoints[nPoints].kashidaWidth > 0
| 0 | ||||||||||||||||||||||||
| 2144 | minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); | - | ||||||||||||||||||||||||
| 2145 | maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); | - | ||||||||||||||||||||||||
| 2146 | ++nPoints; | - | ||||||||||||||||||||||||
| 2147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2149 | kashida_pos = -1; | - | ||||||||||||||||||||||||
| 2150 | kashida_type = Justification_Arabic_Normal; | - | ||||||||||||||||||||||||
| 2151 | - | |||||||||||||||||||||||||
| 2152 | case never executed: Justification_Character:case Justification_Character:never executed: case Justification_Character:code before this statement never executed: case Justification_Character: | 0 | ||||||||||||||||||||||||
| 2153 | set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si)); | - | ||||||||||||||||||||||||
| 2154 | maxJustify = qMax(maxJustify, justification); | - | ||||||||||||||||||||||||
| 2155 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2156 | case never executed: Justification_Arabic_Normal:case Justification_Arabic_Normal:never executed: case Justification_Arabic_Normal: | 0 | ||||||||||||||||||||||||
| 2157 | case never executed: Justification_Arabic_Waw:case Justification_Arabic_Waw:never executed: case Justification_Arabic_Waw: | 0 | ||||||||||||||||||||||||
| 2158 | case never executed: Justification_Arabic_BaRa:case Justification_Arabic_BaRa:never executed: case Justification_Arabic_BaRa: | 0 | ||||||||||||||||||||||||
| 2159 | case never executed: Justification_Arabic_Alef:case Justification_Arabic_Alef:never executed: case Justification_Arabic_Alef: | 0 | ||||||||||||||||||||||||
| 2160 | case never executed: Justification_Arabic_HahDal:case Justification_Arabic_HahDal:never executed: case Justification_Arabic_HahDal: | 0 | ||||||||||||||||||||||||
| 2161 | case never executed: Justification_Arabic_Seen:case Justification_Arabic_Seen:never executed: case Justification_Arabic_Seen: | 0 | ||||||||||||||||||||||||
| 2162 | case never executed: Justification_Arabic_Kashida:case Justification_Arabic_Kashida:never executed: case Justification_Arabic_Kashida: | 0 | ||||||||||||||||||||||||
| 2163 | if (justification >= kashida_type
| 0 | ||||||||||||||||||||||||
| 2164 | kashida_pos = i; | - | ||||||||||||||||||||||||
| 2165 | kashida_type = justification; | - | ||||||||||||||||||||||||
| 2166 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2167 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2168 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2169 | if (kashida_pos >= 0
| 0 | ||||||||||||||||||||||||
| 2170 | set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si)); | - | ||||||||||||||||||||||||
| 2171 | if (justificationPoints[nPoints].kashidaWidth > 0
| 0 | ||||||||||||||||||||||||
| 2172 | minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); | - | ||||||||||||||||||||||||
| 2173 | maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); | - | ||||||||||||||||||||||||
| 2174 | ++nPoints; | - | ||||||||||||||||||||||||
| 2175 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2178 | - | |||||||||||||||||||||||||
| 2179 | QFixed leading = leadingSpaceWidth(line); | - | ||||||||||||||||||||||||
| 2180 | QFixed need = line.width - line.textWidth - leading; | - | ||||||||||||||||||||||||
| 2181 | if (need < 0
| 0 | ||||||||||||||||||||||||
| 2182 | - | |||||||||||||||||||||||||
| 2183 | const_cast<QScriptLine &>(line).justified = true; | - | ||||||||||||||||||||||||
| 2184 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2185 | } | - | ||||||||||||||||||||||||
| 2186 | - | |||||||||||||||||||||||||
| 2187 | - | |||||||||||||||||||||||||
| 2188 | - | |||||||||||||||||||||||||
| 2189 | - | |||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||
| 2191 | if (maxJustify >= Justification_Arabic_Normal
| 0 | ||||||||||||||||||||||||
| 2192 | while (need >= minKashida
| 0 | ||||||||||||||||||||||||
| 2193 | for (int type = maxJustify; need >= minKashida
| 0 | ||||||||||||||||||||||||
| 2194 | for (int i = 0; need >= minKashida
| 0 | ||||||||||||||||||||||||
| 2195 | if (justificationPoints[i].type == type
| 0 | ||||||||||||||||||||||||
| 2196 | justificationPoints[i].glyph.justifications->nKashidas++; | - | ||||||||||||||||||||||||
| 2197 | - | |||||||||||||||||||||||||
| 2198 | justificationPoints[i].glyph.justifications->space_18d6 += justificationPoints[i].kashidaWidth.value(); | - | ||||||||||||||||||||||||
| 2199 | need -= justificationPoints[i].kashidaWidth; | - | ||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||
| 2201 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2202 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2204 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2206 | ((!(need >= 0)) ? qt_assert("need >= 0",__FILE__,2325) : qt_noop()); | - | ||||||||||||||||||||||||
| 2207 | if (!need
| 0 | ||||||||||||||||||||||||
| 2208 | goto never executed: end;goto end;never executed: goto end; | 0 | ||||||||||||||||||||||||
| 2209 | - | |||||||||||||||||||||||||
| 2210 | maxJustify = qMin(maxJustify, int(Justification_Space)); | - | ||||||||||||||||||||||||
| 2211 | for (int type = maxJustify; need != 0
| 0 | ||||||||||||||||||||||||
| 2212 | int n = 0; | - | ||||||||||||||||||||||||
| 2213 | for (int i = 0; i < nPoints
| 0 | ||||||||||||||||||||||||
| 2214 | if (justificationPoints[i].type == type
| 0 | ||||||||||||||||||||||||
| 2215 | ++ never executed: n;++n;never executed: ++n; | 0 | ||||||||||||||||||||||||
| 2216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2217 | - | |||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||
| 2219 | - | |||||||||||||||||||||||||
| 2220 | if (!n
| 0 | ||||||||||||||||||||||||
| 2221 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2222 | - | |||||||||||||||||||||||||
| 2223 | for (int i = 0; i < nPoints
| 0 | ||||||||||||||||||||||||
| 2224 | if (justificationPoints[i].type == type
| 0 | ||||||||||||||||||||||||
| 2225 | QFixed add = need/n; | - | ||||||||||||||||||||||||
| 2226 | - | |||||||||||||||||||||||||
| 2227 | justificationPoints[i].glyph.justifications[0].space_18d6 = add.value(); | - | ||||||||||||||||||||||||
| 2228 | need -= add; | - | ||||||||||||||||||||||||
| 2229 | --n; | - | ||||||||||||||||||||||||
| 2230 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2231 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2232 | - | |||||||||||||||||||||||||
| 2233 | ((!(!need)) ? qt_assert("!need",__FILE__,2352) : qt_noop()); | - | ||||||||||||||||||||||||
| 2234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2235 | end: code before this statement never executed: end: | 0 | ||||||||||||||||||||||||
| 2236 | const_cast<QScriptLine &>(line).justified = true; | - | ||||||||||||||||||||||||
| 2237 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2238 | - | |||||||||||||||||||||||||
| 2239 | void QScriptLine::setDefaultHeight(QTextEngine *eng) | - | ||||||||||||||||||||||||
| 2240 | { | - | ||||||||||||||||||||||||
| 2241 | QFont f; | - | ||||||||||||||||||||||||
| 2242 | QFontEngine *e; | - | ||||||||||||||||||||||||
| 2243 | - | |||||||||||||||||||||||||
| 2244 | if (eng->block.docHandle()
| 0 | ||||||||||||||||||||||||
| 2245 | f = eng->block.charFormat().font(); | - | ||||||||||||||||||||||||
| 2246 | - | |||||||||||||||||||||||||
| 2247 | QPaintDevice *pdev = eng->block.docHandle()->layout()->paintDevice(); | - | ||||||||||||||||||||||||
| 2248 | if (pdev
| 0 | ||||||||||||||||||||||||
| 2249 | f = QFont(f, pdev); never executed: f = QFont(f, pdev); | 0 | ||||||||||||||||||||||||
| 2250 | e = f.d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2251 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2252 | e = eng->fnt.d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2253 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2254 | - | |||||||||||||||||||||||||
| 2255 | QFixed other_ascent = e->ascent(); | - | ||||||||||||||||||||||||
| 2256 | QFixed other_descent = e->descent(); | - | ||||||||||||||||||||||||
| 2257 | QFixed other_leading = e->leading(); | - | ||||||||||||||||||||||||
| 2258 | leading = qMax(leading + ascent, other_leading + other_ascent) - qMax(ascent, other_ascent); | - | ||||||||||||||||||||||||
| 2259 | ascent = qMax(ascent, other_ascent); | - | ||||||||||||||||||||||||
| 2260 | descent = qMax(descent, other_descent); | - | ||||||||||||||||||||||||
| 2261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2262 | - | |||||||||||||||||||||||||
| 2263 | QTextEngine::LayoutData::LayoutData() | - | ||||||||||||||||||||||||
| 2264 | { | - | ||||||||||||||||||||||||
| 2265 | memory = 0; | - | ||||||||||||||||||||||||
| 2266 | allocated = 0; | - | ||||||||||||||||||||||||
| 2267 | memory_on_stack = false; | - | ||||||||||||||||||||||||
| 2268 | used = 0; | - | ||||||||||||||||||||||||
| 2269 | hasBidi = false; | - | ||||||||||||||||||||||||
| 2270 | layoutState = LayoutEmpty; | - | ||||||||||||||||||||||||
| 2271 | haveCharAttributes = false; | - | ||||||||||||||||||||||||
| 2272 | logClustersPtr = 0; | - | ||||||||||||||||||||||||
| 2273 | available_glyphs = 0; | - | ||||||||||||||||||||||||
| 2274 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2275 | - | |||||||||||||||||||||||||
| 2276 | QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int _allocated) | - | ||||||||||||||||||||||||
| 2277 | : string(str) | - | ||||||||||||||||||||||||
| 2278 | { | - | ||||||||||||||||||||||||
| 2279 | allocated = _allocated; | - | ||||||||||||||||||||||||
| 2280 | - | |||||||||||||||||||||||||
| 2281 | int space_charAttributes = sizeof(QCharAttributes)*string.length()/sizeof(void*) + 1; | - | ||||||||||||||||||||||||
| 2282 | int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1; | - | ||||||||||||||||||||||||
| 2283 | available_glyphs = ((int)allocated - space_charAttributes - space_logClusters)*(int)sizeof(void*)/(int)QGlyphLayout::SpaceNeeded; | - | ||||||||||||||||||||||||
| 2284 | - | |||||||||||||||||||||||||
| 2285 | if (available_glyphs < str.length()
| 0 | ||||||||||||||||||||||||
| 2286 | - | |||||||||||||||||||||||||
| 2287 | allocated = 0; | - | ||||||||||||||||||||||||
| 2288 | - | |||||||||||||||||||||||||
| 2289 | memory_on_stack = false; | - | ||||||||||||||||||||||||
| 2290 | memory = 0; | - | ||||||||||||||||||||||||
| 2291 | logClustersPtr = 0; | - | ||||||||||||||||||||||||
| 2292 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2293 | memory_on_stack = true; | - | ||||||||||||||||||||||||
| 2294 | memory = stack_memory; | - | ||||||||||||||||||||||||
| 2295 | logClustersPtr = (unsigned short *)(memory + space_charAttributes); | - | ||||||||||||||||||||||||
| 2296 | - | |||||||||||||||||||||||||
| 2297 | void *m = memory + space_charAttributes + space_logClusters; | - | ||||||||||||||||||||||||
| 2298 | glyphLayout = QGlyphLayout(reinterpret_cast<char *>(m), str.length()); | - | ||||||||||||||||||||||||
| 2299 | glyphLayout.clear(); | - | ||||||||||||||||||||||||
| 2300 | memset(memory, 0, space_charAttributes*sizeof(void *)); | - | ||||||||||||||||||||||||
| 2301 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2302 | used = 0; | - | ||||||||||||||||||||||||
| 2303 | hasBidi = false; | - | ||||||||||||||||||||||||
| 2304 | layoutState = LayoutEmpty; | - | ||||||||||||||||||||||||
| 2305 | haveCharAttributes = false; | - | ||||||||||||||||||||||||
| 2306 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2307 | - | |||||||||||||||||||||||||
| 2308 | QTextEngine::LayoutData::~LayoutData() | - | ||||||||||||||||||||||||
| 2309 | { | - | ||||||||||||||||||||||||
| 2310 | if (!memory_on_stack
| 0 | ||||||||||||||||||||||||
| 2311 | free(memory); never executed: free(memory); | 0 | ||||||||||||||||||||||||
| 2312 | memory = 0; | - | ||||||||||||||||||||||||
| 2313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2314 | - | |||||||||||||||||||||||||
| 2315 | bool QTextEngine::LayoutData::reallocate(int totalGlyphs) | - | ||||||||||||||||||||||||
| 2316 | { | - | ||||||||||||||||||||||||
| 2317 | ((!(totalGlyphs >= glyphLayout.numGlyphs)) ? qt_assert("totalGlyphs >= glyphLayout.numGlyphs",__FILE__,2436) : qt_noop()); | - | ||||||||||||||||||||||||
| 2318 | if (memory_on_stack
| 0 | ||||||||||||||||||||||||
| 2319 | glyphLayout.grow(glyphLayout.data(), totalGlyphs); | - | ||||||||||||||||||||||||
| 2320 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2321 | } | - | ||||||||||||||||||||||||
| 2322 | - | |||||||||||||||||||||||||
| 2323 | int space_charAttributes = sizeof(QCharAttributes)*string.length()/sizeof(void*) + 1; | - | ||||||||||||||||||||||||
| 2324 | int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1; | - | ||||||||||||||||||||||||
| 2325 | int space_glyphs = (totalGlyphs * QGlyphLayout::SpaceNeeded) / sizeof(void *) + 2; | - | ||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||
| 2327 | int newAllocated = space_charAttributes + space_glyphs + space_logClusters; | - | ||||||||||||||||||||||||
| 2328 | - | |||||||||||||||||||||||||
| 2329 | - | |||||||||||||||||||||||||
| 2330 | - | |||||||||||||||||||||||||
| 2331 | if (space_charAttributes < 0
| 0 | ||||||||||||||||||||||||
| 2332 | layoutState = LayoutFailed; | - | ||||||||||||||||||||||||
| 2333 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2334 | } | - | ||||||||||||||||||||||||
| 2335 | - | |||||||||||||||||||||||||
| 2336 | void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *)); | - | ||||||||||||||||||||||||
| 2337 | if (!newMem
| 0 | ||||||||||||||||||||||||
| 2338 | layoutState = LayoutFailed; | - | ||||||||||||||||||||||||
| 2339 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2340 | } | - | ||||||||||||||||||||||||
| 2341 | if (memory_on_stack
| 0 | ||||||||||||||||||||||||
| 2342 | memcpy(newMem, memory, allocated*sizeof(void *)); never executed: memcpy(newMem, memory, allocated*sizeof(void *)); | 0 | ||||||||||||||||||||||||
| 2343 | memory = newMem; | - | ||||||||||||||||||||||||
| 2344 | memory_on_stack = false; | - | ||||||||||||||||||||||||
| 2345 | - | |||||||||||||||||||||||||
| 2346 | void **m = memory; | - | ||||||||||||||||||||||||
| 2347 | m += space_charAttributes; | - | ||||||||||||||||||||||||
| 2348 | logClustersPtr = (unsigned short *) m; | - | ||||||||||||||||||||||||
| 2349 | m += space_logClusters; | - | ||||||||||||||||||||||||
| 2350 | - | |||||||||||||||||||||||||
| 2351 | const int space_preGlyphLayout = space_charAttributes + space_logClusters; | - | ||||||||||||||||||||||||
| 2352 | if (allocated < space_preGlyphLayout
| 0 | ||||||||||||||||||||||||
| 2353 | memset(memory + allocated, 0, (space_preGlyphLayout - allocated)*sizeof(void *)); never executed: memset(memory + allocated, 0, (space_preGlyphLayout - allocated)*sizeof(void *)); | 0 | ||||||||||||||||||||||||
| 2354 | - | |||||||||||||||||||||||||
| 2355 | glyphLayout.grow(reinterpret_cast<char *>(m), totalGlyphs); | - | ||||||||||||||||||||||||
| 2356 | - | |||||||||||||||||||||||||
| 2357 | allocated = newAllocated; | - | ||||||||||||||||||||||||
| 2358 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2359 | } | - | ||||||||||||||||||||||||
| 2360 | - | |||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | void QGlyphLayout::grow(char *address, int totalGlyphs) | - | ||||||||||||||||||||||||
| 2363 | { | - | ||||||||||||||||||||||||
| 2364 | QGlyphLayout oldLayout(address, numGlyphs); | - | ||||||||||||||||||||||||
| 2365 | QGlyphLayout newLayout(address, totalGlyphs); | - | ||||||||||||||||||||||||
| 2366 | - | |||||||||||||||||||||||||
| 2367 | if (numGlyphs
| 0 | ||||||||||||||||||||||||
| 2368 | - | |||||||||||||||||||||||||
| 2369 | memmove(newLayout.attributes, oldLayout.attributes, numGlyphs * sizeof(QGlyphAttributes)); | - | ||||||||||||||||||||||||
| 2370 | memmove(newLayout.justifications, oldLayout.justifications, numGlyphs * sizeof(QGlyphJustification)); | - | ||||||||||||||||||||||||
| 2371 | memmove(newLayout.advances, oldLayout.advances, numGlyphs * sizeof(QFixed)); | - | ||||||||||||||||||||||||
| 2372 | memmove(newLayout.glyphs, oldLayout.glyphs, numGlyphs * sizeof(glyph_t)); | - | ||||||||||||||||||||||||
| 2373 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||
| 2376 | newLayout.clear(numGlyphs); | - | ||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||
| 2378 | *this = newLayout; | - | ||||||||||||||||||||||||
| 2379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2380 | - | |||||||||||||||||||||||||
| 2381 | void QTextEngine::freeMemory() | - | ||||||||||||||||||||||||
| 2382 | { | - | ||||||||||||||||||||||||
| 2383 | if (!stackEngine
| 0 | ||||||||||||||||||||||||
| 2384 | delete layoutData; | - | ||||||||||||||||||||||||
| 2385 | layoutData = 0; | - | ||||||||||||||||||||||||
| 2386 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2387 | layoutData->used = 0; | - | ||||||||||||||||||||||||
| 2388 | layoutData->hasBidi = false; | - | ||||||||||||||||||||||||
| 2389 | layoutData->layoutState = LayoutEmpty; | - | ||||||||||||||||||||||||
| 2390 | layoutData->haveCharAttributes = false; | - | ||||||||||||||||||||||||
| 2391 | layoutData->items.clear(); | - | ||||||||||||||||||||||||
| 2392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2393 | if (specialData
| 0 | ||||||||||||||||||||||||
| 2394 | specialData->resolvedFormats.clear(); never executed: specialData->resolvedFormats.clear(); | 0 | ||||||||||||||||||||||||
| 2395 | for (int i = 0; i < lines.size()
| 0 | ||||||||||||||||||||||||
| 2396 | lines[i].justified = 0; | - | ||||||||||||||||||||||||
| 2397 | lines[i].gridfitted = 0; | - | ||||||||||||||||||||||||
| 2398 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2400 | - | |||||||||||||||||||||||||
| 2401 | int QTextEngine::formatIndex(const QScriptItem *si) const | - | ||||||||||||||||||||||||
| 2402 | { | - | ||||||||||||||||||||||||
| 2403 | if (specialData
| 0 | ||||||||||||||||||||||||
| 2404 | QTextFormatCollection *collection = formatCollection(); | - | ||||||||||||||||||||||||
| 2405 | ((!(collection)) ? qt_assert("collection",__FILE__,2524) : qt_noop()); | - | ||||||||||||||||||||||||
| 2406 | return never executed: collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0]));return collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0]));never executed: return collection->indexForFormat(specialData->resolvedFormats.at(si - &layoutData->items[0])); | 0 | ||||||||||||||||||||||||
| 2407 | } | - | ||||||||||||||||||||||||
| 2408 | - | |||||||||||||||||||||||||
| 2409 | QTextDocumentPrivate *p = block.docHandle(); | - | ||||||||||||||||||||||||
| 2410 | if (!p
| 0 | ||||||||||||||||||||||||
| 2411 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2412 | int pos = si->position; | - | ||||||||||||||||||||||||
| 2413 | if (specialData
| 0 | ||||||||||||||||||||||||
| 2414 | if (si->position < specialData->preeditPosition + specialData->preeditText.length()
| 0 | ||||||||||||||||||||||||
| 2415 | pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0); never executed: pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0); | 0 | ||||||||||||||||||||||||
| 2416 | else | - | ||||||||||||||||||||||||
| 2417 | pos -= specialData->preeditText.length(); never executed: pos -= specialData->preeditText.length(); | 0 | ||||||||||||||||||||||||
| 2418 | } | - | ||||||||||||||||||||||||
| 2419 | QTextDocumentPrivate::FragmentIterator it = p->find(block.position() + pos); | - | ||||||||||||||||||||||||
| 2420 | return never executed: it.value()->format;return it.value()->format;never executed: return it.value()->format; | 0 | ||||||||||||||||||||||||
| 2421 | } | - | ||||||||||||||||||||||||
| 2422 | - | |||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||
| 2424 | QTextCharFormat QTextEngine::format(const QScriptItem *si) const | - | ||||||||||||||||||||||||
| 2425 | { | - | ||||||||||||||||||||||||
| 2426 | if (const
| 0 | ||||||||||||||||||||||||
| 2427 | return never executed: collection->charFormat(formatIndex(si));return collection->charFormat(formatIndex(si));never executed: return collection->charFormat(formatIndex(si)); | 0 | ||||||||||||||||||||||||
| 2428 | return never executed: QTextCharFormat();return QTextCharFormat();never executed: return QTextCharFormat(); | 0 | ||||||||||||||||||||||||
| 2429 | } | - | ||||||||||||||||||||||||
| 2430 | - | |||||||||||||||||||||||||
| 2431 | void QTextEngine::addRequiredBoundaries() const | - | ||||||||||||||||||||||||
| 2432 | { | - | ||||||||||||||||||||||||
| 2433 | if (specialData
| 0 | ||||||||||||||||||||||||
| 2434 | for (int i = 0; i < specialData->formats.size()
| 0 | ||||||||||||||||||||||||
| 2435 | const QTextLayout::FormatRange &r = specialData->formats.at(i); | - | ||||||||||||||||||||||||
| 2436 | setBoundary(r.start); | - | ||||||||||||||||||||||||
| 2437 | setBoundary(r.start + r.length); | - | ||||||||||||||||||||||||
| 2438 | - | |||||||||||||||||||||||||
| 2439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2440 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2441 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2442 | - | |||||||||||||||||||||||||
| 2443 | bool QTextEngine::atWordSeparator(int position) const | - | ||||||||||||||||||||||||
| 2444 | { | - | ||||||||||||||||||||||||
| 2445 | const QChar c = layoutData->string.at(position); | - | ||||||||||||||||||||||||
| 2446 | switch (c.unicode()) { | - | ||||||||||||||||||||||||
| 2447 | case never executed: '.':case '.':never executed: case '.': | 0 | ||||||||||||||||||||||||
| 2448 | case never executed: ',':case ',':never executed: case ',': | 0 | ||||||||||||||||||||||||
| 2449 | case never executed: '?':case '?':never executed: case '?': | 0 | ||||||||||||||||||||||||
| 2450 | case never executed: '!':case '!':never executed: case '!': | 0 | ||||||||||||||||||||||||
| 2451 | case never executed: '@':case '@':never executed: case '@': | 0 | ||||||||||||||||||||||||
| 2452 | case never executed: '#':case '#':never executed: case '#': | 0 | ||||||||||||||||||||||||
| 2453 | case never executed: '$':case '$':never executed: case '$': | 0 | ||||||||||||||||||||||||
| 2454 | case never executed: ':':case ':':never executed: case ':': | 0 | ||||||||||||||||||||||||
| 2455 | case never executed: ';':case ';':never executed: case ';': | 0 | ||||||||||||||||||||||||
| 2456 | case never executed: '-':case '-':never executed: case '-': | 0 | ||||||||||||||||||||||||
| 2457 | case never executed: '<':case '<':never executed: case '<': | 0 | ||||||||||||||||||||||||
| 2458 | case never executed: '>':case '>':never executed: case '>': | 0 | ||||||||||||||||||||||||
| 2459 | case never executed: '[':case '[':never executed: case '[': | 0 | ||||||||||||||||||||||||
| 2460 | case never executed: ']':case ']':never executed: case ']': | 0 | ||||||||||||||||||||||||
| 2461 | case never executed: '(':case '(':never executed: case '(': | 0 | ||||||||||||||||||||||||
| 2462 | case never executed: ')':case ')':never executed: case ')': | 0 | ||||||||||||||||||||||||
| 2463 | case never executed: '{':case '{':never executed: case '{': | 0 | ||||||||||||||||||||||||
| 2464 | case never executed: '}':case '}':never executed: case '}': | 0 | ||||||||||||||||||||||||
| 2465 | case never executed: '=':case '=':never executed: case '=': | 0 | ||||||||||||||||||||||||
| 2466 | case never executed: '/':case '/':never executed: case '/': | 0 | ||||||||||||||||||||||||
| 2467 | case never executed: '+':case '+':never executed: case '+': | 0 | ||||||||||||||||||||||||
| 2468 | case never executed: '%':case '%':never executed: case '%': | 0 | ||||||||||||||||||||||||
| 2469 | case never executed: '&':case '&':never executed: case '&': | 0 | ||||||||||||||||||||||||
| 2470 | case never executed: '^':case '^':never executed: case '^': | 0 | ||||||||||||||||||||||||
| 2471 | case never executed: '*':case '*':never executed: case '*': | 0 | ||||||||||||||||||||||||
| 2472 | case never executed: '\'':case '\'':never executed: case '\'': | 0 | ||||||||||||||||||||||||
| 2473 | case never executed: '"':case '"':never executed: case '"': | 0 | ||||||||||||||||||||||||
| 2474 | case never executed: '`':case '`':never executed: case '`': | 0 | ||||||||||||||||||||||||
| 2475 | case never executed: '~':case '~':never executed: case '~': | 0 | ||||||||||||||||||||||||
| 2476 | case never executed: '|':case '|':never executed: case '|': | 0 | ||||||||||||||||||||||||
| 2477 | case never executed: '\\':case '\\':never executed: case '\\': | 0 | ||||||||||||||||||||||||
| 2478 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2479 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 2480 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2481 | } | - | ||||||||||||||||||||||||
| 2482 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2483 | } | - | ||||||||||||||||||||||||
| 2484 | - | |||||||||||||||||||||||||
| 2485 | void QTextEngine::setPreeditArea(int position, const QString &preeditText) | - | ||||||||||||||||||||||||
| 2486 | { | - | ||||||||||||||||||||||||
| 2487 | if (preeditText.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2488 | if (!specialData
| 0 | ||||||||||||||||||||||||
| 2489 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2490 | if (specialData->formats.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2491 | delete specialData; | - | ||||||||||||||||||||||||
| 2492 | specialData = 0; | - | ||||||||||||||||||||||||
| 2493 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2494 | specialData->preeditText = QString(); | - | ||||||||||||||||||||||||
| 2495 | specialData->preeditPosition = -1; | - | ||||||||||||||||||||||||
| 2496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2497 | } else { | - | ||||||||||||||||||||||||
| 2498 | if (!specialData
| 0 | ||||||||||||||||||||||||
| 2499 | specialData = new SpecialData; never executed: specialData = new SpecialData; | 0 | ||||||||||||||||||||||||
| 2500 | specialData->preeditPosition = position; | - | ||||||||||||||||||||||||
| 2501 | specialData->preeditText = preeditText; | - | ||||||||||||||||||||||||
| 2502 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2503 | invalidate(); | - | ||||||||||||||||||||||||
| 2504 | clearLineData(); | - | ||||||||||||||||||||||||
| 2505 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2506 | - | |||||||||||||||||||||||||
| 2507 | void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats) | - | ||||||||||||||||||||||||
| 2508 | { | - | ||||||||||||||||||||||||
| 2509 | if (formats.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2510 | if (!specialData
| 0 | ||||||||||||||||||||||||
| 2511 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2512 | if (specialData->preeditText.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2513 | delete specialData; | - | ||||||||||||||||||||||||
| 2514 | specialData = 0; | - | ||||||||||||||||||||||||
| 2515 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2516 | specialData->formats.clear(); | - | ||||||||||||||||||||||||
| 2517 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2518 | } else { | - | ||||||||||||||||||||||||
| 2519 | if (!specialData
| 0 | ||||||||||||||||||||||||
| 2520 | specialData = new SpecialData; | - | ||||||||||||||||||||||||
| 2521 | specialData->preeditPosition = -1; | - | ||||||||||||||||||||||||
| 2522 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2523 | specialData->formats = formats; | - | ||||||||||||||||||||||||
| 2524 | indexFormats(); | - | ||||||||||||||||||||||||
| 2525 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2526 | invalidate(); | - | ||||||||||||||||||||||||
| 2527 | clearLineData(); | - | ||||||||||||||||||||||||
| 2528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2529 | - | |||||||||||||||||||||||||
| 2530 | void QTextEngine::indexFormats() | - | ||||||||||||||||||||||||
| 2531 | { | - | ||||||||||||||||||||||||
| 2532 | QTextFormatCollection *collection = formatCollection(); | - | ||||||||||||||||||||||||
| 2533 | if (!collection
| 0 | ||||||||||||||||||||||||
| 2534 | ((!(!block.docHandle())) ? qt_assert("!block.docHandle()",__FILE__,2653) : qt_noop()); | - | ||||||||||||||||||||||||
| 2535 | specialData->formatCollection.reset(new QTextFormatCollection); | - | ||||||||||||||||||||||||
| 2536 | collection = specialData->formatCollection.data(); | - | ||||||||||||||||||||||||
| 2537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2538 | - | |||||||||||||||||||||||||
| 2539 | - | |||||||||||||||||||||||||
| 2540 | for (int i = 0; i < specialData->formats.size()
| 0 | ||||||||||||||||||||||||
| 2541 | QTextCharFormat &format = specialData->formats[i].format; | - | ||||||||||||||||||||||||
| 2542 | format = collection->charFormat(collection->indexForFormat(format)); | - | ||||||||||||||||||||||||
| 2543 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2545 | - | |||||||||||||||||||||||||
| 2546 | - | |||||||||||||||||||||||||
| 2547 | - | |||||||||||||||||||||||||
| 2548 | - | |||||||||||||||||||||||||
| 2549 | - | |||||||||||||||||||||||||
| 2550 | static inline bool nextCharJoins(const QString &string, int pos) | - | ||||||||||||||||||||||||
| 2551 | { | - | ||||||||||||||||||||||||
| 2552 | while (pos < string.length()
| 0 | ||||||||||||||||||||||||
| 2553 | ++ never executed: pos;++pos;never executed: ++pos; | 0 | ||||||||||||||||||||||||
| 2554 | if (pos == string.length()
| 0 | ||||||||||||||||||||||||
| 2555 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2556 | QChar::JoiningType joining = string.at(pos).joiningType(); | - | ||||||||||||||||||||||||
| 2557 | return never executed: joining != QChar::Joining_None && joining != QChar::Joining_Transparent;return joining != QChar::Joining_None && joining != QChar::Joining_Transparent;never executed: return joining != QChar::Joining_None && joining != QChar::Joining_Transparent; | 0 | ||||||||||||||||||||||||
| 2558 | } | - | ||||||||||||||||||||||||
| 2559 | - | |||||||||||||||||||||||||
| 2560 | static inline bool prevCharJoins(const QString &string, int pos) | - | ||||||||||||||||||||||||
| 2561 | { | - | ||||||||||||||||||||||||
| 2562 | while (pos > 0
| 0 | ||||||||||||||||||||||||
| 2563 | -- never executed: pos;--pos;never executed: --pos; | 0 | ||||||||||||||||||||||||
| 2564 | if (pos == 0
| 0 | ||||||||||||||||||||||||
| 2565 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2566 | QChar::JoiningType joining = string.at(pos - 1).joiningType(); | - | ||||||||||||||||||||||||
| 2567 | return never executed: joining == QChar::Joining_Dual || joining == QChar::Joining_Causing;return joining == QChar::Joining_Dual || joining == QChar::Joining_Causing;never executed: return joining == QChar::Joining_Dual || joining == QChar::Joining_Causing; | 0 | ||||||||||||||||||||||||
| 2568 | } | - | ||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||
| 2570 | static inline bool isRetainableControlCode(QChar c) | - | ||||||||||||||||||||||||
| 2571 | { | - | ||||||||||||||||||||||||
| 2572 | return never executed: (c.unicode() >= 0x202a && c.unicode() <= 0x202e)return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069);never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069); | 0 | ||||||||||||||||||||||||
| 2573 | || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069); | 0 | ||||||||||||||||||||||||
| 2574 | || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069); never executed: return (c.unicode() >= 0x202a && c.unicode() <= 0x202e) || (c.unicode() >= 0x200e && c.unicode() <= 0x200f) || (c.unicode() >= 0x2066 && c.unicode() <= 0x2069); | 0 | ||||||||||||||||||||||||
| 2575 | } | - | ||||||||||||||||||||||||
| 2576 | - | |||||||||||||||||||||||||
| 2577 | static QString stringMidRetainingBidiCC(const QString &string, | - | ||||||||||||||||||||||||
| 2578 | const QString &ellidePrefix, | - | ||||||||||||||||||||||||
| 2579 | const QString &ellideSuffix, | - | ||||||||||||||||||||||||
| 2580 | int subStringFrom, | - | ||||||||||||||||||||||||
| 2581 | int subStringTo, | - | ||||||||||||||||||||||||
| 2582 | int midStart, | - | ||||||||||||||||||||||||
| 2583 | int midLength) | - | ||||||||||||||||||||||||
| 2584 | { | - | ||||||||||||||||||||||||
| 2585 | QString prefix; | - | ||||||||||||||||||||||||
| 2586 | for (int i=subStringFrom; i<midStart
| 0 | ||||||||||||||||||||||||
| 2587 | QChar c = string.at(i); | - | ||||||||||||||||||||||||
| 2588 | if (isRetainableControlCode(c)
| 0 | ||||||||||||||||||||||||
| 2589 | prefix += c; never executed: prefix += c; | 0 | ||||||||||||||||||||||||
| 2590 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2591 | - | |||||||||||||||||||||||||
| 2592 | QString suffix; | - | ||||||||||||||||||||||||
| 2593 | for (int i=midStart + midLength; i<subStringTo
| 0 | ||||||||||||||||||||||||
| 2594 | QChar c = string.at(i); | - | ||||||||||||||||||||||||
| 2595 | if (isRetainableControlCode(c)
| 0 | ||||||||||||||||||||||||
| 2596 | suffix += c; never executed: suffix += c; | 0 | ||||||||||||||||||||||||
| 2597 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2598 | - | |||||||||||||||||||||||||
| 2599 | return never executed: prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix;never executed: return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix; | 0 | ||||||||||||||||||||||||
| 2600 | } | - | ||||||||||||||||||||||||
| 2601 | - | |||||||||||||||||||||||||
| 2602 | QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const | - | ||||||||||||||||||||||||
| 2603 | { | - | ||||||||||||||||||||||||
| 2604 | - | |||||||||||||||||||||||||
| 2605 | - | |||||||||||||||||||||||||
| 2606 | if (flags & Qt::TextShowMnemonic
| 0 | ||||||||||||||||||||||||
| 2607 | itemize(); | - | ||||||||||||||||||||||||
| 2608 | QCharAttributes *attributes = const_cast<QCharAttributes *>(this->attributes()); | - | ||||||||||||||||||||||||
| 2609 | if (!attributes
| 0 | ||||||||||||||||||||||||
| 2610 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 2611 | for (int i = 0; i < layoutData->items.size()
| 0 | ||||||||||||||||||||||||
| 2612 | QScriptItem &si = layoutData->items[i]; | - | ||||||||||||||||||||||||
| 2613 | if (!si.num_glyphs
| 0 | ||||||||||||||||||||||||
| 2614 | shape(i); never executed: shape(i); | 0 | ||||||||||||||||||||||||
| 2615 | - | |||||||||||||||||||||||||
| 2616 | unsigned short *logClusters = this->logClusters(&si); | - | ||||||||||||||||||||||||
| 2617 | QGlyphLayout glyphs = shapedGlyphs(&si); | - | ||||||||||||||||||||||||
| 2618 | - | |||||||||||||||||||||||||
| 2619 | const int end = si.position + length(&si); | - | ||||||||||||||||||||||||
| 2620 | for (int i = si.position; i < end - 1
| 0 | ||||||||||||||||||||||||
| 2621 | if (layoutData->string.at(i) == QLatin1Char('&')
| 0 | ||||||||||||||||||||||||
| 2622 | && !attributes[i + 1].whiteSpace
| 0 | ||||||||||||||||||||||||
| 2623 | const int gp = logClusters[i - si.position]; | - | ||||||||||||||||||||||||
| 2624 | glyphs.attributes[gp].dontPrint = true; | - | ||||||||||||||||||||||||
| 2625 | - | |||||||||||||||||||||||||
| 2626 | attributes[i] = attributes[i + 1]; | - | ||||||||||||||||||||||||
| 2627 | memset(attributes + i + 1, 0, sizeof(QCharAttributes)); | - | ||||||||||||||||||||||||
| 2628 | if (layoutData->string.at(i + 1) == QLatin1Char('&')
| 0 | ||||||||||||||||||||||||
| 2629 | ++ never executed: i;++i;never executed: ++i; | 0 | ||||||||||||||||||||||||
| 2630 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2631 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2632 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2633 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | validate(); | - | ||||||||||||||||||||||||
| 2636 | - | |||||||||||||||||||||||||
| 2637 | const int to = count >= 0
| 0 | ||||||||||||||||||||||||
| 2638 | ? from + count | - | ||||||||||||||||||||||||
| 2639 | : layoutData->string.length(); | - | ||||||||||||||||||||||||
| 2640 | - | |||||||||||||||||||||||||
| 2641 | if (mode == Qt::ElideNone
| 0 | ||||||||||||||||||||||||
| 2642 | || this->width(from, layoutData->string.length()) <= width
| 0 | ||||||||||||||||||||||||
| 2643 | || to - from <= 1
| 0 | ||||||||||||||||||||||||
| 2644 | return never executed: layoutData->string.mid(from, from - to);return layoutData->string.mid(from, from - to);never executed: return layoutData->string.mid(from, from - to); | 0 | ||||||||||||||||||||||||
| 2645 | - | |||||||||||||||||||||||||
| 2646 | QFixed ellipsisWidth; | - | ||||||||||||||||||||||||
| 2647 | QString ellipsisText; | - | ||||||||||||||||||||||||
| 2648 | { | - | ||||||||||||||||||||||||
| 2649 | QFontEngine *engine = fnt.d->engineForScript(QChar::Script_Common); | - | ||||||||||||||||||||||||
| 2650 | - | |||||||||||||||||||||||||
| 2651 | QChar ellipsisChar(0x2026); | - | ||||||||||||||||||||||||
| 2652 | - | |||||||||||||||||||||||||
| 2653 | glyph_t glyph = engine->glyphIndex(ellipsisChar.unicode()); | - | ||||||||||||||||||||||||
| 2654 | - | |||||||||||||||||||||||||
| 2655 | QGlyphLayout glyphs; | - | ||||||||||||||||||||||||
| 2656 | glyphs.numGlyphs = 1; | - | ||||||||||||||||||||||||
| 2657 | glyphs.glyphs = &glyph; | - | ||||||||||||||||||||||||
| 2658 | glyphs.advances = &ellipsisWidth; | - | ||||||||||||||||||||||||
| 2659 | - | |||||||||||||||||||||||||
| 2660 | if (glyph != 0
| 0 | ||||||||||||||||||||||||
| 2661 | engine->recalcAdvances(&glyphs, 0); | - | ||||||||||||||||||||||||
| 2662 | - | |||||||||||||||||||||||||
| 2663 | ellipsisText = ellipsisChar; | - | ||||||||||||||||||||||||
| 2664 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2665 | glyph = engine->glyphIndex('.'); | - | ||||||||||||||||||||||||
| 2666 | if (glyph != 0
| 0 | ||||||||||||||||||||||||
| 2667 | engine->recalcAdvances(&glyphs, 0); | - | ||||||||||||||||||||||||
| 2668 | - | |||||||||||||||||||||||||
| 2669 | ellipsisWidth *= 3; | - | ||||||||||||||||||||||||
| 2670 | ellipsisText = ([]() -> QString { enum { Size = sizeof(u"" "...")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "..." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }());return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
| 2671 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2672 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2673 | } | - | ||||||||||||||||||||||||
| 2674 | - | |||||||||||||||||||||||||
| 2675 | const QFixed availableWidth = width - ellipsisWidth; | - | ||||||||||||||||||||||||
| 2676 | if (availableWidth < 0
| 0 | ||||||||||||||||||||||||
| 2677 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 2678 | - | |||||||||||||||||||||||||
| 2679 | const QCharAttributes *attributes = this->attributes(); | - | ||||||||||||||||||||||||
| 2680 | if (!attributes
| 0 | ||||||||||||||||||||||||
| 2681 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 2682 | - | |||||||||||||||||||||||||
| 2683 | if (mode == Qt::ElideRight
| 0 | ||||||||||||||||||||||||
| 2684 | QFixed currentWidth; | - | ||||||||||||||||||||||||
| 2685 | int pos; | - | ||||||||||||||||||||||||
| 2686 | int nextBreak = from; | - | ||||||||||||||||||||||||
| 2687 | - | |||||||||||||||||||||||||
| 2688 | do { | - | ||||||||||||||||||||||||
| 2689 | pos = nextBreak; | - | ||||||||||||||||||||||||
| 2690 | - | |||||||||||||||||||||||||
| 2691 | ++nextBreak; | - | ||||||||||||||||||||||||
| 2692 | while (nextBreak < layoutData->string.length()
| 0 | ||||||||||||||||||||||||
| 2693 | ++ never executed: nextBreak;++nextBreak;never executed: ++nextBreak; | 0 | ||||||||||||||||||||||||
| 2694 | - | |||||||||||||||||||||||||
| 2695 | currentWidth += this->width(pos, nextBreak - pos); | - | ||||||||||||||||||||||||
| 2696 | } never executed: while (nextBreak < toend of block
| 0 | ||||||||||||||||||||||||
| 2697 | && currentWidth < availableWidth
| 0 | ||||||||||||||||||||||||
| 2698 | - | |||||||||||||||||||||||||
| 2699 | if (nextCharJoins(layoutData->string, pos)
| 0 | ||||||||||||||||||||||||
| 2700 | ellipsisText.prepend(QChar(0x200d) ); never executed: ellipsisText.prepend(QChar(0x200d) ); | 0 | ||||||||||||||||||||||||
| 2701 | - | |||||||||||||||||||||||||
| 2702 | return never executed: stringMidRetainingBidiCC(layoutData->string,return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from);never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from); | 0 | ||||||||||||||||||||||||
| 2703 | QString(), ellipsisText, never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from); | 0 | ||||||||||||||||||||||||
| 2704 | from, to, never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from); | 0 | ||||||||||||||||||||||||
| 2705 | from, pos - from); never executed: return stringMidRetainingBidiCC(layoutData->string, QString(), ellipsisText, from, to, from, pos - from); | 0 | ||||||||||||||||||||||||
| 2706 | } else if (mode == Qt::ElideLeft
| 0 | ||||||||||||||||||||||||
| 2707 | QFixed currentWidth; | - | ||||||||||||||||||||||||
| 2708 | int pos; | - | ||||||||||||||||||||||||
| 2709 | int nextBreak = to; | - | ||||||||||||||||||||||||
| 2710 | - | |||||||||||||||||||||||||
| 2711 | do { | - | ||||||||||||||||||||||||
| 2712 | pos = nextBreak; | - | ||||||||||||||||||||||||
| 2713 | - | |||||||||||||||||||||||||
| 2714 | --nextBreak; | - | ||||||||||||||||||||||||
| 2715 | while (nextBreak > 0
| 0 | ||||||||||||||||||||||||
| 2716 | -- never executed: nextBreak;--nextBreak;never executed: --nextBreak; | 0 | ||||||||||||||||||||||||
| 2717 | - | |||||||||||||||||||||||||
| 2718 | currentWidth += this->width(nextBreak, pos - nextBreak); | - | ||||||||||||||||||||||||
| 2719 | } never executed: while (nextBreak > fromend of block
| 0 | ||||||||||||||||||||||||
| 2720 | && currentWidth < availableWidth
| 0 | ||||||||||||||||||||||||
| 2721 | - | |||||||||||||||||||||||||
| 2722 | if (prevCharJoins(layoutData->string, pos)
| 0 | ||||||||||||||||||||||||
| 2723 | ellipsisText.append(QChar(0x200d) ); never executed: ellipsisText.append(QChar(0x200d) ); | 0 | ||||||||||||||||||||||||
| 2724 | - | |||||||||||||||||||||||||
| 2725 | return never executed: stringMidRetainingBidiCC(layoutData->string,return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos);never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos); | 0 | ||||||||||||||||||||||||
| 2726 | ellipsisText, QString(), never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos); | 0 | ||||||||||||||||||||||||
| 2727 | from, to, never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos); | 0 | ||||||||||||||||||||||||
| 2728 | pos, to - pos); never executed: return stringMidRetainingBidiCC(layoutData->string, ellipsisText, QString(), from, to, pos, to - pos); | 0 | ||||||||||||||||||||||||
| 2729 | } else if (mode == Qt::ElideMiddle
| 0 | ||||||||||||||||||||||||
| 2730 | QFixed leftWidth; | - | ||||||||||||||||||||||||
| 2731 | QFixed rightWidth; | - | ||||||||||||||||||||||||
| 2732 | - | |||||||||||||||||||||||||
| 2733 | int leftPos = from; | - | ||||||||||||||||||||||||
| 2734 | int nextLeftBreak = from; | - | ||||||||||||||||||||||||
| 2735 | - | |||||||||||||||||||||||||
| 2736 | int rightPos = to; | - | ||||||||||||||||||||||||
| 2737 | int nextRightBreak = to; | - | ||||||||||||||||||||||||
| 2738 | - | |||||||||||||||||||||||||
| 2739 | do { | - | ||||||||||||||||||||||||
| 2740 | leftPos = nextLeftBreak; | - | ||||||||||||||||||||||||
| 2741 | rightPos = nextRightBreak; | - | ||||||||||||||||||||||||
| 2742 | - | |||||||||||||||||||||||||
| 2743 | ++nextLeftBreak; | - | ||||||||||||||||||||||||
| 2744 | while (nextLeftBreak < layoutData->string.length()
| 0 | ||||||||||||||||||||||||
| 2745 | ++ never executed: nextLeftBreak;++nextLeftBreak;never executed: ++nextLeftBreak; | 0 | ||||||||||||||||||||||||
| 2746 | - | |||||||||||||||||||||||||
| 2747 | --nextRightBreak; | - | ||||||||||||||||||||||||
| 2748 | while (nextRightBreak > from
| 0 | ||||||||||||||||||||||||
| 2749 | -- never executed: nextRightBreak;--nextRightBreak;never executed: --nextRightBreak; | 0 | ||||||||||||||||||||||||
| 2750 | - | |||||||||||||||||||||||||
| 2751 | leftWidth += this->width(leftPos, nextLeftBreak - leftPos); | - | ||||||||||||||||||||||||
| 2752 | rightWidth += this->width(nextRightBreak, rightPos - nextRightBreak); | - | ||||||||||||||||||||||||
| 2753 | } never executed: while (nextLeftBreak < toend of block
| 0 | ||||||||||||||||||||||||
| 2754 | && nextRightBreak > from
| 0 | ||||||||||||||||||||||||
| 2755 | && leftWidth + rightWidth < availableWidth
| 0 | ||||||||||||||||||||||||
| 2756 | - | |||||||||||||||||||||||||
| 2757 | if (nextCharJoins(layoutData->string, leftPos)
| 0 | ||||||||||||||||||||||||
| 2758 | ellipsisText.prepend(QChar(0x200d) ); never executed: ellipsisText.prepend(QChar(0x200d) ); | 0 | ||||||||||||||||||||||||
| 2759 | if (prevCharJoins(layoutData->string, rightPos)
| 0 | ||||||||||||||||||||||||
| 2760 | ellipsisText.append(QChar(0x200d) ); never executed: ellipsisText.append(QChar(0x200d) ); | 0 | ||||||||||||||||||||||||
| 2761 | - | |||||||||||||||||||||||||
| 2762 | return never executed: layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos);never executed: return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos); | 0 | ||||||||||||||||||||||||
| 2763 | } | - | ||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||
| 2765 | return never executed: layoutData->string.mid(from, to - from);return layoutData->string.mid(from, to - from);never executed: return layoutData->string.mid(from, to - from); | 0 | ||||||||||||||||||||||||
| 2766 | } | - | ||||||||||||||||||||||||
| 2767 | - | |||||||||||||||||||||||||
| 2768 | void QTextEngine::setBoundary(int strPos) const | - | ||||||||||||||||||||||||
| 2769 | { | - | ||||||||||||||||||||||||
| 2770 | const int item = findItem(strPos); | - | ||||||||||||||||||||||||
| 2771 | if (item < 0
| 0 | ||||||||||||||||||||||||
| 2772 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2773 | - | |||||||||||||||||||||||||
| 2774 | QScriptItem newItem = layoutData->items.at(item); | - | ||||||||||||||||||||||||
| 2775 | if (newItem.position != strPos
| 0 | ||||||||||||||||||||||||
| 2776 | newItem.position = strPos; | - | ||||||||||||||||||||||||
| 2777 | layoutData->items.insert(item + 1, newItem); | - | ||||||||||||||||||||||||
| 2778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2779 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2780 | - | |||||||||||||||||||||||||
| 2781 | QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const | - | ||||||||||||||||||||||||
| 2782 | { | - | ||||||||||||||||||||||||
| 2783 | const QScriptItem &si = layoutData->items[item]; | - | ||||||||||||||||||||||||
| 2784 | - | |||||||||||||||||||||||||
| 2785 | QFixed dpiScale = 1; | - | ||||||||||||||||||||||||
| 2786 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 2787 | QPaintDevice *pdev = block.docHandle()->layout()->paintDevice(); | - | ||||||||||||||||||||||||
| 2788 | if (pdev
| 0 | ||||||||||||||||||||||||
| 2789 | dpiScale = QFixed::fromReal(pdev->logicalDpiY() / qreal(qt_defaultDpiY())); never executed: dpiScale = QFixed::fromReal(pdev->logicalDpiY() / qreal(qt_defaultDpiY())); | 0 | ||||||||||||||||||||||||
| 2790 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2791 | dpiScale = QFixed::fromReal(fnt.d->dpi / qreal(qt_defaultDpiY())); | - | ||||||||||||||||||||||||
| 2792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2793 | - | |||||||||||||||||||||||||
| 2794 | QList<QTextOption::Tab> tabArray = option.tabs(); | - | ||||||||||||||||||||||||
| 2795 | if (!tabArray.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2796 | if (isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 2797 | QList<QTextOption::Tab> newTabs; | - | ||||||||||||||||||||||||
| 2798 | newTabs.reserve(tabArray.count()); | - | ||||||||||||||||||||||||
| 2799 | QList<QTextOption::Tab>::Iterator iter = tabArray.begin(); | - | ||||||||||||||||||||||||
| 2800 | while(iter != tabArray.end()
| 0 | ||||||||||||||||||||||||
| 2801 | QTextOption::Tab tab = *iter; | - | ||||||||||||||||||||||||
| 2802 | if (tab.type == QTextOption::LeftTab
| 0 | ||||||||||||||||||||||||
| 2803 | tab.type = QTextOption::RightTab; never executed: tab.type = QTextOption::RightTab; | 0 | ||||||||||||||||||||||||
| 2804 | else if (tab.type == QTextOption::RightTab
| 0 | ||||||||||||||||||||||||
| 2805 | tab.type = QTextOption::LeftTab; never executed: tab.type = QTextOption::LeftTab; | 0 | ||||||||||||||||||||||||
| 2806 | newTabs << tab; | - | ||||||||||||||||||||||||
| 2807 | ++iter; | - | ||||||||||||||||||||||||
| 2808 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2809 | tabArray = newTabs; | - | ||||||||||||||||||||||||
| 2810 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2811 | for (int i = 0; i < tabArray.size()
| 0 | ||||||||||||||||||||||||
| 2812 | QFixed tab = QFixed::fromReal(tabArray[i].position) * dpiScale; | - | ||||||||||||||||||||||||
| 2813 | if (tab > x
| 0 | ||||||||||||||||||||||||
| 2814 | QTextOption::Tab tabSpec = tabArray[i]; | - | ||||||||||||||||||||||||
| 2815 | int tabSectionEnd = layoutData->string.count(); | - | ||||||||||||||||||||||||
| 2816 | if (tabSpec.type == QTextOption::RightTab
| 0 | ||||||||||||||||||||||||
| 2817 | - | |||||||||||||||||||||||||
| 2818 | tab = QFixed::fromReal(tabSpec.position); | - | ||||||||||||||||||||||||
| 2819 | for (int i=item + 1; i < layoutData->items.count()
| 0 | ||||||||||||||||||||||||
| 2820 | const QScriptItem &item = layoutData->items[i]; | - | ||||||||||||||||||||||||
| 2821 | if (item.analysis.flags == QScriptAnalysis::TabOrObject
| 0 | ||||||||||||||||||||||||
| 2822 | tabSectionEnd = item.position; | - | ||||||||||||||||||||||||
| 2823 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2824 | } | - | ||||||||||||||||||||||||
| 2825 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2827 | else if (tabSpec.type == QTextOption::DelimiterTab
| 0 | ||||||||||||||||||||||||
| 2828 | - | |||||||||||||||||||||||||
| 2829 | tabSectionEnd = qMax(si.position, layoutData->string.indexOf(tabSpec.delimiter, si.position) + 1); never executed: tabSectionEnd = qMax(si.position, layoutData->string.indexOf(tabSpec.delimiter, si.position) + 1); | 0 | ||||||||||||||||||||||||
| 2830 | - | |||||||||||||||||||||||||
| 2831 | if (tabSectionEnd > si.position
| 0 | ||||||||||||||||||||||||
| 2832 | QFixed length; | - | ||||||||||||||||||||||||
| 2833 | - | |||||||||||||||||||||||||
| 2834 | for (int i=item; i < layoutData->items.count()
| 0 | ||||||||||||||||||||||||
| 2835 | QScriptItem &item = layoutData->items[i]; | - | ||||||||||||||||||||||||
| 2836 | if (item.position > tabSectionEnd
| 0 | ||||||||||||||||||||||||
| 2837 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2838 | shape(i); | - | ||||||||||||||||||||||||
| 2839 | if (item.analysis.flags == QScriptAnalysis::Object
| 0 | ||||||||||||||||||||||||
| 2840 | length += item.width; | - | ||||||||||||||||||||||||
| 2841 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2842 | } | - | ||||||||||||||||||||||||
| 2843 | QGlyphLayout glyphs = this->shapedGlyphs(&item); | - | ||||||||||||||||||||||||
| 2844 | const int end = qMin(item.position + item.num_glyphs, tabSectionEnd) - item.position; | - | ||||||||||||||||||||||||
| 2845 | for (int i=0; i < end
| 0 | ||||||||||||||||||||||||
| 2846 | length += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; never executed: length += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; | 0 | ||||||||||||||||||||||||
| 2847 | if (end + item.position == tabSectionEnd
| 0 | ||||||||||||||||||||||||
| 2848 | length -= glyphs.advances[end] / 2 * !glyphs.attributes[end].dontPrint; never executed: length -= glyphs.advances[end] / 2 * !glyphs.attributes[end].dontPrint; | 0 | ||||||||||||||||||||||||
| 2849 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2850 | - | |||||||||||||||||||||||||
| 2851 | switch (tabSpec.type) { | - | ||||||||||||||||||||||||
| 2852 | case never executed: QTextOption::CenterTab:case QTextOption::CenterTab:never executed: case QTextOption::CenterTab: | 0 | ||||||||||||||||||||||||
| 2853 | length /= 2; | - | ||||||||||||||||||||||||
| 2854 | - | |||||||||||||||||||||||||
| 2855 | case never executed: QTextOption::DelimiterTab:case QTextOption::DelimiterTab:never executed: case QTextOption::DelimiterTab:code before this statement never executed: case QTextOption::DelimiterTab: | 0 | ||||||||||||||||||||||||
| 2856 | - | |||||||||||||||||||||||||
| 2857 | case never executed: QTextOption::RightTab:case QTextOption::RightTab:never executed: case QTextOption::RightTab: | 0 | ||||||||||||||||||||||||
| 2858 | tab = QFixed::fromReal(tabSpec.position) * dpiScale - length; | - | ||||||||||||||||||||||||
| 2859 | if (tab < x
| 0 | ||||||||||||||||||||||||
| 2860 | return never executed: QFixed();return QFixed();never executed: return QFixed(); | 0 | ||||||||||||||||||||||||
| 2861 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2862 | case never executed: QTextOption::LeftTab:case QTextOption::LeftTab:never executed: case QTextOption::LeftTab: | 0 | ||||||||||||||||||||||||
| 2863 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2864 | } | - | ||||||||||||||||||||||||
| 2865 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2866 | return never executed: tab - x;return tab - x;never executed: return tab - x; | 0 | ||||||||||||||||||||||||
| 2867 | } | - | ||||||||||||||||||||||||
| 2868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2869 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2870 | QFixed tab = QFixed::fromReal(option.tabStop()); | - | ||||||||||||||||||||||||
| 2871 | if (tab <= 0
| 0 | ||||||||||||||||||||||||
| 2872 | tab = 80; never executed: tab = 80; | 0 | ||||||||||||||||||||||||
| 2873 | tab *= dpiScale; | - | ||||||||||||||||||||||||
| 2874 | QFixed nextTabPos = ((x / tab).truncate() + 1) * tab; | - | ||||||||||||||||||||||||
| 2875 | QFixed tabWidth = nextTabPos - x; | - | ||||||||||||||||||||||||
| 2876 | - | |||||||||||||||||||||||||
| 2877 | return never executed: tabWidth;return tabWidth;never executed: return tabWidth; | 0 | ||||||||||||||||||||||||
| 2878 | } | - | ||||||||||||||||||||||||
| 2879 | - | |||||||||||||||||||||||||
| 2880 | namespace { | - | ||||||||||||||||||||||||
| 2881 | class FormatRangeComparatorByStart { | - | ||||||||||||||||||||||||
| 2882 | const QVector<QTextLayout::FormatRange> &list; | - | ||||||||||||||||||||||||
| 2883 | public: | - | ||||||||||||||||||||||||
| 2884 | FormatRangeComparatorByStart(const QVector<QTextLayout::FormatRange> &list) : list(list) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2885 | bool operator()(int a, int b) { | - | ||||||||||||||||||||||||
| 2886 | return never executed: list.at(a).start < list.at(b).start;return list.at(a).start < list.at(b).start;never executed: return list.at(a).start < list.at(b).start; | 0 | ||||||||||||||||||||||||
| 2887 | } | - | ||||||||||||||||||||||||
| 2888 | }; | - | ||||||||||||||||||||||||
| 2889 | class FormatRangeComparatorByEnd { | - | ||||||||||||||||||||||||
| 2890 | const QVector<QTextLayout::FormatRange> &list; | - | ||||||||||||||||||||||||
| 2891 | public: | - | ||||||||||||||||||||||||
| 2892 | FormatRangeComparatorByEnd(const QVector<QTextLayout::FormatRange> &list) : list(list) { } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2893 | bool operator()(int a, int b) { | - | ||||||||||||||||||||||||
| 2894 | return never executed: list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;never executed: return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length; | 0 | ||||||||||||||||||||||||
| 2895 | } | - | ||||||||||||||||||||||||
| 2896 | }; | - | ||||||||||||||||||||||||
| 2897 | } | - | ||||||||||||||||||||||||
| 2898 | - | |||||||||||||||||||||||||
| 2899 | void QTextEngine::resolveFormats() const | - | ||||||||||||||||||||||||
| 2900 | { | - | ||||||||||||||||||||||||
| 2901 | if (!specialData
| 0 | ||||||||||||||||||||||||
| 2902 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2903 | ((!(specialData->resolvedFormats.isEmpty())) ? qt_assert("specialData->resolvedFormats.isEmpty()",__FILE__,3022) : qt_noop()); | - | ||||||||||||||||||||||||
| 2904 | - | |||||||||||||||||||||||||
| 2905 | QTextFormatCollection *collection = formatCollection(); | - | ||||||||||||||||||||||||
| 2906 | - | |||||||||||||||||||||||||
| 2907 | QVector<QTextCharFormat> resolvedFormats(layoutData->items.count()); | - | ||||||||||||||||||||||||
| 2908 | - | |||||||||||||||||||||||||
| 2909 | QVarLengthArray<int, 64> formatsSortedByStart; | - | ||||||||||||||||||||||||
| 2910 | formatsSortedByStart.reserve(specialData->formats.size()); | - | ||||||||||||||||||||||||
| 2911 | for (int i = 0; i < specialData->formats.size()
| 0 | ||||||||||||||||||||||||
| 2912 | if (specialData->formats.at(i).length >= 0
| 0 | ||||||||||||||||||||||||
| 2913 | formatsSortedByStart.append(i); never executed: formatsSortedByStart.append(i); | 0 | ||||||||||||||||||||||||
| 2914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2915 | QVarLengthArray<int, 64> formatsSortedByEnd = formatsSortedByStart; | - | ||||||||||||||||||||||||
| 2916 | std::sort(formatsSortedByStart.begin(), formatsSortedByStart.end(), | - | ||||||||||||||||||||||||
| 2917 | FormatRangeComparatorByStart(specialData->formats)); | - | ||||||||||||||||||||||||
| 2918 | std::sort(formatsSortedByEnd.begin(), formatsSortedByEnd.end(), | - | ||||||||||||||||||||||||
| 2919 | FormatRangeComparatorByEnd(specialData->formats)); | - | ||||||||||||||||||||||||
| 2920 | - | |||||||||||||||||||||||||
| 2921 | QVarLengthArray<int, 16> currentFormats; | - | ||||||||||||||||||||||||
| 2922 | const int *startIt = formatsSortedByStart.constBegin(); | - | ||||||||||||||||||||||||
| 2923 | const int *endIt = formatsSortedByEnd.constBegin(); | - | ||||||||||||||||||||||||
| 2924 | - | |||||||||||||||||||||||||
| 2925 | for (int i = 0; i < layoutData->items.count()
| 0 | ||||||||||||||||||||||||
| 2926 | const QScriptItem *si = &layoutData->items.at(i); | - | ||||||||||||||||||||||||
| 2927 | int end = si->position + length(si); | - | ||||||||||||||||||||||||
| 2928 | - | |||||||||||||||||||||||||
| 2929 | while (startIt != formatsSortedByStart.constEnd()
| 0 | ||||||||||||||||||||||||
| 2930 | specialData->formats.at(*startIt).start <= si->position
| 0 | ||||||||||||||||||||||||
| 2931 | currentFormats.insert(std::upper_bound(currentFormats.begin(), currentFormats.end(), *startIt), | - | ||||||||||||||||||||||||
| 2932 | *startIt); | - | ||||||||||||||||||||||||
| 2933 | ++startIt; | - | ||||||||||||||||||||||||
| 2934 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2935 | while (endIt != formatsSortedByEnd.constEnd()
| 0 | ||||||||||||||||||||||||
| 2936 | specialData->formats.at(*endIt).start + specialData->formats.at(*endIt).length < end
| 0 | ||||||||||||||||||||||||
| 2937 | int *currentFormatIterator = std::lower_bound(currentFormats.begin(), currentFormats.end(), *endIt); | - | ||||||||||||||||||||||||
| 2938 | if (*
| 0 | ||||||||||||||||||||||||
| 2939 | currentFormatIterator = currentFormats.end(); never executed: currentFormatIterator = currentFormats.end(); | 0 | ||||||||||||||||||||||||
| 2940 | currentFormats.remove(currentFormatIterator - currentFormats.begin()); | - | ||||||||||||||||||||||||
| 2941 | ++endIt; | - | ||||||||||||||||||||||||
| 2942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2943 | - | |||||||||||||||||||||||||
| 2944 | QTextCharFormat &format = resolvedFormats[i]; | - | ||||||||||||||||||||||||
| 2945 | if (block.docHandle()
| 0 | ||||||||||||||||||||||||
| 2946 | - | |||||||||||||||||||||||||
| 2947 | - | |||||||||||||||||||||||||
| 2948 | format = collection->charFormat(formatIndex(si)); | - | ||||||||||||||||||||||||
| 2949 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2950 | if (!currentFormats.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2951 | for (int cur : currentFormats) { | - | ||||||||||||||||||||||||
| 2952 | const QTextLayout::FormatRange &range = specialData->formats.at(cur); | - | ||||||||||||||||||||||||
| 2953 | ((!(range.start <= si->position && range.start + range.length >= end)) ? qt_assert("range.start <= si->position && range.start + range.length >= end",__FILE__,3072) : qt_noop()); | - | ||||||||||||||||||||||||
| 2954 | format.merge(range.format); | - | ||||||||||||||||||||||||
| 2955 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2956 | format = collection->charFormat(collection->indexForFormat(format)); | - | ||||||||||||||||||||||||
| 2957 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2958 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2959 | - | |||||||||||||||||||||||||
| 2960 | specialData->resolvedFormats = resolvedFormats; | - | ||||||||||||||||||||||||
| 2961 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2962 | - | |||||||||||||||||||||||||
| 2963 | QFixed QTextEngine::leadingSpaceWidth(const QScriptLine &line) | - | ||||||||||||||||||||||||
| 2964 | { | - | ||||||||||||||||||||||||
| 2965 | if (!line.hasTrailingSpaces
| 0 | ||||||||||||||||||||||||
| 2966 | || (
| 0 | ||||||||||||||||||||||||
| 2967 | || !isRightToLeft()
| 0 | ||||||||||||||||||||||||
| 2968 | return never executed: QFixed();return QFixed();never executed: return QFixed(); | 0 | ||||||||||||||||||||||||
| 2969 | - | |||||||||||||||||||||||||
| 2970 | return never executed: width(line.from + line.length, line.trailingSpaces);return width(line.from + line.length, line.trailingSpaces);never executed: return width(line.from + line.length, line.trailingSpaces); | 0 | ||||||||||||||||||||||||
| 2971 | } | - | ||||||||||||||||||||||||
| 2972 | - | |||||||||||||||||||||||||
| 2973 | QFixed QTextEngine::alignLine(const QScriptLine &line) | - | ||||||||||||||||||||||||
| 2974 | { | - | ||||||||||||||||||||||||
| 2975 | QFixed x = 0; | - | ||||||||||||||||||||||||
| 2976 | justify(line); | - | ||||||||||||||||||||||||
| 2977 | - | |||||||||||||||||||||||||
| 2978 | if (!line.justified
| 0 | ||||||||||||||||||||||||
| 2979 | int align = option.alignment(); | - | ||||||||||||||||||||||||
| 2980 | if (align & Qt::AlignJustify
| 0 | ||||||||||||||||||||||||
| 2981 | align = Qt::AlignRight; never executed: align = Qt::AlignRight; | 0 | ||||||||||||||||||||||||
| 2982 | if (align & Qt::AlignRight
| 0 | ||||||||||||||||||||||||
| 2983 | x = line.width - (line.textAdvance); never executed: x = line.width - (line.textAdvance); | 0 | ||||||||||||||||||||||||
| 2984 | else if (align & Qt::AlignHCenter
| 0 | ||||||||||||||||||||||||
| 2985 | x = (line.width - line.textAdvance)/2; never executed: x = (line.width - line.textAdvance)/2; | 0 | ||||||||||||||||||||||||
| 2986 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2987 | return never executed: x;return x;never executed: return x; | 0 | ||||||||||||||||||||||||
| 2988 | } | - | ||||||||||||||||||||||||
| 2989 | - | |||||||||||||||||||||||||
| 2990 | QFixed QTextEngine::offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos) | - | ||||||||||||||||||||||||
| 2991 | { | - | ||||||||||||||||||||||||
| 2992 | unsigned short *logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 2993 | const QGlyphLayout &glyphs = shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 2994 | - | |||||||||||||||||||||||||
| 2995 | int offsetInCluster = 0; | - | ||||||||||||||||||||||||
| 2996 | for (int i = pos - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 2997 | if (logClusters[i] == glyph_pos
| 0 | ||||||||||||||||||||||||
| 2998 | offsetInCluster++; never executed: offsetInCluster++; | 0 | ||||||||||||||||||||||||
| 2999 | else | - | ||||||||||||||||||||||||
| 3000 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3001 | } | - | ||||||||||||||||||||||||
| 3002 | - | |||||||||||||||||||||||||
| 3003 | - | |||||||||||||||||||||||||
| 3004 | - | |||||||||||||||||||||||||
| 3005 | if (offsetInCluster > 0
| 0 | ||||||||||||||||||||||||
| 3006 | int clusterLength = 0; | - | ||||||||||||||||||||||||
| 3007 | for (int i = pos - offsetInCluster; i < max
| 0 | ||||||||||||||||||||||||
| 3008 | if (logClusters[i] == glyph_pos
| 0 | ||||||||||||||||||||||||
| 3009 | clusterLength++; never executed: clusterLength++; | 0 | ||||||||||||||||||||||||
| 3010 | else | - | ||||||||||||||||||||||||
| 3011 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3012 | } | - | ||||||||||||||||||||||||
| 3013 | if (clusterLength
| 0 | ||||||||||||||||||||||||
| 3014 | return never executed: glyphs.advances[glyph_pos] * offsetInCluster / clusterLength;return glyphs.advances[glyph_pos] * offsetInCluster / clusterLength;never executed: return glyphs.advances[glyph_pos] * offsetInCluster / clusterLength; | 0 | ||||||||||||||||||||||||
| 3015 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3016 | - | |||||||||||||||||||||||||
| 3017 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3018 | } | - | ||||||||||||||||||||||||
| 3019 | - | |||||||||||||||||||||||||
| 3020 | - | |||||||||||||||||||||||||
| 3021 | int QTextEngine::getClusterLength(unsigned short *logClusters, | - | ||||||||||||||||||||||||
| 3022 | const QCharAttributes *attributes, | - | ||||||||||||||||||||||||
| 3023 | int from, int to, int glyph_pos, int *start) | - | ||||||||||||||||||||||||
| 3024 | { | - | ||||||||||||||||||||||||
| 3025 | int clusterLength = 0; | - | ||||||||||||||||||||||||
| 3026 | for (int i = from; i < to
| 0 | ||||||||||||||||||||||||
| 3027 | if (logClusters[i] == glyph_pos
| 0 | ||||||||||||||||||||||||
| 3028 | if (*
| 0 | ||||||||||||||||||||||||
| 3029 | * never executed: start = i;*start = i;never executed: *start = i; | 0 | ||||||||||||||||||||||||
| 3030 | clusterLength++; | - | ||||||||||||||||||||||||
| 3031 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3032 | else if (clusterLength
| 0 | ||||||||||||||||||||||||
| 3033 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3034 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3035 | return never executed: clusterLength;return clusterLength;never executed: return clusterLength; | 0 | ||||||||||||||||||||||||
| 3036 | } | - | ||||||||||||||||||||||||
| 3037 | - | |||||||||||||||||||||||||
| 3038 | int QTextEngine::positionInLigature(const QScriptItem *si, int end, | - | ||||||||||||||||||||||||
| 3039 | QFixed x, QFixed edge, int glyph_pos, | - | ||||||||||||||||||||||||
| 3040 | bool cursorOnCharacter) | - | ||||||||||||||||||||||||
| 3041 | { | - | ||||||||||||||||||||||||
| 3042 | unsigned short *logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 3043 | int clusterStart = -1; | - | ||||||||||||||||||||||||
| 3044 | int clusterLength = 0; | - | ||||||||||||||||||||||||
| 3045 | - | |||||||||||||||||||||||||
| 3046 | if (si->analysis.script != QChar::Script_Common
| 0 | ||||||||||||||||||||||||
| 3047 | si->analysis.script != QChar::Script_Greek
| 0 | ||||||||||||||||||||||||
| 3048 | if (glyph_pos == -1
| 0 | ||||||||||||||||||||||||
| 3049 | return never executed: si->position + end;return si->position + end;never executed: return si->position + end; | 0 | ||||||||||||||||||||||||
| 3050 | else { | - | ||||||||||||||||||||||||
| 3051 | int i; | - | ||||||||||||||||||||||||
| 3052 | for (i = 0; i < end
| 0 | ||||||||||||||||||||||||
| 3053 | if (logClusters[i] == glyph_pos
| 0 | ||||||||||||||||||||||||
| 3054 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3055 | return never executed: si->position + i;return si->position + i;never executed: return si->position + i; | 0 | ||||||||||||||||||||||||
| 3056 | } | - | ||||||||||||||||||||||||
| 3057 | } | - | ||||||||||||||||||||||||
| 3058 | - | |||||||||||||||||||||||||
| 3059 | if (glyph_pos == -1
| 0 | ||||||||||||||||||||||||
| 3060 | glyph_pos = logClusters[end - 1]; never executed: glyph_pos = logClusters[end - 1]; | 0 | ||||||||||||||||||||||||
| 3061 | else { | - | ||||||||||||||||||||||||
| 3062 | if (x <= edge
| 0 | ||||||||||||||||||||||||
| 3063 | glyph_pos--; never executed: glyph_pos--; | 0 | ||||||||||||||||||||||||
| 3064 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3065 | - | |||||||||||||||||||||||||
| 3066 | const QCharAttributes *attrs = attributes() + si->position; | - | ||||||||||||||||||||||||
| 3067 | logClusters = this->logClusters(si); | - | ||||||||||||||||||||||||
| 3068 | clusterLength = getClusterLength(logClusters, attrs, 0, end, glyph_pos, &clusterStart); | - | ||||||||||||||||||||||||
| 3069 | - | |||||||||||||||||||||||||
| 3070 | if (clusterLength
| 0 | ||||||||||||||||||||||||
| 3071 | const QGlyphLayout &glyphs = shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 3072 | QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos); | - | ||||||||||||||||||||||||
| 3073 | - | |||||||||||||||||||||||||
| 3074 | QFixed perItemWidth = glyphWidth / clusterLength; | - | ||||||||||||||||||||||||
| 3075 | if (perItemWidth <= 0
| 0 | ||||||||||||||||||||||||
| 3076 | return never executed: si->position + clusterStart;return si->position + clusterStart;never executed: return si->position + clusterStart; | 0 | ||||||||||||||||||||||||
| 3077 | QFixed left = x > edge
| 0 | ||||||||||||||||||||||||
| 3078 | int n = ((x - left) / perItemWidth).floor().toInt(); | - | ||||||||||||||||||||||||
| 3079 | QFixed dist = x - left - n * perItemWidth; | - | ||||||||||||||||||||||||
| 3080 | int closestItem = dist > (perItemWidth / 2)
| 0 | ||||||||||||||||||||||||
| 3081 | if (cursorOnCharacter
| 0 | ||||||||||||||||||||||||
| 3082 | closestItem--; never executed: closestItem--; | 0 | ||||||||||||||||||||||||
| 3083 | int pos = clusterStart + closestItem; | - | ||||||||||||||||||||||||
| 3084 | - | |||||||||||||||||||||||||
| 3085 | while (pos < end
| 0 | ||||||||||||||||||||||||
| 3086 | pos++; never executed: pos++; | 0 | ||||||||||||||||||||||||
| 3087 | return never executed: si->position + pos;return si->position + pos;never executed: return si->position + pos; | 0 | ||||||||||||||||||||||||
| 3088 | } | - | ||||||||||||||||||||||||
| 3089 | return never executed: si->position + end;return si->position + end;never executed: return si->position + end; | 0 | ||||||||||||||||||||||||
| 3090 | } | - | ||||||||||||||||||||||||
| 3091 | - | |||||||||||||||||||||||||
| 3092 | int QTextEngine::previousLogicalPosition(int oldPos) const | - | ||||||||||||||||||||||||
| 3093 | { | - | ||||||||||||||||||||||||
| 3094 | const QCharAttributes *attrs = attributes(); | - | ||||||||||||||||||||||||
| 3095 | int len = block.isValid()
| 0 | ||||||||||||||||||||||||
| 3096 | : layoutData->string.length(); | - | ||||||||||||||||||||||||
| 3097 | ((!(len <= layoutData->string.length())) ? qt_assert("len <= layoutData->string.length()",__FILE__,3216) : qt_noop()); | - | ||||||||||||||||||||||||
| 3098 | if (!attrs
| 0 | ||||||||||||||||||||||||
| 3099 | return never executed: oldPos;return oldPos;never executed: return oldPos; | 0 | ||||||||||||||||||||||||
| 3100 | - | |||||||||||||||||||||||||
| 3101 | oldPos--; | - | ||||||||||||||||||||||||
| 3102 | while (oldPos
| 0 | ||||||||||||||||||||||||
| 3103 | oldPos--; never executed: oldPos--; | 0 | ||||||||||||||||||||||||
| 3104 | return never executed: oldPos;return oldPos;never executed: return oldPos; | 0 | ||||||||||||||||||||||||
| 3105 | } | - | ||||||||||||||||||||||||
| 3106 | - | |||||||||||||||||||||||||
| 3107 | int QTextEngine::nextLogicalPosition(int oldPos) const | - | ||||||||||||||||||||||||
| 3108 | { | - | ||||||||||||||||||||||||
| 3109 | const QCharAttributes *attrs = attributes(); | - | ||||||||||||||||||||||||
| 3110 | int len = block.isValid()
| 0 | ||||||||||||||||||||||||
| 3111 | : layoutData->string.length(); | - | ||||||||||||||||||||||||
| 3112 | ((!(len <= layoutData->string.length())) ? qt_assert("len <= layoutData->string.length()",__FILE__,3231) : qt_noop()); | - | ||||||||||||||||||||||||
| 3113 | if (!attrs
| 0 | ||||||||||||||||||||||||
| 3114 | return never executed: oldPos;return oldPos;never executed: return oldPos; | 0 | ||||||||||||||||||||||||
| 3115 | - | |||||||||||||||||||||||||
| 3116 | oldPos++; | - | ||||||||||||||||||||||||
| 3117 | while (oldPos < len
| 0 | ||||||||||||||||||||||||
| 3118 | oldPos++; never executed: oldPos++; | 0 | ||||||||||||||||||||||||
| 3119 | return never executed: oldPos;return oldPos;never executed: return oldPos; | 0 | ||||||||||||||||||||||||
| 3120 | } | - | ||||||||||||||||||||||||
| 3121 | - | |||||||||||||||||||||||||
| 3122 | int QTextEngine::lineNumberForTextPosition(int pos) | - | ||||||||||||||||||||||||
| 3123 | { | - | ||||||||||||||||||||||||
| 3124 | if (!layoutData
| 0 | ||||||||||||||||||||||||
| 3125 | itemize(); never executed: itemize(); | 0 | ||||||||||||||||||||||||
| 3126 | if (pos == layoutData->string.length()
| 0 | ||||||||||||||||||||||||
| 3127 | return never executed: lines.size() - 1;return lines.size() - 1;never executed: return lines.size() - 1; | 0 | ||||||||||||||||||||||||
| 3128 | for (int i = 0; i < lines.size()
| 0 | ||||||||||||||||||||||||
| 3129 | const QScriptLine& line = lines[i]; | - | ||||||||||||||||||||||||
| 3130 | if (line.from + line.length + line.trailingSpaces > pos
| 0 | ||||||||||||||||||||||||
| 3131 | return never executed: i;return i;never executed: return i; | 0 | ||||||||||||||||||||||||
| 3132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3133 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 3134 | } | - | ||||||||||||||||||||||||
| 3135 | - | |||||||||||||||||||||||||
| 3136 | void QTextEngine::insertionPointsForLine(int lineNum, QVector<int> &insertionPoints) | - | ||||||||||||||||||||||||
| 3137 | { | - | ||||||||||||||||||||||||
| 3138 | QTextLineItemIterator iterator(this, lineNum); | - | ||||||||||||||||||||||||
| 3139 | - | |||||||||||||||||||||||||
| 3140 | insertionPoints.reserve(iterator.line.length); | - | ||||||||||||||||||||||||
| 3141 | - | |||||||||||||||||||||||||
| 3142 | bool lastLine = lineNum >= lines.size() - 1; | - | ||||||||||||||||||||||||
| 3143 | - | |||||||||||||||||||||||||
| 3144 | while (!iterator.atEnd()
| 0 | ||||||||||||||||||||||||
| 3145 | const QScriptItem &si = iterator.next(); | - | ||||||||||||||||||||||||
| 3146 | - | |||||||||||||||||||||||||
| 3147 | int end = iterator.itemEnd; | - | ||||||||||||||||||||||||
| 3148 | if (lastLine
| 0 | ||||||||||||||||||||||||
| 3149 | ++ never executed: end;++end;never executed: ++end; | 0 | ||||||||||||||||||||||||
| 3150 | if (si.analysis.bidiLevel % 2
| 0 | ||||||||||||||||||||||||
| 3151 | for (int i = end - 1; i >= iterator.itemStart
| 0 | ||||||||||||||||||||||||
| 3152 | insertionPoints.push_back(i); never executed: insertionPoints.push_back(i); | 0 | ||||||||||||||||||||||||
| 3153 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3154 | for (int i = iterator.itemStart; i < end
| 0 | ||||||||||||||||||||||||
| 3155 | insertionPoints.push_back(i); never executed: insertionPoints.push_back(i); | 0 | ||||||||||||||||||||||||
| 3156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3157 | } | - | ||||||||||||||||||||||||
| 3158 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3159 | - | |||||||||||||||||||||||||
| 3160 | int QTextEngine::endOfLine(int lineNum) | - | ||||||||||||||||||||||||
| 3161 | { | - | ||||||||||||||||||||||||
| 3162 | QVector<int> insertionPoints; | - | ||||||||||||||||||||||||
| 3163 | insertionPointsForLine(lineNum, insertionPoints); | - | ||||||||||||||||||||||||
| 3164 | - | |||||||||||||||||||||||||
| 3165 | if (insertionPoints.size() > 0
| 0 | ||||||||||||||||||||||||
| 3166 | return never executed: insertionPoints.constLast();return insertionPoints.constLast();never executed: return insertionPoints.constLast(); | 0 | ||||||||||||||||||||||||
| 3167 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3168 | } | - | ||||||||||||||||||||||||
| 3169 | - | |||||||||||||||||||||||||
| 3170 | int QTextEngine::beginningOfLine(int lineNum) | - | ||||||||||||||||||||||||
| 3171 | { | - | ||||||||||||||||||||||||
| 3172 | QVector<int> insertionPoints; | - | ||||||||||||||||||||||||
| 3173 | insertionPointsForLine(lineNum, insertionPoints); | - | ||||||||||||||||||||||||
| 3174 | - | |||||||||||||||||||||||||
| 3175 | if (insertionPoints.size() > 0
| 0 | ||||||||||||||||||||||||
| 3176 | return never executed: insertionPoints.constFirst();return insertionPoints.constFirst();never executed: return insertionPoints.constFirst(); | 0 | ||||||||||||||||||||||||
| 3177 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3178 | } | - | ||||||||||||||||||||||||
| 3179 | - | |||||||||||||||||||||||||
| 3180 | int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation op) | - | ||||||||||||||||||||||||
| 3181 | { | - | ||||||||||||||||||||||||
| 3182 | itemize(); | - | ||||||||||||||||||||||||
| 3183 | - | |||||||||||||||||||||||||
| 3184 | bool moveRight = (op == QTextCursor::Right); | - | ||||||||||||||||||||||||
| 3185 | bool alignRight = isRightToLeft(); | - | ||||||||||||||||||||||||
| 3186 | if (!layoutData->hasBidi
| 0 | ||||||||||||||||||||||||
| 3187 | return never executed: moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);never executed: return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos); | 0 | ||||||||||||||||||||||||
| 3188 | - | |||||||||||||||||||||||||
| 3189 | int lineNum = lineNumberForTextPosition(pos); | - | ||||||||||||||||||||||||
| 3190 | if (lineNum < 0
| 0 | ||||||||||||||||||||||||
| 3191 | return never executed: pos;return pos;never executed: return pos; | 0 | ||||||||||||||||||||||||
| 3192 | - | |||||||||||||||||||||||||
| 3193 | QVector<int> insertionPoints; | - | ||||||||||||||||||||||||
| 3194 | insertionPointsForLine(lineNum, insertionPoints); | - | ||||||||||||||||||||||||
| 3195 | int i, max = insertionPoints.size(); | - | ||||||||||||||||||||||||
| 3196 | for (i = 0; i < max
| 0 | ||||||||||||||||||||||||
| 3197 | if (pos == insertionPoints[i]
| 0 | ||||||||||||||||||||||||
| 3198 | if (moveRight
| 0 | ||||||||||||||||||||||||
| 3199 | if (i + 1 < max
| 0 | ||||||||||||||||||||||||
| 3200 | return never executed: insertionPoints[i + 1];return insertionPoints[i + 1];never executed: return insertionPoints[i + 1]; | 0 | ||||||||||||||||||||||||
| 3201 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3202 | if (i > 0
| 0 | ||||||||||||||||||||||||
| 3203 | return never executed: insertionPoints[i - 1];return insertionPoints[i - 1];never executed: return insertionPoints[i - 1]; | 0 | ||||||||||||||||||||||||
| 3204 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3205 | - | |||||||||||||||||||||||||
| 3206 | if (moveRight ^ alignRight
| 0 | ||||||||||||||||||||||||
| 3207 | if (lineNum + 1 < lines.size()
| 0 | ||||||||||||||||||||||||
| 3208 | return never executed: alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);return alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1);never executed: return alignRight ? endOfLine(lineNum + 1) : beginningOfLine(lineNum + 1); | 0 | ||||||||||||||||||||||||
| 3209 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3210 | else { | - | ||||||||||||||||||||||||
| 3211 | if (lineNum > 0
| 0 | ||||||||||||||||||||||||
| 3212 | return never executed: alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);never executed: return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1); | 0 | ||||||||||||||||||||||||
| 3213 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3214 | - | |||||||||||||||||||||||||
| 3215 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3216 | } | - | ||||||||||||||||||||||||
| 3217 | - | |||||||||||||||||||||||||
| 3218 | return never executed: pos;return pos;never executed: return pos; | 0 | ||||||||||||||||||||||||
| 3219 | } | - | ||||||||||||||||||||||||
| 3220 | - | |||||||||||||||||||||||||
| 3221 | void QTextEngine::addItemDecoration(QPainter *painter, const QLineF &line, ItemDecorationList *decorationList) | - | ||||||||||||||||||||||||
| 3222 | { | - | ||||||||||||||||||||||||
| 3223 | if (delayDecorations
| 0 | ||||||||||||||||||||||||
| 3224 | decorationList->append(ItemDecoration(line.x1(), line.x2(), line.y1(), painter->pen())); | - | ||||||||||||||||||||||||
| 3225 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3226 | painter->drawLine(line); | - | ||||||||||||||||||||||||
| 3227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3228 | } | - | ||||||||||||||||||||||||
| 3229 | - | |||||||||||||||||||||||||
| 3230 | void QTextEngine::addUnderline(QPainter *painter, const QLineF &line) | - | ||||||||||||||||||||||||
| 3231 | { | - | ||||||||||||||||||||||||
| 3232 | - | |||||||||||||||||||||||||
| 3233 | addItemDecoration(painter, line, &underlineList); | - | ||||||||||||||||||||||||
| 3234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3235 | - | |||||||||||||||||||||||||
| 3236 | void QTextEngine::addStrikeOut(QPainter *painter, const QLineF &line) | - | ||||||||||||||||||||||||
| 3237 | { | - | ||||||||||||||||||||||||
| 3238 | addItemDecoration(painter, line, &strikeOutList); | - | ||||||||||||||||||||||||
| 3239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3240 | - | |||||||||||||||||||||||||
| 3241 | void QTextEngine::addOverline(QPainter *painter, const QLineF &line) | - | ||||||||||||||||||||||||
| 3242 | { | - | ||||||||||||||||||||||||
| 3243 | addItemDecoration(painter, line, &overlineList); | - | ||||||||||||||||||||||||
| 3244 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3245 | - | |||||||||||||||||||||||||
| 3246 | void QTextEngine::drawItemDecorationList(QPainter *painter, const ItemDecorationList &decorationList) | - | ||||||||||||||||||||||||
| 3247 | { | - | ||||||||||||||||||||||||
| 3248 | - | |||||||||||||||||||||||||
| 3249 | if (decorationList.isEmpty()
| 0 | ||||||||||||||||||||||||
| 3250 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3251 | - | |||||||||||||||||||||||||
| 3252 | for (const ItemDecoration &decoration : decorationList) { | - | ||||||||||||||||||||||||
| 3253 | painter->setPen(decoration.pen); | - | ||||||||||||||||||||||||
| 3254 | painter->drawLine(QLineF(decoration.x1, decoration.y, decoration.x2, decoration.y)); | - | ||||||||||||||||||||||||
| 3255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3257 | - | |||||||||||||||||||||||||
| 3258 | void QTextEngine::drawDecorations(QPainter *painter) | - | ||||||||||||||||||||||||
| 3259 | { | - | ||||||||||||||||||||||||
| 3260 | QPen oldPen = painter->pen(); | - | ||||||||||||||||||||||||
| 3261 | - | |||||||||||||||||||||||||
| 3262 | bool wasCompatiblePainting = painter->renderHints() | - | ||||||||||||||||||||||||
| 3263 | & QPainter::Qt4CompatiblePainting; | - | ||||||||||||||||||||||||
| 3264 | - | |||||||||||||||||||||||||
| 3265 | if (wasCompatiblePainting
| 0 | ||||||||||||||||||||||||
| 3266 | painter->setRenderHint(QPainter::Qt4CompatiblePainting, false); never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting, false); | 0 | ||||||||||||||||||||||||
| 3267 | - | |||||||||||||||||||||||||
| 3268 | adjustUnderlines(); | - | ||||||||||||||||||||||||
| 3269 | drawItemDecorationList(painter, underlineList); | - | ||||||||||||||||||||||||
| 3270 | drawItemDecorationList(painter, strikeOutList); | - | ||||||||||||||||||||||||
| 3271 | drawItemDecorationList(painter, overlineList); | - | ||||||||||||||||||||||||
| 3272 | - | |||||||||||||||||||||||||
| 3273 | clearDecorations(); | - | ||||||||||||||||||||||||
| 3274 | - | |||||||||||||||||||||||||
| 3275 | if (wasCompatiblePainting
| 0 | ||||||||||||||||||||||||
| 3276 | painter->setRenderHint(QPainter::Qt4CompatiblePainting); never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting); | 0 | ||||||||||||||||||||||||
| 3277 | - | |||||||||||||||||||||||||
| 3278 | painter->setPen(oldPen); | - | ||||||||||||||||||||||||
| 3279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3280 | - | |||||||||||||||||||||||||
| 3281 | void QTextEngine::clearDecorations() | - | ||||||||||||||||||||||||
| 3282 | { | - | ||||||||||||||||||||||||
| 3283 | underlineList.clear(); | - | ||||||||||||||||||||||||
| 3284 | strikeOutList.clear(); | - | ||||||||||||||||||||||||
| 3285 | overlineList.clear(); | - | ||||||||||||||||||||||||
| 3286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3287 | - | |||||||||||||||||||||||||
| 3288 | void QTextEngine::adjustUnderlines() | - | ||||||||||||||||||||||||
| 3289 | { | - | ||||||||||||||||||||||||
| 3290 | - | |||||||||||||||||||||||||
| 3291 | if (underlineList.isEmpty()
| 0 | ||||||||||||||||||||||||
| 3292 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3293 | - | |||||||||||||||||||||||||
| 3294 | ItemDecorationList::iterator start = underlineList.begin(); | - | ||||||||||||||||||||||||
| 3295 | ItemDecorationList::iterator end = underlineList.end(); | - | ||||||||||||||||||||||||
| 3296 | ItemDecorationList::iterator it = start; | - | ||||||||||||||||||||||||
| 3297 | qreal underlinePos = start->y; | - | ||||||||||||||||||||||||
| 3298 | qreal penWidth = start->pen.widthF(); | - | ||||||||||||||||||||||||
| 3299 | qreal lastLineEnd = start->x1; | - | ||||||||||||||||||||||||
| 3300 | - | |||||||||||||||||||||||||
| 3301 | while (it != end
| 0 | ||||||||||||||||||||||||
| 3302 | if (qFuzzyCompare(lastLineEnd, it->x1)
| 0 | ||||||||||||||||||||||||
| 3303 | underlinePos = qMax(underlinePos, it->y); | - | ||||||||||||||||||||||||
| 3304 | penWidth = qMax(penWidth, it->pen.widthF()); | - | ||||||||||||||||||||||||
| 3305 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3306 | adjustUnderlines(start, it, underlinePos, penWidth); | - | ||||||||||||||||||||||||
| 3307 | start = it; | - | ||||||||||||||||||||||||
| 3308 | underlinePos = start->y; | - | ||||||||||||||||||||||||
| 3309 | penWidth = start->pen.widthF(); | - | ||||||||||||||||||||||||
| 3310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3311 | lastLineEnd = it->x2; | - | ||||||||||||||||||||||||
| 3312 | ++it; | - | ||||||||||||||||||||||||
| 3313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3314 | - | |||||||||||||||||||||||||
| 3315 | adjustUnderlines(start, end, underlinePos, penWidth); | - | ||||||||||||||||||||||||
| 3316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3317 | - | |||||||||||||||||||||||||
| 3318 | void QTextEngine::adjustUnderlines(ItemDecorationList::iterator start, | - | ||||||||||||||||||||||||
| 3319 | ItemDecorationList::iterator end, | - | ||||||||||||||||||||||||
| 3320 | qreal underlinePos, qreal penWidth) | - | ||||||||||||||||||||||||
| 3321 | { | - | ||||||||||||||||||||||||
| 3322 | for (ItemDecorationList::iterator it = start; it != end
| 0 | ||||||||||||||||||||||||
| 3323 | it->y = underlinePos; | - | ||||||||||||||||||||||||
| 3324 | it->pen.setWidthF(penWidth); | - | ||||||||||||||||||||||||
| 3325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3326 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3327 | - | |||||||||||||||||||||||||
| 3328 | QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f) | - | ||||||||||||||||||||||||
| 3329 | : QTextEngine(string, f), | - | ||||||||||||||||||||||||
| 3330 | _layoutData(string, _memory, MemSize) | - | ||||||||||||||||||||||||
| 3331 | { | - | ||||||||||||||||||||||||
| 3332 | stackEngine = true; | - | ||||||||||||||||||||||||
| 3333 | layoutData = &_layoutData; | - | ||||||||||||||||||||||||
| 3334 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3335 | - | |||||||||||||||||||||||||
| 3336 | QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format) | - | ||||||||||||||||||||||||
| 3337 | : justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), | - | ||||||||||||||||||||||||
| 3338 | num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0) | - | ||||||||||||||||||||||||
| 3339 | { | - | ||||||||||||||||||||||||
| 3340 | f = font; | - | ||||||||||||||||||||||||
| 3341 | fontEngine = f->d->engineForScript(si.analysis.script); | - | ||||||||||||||||||||||||
| 3342 | ((!(fontEngine)) ? qt_assert("fontEngine",__FILE__,3461) : qt_noop()); | - | ||||||||||||||||||||||||
| 3343 | - | |||||||||||||||||||||||||
| 3344 | initWithScriptItem(si); | - | ||||||||||||||||||||||||
| 3345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3346 | - | |||||||||||||||||||||||||
| 3347 | QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) | - | ||||||||||||||||||||||||
| 3348 | : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), | - | ||||||||||||||||||||||||
| 3349 | num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe) | - | ||||||||||||||||||||||||
| 3350 | { | - | ||||||||||||||||||||||||
| 3351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3352 | - | |||||||||||||||||||||||||
| 3353 | - | |||||||||||||||||||||||||
| 3354 | void QTextItemInt::initWithScriptItem(const QScriptItem &si) | - | ||||||||||||||||||||||||
| 3355 | { | - | ||||||||||||||||||||||||
| 3356 | - | |||||||||||||||||||||||||
| 3357 | - | |||||||||||||||||||||||||
| 3358 | flags = 0; | - | ||||||||||||||||||||||||
| 3359 | if (si.analysis.bidiLevel %2
| 0 | ||||||||||||||||||||||||
| 3360 | flags |= QTextItem::RightToLeft; never executed: flags |= QTextItem::RightToLeft; | 0 | ||||||||||||||||||||||||
| 3361 | ascent = si.ascent; | - | ||||||||||||||||||||||||
| 3362 | descent = si.descent; | - | ||||||||||||||||||||||||
| 3363 | - | |||||||||||||||||||||||||
| 3364 | if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)
| 0 | ||||||||||||||||||||||||
| 3365 | underlineStyle = charFormat.underlineStyle(); | - | ||||||||||||||||||||||||
| 3366 | } never executed: else if (charFormat.boolProperty(QTextFormat::FontUnderline)end of block
| 0 | ||||||||||||||||||||||||
| 3367 | || f->d->underline
| 0 | ||||||||||||||||||||||||
| 3368 | underlineStyle = QTextCharFormat::SingleUnderline; | - | ||||||||||||||||||||||||
| 3369 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3370 | - | |||||||||||||||||||||||||
| 3371 | - | |||||||||||||||||||||||||
| 3372 | if (underlineStyle == QTextCharFormat::SingleUnderline
| 0 | ||||||||||||||||||||||||
| 3373 | flags |= QTextItem::Underline; never executed: flags |= QTextItem::Underline; | 0 | ||||||||||||||||||||||||
| 3374 | - | |||||||||||||||||||||||||
| 3375 | if (f->d->overline
| 0 | ||||||||||||||||||||||||
| 3376 | flags |= QTextItem::Overline; never executed: flags |= QTextItem::Overline; | 0 | ||||||||||||||||||||||||
| 3377 | if (f->d->strikeOut
| 0 | ||||||||||||||||||||||||
| 3378 | flags |= QTextItem::StrikeOut; never executed: flags |= QTextItem::StrikeOut; | 0 | ||||||||||||||||||||||||
| 3379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3380 | - | |||||||||||||||||||||||||
| 3381 | QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const | - | ||||||||||||||||||||||||
| 3382 | { | - | ||||||||||||||||||||||||
| 3383 | QTextItemInt ti = *this; | - | ||||||||||||||||||||||||
| 3384 | const int end = firstGlyphIndex + numGlyphs; | - | ||||||||||||||||||||||||
| 3385 | ti.glyphs = glyphs.mid(firstGlyphIndex, numGlyphs); | - | ||||||||||||||||||||||||
| 3386 | ti.fontEngine = fontEngine; | - | ||||||||||||||||||||||||
| 3387 | - | |||||||||||||||||||||||||
| 3388 | if (logClusters
| 0 | ||||||||||||||||||||||||
| 3389 | const int logClusterOffset = logClusters[0]; | - | ||||||||||||||||||||||||
| 3390 | while (logClusters[ti.chars - chars] - logClusterOffset < firstGlyphIndex
| 0 | ||||||||||||||||||||||||
| 3391 | ++ never executed: ti.chars;++ti.chars;never executed: ++ti.chars; | 0 | ||||||||||||||||||||||||
| 3392 | - | |||||||||||||||||||||||||
| 3393 | ti.logClusters += (ti.chars - chars); | - | ||||||||||||||||||||||||
| 3394 | - | |||||||||||||||||||||||||
| 3395 | ti.num_chars = 0; | - | ||||||||||||||||||||||||
| 3396 | int char_start = ti.chars - chars; | - | ||||||||||||||||||||||||
| 3397 | while (char_start + ti.num_chars < num_chars
| 0 | ||||||||||||||||||||||||
| 3398 | ++ never executed: ti.num_chars;++ti.num_chars;never executed: ++ti.num_chars; | 0 | ||||||||||||||||||||||||
| 3399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3400 | return never executed: ti;return ti;never executed: return ti; | 0 | ||||||||||||||||||||||||
| 3401 | } | - | ||||||||||||||||||||||||
| 3402 | - | |||||||||||||||||||||||||
| 3403 | - | |||||||||||||||||||||||||
| 3404 | QTransform qt_true_matrix(qreal w, qreal h, QTransform x) | - | ||||||||||||||||||||||||
| 3405 | { | - | ||||||||||||||||||||||||
| 3406 | QRectF rect = x.mapRect(QRectF(0, 0, w, h)); | - | ||||||||||||||||||||||||
| 3407 | return never executed: x * QTransform::fromTranslate(-rect.x(), -rect.y());return x * QTransform::fromTranslate(-rect.x(), -rect.y());never executed: return x * QTransform::fromTranslate(-rect.x(), -rect.y()); | 0 | ||||||||||||||||||||||||
| 3408 | } | - | ||||||||||||||||||||||||
| 3409 | - | |||||||||||||||||||||||||
| 3410 | - | |||||||||||||||||||||||||
| 3411 | glyph_metrics_t glyph_metrics_t::transformed(const QTransform &matrix) const | - | ||||||||||||||||||||||||
| 3412 | { | - | ||||||||||||||||||||||||
| 3413 | if (matrix.type() < QTransform::TxTranslate
| 0 | ||||||||||||||||||||||||
| 3414 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||||||||
| 3415 | - | |||||||||||||||||||||||||
| 3416 | glyph_metrics_t m = *this; | - | ||||||||||||||||||||||||
| 3417 | - | |||||||||||||||||||||||||
| 3418 | qreal w = width.toReal(); | - | ||||||||||||||||||||||||
| 3419 | qreal h = height.toReal(); | - | ||||||||||||||||||||||||
| 3420 | QTransform xform = qt_true_matrix(w, h, matrix); | - | ||||||||||||||||||||||||
| 3421 | - | |||||||||||||||||||||||||
| 3422 | QRectF rect(0, 0, w, h); | - | ||||||||||||||||||||||||
| 3423 | rect = xform.mapRect(rect); | - | ||||||||||||||||||||||||
| 3424 | m.width = QFixed::fromReal(rect.width()); | - | ||||||||||||||||||||||||
| 3425 | m.height = QFixed::fromReal(rect.height()); | - | ||||||||||||||||||||||||
| 3426 | - | |||||||||||||||||||||||||
| 3427 | QLineF l = xform.map(QLineF(x.toReal(), y.toReal(), xoff.toReal(), yoff.toReal())); | - | ||||||||||||||||||||||||
| 3428 | - | |||||||||||||||||||||||||
| 3429 | m.x = QFixed::fromReal(l.x1()); | - | ||||||||||||||||||||||||
| 3430 | m.y = QFixed::fromReal(l.y1()); | - | ||||||||||||||||||||||||
| 3431 | - | |||||||||||||||||||||||||
| 3432 | - | |||||||||||||||||||||||||
| 3433 | m.xoff = QFixed::fromReal(l.dx()); | - | ||||||||||||||||||||||||
| 3434 | m.yoff = QFixed::fromReal(l.dy()); | - | ||||||||||||||||||||||||
| 3435 | - | |||||||||||||||||||||||||
| 3436 | return never executed: m;return m;never executed: return m; | 0 | ||||||||||||||||||||||||
| 3437 | } | - | ||||||||||||||||||||||||
| 3438 | - | |||||||||||||||||||||||||
| 3439 | QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int _lineNum, const QPointF &pos, | - | ||||||||||||||||||||||||
| 3440 | const QTextLayout::FormatRange *_selection) | - | ||||||||||||||||||||||||
| 3441 | : eng(_eng), | - | ||||||||||||||||||||||||
| 3442 | line(eng->lines[_lineNum]), | - | ||||||||||||||||||||||||
| 3443 | si(0), | - | ||||||||||||||||||||||||
| 3444 | lineNum(_lineNum), | - | ||||||||||||||||||||||||
| 3445 | lineEnd(line.from + line.length), | - | ||||||||||||||||||||||||
| 3446 | firstItem(eng->findItem(line.from)), | - | ||||||||||||||||||||||||
| 3447 | lastItem(eng->findItem(lineEnd - 1, firstItem)), | - | ||||||||||||||||||||||||
| 3448 | nItems((firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0), | - | ||||||||||||||||||||||||
| 3449 | logicalItem(-1), | - | ||||||||||||||||||||||||
| 3450 | item(-1), | - | ||||||||||||||||||||||||
| 3451 | visualOrder(nItems), | - | ||||||||||||||||||||||||
| 3452 | selection(_selection) | - | ||||||||||||||||||||||||
| 3453 | { | - | ||||||||||||||||||||||||
| 3454 | x = QFixed::fromReal(pos.x()); | - | ||||||||||||||||||||||||
| 3455 | - | |||||||||||||||||||||||||
| 3456 | x += line.x; | - | ||||||||||||||||||||||||
| 3457 | - | |||||||||||||||||||||||||
| 3458 | x += eng->alignLine(line); | - | ||||||||||||||||||||||||
| 3459 | - | |||||||||||||||||||||||||
| 3460 | QVarLengthArray<uchar> levels(nItems); | - | ||||||||||||||||||||||||
| 3461 | for (int i = 0; i < nItems
| 0 | ||||||||||||||||||||||||
| 3462 | levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; never executed: levels[i] = eng->layoutData->items[i+firstItem].analysis.bidiLevel; | 0 | ||||||||||||||||||||||||
| 3463 | QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); | - | ||||||||||||||||||||||||
| 3464 | - | |||||||||||||||||||||||||
| 3465 | eng->shapeLine(line); | - | ||||||||||||||||||||||||
| 3466 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3467 | - | |||||||||||||||||||||||||
| 3468 | QScriptItem &QTextLineItemIterator::next() | - | ||||||||||||||||||||||||
| 3469 | { | - | ||||||||||||||||||||||||
| 3470 | x += itemWidth; | - | ||||||||||||||||||||||||
| 3471 | - | |||||||||||||||||||||||||
| 3472 | ++logicalItem; | - | ||||||||||||||||||||||||
| 3473 | item = visualOrder[logicalItem] + firstItem; | - | ||||||||||||||||||||||||
| 3474 | itemLength = eng->length(item); | - | ||||||||||||||||||||||||
| 3475 | si = &eng->layoutData->items[item]; | - | ||||||||||||||||||||||||
| 3476 | if (!si->num_glyphs
| 0 | ||||||||||||||||||||||||
| 3477 | eng->shape(item); never executed: eng->shape(item); | 0 | ||||||||||||||||||||||||
| 3478 | - | |||||||||||||||||||||||||
| 3479 | itemStart = qMax(line.from, si->position); | - | ||||||||||||||||||||||||
| 3480 | itemEnd = qMin(lineEnd, si->position + itemLength); | - | ||||||||||||||||||||||||
| 3481 | - | |||||||||||||||||||||||||
| 3482 | if (si->analysis.flags >= QScriptAnalysis::TabOrObject
| 0 | ||||||||||||||||||||||||
| 3483 | glyphsStart = 0; | - | ||||||||||||||||||||||||
| 3484 | glyphsEnd = 1; | - | ||||||||||||||||||||||||
| 3485 | itemWidth = si->width; | - | ||||||||||||||||||||||||
| 3486 | return never executed: *si;return *si;never executed: return *si; | 0 | ||||||||||||||||||||||||
| 3487 | } | - | ||||||||||||||||||||||||
| 3488 | - | |||||||||||||||||||||||||
| 3489 | unsigned short *logClusters = eng->logClusters(si); | - | ||||||||||||||||||||||||
| 3490 | QGlyphLayout glyphs = eng->shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 3491 | - | |||||||||||||||||||||||||
| 3492 | glyphsStart = logClusters[itemStart - si->position]; | - | ||||||||||||||||||||||||
| 3493 | glyphsEnd = (
| 0 | ||||||||||||||||||||||||
| 3494 | - | |||||||||||||||||||||||||
| 3495 | - | |||||||||||||||||||||||||
| 3496 | if (si->position + itemLength >= lineEnd
| 0 | ||||||||||||||||||||||||
| 3497 | && eng->layoutData->string.at(lineEnd - 1).unicode() == QChar::SoftHyphen
| 0 | ||||||||||||||||||||||||
| 3498 | glyphs.attributes[glyphsEnd - 1].dontPrint = false; never executed: glyphs.attributes[glyphsEnd - 1].dontPrint = false; | 0 | ||||||||||||||||||||||||
| 3499 | - | |||||||||||||||||||||||||
| 3500 | itemWidth = 0; | - | ||||||||||||||||||||||||
| 3501 | for (int g = glyphsStart; g < glyphsEnd
| 0 | ||||||||||||||||||||||||
| 3502 | itemWidth += glyphs.effectiveAdvance(g); never executed: itemWidth += glyphs.effectiveAdvance(g); | 0 | ||||||||||||||||||||||||
| 3503 | - | |||||||||||||||||||||||||
| 3504 | return never executed: *si;return *si;never executed: return *si; | 0 | ||||||||||||||||||||||||
| 3505 | } | - | ||||||||||||||||||||||||
| 3506 | - | |||||||||||||||||||||||||
| 3507 | bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const | - | ||||||||||||||||||||||||
| 3508 | { | - | ||||||||||||||||||||||||
| 3509 | *selectionX = *selectionWidth = 0; | - | ||||||||||||||||||||||||
| 3510 | - | |||||||||||||||||||||||||
| 3511 | if (!selection
| 0 | ||||||||||||||||||||||||
| 3512 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 3513 | - | |||||||||||||||||||||||||
| 3514 | if (si->analysis.flags >= QScriptAnalysis::TabOrObject
| 0 | ||||||||||||||||||||||||
| 3515 | if (si->position >= selection->start + selection->length
| 0 | ||||||||||||||||||||||||
| 3516 | || si->position + itemLength <= selection->start
| 0 | ||||||||||||||||||||||||
| 3517 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 3518 | - | |||||||||||||||||||||||||
| 3519 | *selectionX = x; | - | ||||||||||||||||||||||||
| 3520 | *selectionWidth = itemWidth; | - | ||||||||||||||||||||||||
| 3521 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3522 | unsigned short *logClusters = eng->logClusters(si); | - | ||||||||||||||||||||||||
| 3523 | QGlyphLayout glyphs = eng->shapedGlyphs(si); | - | ||||||||||||||||||||||||
| 3524 | - | |||||||||||||||||||||||||
| 3525 | int from = qMax(itemStart, selection->start) - si->position; | - | ||||||||||||||||||||||||
| 3526 | int to = qMin(itemEnd, selection->start + selection->length) - si->position; | - | ||||||||||||||||||||||||
| 3527 | if (from >= to
| 0 | ||||||||||||||||||||||||
| 3528 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 3529 | - | |||||||||||||||||||||||||
| 3530 | int start_glyph = logClusters[from]; | - | ||||||||||||||||||||||||
| 3531 | int end_glyph = (
| 0 | ||||||||||||||||||||||||
| 3532 | QFixed soff; | - | ||||||||||||||||||||||||
| 3533 | QFixed swidth; | - | ||||||||||||||||||||||||
| 3534 | if (si->analysis.bidiLevel %2
| 0 | ||||||||||||||||||||||||
| 3535 | for (int g = glyphsEnd - 1; g >= end_glyph
| 0 | ||||||||||||||||||||||||
| 3536 | soff += glyphs.effectiveAdvance(g); never executed: soff += glyphs.effectiveAdvance(g); | 0 | ||||||||||||||||||||||||
| 3537 | for (int g = end_glyph - 1; g >= start_glyph
| 0 | ||||||||||||||||||||||||
| 3538 | swidth += glyphs.effectiveAdvance(g); never executed: swidth += glyphs.effectiveAdvance(g); | 0 | ||||||||||||||||||||||||
| 3539 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3540 | for (int g = glyphsStart; g < start_glyph
| 0 | ||||||||||||||||||||||||
| 3541 | soff += glyphs.effectiveAdvance(g); never executed: soff += glyphs.effectiveAdvance(g); | 0 | ||||||||||||||||||||||||
| 3542 | for (int g = start_glyph; g < end_glyph
| 0 | ||||||||||||||||||||||||
| 3543 | swidth += glyphs.effectiveAdvance(g); never executed: swidth += glyphs.effectiveAdvance(g); | 0 | ||||||||||||||||||||||||
| 3544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3545 | - | |||||||||||||||||||||||||
| 3546 | - | |||||||||||||||||||||||||
| 3547 | - | |||||||||||||||||||||||||
| 3548 | - | |||||||||||||||||||||||||
| 3549 | - | |||||||||||||||||||||||||
| 3550 | QFixed leftOffsetInLigature = eng->offsetInLigature(si, from, to, start_glyph); | - | ||||||||||||||||||||||||
| 3551 | *selectionX = x + soff + leftOffsetInLigature; | - | ||||||||||||||||||||||||
| 3552 | *selectionWidth = swidth - leftOffsetInLigature; | - | ||||||||||||||||||||||||
| 3553 | - | |||||||||||||||||||||||||
| 3554 | - | |||||||||||||||||||||||||
| 3555 | - | |||||||||||||||||||||||||
| 3556 | *selectionWidth += eng->offsetInLigature(si, to, itemLength, end_glyph); | - | ||||||||||||||||||||||||
| 3557 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3558 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 3559 | } | - | ||||||||||||||||||||||||
| 3560 | - | |||||||||||||||||||||||||
| 3561 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |