| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | void QTextBlockData::invalidate() const | - |
| 7 | { | - |
| 8 | if (layout) evaluated: layout| yes Evaluation Count:4235 | yes Evaluation Count:10547 |
| 4235-10547 |
| 9 | layout->engine()->invalidate(); executed: layout->engine()->invalidate();Execution Count:4235 | 4235 |
| 10 | } executed: }Execution Count:14782 | 14782 |
| 11 | | - |
| 12 | static bool isValidBlockSeparator(QChar ch) | - |
| 13 | { | - |
| 14 | return ch == QChar::ParagraphSeparator | 3849 |
| 15 | || ch == QChar(0xfdd0) | 3849 |
| 16 | || ch == QChar(0xfdd1); executed: return ch == QChar::ParagraphSeparator || ch == QChar(0xfdd0) || ch == QChar(0xfdd1);Execution Count:3849 | 3849 |
| 17 | } | - |
| 18 | bool QTextUndoCommand::tryMerge(const QTextUndoCommand &other) | - |
| 19 | { | - |
| 20 | if (command != other.command) evaluated: command != other.command| yes Evaluation Count:240 | yes Evaluation Count:496 |
| 240-496 |
| 21 | return false; executed: return false;Execution Count:240 | 240 |
| 22 | | - |
| 23 | if (command == Inserted evaluated: command == Inserted| yes Evaluation Count:204 | yes Evaluation Count:292 |
| 204-292 |
| 24 | && (pos + length == other.pos) evaluated: (pos + length == other.pos)| yes Evaluation Count:78 | yes Evaluation Count:126 |
| 78-126 |
| 25 | && (strPos + length == other.strPos) evaluated: (strPos + length == other.strPos)| yes Evaluation Count:77 | yes Evaluation Count:1 |
| 1-77 |
| 26 | && format == other.format) { evaluated: format == other.format| yes Evaluation Count:71 | yes Evaluation Count:6 |
| 6-71 |
| 27 | | - |
| 28 | length += other.length; | - |
| 29 | return true; executed: return true;Execution Count:71 | 71 |
| 30 | } | - |
| 31 | | - |
| 32 | | - |
| 33 | if (command == Removed evaluated: command == Removed| yes Evaluation Count:13 | yes Evaluation Count:412 |
| 13-412 |
| 34 | && pos == other.pos evaluated: pos == other.pos| yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
| 35 | && (strPos + length == other.strPos) partially evaluated: (strPos + length == other.strPos)| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 36 | && format == other.format) { never evaluated: format == other.format | 0 |
| 37 | | - |
| 38 | length += other.length; | - |
| 39 | return true; never executed: return true; | 0 |
| 40 | } | - |
| 41 | | - |
| 42 | | - |
| 43 | if (command == Removed evaluated: command == Removed| yes Evaluation Count:13 | yes Evaluation Count:412 |
| 13-412 |
| 44 | && (other.pos + other.length == pos) evaluated: (other.pos + other.length == pos)| yes Evaluation Count:7 | yes Evaluation Count:6 |
| 6-7 |
| 45 | && (other.strPos + other.length == strPos) partially evaluated: (other.strPos + other.length == strPos)| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
| 46 | && (format == other.format)) { partially evaluated: (format == other.format)| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
| 47 | | - |
| 48 | int l = length; | - |
| 49 | (*this) = other; | - |
| 50 | | - |
| 51 | length += l; | - |
| 52 | return true; executed: return true;Execution Count:7 | 7 |
| 53 | } | - |
| 54 | | - |
| 55 | return false; executed: return false;Execution Count:418 | 418 |
| 56 | } | - |
| 57 | | - |
| 58 | QTextDocumentPrivate::QTextDocumentPrivate() | - |
| 59 | : wasUndoAvailable(false), | - |
| 60 | wasRedoAvailable(false), | - |
| 61 | docChangeOldLength(0), | - |
| 62 | docChangeLength(0), | - |
| 63 | framesDirty(true), | - |
| 64 | rtFrame(0), | - |
| 65 | initialBlockCharFormatIndex(-1) | - |
| 66 | { | - |
| 67 | editBlock = 0; | - |
| 68 | editBlockCursorPosition = -1; | - |
| 69 | docChangeFrom = -1; | - |
| 70 | | - |
| 71 | undoState = 0; | - |
| 72 | revision = -1; | - |
| 73 | | - |
| 74 | lout = 0; | - |
| 75 | | - |
| 76 | modified = false; | - |
| 77 | modifiedState = 0; | - |
| 78 | | - |
| 79 | undoEnabled = true; | - |
| 80 | inContentsChange = false; | - |
| 81 | blockCursorAdjustment = false; | - |
| 82 | | - |
| 83 | defaultTextOption.setTabStop(80); | - |
| 84 | defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); | - |
| 85 | defaultCursorMoveStyle = Qt::LogicalMoveStyle; | - |
| 86 | | - |
| 87 | indentWidth = 40; | - |
| 88 | documentMargin = 4; | - |
| 89 | | - |
| 90 | maximumBlockCount = 0; | - |
| 91 | needsEnsureMaximumBlockCount = false; | - |
| 92 | unreachableCharacterCount = 0; | - |
| 93 | lastBlockCount = 0; | - |
| 94 | } executed: }Execution Count:1941 | 1941 |
| 95 | | - |
| 96 | void QTextDocumentPrivate::init() | - |
| 97 | { | - |
| 98 | framesDirty = false; | - |
| 99 | | - |
| 100 | bool undoState = undoEnabled; | - |
| 101 | undoEnabled = false; | - |
| 102 | initialBlockCharFormatIndex = formats.indexForFormat(QTextCharFormat()); | - |
| 103 | insertBlock(0, formats.indexForFormat(QTextBlockFormat()), formats.indexForFormat(QTextCharFormat())); | - |
| 104 | undoEnabled = undoState; | - |
| 105 | modified = false; | - |
| 106 | modifiedState = 0; | - |
| 107 | | - |
| 108 | qRegisterMetaType<QTextDocument *>(); | - |
| 109 | } executed: }Execution Count:3140 | 3140 |
| 110 | | - |
| 111 | void QTextDocumentPrivate::clear() | - |
| 112 | { | - |
| 113 | QTextDocument * const q = q_func(); | - |
| 114 | | - |
| 115 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 116 | curs->setPosition(0); | - |
| 117 | curs->currentCharFormat = -1; | - |
| 118 | curs->anchor = 0; | - |
| 119 | curs->adjusted_anchor = 0; | - |
| 120 | } executed: }Execution Count:1117 | 1117 |
| 121 | | - |
| 122 | QList<QTextCursorPrivate *>oldCursors = cursors; | - |
| 123 | if (true){ partially evaluated: true| yes Evaluation Count:1199 | no Evaluation Count:0 |
| 0-1199 |
| 124 | cursors.clear(); | - |
| 125 | | - |
| 126 | QMap<int, QTextObject *>::Iterator objectIt = objects.begin(); | - |
| 127 | while (objectIt != objects.end()) { evaluated: objectIt != objects.end()| yes Evaluation Count:574 | yes Evaluation Count:1199 |
| 574-1199 |
| 128 | if (*objectIt != rtFrame) { evaluated: *objectIt != rtFrame| yes Evaluation Count:29 | yes Evaluation Count:545 |
| 29-545 |
| 129 | delete *objectIt; | - |
| 130 | objectIt = objects.erase(objectIt); | - |
| 131 | } else { executed: }Execution Count:29 | 29 |
| 132 | ++objectIt; | - |
| 133 | } executed: }Execution Count:545 | 545 |
| 134 | } | - |
| 135 | | - |
| 136 | | - |
| 137 | objects.clear(); | - |
| 138 | | - |
| 139 | title.clear(); | - |
| 140 | clearUndoRedoStacks(QTextDocument::UndoAndRedoStacks); | - |
| 141 | text = QString(); | - |
| 142 | unreachableCharacterCount = 0; | - |
| 143 | modifiedState = 0; | - |
| 144 | modified = false; | - |
| 145 | formats = QTextFormatCollection(); | - |
| 146 | int len = fragments.length(); | - |
| 147 | fragments.clear(); | - |
| 148 | blocks.clear(); | - |
| 149 | cachedResources.clear(); | - |
| 150 | delete rtFrame; | - |
| 151 | rtFrame = 0; | - |
| 152 | init(); | - |
| 153 | cursors = oldCursors; | - |
| 154 | inContentsChange = true; | - |
| 155 | q->contentsChange(0, len, 0); | - |
| 156 | inContentsChange = false; | - |
| 157 | if (lout) evaluated: lout| yes Evaluation Count:584 | yes Evaluation Count:615 |
| 584-615 |
| 158 | lout->documentChanged(0, len, 0); executed: lout->documentChanged(0, len, 0);Execution Count:584 | 584 |
| 159 | } else { executed: }Execution Count:1199 | 1199 |
| 160 | cursors = oldCursors; | - |
| 161 | qt_noop(); | - |
| 162 | } | 0 |
| 163 | } | - |
| 164 | | - |
| 165 | QTextDocumentPrivate::~QTextDocumentPrivate() | - |
| 166 | { | - |
| 167 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
| 168 | curs->priv = 0; executed: curs->priv = 0;Execution Count:403 | 403 |
| 169 | cursors.clear(); | - |
| 170 | undoState = 0; | - |
| 171 | undoEnabled = true; | - |
| 172 | clearUndoRedoStacks(QTextDocument::RedoStack); | - |
| 173 | } executed: }Execution Count:1937 | 1937 |
| 174 | | - |
| 175 | void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout) | - |
| 176 | { | - |
| 177 | QTextDocument * const q = q_func(); | - |
| 178 | if (lout == layout) partially evaluated: lout == layout| no Evaluation Count:0 | yes Evaluation Count:453 |
| 0-453 |
| 179 | return; | 0 |
| 180 | const bool firstLayout = !lout; | - |
| 181 | delete lout; | - |
| 182 | lout = layout; | - |
| 183 | | - |
| 184 | if (!firstLayout) evaluated: !firstLayout| yes Evaluation Count:2 | yes Evaluation Count:451 |
| 2-451 |
| 185 | for (BlockMap::Iterator it = blocks.begin(); !it.atEnd(); ++it) evaluated: !it.atEnd()| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
| 186 | it->free(); executed: it->free();Execution Count:2 | 2 |
| 187 | | - |
| 188 | q->documentLayoutChanged(); | - |
| 189 | inContentsChange = true; | - |
| 190 | q->contentsChange(0, 0, length()); | - |
| 191 | inContentsChange = false; | - |
| 192 | if (lout) evaluated: lout| yes Evaluation Count:452 | yes Evaluation Count:1 |
| 1-452 |
| 193 | lout->documentChanged(0, 0, length()); executed: lout->documentChanged(0, 0, length());Execution Count:452 | 452 |
| 194 | } executed: }Execution Count:453 | 453 |
| 195 | | - |
| 196 | | - |
| 197 | void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op) | - |
| 198 | { | - |
| 199 | | - |
| 200 | qt_noop(); | - |
| 201 | | - |
| 202 | split(pos); | - |
| 203 | uint x = fragments.insert_single(pos, length); | - |
| 204 | QTextFragmentData *X = fragments.fragment(x); | - |
| 205 | X->format = format; | - |
| 206 | X->stringPosition = strPos; | - |
| 207 | uint w = fragments.previous(x); | - |
| 208 | if (w) evaluated: w| yes Evaluation Count:5092 | yes Evaluation Count:1576 |
| 1576-5092 |
| 209 | unite(w); executed: unite(w);Execution Count:5092 | 5092 |
| 210 | | - |
| 211 | int b = blocks.findNode(pos); | - |
| 212 | blocks.setSize(b, blocks.size(b)+length); | - |
| 213 | | - |
| 214 | qt_noop(); | - |
| 215 | | - |
| 216 | QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(format)); | - |
| 217 | if (frame) { evaluated: frame| yes Evaluation Count:33 | yes Evaluation Count:6635 |
| 33-6635 |
| 218 | frame->d_func()->fragmentAdded(text.at(strPos), x); | - |
| 219 | framesDirty = true; | - |
| 220 | } executed: }Execution Count:33 | 33 |
| 221 | | - |
| 222 | adjustDocumentChangesAndCursors(pos, length, op); | - |
| 223 | } executed: }Execution Count:6668 | 6668 |
| 224 | | - |
| 225 | int QTextDocumentPrivate::insert_block(int pos, uint strPos, int format, int blockFormat, QTextUndoCommand::Operation op, int command) | - |
| 226 | { | - |
| 227 | split(pos); | - |
| 228 | uint x = fragments.insert_single(pos, 1); | - |
| 229 | QTextFragmentData *X = fragments.fragment(x); | - |
| 230 | X->format = format; | - |
| 231 | X->stringPosition = strPos; | - |
| 232 | | - |
| 233 | | - |
| 234 | qt_noop(); | - |
| 235 | qt_noop(); | - |
| 236 | | - |
| 237 | int block_pos = pos; | - |
| 238 | if (blocks.length() && command == QTextUndoCommand::BlockRemoved) evaluated: blocks.length()| yes Evaluation Count:16670 | yes Evaluation Count:3140 |
partially evaluated: command == QTextUndoCommand::BlockRemoved| yes Evaluation Count:16670 | no Evaluation Count:0 |
| 0-16670 |
| 239 | ++block_pos; executed: ++block_pos;Execution Count:16670 | 16670 |
| 240 | int size = 1; | - |
| 241 | int n = blocks.findNode(block_pos); | - |
| 242 | int key = n ? blocks.position(n) : blocks.length(); evaluated: n| yes Evaluation Count:2174 | yes Evaluation Count:17636 |
| 2174-17636 |
| 243 | | - |
| 244 | qt_noop(); | - |
| 245 | if (key != block_pos) { evaluated: key != block_pos| yes Evaluation Count:2028 | yes Evaluation Count:17782 |
| 2028-17782 |
| 246 | qt_noop(); | - |
| 247 | int oldSize = blocks.size(n); | - |
| 248 | blocks.setSize(n, block_pos-key); | - |
| 249 | size += oldSize - (block_pos-key); | - |
| 250 | } executed: }Execution Count:2028 | 2028 |
| 251 | int b = blocks.insert_single(block_pos, size); | - |
| 252 | QTextBlockData *B = blocks.fragment(b); | - |
| 253 | B->format = blockFormat; | - |
| 254 | | - |
| 255 | qt_noop(); | - |
| 256 | | - |
| 257 | QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blockFormat)); | - |
| 258 | if (group) evaluated: group| yes Evaluation Count:10953 | yes Evaluation Count:8857 |
| 8857-10953 |
| 259 | group->blockInserted(QTextBlock(this, b)); executed: group->blockInserted(QTextBlock(this, b));Execution Count:10953 | 10953 |
| 260 | | - |
| 261 | QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(formats.format(format))); | - |
| 262 | if (frame) { evaluated: frame| yes Evaluation Count:1447 | yes Evaluation Count:18363 |
| 1447-18363 |
| 263 | frame->d_func()->fragmentAdded(text.at(strPos), x); | - |
| 264 | framesDirty = true; | - |
| 265 | } executed: }Execution Count:1447 | 1447 |
| 266 | | - |
| 267 | adjustDocumentChangesAndCursors(pos, 1, op); | - |
| 268 | return x; executed: return x;Execution Count:19810 | 19810 |
| 269 | } | - |
| 270 | | - |
| 271 | int QTextDocumentPrivate::insertBlock(QChar blockSeparator, | - |
| 272 | int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation op) | - |
| 273 | { | - |
| 274 | qt_noop(); | - |
| 275 | qt_noop(); | - |
| 276 | qt_noop(); | - |
| 277 | qt_noop(); | - |
| 278 | | - |
| 279 | beginEditBlock(); | - |
| 280 | | - |
| 281 | int strPos = text.length(); | - |
| 282 | text.append(blockSeparator); | - |
| 283 | | - |
| 284 | int ob = blocks.findNode(pos); | - |
| 285 | bool atBlockEnd = true; | - |
| 286 | bool atBlockStart = true; | - |
| 287 | int oldRevision = 0; | - |
| 288 | if (ob) { evaluated: ob| yes Evaluation Count:16652 | yes Evaluation Count:3140 |
| 3140-16652 |
| 289 | atBlockEnd = (pos - blocks.position(ob) == blocks.size(ob)-1); | - |
| 290 | atBlockStart = ((int)blocks.position(ob) == pos); | - |
| 291 | oldRevision = blocks.fragment(ob)->revision; | - |
| 292 | } executed: }Execution Count:16652 | 16652 |
| 293 | | - |
| 294 | const int fragment = insert_block(pos, strPos, charFormat, blockFormat, op, QTextUndoCommand::BlockRemoved); | - |
| 295 | | - |
| 296 | qt_noop(); | - |
| 297 | | - |
| 298 | int b = blocks.findNode(pos); | - |
| 299 | QTextBlockData *B = blocks.fragment(b); | - |
| 300 | | - |
| 301 | QTextUndoCommand c = { QTextUndoCommand::BlockInserted, (editBlock != 0), 0, 0, quint8(op), charFormat, quint32(strPos), quint32(pos), { int(blockFormat) }, quint32(B->revision) }; | - |
| 302 | | - |
| 303 | | - |
| 304 | | - |
| 305 | appendUndoItem(c); | - |
| 306 | qt_noop(); | - |
| 307 | | - |
| 308 | | - |
| 309 | B->revision = (atBlockEnd && !atBlockStart)? oldRevision : revision; evaluated: atBlockEnd| yes Evaluation Count:17766 | yes Evaluation Count:2026 |
evaluated: !atBlockStart| yes Evaluation Count:2274 | yes Evaluation Count:15492 |
| 2026-17766 |
| 310 | b = blocks.next(b); | - |
| 311 | if (b) { evaluated: b| yes Evaluation Count:16652 | yes Evaluation Count:3140 |
| 3140-16652 |
| 312 | B = blocks.fragment(b); | - |
| 313 | B->revision = atBlockStart ? oldRevision : revision; evaluated: atBlockStart| yes Evaluation Count:12372 | yes Evaluation Count:4280 |
| 4280-12372 |
| 314 | } executed: }Execution Count:16652 | 16652 |
| 315 | | - |
| 316 | if (formats.charFormat(charFormat).objectIndex() == -1) evaluated: formats.charFormat(charFormat).objectIndex() == -1| yes Evaluation Count:18354 | yes Evaluation Count:1438 |
| 1438-18354 |
| 317 | needsEnsureMaximumBlockCount = true; executed: needsEnsureMaximumBlockCount = true;Execution Count:18354 | 18354 |
| 318 | | - |
| 319 | endEditBlock(); | - |
| 320 | return fragment; executed: return fragment;Execution Count:19792 | 19792 |
| 321 | } | - |
| 322 | | - |
| 323 | int QTextDocumentPrivate::insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation op) | - |
| 324 | { | - |
| 325 | return insertBlock(QChar::ParagraphSeparator, pos, blockFormat, charFormat, op); executed: return insertBlock(QChar::ParagraphSeparator, pos, blockFormat, charFormat, op);Execution Count:18241 | 18241 |
| 326 | } | - |
| 327 | | - |
| 328 | void QTextDocumentPrivate::insert(int pos, int strPos, int strLength, int format) | - |
| 329 | { | - |
| 330 | if (strLength <= 0) partially evaluated: strLength <= 0| no Evaluation Count:0 | yes Evaluation Count:6644 |
| 0-6644 |
| 331 | return; | 0 |
| 332 | | - |
| 333 | qt_noop(); | - |
| 334 | qt_noop(); | - |
| 335 | | - |
| 336 | insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor); | - |
| 337 | if (undoEnabled) { evaluated: undoEnabled| yes Evaluation Count:3247 | yes Evaluation Count:3397 |
| 3247-3397 |
| 338 | int b = blocks.findNode(pos); | - |
| 339 | QTextBlockData *B = blocks.fragment(b); | - |
| 340 | | - |
| 341 | QTextUndoCommand c = { QTextUndoCommand::Inserted, (editBlock != 0), 0, 0, quint8(QTextUndoCommand::MoveCursor), format, quint32(strPos), quint32(pos), { int(strLength) }, quint32(B->revision) }; | - |
| 342 | | - |
| 343 | | - |
| 344 | appendUndoItem(c); | - |
| 345 | B->revision = revision; | - |
| 346 | qt_noop(); | - |
| 347 | } executed: }Execution Count:3247 | 3247 |
| 348 | finishEdit(); | - |
| 349 | } executed: }Execution Count:6644 | 6644 |
| 350 | | - |
| 351 | void QTextDocumentPrivate::insert(int pos, const QString &str, int format) | - |
| 352 | { | - |
| 353 | if (str.size() == 0) partially evaluated: str.size() == 0| no Evaluation Count:0 | yes Evaluation Count:822 |
| 0-822 |
| 354 | return; | 0 |
| 355 | | - |
| 356 | qt_noop(); | - |
| 357 | | - |
| 358 | int strPos = text.length(); | - |
| 359 | text.append(str); | - |
| 360 | insert(pos, strPos, str.length(), format); | - |
| 361 | } executed: }Execution Count:822 | 822 |
| 362 | | - |
| 363 | int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::Operation op) | - |
| 364 | { | - |
| 365 | qt_noop(); | - |
| 366 | qt_noop(); | - |
| 367 | qt_noop(); | - |
| 368 | | - |
| 369 | int b = blocks.findNode(pos); | - |
| 370 | uint x = fragments.findNode(pos); | - |
| 371 | | - |
| 372 | qt_noop(); | - |
| 373 | qt_noop(); | - |
| 374 | qt_noop(); | - |
| 375 | | - |
| 376 | blocks.setSize(b, blocks.size(b)-length); | - |
| 377 | | - |
| 378 | QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format)); | - |
| 379 | if (frame) { partially evaluated: frame| no Evaluation Count:0 | yes Evaluation Count:1146 |
| 0-1146 |
| 380 | frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x); | - |
| 381 | framesDirty = true; | - |
| 382 | } | 0 |
| 383 | | - |
| 384 | const int w = fragments.erase_single(x); | - |
| 385 | | - |
| 386 | if (!undoEnabled) evaluated: !undoEnabled| yes Evaluation Count:1070 | yes Evaluation Count:76 |
| 76-1070 |
| 387 | unreachableCharacterCount += length; executed: unreachableCharacterCount += length;Execution Count:1070 | 1070 |
| 388 | | - |
| 389 | adjustDocumentChangesAndCursors(pos, -int(length), op); | - |
| 390 | | - |
| 391 | return w; executed: return w;Execution Count:1146 | 1146 |
| 392 | } | - |
| 393 | | - |
| 394 | int QTextDocumentPrivate::remove_block(int pos, int *blockFormat, int command, QTextUndoCommand::Operation op) | - |
| 395 | { | - |
| 396 | qt_noop(); | - |
| 397 | qt_noop(); | - |
| 398 | qt_noop(); | - |
| 399 | | - |
| 400 | int b = blocks.findNode(pos); | - |
| 401 | uint x = fragments.findNode(pos); | - |
| 402 | | - |
| 403 | qt_noop(); | - |
| 404 | qt_noop(); | - |
| 405 | qt_noop(); | - |
| 406 | qt_noop(); | - |
| 407 | | - |
| 408 | if (blocks.size(b) == 1 && command == QTextUndoCommand::BlockAdded) { evaluated: blocks.size(b) == 1| yes Evaluation Count:1212 | yes Evaluation Count:47 |
evaluated: command == QTextUndoCommand::BlockAdded| yes Evaluation Count:1200 | yes Evaluation Count:12 |
| 12-1212 |
| 409 | qt_noop(); | - |
| 410 | | - |
| 411 | | - |
| 412 | } else { executed: }Execution Count:1200 | 1200 |
| 413 | | - |
| 414 | | - |
| 415 | int n = blocks.next(b); | - |
| 416 | qt_noop(); | - |
| 417 | blocks.setSize(b, blocks.size(b) + blocks.size(n) - 1); | - |
| 418 | blocks.fragment(b)->userState = blocks.fragment(n)->userState; | - |
| 419 | b = n; | - |
| 420 | } executed: }Execution Count:59 | 59 |
| 421 | *blockFormat = blocks.fragment(b)->format; | - |
| 422 | | - |
| 423 | QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blocks.fragment(b)->format)); | - |
| 424 | if (group) evaluated: group| yes Evaluation Count:3 | yes Evaluation Count:1256 |
| 3-1256 |
| 425 | group->blockRemoved(QTextBlock(this, b)); executed: group->blockRemoved(QTextBlock(this, b));Execution Count:3 | 3 |
| 426 | | - |
| 427 | QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format)); | - |
| 428 | if (frame) { evaluated: frame| yes Evaluation Count:229 | yes Evaluation Count:1030 |
| 229-1030 |
| 429 | frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x); | - |
| 430 | framesDirty = true; | - |
| 431 | } executed: }Execution Count:229 | 229 |
| 432 | | - |
| 433 | blocks.erase_single(b); | - |
| 434 | const int w = fragments.erase_single(x); | - |
| 435 | | - |
| 436 | adjustDocumentChangesAndCursors(pos, -1, op); | - |
| 437 | | - |
| 438 | return w; executed: return w;Execution Count:1259 | 1259 |
| 439 | } | - |
| 440 | void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::Operation op) | - |
| 441 | { | - |
| 442 | qt_noop(); | - |
| 443 | qt_noop(); | - |
| 444 | qt_noop(); | - |
| 445 | | - |
| 446 | if (pos == to) evaluated: pos == to| yes Evaluation Count:2 | yes Evaluation Count:1212 |
| 2-1212 |
| 447 | return; executed: return;Execution Count:2 | 2 |
| 448 | | - |
| 449 | const bool needsInsert = to != -1; | - |
| 450 | split(pos); | - |
| 451 | split(pos+length); | - |
| 452 | | - |
| 453 | uint dst = needsInsert ? fragments.findNode(to) : 0; evaluated: needsInsert| yes Evaluation Count:3 | yes Evaluation Count:1209 |
| 3-1209 |
| 454 | uint dstKey = needsInsert ? fragments.position(dst) : 0; evaluated: needsInsert| yes Evaluation Count:3 | yes Evaluation Count:1209 |
| 3-1209 |
| 455 | | - |
| 456 | uint x = fragments.findNode(pos); | - |
| 457 | uint end = fragments.findNode(pos+length); | - |
| 458 | | - |
| 459 | uint w = 0; | - |
| 460 | while (x != end) { evaluated: x != end| yes Evaluation Count:2378 | yes Evaluation Count:1212 |
| 1212-2378 |
| 461 | uint n = fragments.next(x); | - |
| 462 | | - |
| 463 | uint key = fragments.position(x); | - |
| 464 | uint b = blocks.findNode(key+1); | - |
| 465 | QTextBlockData *B = blocks.fragment(b); | - |
| 466 | int blockRevision = B->revision; | - |
| 467 | | - |
| 468 | QTextFragmentData *X = fragments.fragment(x); | - |
| 469 | QTextUndoCommand c = { QTextUndoCommand::Removed, (editBlock != 0), 0, 0, quint8(op), X->format, quint32(X->stringPosition), quint32(key), { int(X->size_array[0]) }, quint32(blockRevision) }; | - |
| 470 | | - |
| 471 | | - |
| 472 | QTextUndoCommand cInsert = { QTextUndoCommand::Inserted, (editBlock != 0), 0, 0, quint8(op), X->format, quint32(X->stringPosition), quint32(dstKey), { int(X->size_array[0]) }, quint32(blockRevision) }; | - |
| 473 | | - |
| 474 | | - |
| 475 | | - |
| 476 | if (key+1 != blocks.position(b)) { evaluated: key+1 != blocks.position(b)| yes Evaluation Count:1146 | yes Evaluation Count:1232 |
| 1146-1232 |
| 477 | | - |
| 478 | qt_noop(); | - |
| 479 | w = remove_string(key, X->size_array[0], op); | - |
| 480 | | - |
| 481 | if (needsInsert) { evaluated: needsInsert| yes Evaluation Count:3 | yes Evaluation Count:1143 |
| 3-1143 |
| 482 | insert_string(dstKey, X->stringPosition, X->size_array[0], X->format, op); | - |
| 483 | dstKey += X->size_array[0]; | - |
| 484 | } executed: }Execution Count:3 | 3 |
| 485 | } else { executed: }Execution Count:1146 | 1146 |
| 486 | | - |
| 487 | qt_noop(); | - |
| 488 | b = blocks.previous(b); | - |
| 489 | B = 0; | - |
| 490 | c.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockDeleted : QTextUndoCommand::BlockRemoved; evaluated: blocks.size(b) == 1| yes Evaluation Count:1200 | yes Evaluation Count:32 |
| 32-1200 |
| 491 | w = remove_block(key, &c.blockFormat, QTextUndoCommand::BlockAdded, op); | - |
| 492 | | - |
| 493 | if (needsInsert) { evaluated: needsInsert| yes Evaluation Count:5 | yes Evaluation Count:1227 |
| 5-1227 |
| 494 | insert_block(dstKey++, X->stringPosition, X->format, c.blockFormat, op, QTextUndoCommand::BlockRemoved); | - |
| 495 | cInsert.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockAdded : QTextUndoCommand::BlockInserted; partially evaluated: blocks.size(b) == 1| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 496 | cInsert.blockFormat = c.blockFormat; | - |
| 497 | } executed: }Execution Count:5 | 5 |
| 498 | } executed: }Execution Count:1232 | 1232 |
| 499 | appendUndoItem(c); | - |
| 500 | if (B) evaluated: B| yes Evaluation Count:1146 | yes Evaluation Count:1232 |
| 1146-1232 |
| 501 | B->revision = revision; executed: B->revision = revision;Execution Count:1146 | 1146 |
| 502 | x = n; | - |
| 503 | | - |
| 504 | if (needsInsert) evaluated: needsInsert| yes Evaluation Count:8 | yes Evaluation Count:2370 |
| 8-2370 |
| 505 | appendUndoItem(cInsert); executed: appendUndoItem(cInsert);Execution Count:8 | 8 |
| 506 | } executed: }Execution Count:2378 | 2378 |
| 507 | if (w) evaluated: w| yes Evaluation Count:259 | yes Evaluation Count:953 |
| 259-953 |
| 508 | unite(w); executed: unite(w);Execution Count:259 | 259 |
| 509 | | - |
| 510 | qt_noop(); | - |
| 511 | | - |
| 512 | if (!blockCursorAdjustment) evaluated: !blockCursorAdjustment| yes Evaluation Count:3 | yes Evaluation Count:1209 |
| 3-1209 |
| 513 | finishEdit(); executed: finishEdit();Execution Count:3 | 3 |
| 514 | } executed: }Execution Count:1212 | 1212 |
| 515 | | - |
| 516 | void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op) | - |
| 517 | { | - |
| 518 | if (length == 0) evaluated: length == 0| yes Evaluation Count:2 | yes Evaluation Count:1209 |
| 2-1209 |
| 519 | return; executed: return;Execution Count:2 | 2 |
| 520 | blockCursorAdjustment = true; | - |
| 521 | move(pos, -1, length, op); | - |
| 522 | blockCursorAdjustment = false; | - |
| 523 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 524 | if (curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved) { evaluated: curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved| yes Evaluation Count:2036 | yes Evaluation Count:193 |
| 193-2036 |
| 525 | curs->changed = true; | - |
| 526 | } executed: }Execution Count:2036 | 2036 |
| 527 | } executed: }Execution Count:2229 | 2229 |
| 528 | finishEdit(); | - |
| 529 | } executed: }Execution Count:1209 | 1209 |
| 530 | | - |
| 531 | void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode) | - |
| 532 | { | - |
| 533 | beginEditBlock(); | - |
| 534 | | - |
| 535 | qt_noop(); | - |
| 536 | | - |
| 537 | int newFormatIdx = -1; | - |
| 538 | if (mode == SetFormatAndPreserveObjectIndices) { evaluated: mode == SetFormatAndPreserveObjectIndices| yes Evaluation Count:1599 | yes Evaluation Count:643 |
| 643-1599 |
| 539 | QTextCharFormat cleanFormat = newFormat; | - |
| 540 | cleanFormat.clearProperty(QTextFormat::ObjectIndex); | - |
| 541 | newFormatIdx = formats.indexForFormat(cleanFormat); | - |
| 542 | } else if (mode == SetFormat) { evaluated: mode == SetFormat| yes Evaluation Count:593 | yes Evaluation Count:50 |
executed: }Execution Count:1599 | 50-1599 |
| 543 | newFormatIdx = formats.indexForFormat(newFormat); | - |
| 544 | } executed: }Execution Count:593 | 593 |
| 545 | | - |
| 546 | if (pos == -1) { evaluated: pos == -1| yes Evaluation Count:1766 | yes Evaluation Count:476 |
| 476-1766 |
| 547 | if (mode == MergeFormat) { evaluated: mode == MergeFormat| yes Evaluation Count:1 | yes Evaluation Count:1765 |
| 1-1765 |
| 548 | QTextFormat format = formats.format(initialBlockCharFormatIndex); | - |
| 549 | format.merge(newFormat); | - |
| 550 | initialBlockCharFormatIndex = formats.indexForFormat(format); | - |
| 551 | } else if (mode == SetFormatAndPreserveObjectIndices evaluated: mode == SetFormatAndPreserveObjectIndices| yes Evaluation Count:1245 | yes Evaluation Count:520 |
executed: }Execution Count:1 | 1-1245 |
| 552 | && formats.format(initialBlockCharFormatIndex).objectIndex() != -1) { partially evaluated: formats.format(initialBlockCharFormatIndex).objectIndex() != -1| no Evaluation Count:0 | yes Evaluation Count:1245 |
| 0-1245 |
| 553 | QTextCharFormat f = newFormat; | - |
| 554 | f.setObjectIndex(formats.format(initialBlockCharFormatIndex).objectIndex()); | - |
| 555 | initialBlockCharFormatIndex = formats.indexForFormat(f); | - |
| 556 | } else { | 0 |
| 557 | initialBlockCharFormatIndex = newFormatIdx; | - |
| 558 | } executed: }Execution Count:1765 | 1765 |
| 559 | | - |
| 560 | ++pos; | - |
| 561 | --length; | - |
| 562 | } executed: }Execution Count:1766 | 1766 |
| 563 | | - |
| 564 | const int startPos = pos; | - |
| 565 | const int endPos = pos + length; | - |
| 566 | | - |
| 567 | split(startPos); | - |
| 568 | split(endPos); | - |
| 569 | | - |
| 570 | while (pos < endPos) { evaluated: pos < endPos| yes Evaluation Count:2124 | yes Evaluation Count:2242 |
| 2124-2242 |
| 571 | FragmentMap::Iterator it = fragments.find(pos); | - |
| 572 | qt_noop(); | - |
| 573 | | - |
| 574 | QTextFragmentData *fragment = it.value(); | - |
| 575 | | - |
| 576 | qt_noop(); | - |
| 577 | | - |
| 578 | int offset = pos - it.position(); | - |
| 579 | int length = qMin(endPos - pos, int(fragment->size_array[0] - offset)); | - |
| 580 | int oldFormat = fragment->format; | - |
| 581 | | - |
| 582 | if (mode == MergeFormat) { evaluated: mode == MergeFormat| yes Evaluation Count:55 | yes Evaluation Count:2069 |
| 55-2069 |
| 583 | QTextFormat format = formats.format(fragment->format); | - |
| 584 | format.merge(newFormat); | - |
| 585 | fragment->format = formats.indexForFormat(format); | - |
| 586 | } else if (mode == SetFormatAndPreserveObjectIndices evaluated: mode == SetFormatAndPreserveObjectIndices| yes Evaluation Count:1996 | yes Evaluation Count:73 |
executed: }Execution Count:55 | 55-1996 |
| 587 | && formats.format(oldFormat).objectIndex() != -1) { evaluated: formats.format(oldFormat).objectIndex() != -1| yes Evaluation Count:188 | yes Evaluation Count:1808 |
| 188-1808 |
| 588 | QTextCharFormat f = newFormat; | - |
| 589 | f.setObjectIndex(formats.format(oldFormat).objectIndex()); | - |
| 590 | fragment->format = formats.indexForFormat(f); | - |
| 591 | } else { executed: }Execution Count:188 | 188 |
| 592 | fragment->format = newFormatIdx; | - |
| 593 | } executed: }Execution Count:1881 | 1881 |
| 594 | | - |
| 595 | QTextUndoCommand c = { QTextUndoCommand::CharFormatChanged, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormat, quint32(0), quint32(pos), { int(length) }, quint32(0) }; | - |
| 596 | | - |
| 597 | appendUndoItem(c); | - |
| 598 | | - |
| 599 | pos += length; | - |
| 600 | qt_noop(); | - |
| 601 | } executed: }Execution Count:2124 | 2124 |
| 602 | | - |
| 603 | int n = fragments.findNode(startPos - 1); | - |
| 604 | if (n) evaluated: n| yes Evaluation Count:173 | yes Evaluation Count:2069 |
| 173-2069 |
| 605 | unite(n); executed: unite(n);Execution Count:173 | 173 |
| 606 | | - |
| 607 | n = fragments.findNode(endPos); | - |
| 608 | if (n) partially evaluated: n| yes Evaluation Count:2242 | no Evaluation Count:0 |
| 0-2242 |
| 609 | unite(n); executed: unite(n);Execution Count:2242 | 2242 |
| 610 | | - |
| 611 | QTextBlock blockIt = blocksFind(startPos); | - |
| 612 | QTextBlock endIt = blocksFind(endPos); | - |
| 613 | if (endIt.isValid()) partially evaluated: endIt.isValid()| yes Evaluation Count:2242 | no Evaluation Count:0 |
| 0-2242 |
| 614 | endIt = endIt.next(); executed: endIt = endIt.next();Execution Count:2242 | 2242 |
| 615 | for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) evaluated: blockIt.isValid()| yes Evaluation Count:4515 | yes Evaluation Count:1067 |
evaluated: blockIt != endIt| yes Evaluation Count:3340 | yes Evaluation Count:1175 |
| 1067-4515 |
| 616 | QTextDocumentPrivate::block(blockIt)->invalidate(); executed: QTextDocumentPrivate::block(blockIt)->invalidate();Execution Count:3340 | 3340 |
| 617 | | - |
| 618 | documentChange(startPos, length); | - |
| 619 | | - |
| 620 | endEditBlock(); | - |
| 621 | } executed: }Execution Count:2242 | 2242 |
| 622 | | - |
| 623 | void QTextDocumentPrivate::setBlockFormat(const QTextBlock &from, const QTextBlock &to, | - |
| 624 | const QTextBlockFormat &newFormat, FormatChangeMode mode) | - |
| 625 | { | - |
| 626 | beginEditBlock(); | - |
| 627 | | - |
| 628 | qt_noop(); | - |
| 629 | | - |
| 630 | qt_noop(); | - |
| 631 | | - |
| 632 | int newFormatIdx = -1; | - |
| 633 | if (mode == SetFormat) evaluated: mode == SetFormat| yes Evaluation Count:1407 | yes Evaluation Count:131 |
| 131-1407 |
| 634 | newFormatIdx = formats.indexForFormat(newFormat); executed: newFormatIdx = formats.indexForFormat(newFormat);Execution Count:1407 | 1407 |
| 635 | QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(newFormat)); | - |
| 636 | | - |
| 637 | QTextBlock it = from; | - |
| 638 | QTextBlock end = to; | - |
| 639 | if (end.isValid()) partially evaluated: end.isValid()| yes Evaluation Count:1538 | no Evaluation Count:0 |
| 0-1538 |
| 640 | end = end.next(); executed: end = end.next();Execution Count:1538 | 1538 |
| 641 | | - |
| 642 | for (; it != end; it = it.next()) { evaluated: it != end| yes Evaluation Count:1541 | yes Evaluation Count:1538 |
| 1538-1541 |
| 643 | int oldFormat = block(it)->format; | - |
| 644 | QTextBlockFormat format = formats.blockFormat(oldFormat); | - |
| 645 | QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(format)); | - |
| 646 | if (mode == MergeFormat) { evaluated: mode == MergeFormat| yes Evaluation Count:134 | yes Evaluation Count:1407 |
| 134-1407 |
| 647 | format.merge(newFormat); | - |
| 648 | newFormatIdx = formats.indexForFormat(format); | - |
| 649 | group = qobject_cast<QTextBlockGroup *>(objectForFormat(format)); | - |
| 650 | } executed: }Execution Count:134 | 134 |
| 651 | block(it)->format = newFormatIdx; | - |
| 652 | | - |
| 653 | block(it)->invalidate(); | - |
| 654 | | - |
| 655 | QTextUndoCommand c = { QTextUndoCommand::BlockFormatChanged, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormat, quint32(0), quint32(it.position()), { int(1) }, quint32(0) }; | - |
| 656 | | - |
| 657 | appendUndoItem(c); | - |
| 658 | | - |
| 659 | if (group != oldGroup) { evaluated: group != oldGroup| yes Evaluation Count:119 | yes Evaluation Count:1422 |
| 119-1422 |
| 660 | if (oldGroup) evaluated: oldGroup| yes Evaluation Count:7 | yes Evaluation Count:112 |
| 7-112 |
| 661 | oldGroup->blockRemoved(it); executed: oldGroup->blockRemoved(it);Execution Count:7 | 7 |
| 662 | if (group) evaluated: group| yes Evaluation Count:115 | yes Evaluation Count:4 |
| 4-115 |
| 663 | group->blockInserted(it); executed: group->blockInserted(it);Execution Count:115 | 115 |
| 664 | } else if (group) { evaluated: group| yes Evaluation Count:57 | yes Evaluation Count:1365 |
executed: }Execution Count:119 | 57-1365 |
| 665 | group->blockFormatChanged(it); | - |
| 666 | } executed: }Execution Count:57 | 57 |
| 667 | } | - |
| 668 | | - |
| 669 | documentChange(from.position(), to.position() + to.length() - from.position()); | - |
| 670 | | - |
| 671 | endEditBlock(); | - |
| 672 | } executed: }Execution Count:1538 | 1538 |
| 673 | | - |
| 674 | | - |
| 675 | bool QTextDocumentPrivate::split(int pos) | - |
| 676 | { | - |
| 677 | uint x = fragments.findNode(pos); | - |
| 678 | if (x) { evaluated: x| yes Evaluation Count:30246 | yes Evaluation Count:3140 |
| 3140-30246 |
| 679 | int k = fragments.position(x); | - |
| 680 | | - |
| 681 | | - |
| 682 | if (k != pos) { evaluated: k != pos| yes Evaluation Count:101 | yes Evaluation Count:30145 |
| 101-30145 |
| 683 | qt_noop(); | - |
| 684 | | - |
| 685 | QTextFragmentData *X = fragments.fragment(x); | - |
| 686 | int oldsize = X->size_array[0]; | - |
| 687 | fragments.setSize(x, pos-k); | - |
| 688 | uint n = fragments.insert_single(pos, oldsize-(pos-k)); | - |
| 689 | X = fragments.fragment(x); | - |
| 690 | QTextFragmentData *N = fragments.fragment(n); | - |
| 691 | N->stringPosition = X->stringPosition + pos-k; | - |
| 692 | N->format = X->format; | - |
| 693 | return true; executed: return true;Execution Count:101 | 101 |
| 694 | } | - |
| 695 | } executed: }Execution Count:30145 | 30145 |
| 696 | return false; executed: return false;Execution Count:33285 | 33285 |
| 697 | } | - |
| 698 | | - |
| 699 | bool QTextDocumentPrivate::unite(uint f) | - |
| 700 | { | - |
| 701 | uint n = fragments.next(f); | - |
| 702 | if (!n) evaluated: !n| yes Evaluation Count:1053 | yes Evaluation Count:6713 |
| 1053-6713 |
| 703 | return false; executed: return false;Execution Count:1053 | 1053 |
| 704 | | - |
| 705 | QTextFragmentData *ff = fragments.fragment(f); | - |
| 706 | QTextFragmentData *nf = fragments.fragment(n); | - |
| 707 | | - |
| 708 | if (nf->format == ff->format && (ff->stringPosition + (int)ff->size_array[0] == nf->stringPosition)) { evaluated: nf->format == ff->format| yes Evaluation Count:5778 | yes Evaluation Count:935 |
evaluated: (ff->stringPosition + (int)ff->size_array[0] == nf->stringPosition)| yes Evaluation Count:2632 | yes Evaluation Count:3146 |
| 935-5778 |
| 709 | if (isValidBlockSeparator(text.at(ff->stringPosition)) evaluated: isValidBlockSeparator(text.at(ff->stringPosition))| yes Evaluation Count:1415 | yes Evaluation Count:1217 |
| 1217-1415 |
| 710 | || isValidBlockSeparator(text.at(nf->stringPosition))) evaluated: isValidBlockSeparator(text.at(nf->stringPosition))| yes Evaluation Count:904 | yes Evaluation Count:313 |
| 313-904 |
| 711 | return false; executed: return false;Execution Count:2319 | 2319 |
| 712 | | - |
| 713 | fragments.setSize(f, ff->size_array[0] + nf->size_array[0]); | - |
| 714 | fragments.erase_single(n); | - |
| 715 | return true; executed: return true;Execution Count:313 | 313 |
| 716 | } | - |
| 717 | return false; executed: return false;Execution Count:4081 | 4081 |
| 718 | } | - |
| 719 | | - |
| 720 | | - |
| 721 | int QTextDocumentPrivate::undoRedo(bool undo) | - |
| 722 | { | - |
| 723 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 881, __PRETTY_FUNCTION__).debug("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size()); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:76 |
never executed: QMessageLogger("text/qtextdocument_p.cpp", 881, __PRETTY_FUNCTION__).debug("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size()); | 0-76 |
| 724 | if (!undoEnabled || (undo && undoState == 0) || (!undo && undoState == undoStack.size())) evaluated: !undoEnabled| yes Evaluation Count:5 | yes Evaluation Count:71 |
evaluated: undo| yes Evaluation Count:57 | yes Evaluation Count:14 |
partially evaluated: undoState == 0| no Evaluation Count:0 | yes Evaluation Count:57 |
evaluated: !undo| yes Evaluation Count:14 | yes Evaluation Count:57 |
partially evaluated: undoState == undoStack.size()| no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-71 |
| 725 | return -1; executed: return -1;Execution Count:5 | 5 |
| 726 | | - |
| 727 | undoEnabled = false; | - |
| 728 | beginEditBlock(); | - |
| 729 | int editPos = -1; | - |
| 730 | int editLength = -1; | - |
| 731 | while (1) { partially evaluated: 1| yes Evaluation Count:131 | no Evaluation Count:0 |
| 0-131 |
| 732 | if (undo) evaluated: undo| yes Evaluation Count:100 | yes Evaluation Count:31 |
| 31-100 |
| 733 | --undoState; executed: --undoState;Execution Count:100 | 100 |
| 734 | QTextUndoCommand &c = undoStack[undoState]; | - |
| 735 | int resetBlockRevision = c.pos; | - |
| 736 | | - |
| 737 | switch(c.command) { | - |
| 738 | case QTextUndoCommand::Inserted: | - |
| 739 | remove(c.pos, c.length, (QTextUndoCommand::Operation)c.operation); | - |
| 740 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 898, __PRETTY_FUNCTION__).debug(" erase: from %d, length %d", c.pos, c.length); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:58 |
never executed: QMessageLogger("text/qtextdocument_p.cpp", 898, __PRETTY_FUNCTION__).debug(" erase: from %d, length %d", c.pos, c.length); | 0-58 |
| 741 | c.command = QTextUndoCommand::Removed; | - |
| 742 | editPos = c.pos; | - |
| 743 | editLength = 0; | - |
| 744 | break; executed: break;Execution Count:58 | 58 |
| 745 | case QTextUndoCommand::Removed: | - |
| 746 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 904, __PRETTY_FUNCTION__).debug(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:21 |
never executed: QMessageLogger("text/qtextdocument_p.cpp", 904, __PRETTY_FUNCTION__).debug(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos); | 0-21 |
| 747 | insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation); | - |
| 748 | c.command = QTextUndoCommand::Inserted; | - |
| 749 | if (editPos != (int)c.pos) evaluated: editPos != (int)c.pos| yes Evaluation Count:17 | yes Evaluation Count:4 |
| 4-17 |
| 750 | editLength = 0; executed: editLength = 0;Execution Count:17 | 17 |
| 751 | editPos = c.pos; | - |
| 752 | editLength += c.length; | - |
| 753 | break; executed: break;Execution Count:21 | 21 |
| 754 | case QTextUndoCommand::BlockInserted: | - |
| 755 | case QTextUndoCommand::BlockAdded: | - |
| 756 | remove_block(c.pos, &c.blockFormat, c.command, (QTextUndoCommand::Operation)c.operation); | - |
| 757 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 915, __PRETTY_FUNCTION__).debug(" blockremove: from %d", c.pos); never executed: QMessageLogger("text/qtextdocument_p.cpp", 915, __PRETTY_FUNCTION__).debug(" blockremove: from %d", c.pos); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
| 758 | if (c.command == QTextUndoCommand::BlockInserted) partially evaluated: c.command == QTextUndoCommand::BlockInserted| yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
| 759 | c.command = QTextUndoCommand::BlockRemoved; executed: c.command = QTextUndoCommand::BlockRemoved;Execution Count:27 | 27 |
| 760 | else | - |
| 761 | c.command = QTextUndoCommand::BlockDeleted; never executed: c.command = QTextUndoCommand::BlockDeleted; | 0 |
| 762 | editPos = c.pos; | - |
| 763 | editLength = 0; | - |
| 764 | break; executed: break;Execution Count:27 | 27 |
| 765 | case QTextUndoCommand::BlockRemoved: | - |
| 766 | case QTextUndoCommand::BlockDeleted: | - |
| 767 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 925, __PRETTY_FUNCTION__).debug(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos); never executed: QMessageLogger("text/qtextdocument_p.cpp", 925, __PRETTY_FUNCTION__).debug(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 768 | insert_block(c.pos, c.strPos, c.format, c.blockFormat, (QTextUndoCommand::Operation)c.operation, c.command); | - |
| 769 | resetBlockRevision += 1; | - |
| 770 | if (c.command == QTextUndoCommand::BlockRemoved) partially evaluated: c.command == QTextUndoCommand::BlockRemoved| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 771 | c.command = QTextUndoCommand::BlockInserted; executed: c.command = QTextUndoCommand::BlockInserted;Execution Count:13 | 13 |
| 772 | else | - |
| 773 | c.command = QTextUndoCommand::BlockAdded; never executed: c.command = QTextUndoCommand::BlockAdded; | 0 |
| 774 | if (editPos != (int)c.pos) evaluated: editPos != (int)c.pos| yes Evaluation Count:12 | yes Evaluation Count:1 |
| 1-12 |
| 775 | editLength = 0; executed: editLength = 0;Execution Count:12 | 12 |
| 776 | editPos = c.pos; | - |
| 777 | editLength += 1; | - |
| 778 | break; executed: break;Execution Count:13 | 13 |
| 779 | case QTextUndoCommand::CharFormatChanged: { | - |
| 780 | resetBlockRevision = -1; | - |
| 781 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 939, __PRETTY_FUNCTION__).debug(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length); never executed: QMessageLogger("text/qtextdocument_p.cpp", 939, __PRETTY_FUNCTION__).debug(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 782 | FragmentIterator it = find(c.pos); | - |
| 783 | qt_noop(); | - |
| 784 | | - |
| 785 | int oldFormat = it.value()->format; | - |
| 786 | setCharFormat(c.pos, c.length, formats.charFormat(c.format)); | - |
| 787 | c.format = oldFormat; | - |
| 788 | if (editPos != (int)c.pos) partially evaluated: editPos != (int)c.pos| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 789 | editLength = 0; executed: editLength = 0;Execution Count:6 | 6 |
| 790 | editPos = c.pos; | - |
| 791 | editLength += c.length; | - |
| 792 | break; executed: break;Execution Count:6 | 6 |
| 793 | } | - |
| 794 | case QTextUndoCommand::BlockFormatChanged: { | - |
| 795 | resetBlockRevision = -1; | - |
| 796 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 954, __PRETTY_FUNCTION__).debug(" blockformat: format %d pos %d", c.format, c.pos); never executed: QMessageLogger("text/qtextdocument_p.cpp", 954, __PRETTY_FUNCTION__).debug(" blockformat: format %d pos %d", c.format, c.pos); | 0 |
| 797 | QTextBlock it = blocksFind(c.pos); | - |
| 798 | qt_noop(); | - |
| 799 | | - |
| 800 | int oldFormat = block(it)->format; | - |
| 801 | block(it)->format = c.format; | - |
| 802 | QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(oldFormat))); | - |
| 803 | QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(c.format))); | - |
| 804 | c.format = oldFormat; | - |
| 805 | if (group != oldGroup) { never evaluated: group != oldGroup | 0 |
| 806 | if (oldGroup) never evaluated: oldGroup | 0 |
| 807 | oldGroup->blockRemoved(it); never executed: oldGroup->blockRemoved(it); | 0 |
| 808 | if (group) | 0 |
| 809 | group->blockInserted(it); never executed: group->blockInserted(it); | 0 |
| 810 | } else if (group) { | 0 |
| 811 | group->blockFormatChanged(it); | - |
| 812 | } | 0 |
| 813 | documentChange(it.position(), it.length()); | - |
| 814 | editPos = -1; | - |
| 815 | break; | 0 |
| 816 | } | - |
| 817 | case QTextUndoCommand::GroupFormatChange: { | - |
| 818 | resetBlockRevision = -1; | - |
| 819 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 977, __PRETTY_FUNCTION__).debug(" group format change"); never executed: QMessageLogger("text/qtextdocument_p.cpp", 977, __PRETTY_FUNCTION__).debug(" group format change"); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 820 | QTextObject *object = objectForIndex(c.objectIndex); | - |
| 821 | int oldFormat = formats.objectFormatIndex(c.objectIndex); | - |
| 822 | changeObjectFormat(object, c.format); | - |
| 823 | c.format = oldFormat; | - |
| 824 | editPos = -1; | - |
| 825 | break; executed: break;Execution Count:1 | 1 |
| 826 | } | - |
| 827 | case QTextUndoCommand::CursorMoved: | - |
| 828 | editPos = c.pos; | - |
| 829 | editLength = 0; | - |
| 830 | break; executed: break;Execution Count:5 | 5 |
| 831 | case QTextUndoCommand::Custom: | - |
| 832 | resetBlockRevision = -1; | - |
| 833 | if (undo) | 0 |
| 834 | c.custom->undo(); never executed: c.custom->undo(); | 0 |
| 835 | else | - |
| 836 | c.custom->redo(); never executed: c.custom->redo(); | 0 |
| 837 | editPos = -1; | - |
| 838 | break; | 0 |
| 839 | default: | - |
| 840 | qt_noop(); | - |
| 841 | } | 0 |
| 842 | | - |
| 843 | if (resetBlockRevision >= 0) { evaluated: resetBlockRevision >= 0| yes Evaluation Count:124 | yes Evaluation Count:7 |
| 7-124 |
| 844 | int b = blocks.findNode(resetBlockRevision); | - |
| 845 | QTextBlockData *B = blocks.fragment(b); | - |
| 846 | B->revision = c.revision; | - |
| 847 | } executed: }Execution Count:124 | 124 |
| 848 | | - |
| 849 | if (!undo) evaluated: !undo| yes Evaluation Count:31 | yes Evaluation Count:100 |
| 31-100 |
| 850 | ++undoState; executed: ++undoState;Execution Count:31 | 31 |
| 851 | | - |
| 852 | bool inBlock = ( | - |
| 853 | undoState > 0 evaluated: undoState > 0| yes Evaluation Count:114 | yes Evaluation Count:17 |
| 17-114 |
| 854 | && undoState < undoStack.size() evaluated: undoState < undoStack.size()| yes Evaluation Count:104 | yes Evaluation Count:10 |
| 10-104 |
| 855 | && undoStack[undoState].block_part evaluated: undoStack[undoState].block_part| yes Evaluation Count:81 | yes Evaluation Count:23 |
| 23-81 |
| 856 | && undoStack[undoState-1].block_part evaluated: undoStack[undoState-1].block_part| yes Evaluation Count:70 | yes Evaluation Count:11 |
| 11-70 |
| 857 | && !undoStack[undoState-1].block_end evaluated: !undoStack[undoState-1].block_end| yes Evaluation Count:60 | yes Evaluation Count:10 |
| 10-60 |
| 858 | ); | - |
| 859 | if (!inBlock) evaluated: !inBlock| yes Evaluation Count:71 | yes Evaluation Count:60 |
| 60-71 |
| 860 | break; executed: break;Execution Count:71 | 71 |
| 861 | } executed: }Execution Count:60 | 60 |
| 862 | undoEnabled = true; | - |
| 863 | | - |
| 864 | int newCursorPos = -1; | - |
| 865 | | - |
| 866 | if (editPos >=0) evaluated: editPos >=0| yes Evaluation Count:70 | yes Evaluation Count:1 |
| 1-70 |
| 867 | newCursorPos = editPos + editLength; executed: newCursorPos = editPos + editLength;Execution Count:70 | 70 |
| 868 | else if (docChangeFrom >= 0) partially evaluated: docChangeFrom >= 0| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 869 | newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1); executed: newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1);Execution Count:1 | 1 |
| 870 | | - |
| 871 | endEditBlock(); | - |
| 872 | emitUndoAvailable(isUndoAvailable()); | - |
| 873 | emitRedoAvailable(isRedoAvailable()); | - |
| 874 | | - |
| 875 | return newCursorPos; executed: return newCursorPos;Execution Count:71 | 71 |
| 876 | } | - |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | void QTextDocumentPrivate::appendUndoItem(QAbstractUndoItem *item) | - |
| 882 | { | - |
| 883 | if (!undoEnabled) { never evaluated: !undoEnabled | 0 |
| 884 | delete item; | - |
| 885 | return; | 0 |
| 886 | } | - |
| 887 | | - |
| 888 | QTextUndoCommand c; | - |
| 889 | c.command = QTextUndoCommand::Custom; | - |
| 890 | c.block_part = editBlock != 0; | - |
| 891 | c.block_end = 0; | - |
| 892 | c.operation = QTextUndoCommand::MoveCursor; | - |
| 893 | c.format = 0; | - |
| 894 | c.strPos = 0; | - |
| 895 | c.pos = 0; | - |
| 896 | c.blockFormat = 0; | - |
| 897 | | - |
| 898 | c.custom = item; | - |
| 899 | appendUndoItem(c); | - |
| 900 | } | 0 |
| 901 | | - |
| 902 | void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) | - |
| 903 | { | - |
| 904 | if(0) QMessageLogger("text/qtextdocument_p.cpp", 1062, __PRETTY_FUNCTION__).debug("appendUndoItem, command=%d enabled=%d", c.command, undoEnabled); never executed: QMessageLogger("text/qtextdocument_p.cpp", 1062, __PRETTY_FUNCTION__).debug("appendUndoItem, command=%d enabled=%d", c.command, undoEnabled); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:29195 |
| 0-29195 |
| 905 | if (!undoEnabled) evaluated: !undoEnabled| yes Evaluation Count:10758 | yes Evaluation Count:18437 |
| 10758-18437 |
| 906 | return; executed: return;Execution Count:10758 | 10758 |
| 907 | if (undoState < undoStack.size()) evaluated: undoState < undoStack.size()| yes Evaluation Count:20 | yes Evaluation Count:18417 |
| 20-18417 |
| 908 | clearUndoRedoStacks(QTextDocument::RedoStack); executed: clearUndoRedoStacks(QTextDocument::RedoStack);Execution Count:20 | 20 |
| 909 | | - |
| 910 | if (editBlock != 0 && editBlockCursorPosition >= 0) { evaluated: editBlock != 0| yes Evaluation Count:17921 | yes Evaluation Count:516 |
evaluated: editBlockCursorPosition >= 0| yes Evaluation Count:42 | yes Evaluation Count:17879 |
| 42-17921 |
| 911 | if (c.pos != (quint32) editBlockCursorPosition) { evaluated: c.pos != (quint32) editBlockCursorPosition| yes Evaluation Count:20 | yes Evaluation Count:22 |
| 20-22 |
| 912 | | - |
| 913 | QTextUndoCommand cc = { QTextUndoCommand::CursorMoved, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), 0, quint32(0), quint32(editBlockCursorPosition), { int(0) }, quint32(0) }; | - |
| 914 | | - |
| 915 | undoStack.append(cc); | - |
| 916 | undoState++; | - |
| 917 | editBlockCursorPosition = -1; | - |
| 918 | } executed: }Execution Count:20 | 20 |
| 919 | } executed: }Execution Count:42 | 42 |
| 920 | | - |
| 921 | | - |
| 922 | if (!undoStack.isEmpty() && modified) { evaluated: !undoStack.isEmpty()| yes Evaluation Count:17558 | yes Evaluation Count:879 |
evaluated: modified| yes Evaluation Count:12069 | yes Evaluation Count:5489 |
| 879-17558 |
| 923 | QTextUndoCommand &last = undoStack[undoState - 1]; | - |
| 924 | | - |
| 925 | if ( (last.block_part && c.block_part && !last.block_end) evaluated: last.block_part| yes Evaluation Count:11728 | yes Evaluation Count:341 |
evaluated: c.block_part| yes Evaluation Count:11603 | yes Evaluation Count:125 |
evaluated: !last.block_end| yes Evaluation Count:511 | yes Evaluation Count:11092 |
| 125-11728 |
| 926 | || (!c.block_part && !last.block_part)) { evaluated: !c.block_part| yes Evaluation Count:350 | yes Evaluation Count:11208 |
evaluated: !last.block_part| yes Evaluation Count:225 | yes Evaluation Count:125 |
| 125-11208 |
| 927 | | - |
| 928 | if (last.tryMerge(c)) evaluated: last.tryMerge(c)| yes Evaluation Count:78 | yes Evaluation Count:658 |
| 78-658 |
| 929 | return; executed: return;Execution Count:78 | 78 |
| 930 | } executed: }Execution Count:658 | 658 |
| 931 | } executed: }Execution Count:11991 | 11991 |
| 932 | if (modifiedState > undoState) evaluated: modifiedState > undoState| yes Evaluation Count:1 | yes Evaluation Count:18358 |
| 1-18358 |
| 933 | modifiedState = -1; executed: modifiedState = -1;Execution Count:1 | 1 |
| 934 | undoStack.append(c); | - |
| 935 | undoState++; | - |
| 936 | emitUndoAvailable(true); | - |
| 937 | emitRedoAvailable(false); | - |
| 938 | | - |
| 939 | if (!c.block_part) evaluated: !c.block_part| yes Evaluation Count:439 | yes Evaluation Count:17920 |
| 439-17920 |
| 940 | document()->undoCommandAdded(); executed: document()->undoCommandAdded();Execution Count:439 | 439 |
| 941 | } executed: }Execution Count:18359 | 18359 |
| 942 | | - |
| 943 | void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToClear, | - |
| 944 | bool emitSignals) | - |
| 945 | { | - |
| 946 | bool undoCommandsAvailable = undoState != 0; | - |
| 947 | bool redoCommandsAvailable = undoState != undoStack.size(); | - |
| 948 | if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) { partially evaluated: stacksToClear == QTextDocument::UndoStack| no Evaluation Count:0 | yes Evaluation Count:5448 |
never evaluated: undoCommandsAvailable | 0-5448 |
| 949 | for (int i = 0; i < undoState; ++i) { never evaluated: i < undoState | 0 |
| 950 | QTextUndoCommand c = undoStack[undoState]; | - |
| 951 | if (c.command & QTextUndoCommand::Custom) never evaluated: c.command & QTextUndoCommand::Custom | 0 |
| 952 | delete c.custom; never executed: delete c.custom; | 0 |
| 953 | } | 0 |
| 954 | undoStack.remove(0, undoState); | - |
| 955 | undoStack.resize(undoStack.size() - undoState); | - |
| 956 | undoState = 0; | - |
| 957 | if (emitSignals) never evaluated: emitSignals | 0 |
| 958 | emitUndoAvailable(false); never executed: emitUndoAvailable(false); | 0 |
| 959 | } else if (stacksToClear == QTextDocument::RedoStack evaluated: stacksToClear == QTextDocument::RedoStack| yes Evaluation Count:4249 | yes Evaluation Count:1199 |
| 0-4249 |
| 960 | && redoCommandsAvailable) { evaluated: redoCommandsAvailable| yes Evaluation Count:847 | yes Evaluation Count:3402 |
| 847-3402 |
| 961 | for (int i = undoState; i < undoStack.size(); ++i) { evaluated: i < undoStack.size()| yes Evaluation Count:18256 | yes Evaluation Count:847 |
| 847-18256 |
| 962 | QTextUndoCommand c = undoStack[i]; | - |
| 963 | if (c.command & QTextUndoCommand::Custom) partially evaluated: c.command & QTextUndoCommand::Custom| no Evaluation Count:0 | yes Evaluation Count:18256 |
| 0-18256 |
| 964 | delete c.custom; never executed: delete c.custom; | 0 |
| 965 | } executed: }Execution Count:18256 | 18256 |
| 966 | undoStack.resize(undoState); | - |
| 967 | if (emitSignals) partially evaluated: emitSignals| no Evaluation Count:0 | yes Evaluation Count:847 |
| 0-847 |
| 968 | emitRedoAvailable(false); never executed: emitRedoAvailable(false); | 0 |
| 969 | } else if (stacksToClear == QTextDocument::UndoAndRedoStacks executed: }Execution Count:847 evaluated: stacksToClear == QTextDocument::UndoAndRedoStacks| yes Evaluation Count:1199 | yes Evaluation Count:3402 |
| 847-3402 |
| 970 | && !undoStack.isEmpty()) { evaluated: !undoStack.isEmpty()| yes Evaluation Count:48 | yes Evaluation Count:1151 |
| 48-1151 |
| 971 | for (int i = 0; i < undoStack.size(); ++i) { evaluated: i < undoStack.size()| yes Evaluation Count:122 | yes Evaluation Count:48 |
| 48-122 |
| 972 | QTextUndoCommand c = undoStack[i]; | - |
| 973 | if (c.command & QTextUndoCommand::Custom) partially evaluated: c.command & QTextUndoCommand::Custom| no Evaluation Count:0 | yes Evaluation Count:122 |
| 0-122 |
| 974 | delete c.custom; never executed: delete c.custom; | 0 |
| 975 | } executed: }Execution Count:122 | 122 |
| 976 | undoState = 0; | - |
| 977 | undoStack.resize(0); | - |
| 978 | if (emitSignals && undoCommandsAvailable) partially evaluated: emitSignals| no Evaluation Count:0 | yes Evaluation Count:48 |
never evaluated: undoCommandsAvailable | 0-48 |
| 979 | emitUndoAvailable(false); never executed: emitUndoAvailable(false); | 0 |
| 980 | if (emitSignals && redoCommandsAvailable) partially evaluated: emitSignals| no Evaluation Count:0 | yes Evaluation Count:48 |
never evaluated: redoCommandsAvailable | 0-48 |
| 981 | emitRedoAvailable(false); never executed: emitRedoAvailable(false); | 0 |
| 982 | } executed: }Execution Count:48 | 48 |
| 983 | } | - |
| 984 | | - |
| 985 | void QTextDocumentPrivate::emitUndoAvailable(bool available) | - |
| 986 | { | - |
| 987 | if (available != wasUndoAvailable) { evaluated: available != wasUndoAvailable| yes Evaluation Count:866 | yes Evaluation Count:19856 |
| 866-19856 |
| 988 | QTextDocument * const q = q_func(); | - |
| 989 | q->undoAvailable(available); | - |
| 990 | wasUndoAvailable = available; | - |
| 991 | } executed: }Execution Count:866 | 866 |
| 992 | } executed: }Execution Count:20722 | 20722 |
| 993 | | - |
| 994 | void QTextDocumentPrivate::emitRedoAvailable(bool available) | - |
| 995 | { | - |
| 996 | if (available != wasRedoAvailable) { evaluated: available != wasRedoAvailable| yes Evaluation Count:76 | yes Evaluation Count:20646 |
| 76-20646 |
| 997 | QTextDocument * const q = q_func(); | - |
| 998 | q->redoAvailable(available); | - |
| 999 | wasRedoAvailable = available; | - |
| 1000 | } executed: }Execution Count:76 | 76 |
| 1001 | } executed: }Execution Count:20722 | 20722 |
| 1002 | | - |
| 1003 | void QTextDocumentPrivate::enableUndoRedo(bool enable) | - |
| 1004 | { | - |
| 1005 | if (enable && maximumBlockCount > 0) evaluated: enable| yes Evaluation Count:1066 | yes Evaluation Count:2292 |
partially evaluated: maximumBlockCount > 0| no Evaluation Count:0 | yes Evaluation Count:1066 |
| 0-2292 |
| 1006 | return; | 0 |
| 1007 | | - |
| 1008 | if (!enable) { evaluated: !enable| yes Evaluation Count:2292 | yes Evaluation Count:1066 |
| 1066-2292 |
| 1009 | undoState = 0; | - |
| 1010 | clearUndoRedoStacks(QTextDocument::RedoStack); | - |
| 1011 | emitUndoAvailable(false); | - |
| 1012 | emitRedoAvailable(false); | - |
| 1013 | } executed: }Execution Count:2292 | 2292 |
| 1014 | modifiedState = modified ? -1 : undoState; evaluated: modified| yes Evaluation Count:685 | yes Evaluation Count:2673 |
| 685-2673 |
| 1015 | undoEnabled = enable; | - |
| 1016 | if (!undoEnabled) evaluated: !undoEnabled| yes Evaluation Count:2292 | yes Evaluation Count:1066 |
| 1066-2292 |
| 1017 | compressPieceTable(); executed: compressPieceTable();Execution Count:2292 | 2292 |
| 1018 | } executed: }Execution Count:3358 | 3358 |
| 1019 | | - |
| 1020 | void QTextDocumentPrivate::joinPreviousEditBlock() | - |
| 1021 | { | - |
| 1022 | beginEditBlock(); | - |
| 1023 | | - |
| 1024 | if (undoEnabled && undoState) partially evaluated: undoEnabled| yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: undoState| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1025 | undoStack[undoState - 1].block_end = false; executed: undoStack[undoState - 1].block_end = false;Execution Count:1 | 1 |
| 1026 | } executed: }Execution Count:1 | 1 |
| 1027 | | - |
| 1028 | void QTextDocumentPrivate::endEditBlock() | - |
| 1029 | { | - |
| 1030 | qt_noop(); | - |
| 1031 | if (--editBlock) evaluated: --editBlock| yes Evaluation Count:24284 | yes Evaluation Count:17724 |
| 17724-24284 |
| 1032 | return; executed: return;Execution Count:24284 | 24284 |
| 1033 | | - |
| 1034 | if (undoEnabled && undoState > 0) { evaluated: undoEnabled| yes Evaluation Count:12021 | yes Evaluation Count:5703 |
evaluated: undoState > 0| yes Evaluation Count:11996 | yes Evaluation Count:25 |
| 25-12021 |
| 1035 | const bool wasBlocking = !undoStack[undoState - 1].block_end; | - |
| 1036 | if (undoStack[undoState - 1].block_part) { evaluated: undoStack[undoState - 1].block_part| yes Evaluation Count:11959 | yes Evaluation Count:37 |
| 37-11959 |
| 1037 | undoStack[undoState - 1].block_end = true; | - |
| 1038 | if (wasBlocking) evaluated: wasBlocking| yes Evaluation Count:11935 | yes Evaluation Count:24 |
| 24-11935 |
| 1039 | document()->undoCommandAdded(); executed: document()->undoCommandAdded();Execution Count:11935 | 11935 |
| 1040 | } executed: }Execution Count:11959 | 11959 |
| 1041 | } executed: }Execution Count:11996 | 11996 |
| 1042 | | - |
| 1043 | editBlockCursorPosition = -1; | - |
| 1044 | | - |
| 1045 | finishEdit(); | - |
| 1046 | } executed: }Execution Count:17724 | 17724 |
| 1047 | | - |
| 1048 | void QTextDocumentPrivate::finishEdit() | - |
| 1049 | { | - |
| 1050 | QTextDocument * const q = q_func(); | - |
| 1051 | | - |
| 1052 | if (editBlock) evaluated: editBlock| yes Evaluation Count:7262 | yes Evaluation Count:19281 |
| 7262-19281 |
| 1053 | return; executed: return;Execution Count:7262 | 7262 |
| 1054 | | - |
| 1055 | if (framesDirty) evaluated: framesDirty| yes Evaluation Count:381 | yes Evaluation Count:18900 |
| 381-18900 |
| 1056 | scan_frames(docChangeFrom, docChangeOldLength, docChangeLength); executed: scan_frames(docChangeFrom, docChangeOldLength, docChangeLength);Execution Count:381 | 381 |
| 1057 | | - |
| 1058 | if (lout && docChangeFrom >= 0) { evaluated: lout| yes Evaluation Count:11840 | yes Evaluation Count:7441 |
evaluated: docChangeFrom >= 0| yes Evaluation Count:11826 | yes Evaluation Count:14 |
| 14-11840 |
| 1059 | if (!inContentsChange) { evaluated: !inContentsChange| yes Evaluation Count:11825 | yes Evaluation Count:1 |
| 1-11825 |
| 1060 | inContentsChange = true; | - |
| 1061 | q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength); | - |
| 1062 | inContentsChange = false; | - |
| 1063 | } executed: }Execution Count:11825 | 11825 |
| 1064 | lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength); | - |
| 1065 | } executed: }Execution Count:11826 | 11826 |
| 1066 | | - |
| 1067 | docChangeFrom = -1; | - |
| 1068 | | - |
| 1069 | if (needsEnsureMaximumBlockCount) { evaluated: needsEnsureMaximumBlockCount| yes Evaluation Count:15365 | yes Evaluation Count:3916 |
| 3916-15365 |
| 1070 | needsEnsureMaximumBlockCount = false; | - |
| 1071 | if (ensureMaximumBlockCount()) { evaluated: ensureMaximumBlockCount()| yes Evaluation Count:906 | yes Evaluation Count:14459 |
| 906-14459 |
| 1072 | | - |
| 1073 | | - |
| 1074 | | - |
| 1075 | | - |
| 1076 | return; executed: return;Execution Count:906 | 906 |
| 1077 | } | - |
| 1078 | } executed: }Execution Count:14459 | 14459 |
| 1079 | | - |
| 1080 | QList<QTextCursor> changedCursors; | - |
| 1081 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 1082 | if (curs->changed) { evaluated: curs->changed| yes Evaluation Count:16784 | yes Evaluation Count:481 |
| 481-16784 |
| 1083 | curs->changed = false; | - |
| 1084 | changedCursors.append(QTextCursor(curs)); | - |
| 1085 | } executed: }Execution Count:16784 | 16784 |
| 1086 | } executed: }Execution Count:17265 | 17265 |
| 1087 | for (QForeachContainer<__typeof__(changedCursors)> _container_(changedCursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QTextCursor &cursor = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
| 1088 | q->cursorPositionChanged(cursor); executed: q->cursorPositionChanged(cursor);Execution Count:16784 | 16784 |
| 1089 | | - |
| 1090 | contentsChanged(); | - |
| 1091 | | - |
| 1092 | if (blocks.numNodes() != lastBlockCount) { evaluated: blocks.numNodes() != lastBlockCount| yes Evaluation Count:13702 | yes Evaluation Count:4673 |
| 4673-13702 |
| 1093 | lastBlockCount = blocks.numNodes(); | - |
| 1094 | q->blockCountChanged(lastBlockCount); | - |
| 1095 | } executed: }Execution Count:13702 | 13702 |
| 1096 | | - |
| 1097 | if (!undoEnabled && unreachableCharacterCount) evaluated: !undoEnabled| yes Evaluation Count:5818 | yes Evaluation Count:12557 |
evaluated: unreachableCharacterCount| yes Evaluation Count:2036 | yes Evaluation Count:3782 |
| 2036-12557 |
| 1098 | compressPieceTable(); executed: compressPieceTable();Execution Count:2036 | 2036 |
| 1099 | } executed: }Execution Count:18375 | 18375 |
| 1100 | | - |
| 1101 | void QTextDocumentPrivate::documentChange(int from, int length) | - |
| 1102 | { | - |
| 1103 | | - |
| 1104 | if (docChangeFrom < 0) { evaluated: docChangeFrom < 0| yes Evaluation Count:11989 | yes Evaluation Count:25262565 |
| 11989-25262565 |
| 1105 | docChangeFrom = from; | - |
| 1106 | docChangeOldLength = length; | - |
| 1107 | docChangeLength = length; | - |
| 1108 | return; executed: return;Execution Count:11989 | 11989 |
| 1109 | } | - |
| 1110 | int start = qMin(from, docChangeFrom); | - |
| 1111 | int end = qMax(from + length, docChangeFrom + docChangeLength); | - |
| 1112 | int diff = qMax(0, end - start - docChangeLength); | - |
| 1113 | docChangeFrom = start; | - |
| 1114 | docChangeOldLength += diff; | - |
| 1115 | docChangeLength += diff; | - |
| 1116 | } executed: }Execution Count:25262565 | 25262565 |
| 1117 | void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op) | - |
| 1118 | { | - |
| 1119 | if (!editBlock) evaluated: !editBlock| yes Evaluation Count:1537 | yes Evaluation Count:27346 |
| 1537-27346 |
| 1120 | ++revision; executed: ++revision;Execution Count:1537 | 1537 |
| 1121 | | - |
| 1122 | if (blockCursorAdjustment) { evaluated: blockCursorAdjustment| yes Evaluation Count:2370 | yes Evaluation Count:26513 |
| 2370-26513 |
| 1123 | ; | - |
| 1124 | } else { executed: }Execution Count:2370 | 2370 |
| 1125 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 1126 | if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) { evaluated: curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved| yes Evaluation Count:30357 | yes Evaluation Count:255 |
| 255-30357 |
| 1127 | curs->changed = true; | - |
| 1128 | } executed: }Execution Count:30357 | 30357 |
| 1129 | } executed: }Execution Count:30612 | 30612 |
| 1130 | } executed: }Execution Count:26513 | 26513 |
| 1131 | | - |
| 1132 | | - |
| 1133 | if (docChangeFrom < 0) { evaluated: docChangeFrom < 0| yes Evaluation Count:7265 | yes Evaluation Count:21618 |
| 7265-21618 |
| 1134 | docChangeFrom = from; | - |
| 1135 | if (addedOrRemoved > 0) { evaluated: addedOrRemoved > 0| yes Evaluation Count:6187 | yes Evaluation Count:1078 |
| 1078-6187 |
| 1136 | docChangeOldLength = 0; | - |
| 1137 | docChangeLength = addedOrRemoved; | - |
| 1138 | } else { executed: }Execution Count:6187 | 6187 |
| 1139 | docChangeOldLength = -addedOrRemoved; | - |
| 1140 | docChangeLength = 0; | - |
| 1141 | } executed: }Execution Count:1078 | 1078 |
| 1142 | | - |
| 1143 | | - |
| 1144 | return; executed: return;Execution Count:7265 | 7265 |
| 1145 | } | - |
| 1146 | | - |
| 1147 | | - |
| 1148 | int added = qMax(0, addedOrRemoved); | - |
| 1149 | int removed = qMax(0, -addedOrRemoved); | - |
| 1150 | | - |
| 1151 | int diff = 0; | - |
| 1152 | if(from + removed < docChangeFrom) evaluated: from + removed < docChangeFrom| yes Evaluation Count:27 | yes Evaluation Count:21591 |
| 27-21591 |
| 1153 | diff = docChangeFrom - from - removed; executed: diff = docChangeFrom - from - removed;Execution Count:27 | 27 |
| 1154 | else if(from > docChangeFrom + docChangeLength) evaluated: from > docChangeFrom + docChangeLength| yes Evaluation Count:79 | yes Evaluation Count:21512 |
| 79-21512 |
| 1155 | diff = from - (docChangeFrom + docChangeLength); executed: diff = from - (docChangeFrom + docChangeLength);Execution Count:79 | 79 |
| 1156 | | - |
| 1157 | int overlap_start = qMax(from, docChangeFrom); | - |
| 1158 | int overlap_end = qMin(from + removed, docChangeFrom + docChangeLength); | - |
| 1159 | int removedInside = qMax(0, overlap_end - overlap_start); | - |
| 1160 | removed -= removedInside; | - |
| 1161 | | - |
| 1162 | | - |
| 1163 | docChangeFrom = qMin(docChangeFrom, from); | - |
| 1164 | docChangeOldLength += removed + diff; | - |
| 1165 | docChangeLength += added - removedInside + diff; | - |
| 1166 | | - |
| 1167 | | - |
| 1168 | } executed: }Execution Count:21618 | 21618 |
| 1169 | | - |
| 1170 | | - |
| 1171 | QString QTextDocumentPrivate::plainText() const | - |
| 1172 | { | - |
| 1173 | QString result; | - |
| 1174 | result.resize(length()); | - |
| 1175 | const QChar *text_unicode = text.unicode(); | - |
| 1176 | QChar *data = result.data(); | - |
| 1177 | for (QTextDocumentPrivate::FragmentIterator it = begin(); it != end(); ++it) { evaluated: it != end()| yes Evaluation Count:636 | yes Evaluation Count:210 |
| 210-636 |
| 1178 | const QTextFragmentData *f = *it; | - |
| 1179 | ::memcpy(data, text_unicode + f->stringPosition, f->size_array[0] * sizeof(QChar)); | - |
| 1180 | data += f->size_array[0]; | - |
| 1181 | } executed: }Execution Count:636 | 636 |
| 1182 | | - |
| 1183 | result.chop(1); | - |
| 1184 | return result; executed: return result;Execution Count:210 | 210 |
| 1185 | } | - |
| 1186 | | - |
| 1187 | int QTextDocumentPrivate::blockCharFormatIndex(int node) const | - |
| 1188 | { | - |
| 1189 | int pos = blocks.position(node); | - |
| 1190 | if (pos == 0) evaluated: pos == 0| yes Evaluation Count:6132 | yes Evaluation Count:2076 |
| 2076-6132 |
| 1191 | return initialBlockCharFormatIndex; executed: return initialBlockCharFormatIndex;Execution Count:6132 | 6132 |
| 1192 | | - |
| 1193 | return fragments.find(pos - 1)->format; executed: return fragments.find(pos - 1)->format;Execution Count:2076 | 2076 |
| 1194 | } | - |
| 1195 | | - |
| 1196 | int QTextDocumentPrivate::nextCursorPosition(int position, QTextLayout::CursorMode mode) const | - |
| 1197 | { | - |
| 1198 | if (position == length()-1) evaluated: position == length()-1| yes Evaluation Count:5 | yes Evaluation Count:139 |
| 5-139 |
| 1199 | return position; executed: return position;Execution Count:5 | 5 |
| 1200 | | - |
| 1201 | QTextBlock it = blocksFind(position); | - |
| 1202 | int start = it.position(); | - |
| 1203 | int end = start + it.length() - 1; | - |
| 1204 | if (position == end) evaluated: position == end| yes Evaluation Count:7 | yes Evaluation Count:132 |
| 7-132 |
| 1205 | return end + 1; executed: return end + 1;Execution Count:7 | 7 |
| 1206 | | - |
| 1207 | return it.layout()->nextCursorPosition(position-start, mode) + start; executed: return it.layout()->nextCursorPosition(position-start, mode) + start;Execution Count:132 | 132 |
| 1208 | } | - |
| 1209 | | - |
| 1210 | int QTextDocumentPrivate::previousCursorPosition(int position, QTextLayout::CursorMode mode) const | - |
| 1211 | { | - |
| 1212 | if (position == 0) evaluated: position == 0| yes Evaluation Count:4 | yes Evaluation Count:107 |
| 4-107 |
| 1213 | return position; executed: return position;Execution Count:4 | 4 |
| 1214 | | - |
| 1215 | QTextBlock it = blocksFind(position); | - |
| 1216 | int start = it.position(); | - |
| 1217 | if (position == start) evaluated: position == start| yes Evaluation Count:29 | yes Evaluation Count:78 |
| 29-78 |
| 1218 | return start - 1; executed: return start - 1;Execution Count:29 | 29 |
| 1219 | | - |
| 1220 | return it.layout()->previousCursorPosition(position-start, mode) + start; executed: return it.layout()->previousCursorPosition(position-start, mode) + start;Execution Count:78 | 78 |
| 1221 | } | - |
| 1222 | | - |
| 1223 | int QTextDocumentPrivate::leftCursorPosition(int position) const | - |
| 1224 | { | - |
| 1225 | QTextBlock it = blocksFind(position); | - |
| 1226 | int start = it.position(); | - |
| 1227 | return it.layout()->leftCursorPosition(position-start) + start; never executed: return it.layout()->leftCursorPosition(position-start) + start; | 0 |
| 1228 | } | - |
| 1229 | | - |
| 1230 | int QTextDocumentPrivate::rightCursorPosition(int position) const | - |
| 1231 | { | - |
| 1232 | QTextBlock it = blocksFind(position); | - |
| 1233 | int start = it.position(); | - |
| 1234 | return it.layout()->rightCursorPosition(position-start) + start; never executed: return it.layout()->rightCursorPosition(position-start) + start; | 0 |
| 1235 | } | - |
| 1236 | | - |
| 1237 | void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format) | - |
| 1238 | { | - |
| 1239 | beginEditBlock(); | - |
| 1240 | int objectIndex = obj->objectIndex(); | - |
| 1241 | int oldFormatIndex = formats.objectFormatIndex(objectIndex); | - |
| 1242 | formats.setObjectFormatIndex(objectIndex, format); | - |
| 1243 | | - |
| 1244 | QTextBlockGroup *b = qobject_cast<QTextBlockGroup *>(obj); | - |
| 1245 | if (b) { evaluated: b| yes Evaluation Count:1 | yes Evaluation Count:104 |
| 1-104 |
| 1246 | b->d_func()->markBlocksDirty(); | - |
| 1247 | } executed: }Execution Count:1 | 1 |
| 1248 | QTextFrame *f = qobject_cast<QTextFrame *>(obj); | - |
| 1249 | if (f) evaluated: f| yes Evaluation Count:104 | yes Evaluation Count:1 |
| 1-104 |
| 1250 | documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition()); executed: documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition());Execution Count:104 | 104 |
| 1251 | | - |
| 1252 | QTextUndoCommand c = { QTextUndoCommand::GroupFormatChange, (editBlock != 0), 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormatIndex, quint32(0), quint32(0), { int(obj->d_func()->objectIndex) }, quint32(0) }; | - |
| 1253 | | - |
| 1254 | appendUndoItem(c); | - |
| 1255 | | - |
| 1256 | endEditBlock(); | - |
| 1257 | } executed: }Execution Count:105 | 105 |
| 1258 | | - |
| 1259 | static QTextFrame *findChildFrame(QTextFrame *f, int pos) | - |
| 1260 | { | - |
| 1261 | | - |
| 1262 | const QList<QTextFrame *> children = f->childFrames(); | - |
| 1263 | int first = 0; | - |
| 1264 | int last = children.size() - 1; | - |
| 1265 | while (first <= last) { evaluated: first <= last| yes Evaluation Count:1155 | yes Evaluation Count:10991 |
| 1155-10991 |
| 1266 | int mid = (first + last) / 2; | - |
| 1267 | QTextFrame *c = children.at(mid); | - |
| 1268 | if (pos > c->lastPosition()) evaluated: pos > c->lastPosition()| yes Evaluation Count:195 | yes Evaluation Count:960 |
| 195-960 |
| 1269 | first = mid + 1; executed: first = mid + 1;Execution Count:195 | 195 |
| 1270 | else if (pos < c->firstPosition()) evaluated: pos < c->firstPosition()| yes Evaluation Count:236 | yes Evaluation Count:724 |
| 236-724 |
| 1271 | last = mid - 1; executed: last = mid - 1;Execution Count:236 | 236 |
| 1272 | else | - |
| 1273 | return c; executed: return c;Execution Count:724 | 724 |
| 1274 | } | - |
| 1275 | return 0; executed: return 0;Execution Count:10991 | 10991 |
| 1276 | } | - |
| 1277 | | - |
| 1278 | QTextFrame *QTextDocumentPrivate::rootFrame() const | - |
| 1279 | { | - |
| 1280 | if (!rtFrame) { evaluated: !rtFrame| yes Evaluation Count:1821 | yes Evaluation Count:21393 |
| 1821-21393 |
| 1281 | QTextFrameFormat defaultRootFrameFormat; | - |
| 1282 | defaultRootFrameFormat.setMargin(documentMargin); | - |
| 1283 | rtFrame = qobject_cast<QTextFrame *>(const_cast<QTextDocumentPrivate *>(this)->createObject(defaultRootFrameFormat)); | - |
| 1284 | } executed: }Execution Count:1821 | 1821 |
| 1285 | return rtFrame; executed: return rtFrame;Execution Count:23214 | 23214 |
| 1286 | } | - |
| 1287 | | - |
| 1288 | QTextFrame *QTextDocumentPrivate::frameAt(int pos) const | - |
| 1289 | { | - |
| 1290 | QTextFrame *f = rootFrame(); | - |
| 1291 | | - |
| 1292 | while (1) { partially evaluated: 1| yes Evaluation Count:11715 | no Evaluation Count:0 |
| 0-11715 |
| 1293 | QTextFrame *c = findChildFrame(f, pos); | - |
| 1294 | if (!c) evaluated: !c| yes Evaluation Count:10991 | yes Evaluation Count:724 |
| 724-10991 |
| 1295 | return f; executed: return f;Execution Count:10991 | 10991 |
| 1296 | f = c; | - |
| 1297 | } executed: }Execution Count:724 | 724 |
| 1298 | } | 0 |
| 1299 | | - |
| 1300 | void QTextDocumentPrivate::clearFrame(QTextFrame *f) | - |
| 1301 | { | - |
| 1302 | for (int i = 0; i < f->d_func()->childFrames.count(); ++i) evaluated: i < f->d_func()->childFrames.count()| yes Evaluation Count:124 | yes Evaluation Count:505 |
| 124-505 |
| 1303 | clearFrame(f->d_func()->childFrames.at(i)); executed: clearFrame(f->d_func()->childFrames.at(i));Execution Count:124 | 124 |
| 1304 | f->d_func()->childFrames.clear(); | - |
| 1305 | f->d_func()->parentFrame = 0; | - |
| 1306 | } executed: }Execution Count:505 | 505 |
| 1307 | | - |
| 1308 | void QTextDocumentPrivate::scan_frames(int pos, int charsRemoved, int charsAdded) | - |
| 1309 | { | - |
| 1310 | | - |
| 1311 | (void)pos;; | - |
| 1312 | (void)charsRemoved;; | - |
| 1313 | (void)charsAdded;; | - |
| 1314 | | - |
| 1315 | QTextFrame *f = rootFrame(); | - |
| 1316 | clearFrame(f); | - |
| 1317 | | - |
| 1318 | for (FragmentIterator it = begin(); it != end(); ++it) { evaluated: it != end()| yes Evaluation Count:3402 | yes Evaluation Count:381 |
| 381-3402 |
| 1319 | | - |
| 1320 | QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(it->format)); | - |
| 1321 | if (!frame) evaluated: !frame| yes Evaluation Count:827 | yes Evaluation Count:2575 |
| 827-2575 |
| 1322 | continue; executed: continue;Execution Count:827 | 827 |
| 1323 | | - |
| 1324 | qt_noop(); | - |
| 1325 | QChar ch = text.at(it->stringPosition); | - |
| 1326 | | - |
| 1327 | if (ch == QChar(0xfdd0)) { evaluated: ch == QChar(0xfdd0)| yes Evaluation Count:2169 | yes Evaluation Count:406 |
| 406-2169 |
| 1328 | if (f != frame) { evaluated: f != frame| yes Evaluation Count:373 | yes Evaluation Count:1796 |
| 373-1796 |
| 1329 | | - |
| 1330 | qt_noop(); | - |
| 1331 | frame->d_func()->parentFrame = f; | - |
| 1332 | f->d_func()->childFrames.append(frame); | - |
| 1333 | f = frame; | - |
| 1334 | } executed: }Execution Count:373 | 373 |
| 1335 | } else if (ch == QChar(0xfdd1)) { executed: }Execution Count:2169 evaluated: ch == QChar(0xfdd1)| yes Evaluation Count:373 | yes Evaluation Count:33 |
| 33-2169 |
| 1336 | qt_noop(); | - |
| 1337 | qt_noop(); | - |
| 1338 | f = frame->d_func()->parentFrame; | - |
| 1339 | } else if (ch == QChar::ObjectReplacementCharacter) { executed: }Execution Count:373 partially evaluated: ch == QChar::ObjectReplacementCharacter| yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-373 |
| 1340 | qt_noop(); | - |
| 1341 | qt_noop(); | - |
| 1342 | qt_noop(); | - |
| 1343 | frame->d_func()->parentFrame = f; | - |
| 1344 | f->d_func()->childFrames.append(frame); | - |
| 1345 | } else { executed: }Execution Count:33 | 33 |
| 1346 | qt_noop(); | - |
| 1347 | } | 0 |
| 1348 | } | - |
| 1349 | qt_noop(); | - |
| 1350 | framesDirty = false; | - |
| 1351 | } executed: }Execution Count:381 | 381 |
| 1352 | | - |
| 1353 | void QTextDocumentPrivate::insert_frame(QTextFrame *f) | - |
| 1354 | { | - |
| 1355 | int start = f->firstPosition(); | - |
| 1356 | int end = f->lastPosition(); | - |
| 1357 | QTextFrame *parent = frameAt(start-1); | - |
| 1358 | qt_noop(); | - |
| 1359 | | - |
| 1360 | if (start != end) { evaluated: start != end| yes Evaluation Count:1 | yes Evaluation Count:8 |
| 1-8 |
| 1361 | | - |
| 1362 | for (int i = 0; i < parent->d_func()->childFrames.size(); ++i) { partially evaluated: i < parent->d_func()->childFrames.size()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1363 | QTextFrame *c = parent->d_func()->childFrames.at(i); | - |
| 1364 | if (start < c->firstPosition() && end > c->lastPosition()) { never evaluated: start < c->firstPosition() never evaluated: end > c->lastPosition() | 0 |
| 1365 | parent->d_func()->childFrames.removeAt(i); | - |
| 1366 | f->d_func()->childFrames.append(c); | - |
| 1367 | c->d_func()->parentFrame = f; | - |
| 1368 | } | 0 |
| 1369 | } | 0 |
| 1370 | } executed: }Execution Count:1 | 1 |
| 1371 | | - |
| 1372 | int i = 0; | - |
| 1373 | for (; i < parent->d_func()->childFrames.size(); ++i) { partially evaluated: i < parent->d_func()->childFrames.size()| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 1374 | QTextFrame *c = parent->d_func()->childFrames.at(i); | - |
| 1375 | if (c->firstPosition() > end) never evaluated: c->firstPosition() > end | 0 |
| 1376 | break; | 0 |
| 1377 | } | 0 |
| 1378 | parent->d_func()->childFrames.insert(i, f); | - |
| 1379 | f->d_func()->parentFrame = parent; | - |
| 1380 | } executed: }Execution Count:9 | 9 |
| 1381 | | - |
| 1382 | QTextFrame *QTextDocumentPrivate::insertFrame(int start, int end, const QTextFrameFormat &format) | - |
| 1383 | { | - |
| 1384 | qt_noop(); | - |
| 1385 | qt_noop(); | - |
| 1386 | qt_noop(); | - |
| 1387 | | - |
| 1388 | if (start != end && frameAt(start) != frameAt(end)) evaluated: start != end| yes Evaluation Count:1 | yes Evaluation Count:8 |
partially evaluated: frameAt(start) != frameAt(end)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-8 |
| 1389 | return 0; never executed: return 0; | 0 |
| 1390 | | - |
| 1391 | beginEditBlock(); | - |
| 1392 | | - |
| 1393 | QTextFrame *frame = qobject_cast<QTextFrame *>(createObject(format)); | - |
| 1394 | qt_noop(); | - |
| 1395 | | - |
| 1396 | | - |
| 1397 | int idx = formats.indexForFormat(QTextBlockFormat()); | - |
| 1398 | QTextCharFormat cfmt; | - |
| 1399 | cfmt.setObjectIndex(frame->objectIndex()); | - |
| 1400 | int charIdx = formats.indexForFormat(cfmt); | - |
| 1401 | | - |
| 1402 | insertBlock(QChar(0xfdd0), start, idx, charIdx, QTextUndoCommand::MoveCursor); | - |
| 1403 | insertBlock(QChar(0xfdd1), ++end, idx, charIdx, QTextUndoCommand::KeepCursor); | - |
| 1404 | | - |
| 1405 | frame->d_func()->fragment_start = find(start).n; | - |
| 1406 | frame->d_func()->fragment_end = find(end).n; | - |
| 1407 | | - |
| 1408 | insert_frame(frame); | - |
| 1409 | | - |
| 1410 | endEditBlock(); | - |
| 1411 | | - |
| 1412 | return frame; executed: return frame;Execution Count:9 | 9 |
| 1413 | } | - |
| 1414 | | - |
| 1415 | void QTextDocumentPrivate::removeFrame(QTextFrame *frame) | - |
| 1416 | { | - |
| 1417 | QTextFrame *parent = frame->d_func()->parentFrame; | - |
| 1418 | if (!parent) | 0 |
| 1419 | return; | 0 |
| 1420 | | - |
| 1421 | int start = frame->firstPosition(); | - |
| 1422 | int end = frame->lastPosition(); | - |
| 1423 | qt_noop(); | - |
| 1424 | | - |
| 1425 | beginEditBlock(); | - |
| 1426 | | - |
| 1427 | | - |
| 1428 | remove(end, 1); | - |
| 1429 | remove(start-1, 1); | - |
| 1430 | | - |
| 1431 | endEditBlock(); | - |
| 1432 | } | 0 |
| 1433 | | - |
| 1434 | QTextObject *QTextDocumentPrivate::objectForIndex(int objectIndex) const | - |
| 1435 | { | - |
| 1436 | if (objectIndex < 0) evaluated: objectIndex < 0| yes Evaluation Count:45953 | yes Evaluation Count:15873 |
| 15873-45953 |
| 1437 | return 0; executed: return 0;Execution Count:45953 | 45953 |
| 1438 | | - |
| 1439 | QTextObject *object = objects.value(objectIndex, 0); | - |
| 1440 | if (!object) { evaluated: !object| yes Evaluation Count:143 | yes Evaluation Count:15730 |
| 143-15730 |
| 1441 | QTextDocumentPrivate *that = const_cast<QTextDocumentPrivate *>(this); | - |
| 1442 | QTextFormat fmt = formats.objectFormat(objectIndex); | - |
| 1443 | object = that->createObject(fmt, objectIndex); | - |
| 1444 | } executed: }Execution Count:143 | 143 |
| 1445 | return object; executed: return object;Execution Count:15873 | 15873 |
| 1446 | } | - |
| 1447 | | - |
| 1448 | QTextObject *QTextDocumentPrivate::objectForFormat(int formatIndex) const | - |
| 1449 | { | - |
| 1450 | int objectIndex = formats.format(formatIndex).objectIndex(); | - |
| 1451 | return objectForIndex(objectIndex); executed: return objectForIndex(objectIndex);Execution Count:33635 | 33635 |
| 1452 | } | - |
| 1453 | | - |
| 1454 | QTextObject *QTextDocumentPrivate::objectForFormat(const QTextFormat &f) const | - |
| 1455 | { | - |
| 1456 | return objectForIndex(f.objectIndex()); executed: return objectForIndex(f.objectIndex());Execution Count:28190 | 28190 |
| 1457 | } | - |
| 1458 | | - |
| 1459 | QTextObject *QTextDocumentPrivate::createObject(const QTextFormat &f, int objectIndex) | - |
| 1460 | { | - |
| 1461 | QTextObject *obj = document()->createObject(f); | - |
| 1462 | | - |
| 1463 | if (obj) { partially evaluated: obj| yes Evaluation Count:2216 | no Evaluation Count:0 |
| 0-2216 |
| 1464 | obj->d_func()->objectIndex = objectIndex == -1 ? formats.createObjectIndex(f) : objectIndex; evaluated: objectIndex == -1| yes Evaluation Count:2073 | yes Evaluation Count:143 |
| 143-2073 |
| 1465 | objects[obj->d_func()->objectIndex] = obj; | - |
| 1466 | } executed: }Execution Count:2216 | 2216 |
| 1467 | | - |
| 1468 | return obj; executed: return obj;Execution Count:2216 | 2216 |
| 1469 | } | - |
| 1470 | | - |
| 1471 | void QTextDocumentPrivate::deleteObject(QTextObject *object) | - |
| 1472 | { | - |
| 1473 | const int objIdx = object->d_func()->objectIndex; | - |
| 1474 | objects.remove(objIdx); | - |
| 1475 | delete object; | - |
| 1476 | } executed: }Execution Count:11 | 11 |
| 1477 | | - |
| 1478 | void QTextDocumentPrivate::contentsChanged() | - |
| 1479 | { | - |
| 1480 | QTextDocument * const q = q_func(); | - |
| 1481 | if (editBlock) partially evaluated: editBlock| no Evaluation Count:0 | yes Evaluation Count:18375 |
| 0-18375 |
| 1482 | return; | 0 |
| 1483 | | - |
| 1484 | bool m = undoEnabled ? (modifiedState != undoState) : true; evaluated: undoEnabled| yes Evaluation Count:12557 | yes Evaluation Count:5818 |
| 5818-12557 |
| 1485 | if (modified != m) { evaluated: modified != m| yes Evaluation Count:4630 | yes Evaluation Count:13745 |
| 4630-13745 |
| 1486 | modified = m; | - |
| 1487 | q->modificationChanged(modified); | - |
| 1488 | } executed: }Execution Count:4630 | 4630 |
| 1489 | | - |
| 1490 | q->contentsChanged(); | - |
| 1491 | } executed: }Execution Count:18375 | 18375 |
| 1492 | | - |
| 1493 | void QTextDocumentPrivate::compressPieceTable() | - |
| 1494 | { | - |
| 1495 | if (undoEnabled) evaluated: undoEnabled| yes Evaluation Count:1 | yes Evaluation Count:5235 |
| 1-5235 |
| 1496 | return; executed: return;Execution Count:1 | 1 |
| 1497 | | - |
| 1498 | const uint garbageCollectionThreshold = 96 * 1024; | - |
| 1499 | | - |
| 1500 | | - |
| 1501 | | - |
| 1502 | bool compressTable = unreachableCharacterCount * sizeof(QChar) > garbageCollectionThreshold partially evaluated: unreachableCharacterCount * sizeof(QChar) > garbageCollectionThreshold| no Evaluation Count:0 | yes Evaluation Count:5235 |
| 0-5235 |
| 1503 | && text.size() >= text.capacity() * 0.9; never evaluated: text.size() >= text.capacity() * 0.9 | 0 |
| 1504 | if (!compressTable) partially evaluated: !compressTable| yes Evaluation Count:5235 | no Evaluation Count:0 |
| 0-5235 |
| 1505 | return; executed: return;Execution Count:5235 | 5235 |
| 1506 | | - |
| 1507 | QString newText; | - |
| 1508 | newText.resize(text.size()); | - |
| 1509 | QChar *newTextPtr = newText.data(); | - |
| 1510 | int newLen = 0; | - |
| 1511 | | - |
| 1512 | for (FragmentMap::Iterator it = fragments.begin(); !it.atEnd(); ++it) { never evaluated: !it.atEnd() | 0 |
| 1513 | memcpy(newTextPtr, text.constData() + it->stringPosition, it->size_array[0] * sizeof(QChar)); | - |
| 1514 | it->stringPosition = newLen; | - |
| 1515 | newTextPtr += it->size_array[0]; | - |
| 1516 | newLen += it->size_array[0]; | - |
| 1517 | } | 0 |
| 1518 | | - |
| 1519 | newText.resize(newLen); | - |
| 1520 | newText.squeeze(); | - |
| 1521 | | - |
| 1522 | text = newText; | - |
| 1523 | unreachableCharacterCount = 0; | - |
| 1524 | } | 0 |
| 1525 | | - |
| 1526 | void QTextDocumentPrivate::setModified(bool m) | - |
| 1527 | { | - |
| 1528 | QTextDocument * const q = q_func(); | - |
| 1529 | if (m == modified) evaluated: m == modified| yes Evaluation Count:326 | yes Evaluation Count:235 |
| 235-326 |
| 1530 | return; executed: return;Execution Count:326 | 326 |
| 1531 | | - |
| 1532 | modified = m; | - |
| 1533 | if (!modified) partially evaluated: !modified| yes Evaluation Count:235 | no Evaluation Count:0 |
| 0-235 |
| 1534 | modifiedState = undoState; executed: modifiedState = undoState;Execution Count:235 | 235 |
| 1535 | else | - |
| 1536 | modifiedState = -1; never executed: modifiedState = -1; | 0 |
| 1537 | | - |
| 1538 | q->modificationChanged(modified); | - |
| 1539 | } executed: }Execution Count:235 | 235 |
| 1540 | | - |
| 1541 | bool QTextDocumentPrivate::ensureMaximumBlockCount() | - |
| 1542 | { | - |
| 1543 | if (maximumBlockCount <= 0) evaluated: maximumBlockCount <= 0| yes Evaluation Count:14351 | yes Evaluation Count:1019 |
| 1019-14351 |
| 1544 | return false; executed: return false;Execution Count:14351 | 14351 |
| 1545 | if (blocks.numNodes() <= maximumBlockCount) evaluated: blocks.numNodes() <= maximumBlockCount| yes Evaluation Count:111 | yes Evaluation Count:908 |
| 111-908 |
| 1546 | return false; executed: return false;Execution Count:111 | 111 |
| 1547 | | - |
| 1548 | beginEditBlock(); | - |
| 1549 | | - |
| 1550 | const int blocksToRemove = blocks.numNodes() - maximumBlockCount; | - |
| 1551 | QTextCursor cursor(this, 0); | - |
| 1552 | cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove); | - |
| 1553 | | - |
| 1554 | unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart(); | - |
| 1555 | | - |
| 1556 | | - |
| 1557 | QTextCharFormat charFmt = cursor.blockCharFormat(); | - |
| 1558 | cursor.removeSelectedText(); | - |
| 1559 | cursor.setBlockCharFormat(charFmt); | - |
| 1560 | | - |
| 1561 | endEditBlock(); | - |
| 1562 | | - |
| 1563 | compressPieceTable(); | - |
| 1564 | | - |
| 1565 | return true; executed: return true;Execution Count:908 | 908 |
| 1566 | } | - |
| 1567 | | - |
| 1568 | | - |
| 1569 | void QTextDocumentPrivate::aboutToRemoveCell(int from, int to) | - |
| 1570 | { | - |
| 1571 | qt_noop(); | - |
| 1572 | for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
| 1573 | curs->aboutToRemoveCell(from, to); executed: curs->aboutToRemoveCell(from, to);Execution Count:32 | 32 |
| 1574 | } executed: }Execution Count:25 | 25 |
| 1575 | | - |
| 1576 | | - |
| 1577 | | - |
| | |