| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | void QTextTableCell::setFormat(const QTextCharFormat &format) | - |
| 7 | { | - |
| 8 | QTextCharFormat fmt = format; | - |
| 9 | fmt.clearProperty(QTextFormat::ObjectIndex); | - |
| 10 | fmt.setObjectType(QTextFormat::TableCellObject); | - |
| 11 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 12 | QTextDocumentPrivate::FragmentIterator frag(&p->fragmentMap(), fragment); | - |
| 13 | | - |
| 14 | QTextFormatCollection *c = p->formatCollection(); | - |
| 15 | QTextCharFormat oldFormat = c->charFormat(frag->format); | - |
| 16 | fmt.setTableCellRowSpan(oldFormat.tableCellRowSpan()); | - |
| 17 | fmt.setTableCellColumnSpan(oldFormat.tableCellColumnSpan()); | - |
| 18 | | - |
| 19 | p->setCharFormat(frag.position(), 1, fmt, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices); | - |
| 20 | } executed: }Execution Count:162 | 162 |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | QTextCharFormat QTextTableCell::format() const | - |
| 26 | { | - |
| 27 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 28 | QTextFormatCollection *c = p->formatCollection(); | - |
| 29 | | - |
| 30 | QTextCharFormat fmt = c->charFormat(tableCellFormatIndex()); | - |
| 31 | fmt.setObjectType(QTextFormat::TableCellObject); | - |
| 32 | return fmt; executed: return fmt;Execution Count:6354 | 6354 |
| 33 | } | - |
| 34 | int QTextTableCell::tableCellFormatIndex() const | - |
| 35 | { | - |
| 36 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 37 | return QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format; executed: return QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format;Execution Count:6354 | 6354 |
| 38 | } | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | int QTextTableCell::row() const | - |
| 46 | { | - |
| 47 | const QTextTablePrivate *tp = table->d_func(); | - |
| 48 | if (tp->dirty) partially evaluated: tp->dirty| no Evaluation Count:0 | yes Evaluation Count:2324 |
| 0-2324 |
| 49 | tp->update(); never executed: tp->update(); | 0 |
| 50 | | - |
| 51 | int idx = tp->findCellIndex(fragment); | - |
| 52 | if (idx == -1) partially evaluated: idx == -1| no Evaluation Count:0 | yes Evaluation Count:2324 |
| 0-2324 |
| 53 | return idx; never executed: return idx; | 0 |
| 54 | return tp->cellIndices.at(idx) / tp->nCols; executed: return tp->cellIndices.at(idx) / tp->nCols;Execution Count:2324 | 2324 |
| 55 | } | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | | - |
| 60 | | - |
| 61 | | - |
| 62 | int QTextTableCell::column() const | - |
| 63 | { | - |
| 64 | const QTextTablePrivate *tp = table->d_func(); | - |
| 65 | if (tp->dirty) partially evaluated: tp->dirty| no Evaluation Count:0 | yes Evaluation Count:1915 |
| 0-1915 |
| 66 | tp->update(); never executed: tp->update(); | 0 |
| 67 | | - |
| 68 | int idx = tp->findCellIndex(fragment); | - |
| 69 | if (idx == -1) partially evaluated: idx == -1| no Evaluation Count:0 | yes Evaluation Count:1915 |
| 0-1915 |
| 70 | return idx; never executed: return idx; | 0 |
| 71 | return tp->cellIndices.at(idx) % tp->nCols; executed: return tp->cellIndices.at(idx) % tp->nCols;Execution Count:1915 | 1915 |
| 72 | } | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | | - |
| 79 | int QTextTableCell::rowSpan() const | - |
| 80 | { | - |
| 81 | return format().tableCellRowSpan(); executed: return format().tableCellRowSpan();Execution Count:1722 | 1722 |
| 82 | } | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | | - |
| 89 | int QTextTableCell::columnSpan() const | - |
| 90 | { | - |
| 91 | return format().tableCellColumnSpan(); executed: return format().tableCellColumnSpan();Execution Count:2204 | 2204 |
| 92 | } | - |
| 93 | QTextCursor QTextTableCell::firstCursorPosition() const | - |
| 94 | { | - |
| 95 | return QTextCursor(table->d_func()->pieceTable, firstPosition()); executed: return QTextCursor(table->d_func()->pieceTable, firstPosition());Execution Count:317 | 317 |
| 96 | } | - |
| 97 | | - |
| 98 | | - |
| 99 | | - |
| 100 | | - |
| 101 | | - |
| 102 | | - |
| 103 | QTextCursor QTextTableCell::lastCursorPosition() const | - |
| 104 | { | - |
| 105 | return QTextCursor(table->d_func()->pieceTable, lastPosition()); executed: return QTextCursor(table->d_func()->pieceTable, lastPosition());Execution Count:12 | 12 |
| 106 | } | - |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | | - |
| 111 | | - |
| 112 | | - |
| 113 | | - |
| 114 | int QTextTableCell::firstPosition() const | - |
| 115 | { | - |
| 116 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 117 | return p->fragmentMap().position(fragment) + 1; executed: return p->fragmentMap().position(fragment) + 1;Execution Count:2212 | 2212 |
| 118 | } | - |
| 119 | | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | int QTextTableCell::lastPosition() const | - |
| 126 | { | - |
| 127 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 128 | const QTextTablePrivate *td = table->d_func(); | - |
| 129 | int index = table->d_func()->findCellIndex(fragment); | - |
| 130 | int f; | - |
| 131 | if (index != -1) partially evaluated: index != -1| yes Evaluation Count:1436 | no Evaluation Count:0 |
| 0-1436 |
| 132 | f = td->cells.value(index + 1, td->fragment_end); executed: f = td->cells.value(index + 1, td->fragment_end);Execution Count:1436 | 1436 |
| 133 | else | - |
| 134 | f = td->fragment_end; never executed: f = td->fragment_end; | 0 |
| 135 | return p->fragmentMap().position(f); executed: return p->fragmentMap().position(f);Execution Count:1436 | 1436 |
| 136 | } | - |
| 137 | | - |
| 138 | | - |
| 139 | | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | QTextFrame::iterator QTextTableCell::begin() const | - |
| 145 | { | - |
| 146 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 147 | int b = p->blockMap().findNode(firstPosition()); | - |
| 148 | int e = p->blockMap().findNode(lastPosition()+1); | - |
| 149 | return QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e); executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e);Execution Count:1293 | 1293 |
| 150 | } | - |
| 151 | | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | QTextFrame::iterator QTextTableCell::end() const | - |
| 158 | { | - |
| 159 | QTextDocumentPrivate *p = table->docHandle(); | - |
| 160 | int b = p->blockMap().findNode(firstPosition()); | - |
| 161 | int e = p->blockMap().findNode(lastPosition()+1); | - |
| 162 | return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e); never executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e); | 0 |
| 163 | } | - |
| 164 | QTextTablePrivate::~QTextTablePrivate() | - |
| 165 | { | - |
| 166 | if (grid) evaluated: grid| yes Evaluation Count:182 | yes Evaluation Count:58 |
| 58-182 |
| 167 | free(grid); executed: free(grid);Execution Count:182 | 182 |
| 168 | } executed: }Execution Count:240 | 240 |
| 169 | | - |
| 170 | | - |
| 171 | QTextTable *QTextTablePrivate::createTable(QTextDocumentPrivate *pieceTable, int pos, int rows, int cols, const QTextTableFormat &tableFormat) | - |
| 172 | { | - |
| 173 | QTextTableFormat fmt = tableFormat; | - |
| 174 | fmt.setColumns(cols); | - |
| 175 | QTextTable *table = qobject_cast<QTextTable *>(pieceTable->createObject(fmt)); | - |
| 176 | qt_noop(); | - |
| 177 | | - |
| 178 | pieceTable->beginEditBlock(); | - |
| 179 | | - |
| 180 | | - |
| 181 | | - |
| 182 | QTextCharFormat charFmt; | - |
| 183 | charFmt.setObjectIndex(table->objectIndex()); | - |
| 184 | charFmt.setObjectType(QTextFormat::TableCellObject); | - |
| 185 | | - |
| 186 | | - |
| 187 | int charIdx = pieceTable->formatCollection()->indexForFormat(charFmt); | - |
| 188 | int cellIdx = pieceTable->formatCollection()->indexForFormat(QTextBlockFormat()); | - |
| 189 | | - |
| 190 | QTextTablePrivate *d = table->d_func(); | - |
| 191 | d->blockFragmentUpdates = true; | - |
| 192 | | - |
| 193 | d->fragment_start = pieceTable->insertBlock(QChar(0xfdd0), pos, cellIdx, charIdx); | - |
| 194 | d->cells.append(d->fragment_start); | - |
| 195 | ++pos; | - |
| 196 | | - |
| 197 | for (int i = 1; i < rows*cols; ++i) { evaluated: i < rows*cols| yes Evaluation Count:677 | yes Evaluation Count:151 |
| 151-677 |
| 198 | d->cells.append(pieceTable->insertBlock(QChar(0xfdd0), pos, cellIdx, charIdx)); | - |
| 199 | | - |
| 200 | ++pos; | - |
| 201 | } executed: }Execution Count:677 | 677 |
| 202 | | - |
| 203 | d->fragment_end = pieceTable->insertBlock(QChar(0xfdd1), pos, cellIdx, charIdx); | - |
| 204 | | - |
| 205 | ++pos; | - |
| 206 | | - |
| 207 | d->blockFragmentUpdates = false; | - |
| 208 | d->dirty = true; | - |
| 209 | | - |
| 210 | pieceTable->endEditBlock(); | - |
| 211 | | - |
| 212 | return table; executed: return table;Execution Count:151 | 151 |
| 213 | } | - |
| 214 | | - |
| 215 | struct QFragmentFindHelper | - |
| 216 | { | - |
| 217 | inline QFragmentFindHelper(int _pos, const QTextDocumentPrivate::FragmentMap &map) | - |
| 218 | : pos(_pos), fragmentMap(map) {} executed: }Execution Count:6998 | 6998 |
| 219 | uint pos; | - |
| 220 | const QTextDocumentPrivate::FragmentMap &fragmentMap; | - |
| 221 | }; | - |
| 222 | | - |
| 223 | static inline bool operator<(int fragment, const QFragmentFindHelper &helper) | - |
| 224 | { | - |
| 225 | return helper.fragmentMap.position(fragment) < helper.pos; executed: return helper.fragmentMap.position(fragment) < helper.pos;Execution Count:27307 | 27307 |
| 226 | } | - |
| 227 | | - |
| 228 | static inline bool operator<(const QFragmentFindHelper &helper, int fragment) | - |
| 229 | { | - |
| 230 | return helper.pos < helper.fragmentMap.position(fragment); executed: return helper.pos < helper.fragmentMap.position(fragment);Execution Count:5873 | 5873 |
| 231 | } | - |
| 232 | | - |
| 233 | int QTextTablePrivate::findCellIndex(int fragment) const | - |
| 234 | { | - |
| 235 | QFragmentFindHelper helper(pieceTable->fragmentMap().position(fragment), | - |
| 236 | pieceTable->fragmentMap()); | - |
| 237 | QList<int>::ConstIterator it = qBinaryFind(cells.begin(), cells.end(), helper); | - |
| 238 | if (it == cells.end()) partially evaluated: it == cells.end()| no Evaluation Count:0 | yes Evaluation Count:5778 |
| 0-5778 |
| 239 | return -1; never executed: return -1; | 0 |
| 240 | return it - cells.begin(); executed: return it - cells.begin();Execution Count:5778 | 5778 |
| 241 | } | - |
| 242 | | - |
| 243 | void QTextTablePrivate::fragmentAdded(QChar type, uint fragment) | - |
| 244 | { | - |
| 245 | dirty = true; | - |
| 246 | if (blockFragmentUpdates) evaluated: blockFragmentUpdates| yes Evaluation Count:979 | yes Evaluation Count:434 |
| 434-979 |
| 247 | return; executed: return;Execution Count:979 | 979 |
| 248 | if (type == QChar(0xfdd0)) { evaluated: type == QChar(0xfdd0)| yes Evaluation Count:344 | yes Evaluation Count:90 |
| 90-344 |
| 249 | qt_noop(); | - |
| 250 | const uint pos = pieceTable->fragmentMap().position(fragment); | - |
| 251 | QFragmentFindHelper helper(pos, pieceTable->fragmentMap()); | - |
| 252 | QList<int>::Iterator it = std::lower_bound(cells.begin(), cells.end(), helper); | - |
| 253 | cells.insert(it, fragment); | - |
| 254 | if (!fragment_start || pos < pieceTable->fragmentMap().position(fragment_start)) evaluated: !fragment_start| yes Evaluation Count:89 | yes Evaluation Count:255 |
evaluated: pos < pieceTable->fragmentMap().position(fragment_start)| yes Evaluation Count:11 | yes Evaluation Count:244 |
| 11-255 |
| 255 | fragment_start = fragment; executed: fragment_start = fragment;Execution Count:100 | 100 |
| 256 | return; executed: return;Execution Count:344 | 344 |
| 257 | } | - |
| 258 | QTextFramePrivate::fragmentAdded(type, fragment); | - |
| 259 | } executed: }Execution Count:90 | 90 |
| 260 | | - |
| 261 | void QTextTablePrivate::fragmentRemoved(QChar type, uint fragment) | - |
| 262 | { | - |
| 263 | dirty = true; | - |
| 264 | if (blockFragmentUpdates) evaluated: blockFragmentUpdates| yes Evaluation Count:106 | yes Evaluation Count:119 |
| 106-119 |
| 265 | return; executed: return;Execution Count:106 | 106 |
| 266 | if (type == QChar(0xfdd0)) { evaluated: type == QChar(0xfdd0)| yes Evaluation Count:114 | yes Evaluation Count:5 |
| 5-114 |
| 267 | qt_noop(); | - |
| 268 | cells.removeAll(fragment); | - |
| 269 | if (fragment_start == fragment && cells.size()) { evaluated: fragment_start == fragment| yes Evaluation Count:42 | yes Evaluation Count:72 |
evaluated: cells.size()| yes Evaluation Count:38 | yes Evaluation Count:4 |
| 4-72 |
| 270 | fragment_start = cells.at(0); | - |
| 271 | } executed: }Execution Count:38 | 38 |
| 272 | if (fragment_start != fragment) evaluated: fragment_start != fragment| yes Evaluation Count:110 | yes Evaluation Count:4 |
| 4-110 |
| 273 | return; executed: return;Execution Count:110 | 110 |
| 274 | } executed: }Execution Count:4 | 4 |
| 275 | QTextFramePrivate::fragmentRemoved(type, fragment); | - |
| 276 | } executed: }Execution Count:9 | 9 |
| 277 | void QTextTablePrivate::update() const | - |
| 278 | { | - |
| 279 | const QTextTable * const q = q_func(); | - |
| 280 | nCols = q->format().columns(); | - |
| 281 | nRows = (cells.size() + nCols-1)/nCols; | - |
| 282 | | - |
| 283 | | - |
| 284 | grid = q_check_ptr((int *)realloc(grid, nRows*nCols*sizeof(int))); | - |
| 285 | memset(grid, 0, nRows*nCols*sizeof(int)); | - |
| 286 | | - |
| 287 | QTextDocumentPrivate *p = pieceTable; | - |
| 288 | QTextFormatCollection *c = p->formatCollection(); | - |
| 289 | | - |
| 290 | cellIndices.resize(cells.size()); | - |
| 291 | | - |
| 292 | int cell = 0; | - |
| 293 | for (int i = 0; i < cells.size(); ++i) { evaluated: i < cells.size()| yes Evaluation Count:1431 | yes Evaluation Count:243 |
| 243-1431 |
| 294 | int fragment = cells.at(i); | - |
| 295 | QTextCharFormat fmt = c->charFormat(QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format); | - |
| 296 | int rowspan = fmt.tableCellRowSpan(); | - |
| 297 | int colspan = fmt.tableCellColumnSpan(); | - |
| 298 | | - |
| 299 | | - |
| 300 | while (cell < nRows*nCols && grid[cell]) evaluated: cell < nRows*nCols| yes Evaluation Count:2673 | yes Evaluation Count:5 |
evaluated: grid[cell]| yes Evaluation Count:1247 | yes Evaluation Count:1426 |
| 5-2673 |
| 301 | ++cell; executed: ++cell;Execution Count:1247 | 1247 |
| 302 | | - |
| 303 | int r = cell/nCols; | - |
| 304 | int c = cell%nCols; | - |
| 305 | cellIndices[i] = cell; | - |
| 306 | | - |
| 307 | if (r + rowspan > nRows) { evaluated: r + rowspan > nRows| yes Evaluation Count:9 | yes Evaluation Count:1422 |
| 9-1422 |
| 308 | grid = q_check_ptr((int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols)); | - |
| 309 | memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols); | - |
| 310 | nRows = r + rowspan; | - |
| 311 | } executed: }Execution Count:9 | 9 |
| 312 | | - |
| 313 | qt_noop(); | - |
| 314 | for (int ii = 0; ii < rowspan; ++ii) { evaluated: ii < rowspan| yes Evaluation Count:1462 | yes Evaluation Count:1431 |
| 1431-1462 |
| 315 | for (int jj = 0; jj < colspan; ++jj) { evaluated: jj < colspan| yes Evaluation Count:1513 | yes Evaluation Count:1462 |
| 1462-1513 |
| 316 | qt_noop(); | - |
| 317 | grid[(r+ii)*nCols + c+jj] = fragment; | - |
| 318 | | - |
| 319 | } executed: }Execution Count:1513 | 1513 |
| 320 | } executed: }Execution Count:1462 | 1462 |
| 321 | } executed: }Execution Count:1431 | 1431 |
| 322 | | - |
| 323 | | - |
| 324 | dirty = false; | - |
| 325 | } executed: }Execution Count:243 | 243 |
| 326 | QTextTable::QTextTable(QTextDocument *doc) | - |
| 327 | : QTextFrame(*new QTextTablePrivate(doc), doc) | - |
| 328 | { | - |
| 329 | } executed: }Execution Count:240 | 240 |
| 330 | | - |
| 331 | | - |
| 332 | | - |
| 333 | | - |
| 334 | | - |
| 335 | QTextTable::~QTextTable() | - |
| 336 | { | - |
| 337 | } | - |
| 338 | QTextTableCell QTextTable::cellAt(int row, int col) const | - |
| 339 | { | - |
| 340 | const QTextTablePrivate * const d = d_func(); | - |
| 341 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:60 | yes Evaluation Count:3443 |
| 60-3443 |
| 342 | d->update(); executed: d->update();Execution Count:60 | 60 |
| 343 | | - |
| 344 | if (row < 0 || row >= d->nRows || col < 0 || col >= d->nCols) evaluated: row < 0| yes Evaluation Count:60 | yes Evaluation Count:3443 |
evaluated: row >= d->nRows| yes Evaluation Count:57 | yes Evaluation Count:3386 |
evaluated: col < 0| yes Evaluation Count:42 | yes Evaluation Count:3344 |
evaluated: col >= d->nCols| yes Evaluation Count:48 | yes Evaluation Count:3296 |
| 42-3443 |
| 345 | return QTextTableCell(); executed: return QTextTableCell();Execution Count:207 | 207 |
| 346 | | - |
| 347 | return QTextTableCell(this, d->grid[row*d->nCols + col]); executed: return QTextTableCell(this, d->grid[row*d->nCols + col]);Execution Count:3296 | 3296 |
| 348 | } | - |
| 349 | | - |
| 350 | | - |
| 351 | | - |
| 352 | | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | QTextTableCell QTextTable::cellAt(int position) const | - |
| 357 | { | - |
| 358 | const QTextTablePrivate * const d = d_func(); | - |
| 359 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:1 | yes Evaluation Count:782 |
| 1-782 |
| 360 | d->update(); executed: d->update();Execution Count:1 | 1 |
| 361 | | - |
| 362 | uint pos = (uint)position; | - |
| 363 | const QTextDocumentPrivate::FragmentMap &map = d->pieceTable->fragmentMap(); | - |
| 364 | if (position < 0 || map.position(d->fragment_start) >= pos || map.position(d->fragment_end) < pos) partially evaluated: position < 0| no Evaluation Count:0 | yes Evaluation Count:783 |
evaluated: map.position(d->fragment_start) >= pos| yes Evaluation Count:1 | yes Evaluation Count:782 |
evaluated: map.position(d->fragment_end) < pos| yes Evaluation Count:1 | yes Evaluation Count:781 |
| 0-783 |
| 365 | return QTextTableCell(); executed: return QTextTableCell();Execution Count:2 | 2 |
| 366 | | - |
| 367 | QFragmentFindHelper helper(position, map); | - |
| 368 | QList<int>::ConstIterator it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); | - |
| 369 | if (it != d->cells.begin()) partially evaluated: it != d->cells.begin()| yes Evaluation Count:781 | no Evaluation Count:0 |
| 0-781 |
| 370 | --it; executed: --it;Execution Count:781 | 781 |
| 371 | | - |
| 372 | return QTextTableCell(this, *it); executed: return QTextTableCell(this, *it);Execution Count:781 | 781 |
| 373 | } | - |
| 374 | QTextTableCell QTextTable::cellAt(const QTextCursor &c) const | - |
| 375 | { | - |
| 376 | return cellAt(c.position()); executed: return cellAt(c.position());Execution Count:10 | 10 |
| 377 | } | - |
| 378 | void QTextTable::resize(int rows, int cols) | - |
| 379 | { | - |
| 380 | QTextTablePrivate * const d = d_func(); | - |
| 381 | if (d->dirty) partially evaluated: d->dirty| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 382 | d->update(); never executed: d->update(); | 0 |
| 383 | | - |
| 384 | int nRows = this->rows(); | - |
| 385 | int nCols = this->columns(); | - |
| 386 | | - |
| 387 | if (rows == nRows && cols == nCols) partially evaluated: rows == nRows| no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: cols == nCols | 0-2 |
| 388 | return; | 0 |
| 389 | | - |
| 390 | d->pieceTable->beginEditBlock(); | - |
| 391 | | - |
| 392 | if (nCols < cols) evaluated: nCols < cols| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 393 | insertColumns(nCols, cols - nCols); executed: insertColumns(nCols, cols - nCols);Execution Count:1 | 1 |
| 394 | else if (nCols > cols) partially evaluated: nCols > cols| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 395 | removeColumns(cols, nCols - cols); executed: removeColumns(cols, nCols - cols);Execution Count:1 | 1 |
| 396 | | - |
| 397 | if (nRows < rows) evaluated: nRows < rows| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 398 | insertRows(nRows, rows-nRows); executed: insertRows(nRows, rows-nRows);Execution Count:1 | 1 |
| 399 | else if (nRows > rows) partially evaluated: nRows > rows| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 400 | removeRows(rows, nRows-rows); executed: removeRows(rows, nRows-rows);Execution Count:1 | 1 |
| 401 | | - |
| 402 | d->pieceTable->endEditBlock(); | - |
| 403 | } executed: }Execution Count:2 | 2 |
| 404 | void QTextTable::insertRows(int pos, int num) | - |
| 405 | { | - |
| 406 | QTextTablePrivate * const d = d_func(); | - |
| 407 | if (num <= 0) partially evaluated: num <= 0| no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
| 408 | return; | 0 |
| 409 | | - |
| 410 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
| 411 | d->update(); executed: d->update();Execution Count:1 | 1 |
| 412 | | - |
| 413 | if (pos > d->nRows || pos < 0) partially evaluated: pos > d->nRows| no Evaluation Count:0 | yes Evaluation Count:12 |
evaluated: pos < 0| yes Evaluation Count:1 | yes Evaluation Count:11 |
| 0-12 |
| 414 | pos = d->nRows; executed: pos = d->nRows;Execution Count:1 | 1 |
| 415 | | - |
| 416 | | - |
| 417 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 418 | QTextFormatCollection *c = p->formatCollection(); | - |
| 419 | p->beginEditBlock(); | - |
| 420 | | - |
| 421 | int extended = 0; | - |
| 422 | int insert_before = 0; | - |
| 423 | if (pos > 0 && pos < d->nRows) { evaluated: pos > 0| yes Evaluation Count:10 | yes Evaluation Count:2 |
evaluated: pos < d->nRows| yes Evaluation Count:2 | yes Evaluation Count:8 |
| 2-10 |
| 424 | for (int i = 0; i < d->nCols; ++i) { evaluated: i < d->nCols| yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
| 425 | int cell = d->grid[pos*d->nCols + i]; | - |
| 426 | if (cell == d->grid[(pos-1)*d->nCols+i]) { partially evaluated: cell == d->grid[(pos-1)*d->nCols+i]| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 427 | | - |
| 428 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); | - |
| 429 | QTextCharFormat fmt = c->charFormat(it->format); | - |
| 430 | fmt.setTableCellRowSpan(fmt.tableCellRowSpan() + num); | - |
| 431 | p->setCharFormat(it.position(), 1, fmt); | - |
| 432 | extended++; | - |
| 433 | } else if (!insert_before) { evaluated: !insert_before| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 0-2 |
| 434 | insert_before = cell; | - |
| 435 | } executed: }Execution Count:2 | 2 |
| 436 | } | - |
| 437 | } else { executed: }Execution Count:2 | 2 |
| 438 | insert_before = (pos == 0 ? d->grid[0] : d->fragment_end); evaluated: pos == 0| yes Evaluation Count:2 | yes Evaluation Count:8 |
| 2-8 |
| 439 | } executed: }Execution Count:10 | 10 |
| 440 | if (extended < d->nCols) { partially evaluated: extended < d->nCols| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
| 441 | qt_noop(); | - |
| 442 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), insert_before); | - |
| 443 | QTextCharFormat fmt = c->charFormat(it->format); | - |
| 444 | fmt.setTableCellRowSpan(1); | - |
| 445 | fmt.setTableCellColumnSpan(1); | - |
| 446 | qt_noop(); | - |
| 447 | int pos = it.position(); | - |
| 448 | int cfmt = p->formatCollection()->indexForFormat(fmt); | - |
| 449 | int bfmt = p->formatCollection()->indexForFormat(QTextBlockFormat()); | - |
| 450 | | - |
| 451 | for (int i = 0; i < num*(d->nCols-extended); ++i) evaluated: i < num*(d->nCols-extended)| yes Evaluation Count:41 | yes Evaluation Count:12 |
| 12-41 |
| 452 | p->insertBlock(QChar(0xfdd0), pos, bfmt, cfmt, QTextUndoCommand::MoveCursor); executed: p->insertBlock(QChar(0xfdd0), pos, bfmt, cfmt, QTextUndoCommand::MoveCursor);Execution Count:41 | 41 |
| 453 | } executed: }Execution Count:12 | 12 |
| 454 | | - |
| 455 | | - |
| 456 | p->endEditBlock(); | - |
| 457 | } executed: }Execution Count:12 | 12 |
| 458 | void QTextTable::insertColumns(int pos, int num) | - |
| 459 | { | - |
| 460 | QTextTablePrivate * const d = d_func(); | - |
| 461 | if (num <= 0) partially evaluated: num <= 0| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 462 | return; | 0 |
| 463 | | - |
| 464 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:1 | yes Evaluation Count:15 |
| 1-15 |
| 465 | d->update(); executed: d->update();Execution Count:1 | 1 |
| 466 | | - |
| 467 | if (pos > d->nCols || pos < 0) partially evaluated: pos > d->nCols| no Evaluation Count:0 | yes Evaluation Count:16 |
partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 468 | pos = d->nCols; never executed: pos = d->nCols; | 0 |
| 469 | | - |
| 470 | | - |
| 471 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 472 | QTextFormatCollection *c = p->formatCollection(); | - |
| 473 | p->beginEditBlock(); | - |
| 474 | | - |
| 475 | QList<int> extendedSpans; | - |
| 476 | for (int i = 0; i < d->nRows; ++i) { evaluated: i < d->nRows| yes Evaluation Count:46 | yes Evaluation Count:16 |
| 16-46 |
| 477 | int cell; | - |
| 478 | if (i == d->nRows - 1 && pos == d->nCols) { evaluated: i == d->nRows - 1| yes Evaluation Count:16 | yes Evaluation Count:30 |
evaluated: pos == d->nCols| yes Evaluation Count:5 | yes Evaluation Count:11 |
| 5-30 |
| 479 | cell = d->fragment_end; | - |
| 480 | } else { executed: }Execution Count:5 | 5 |
| 481 | int logicalGridIndexBeforePosition = pos > 0 evaluated: pos > 0| yes Evaluation Count:39 | yes Evaluation Count:2 |
| 2-39 |
| 482 | ? d->findCellIndex(d->grid[i*d->nCols + pos - 1]) | - |
| 483 | : -1; | - |
| 484 | | - |
| 485 | | - |
| 486 | | - |
| 487 | | - |
| 488 | int logicalGridIndex; | - |
| 489 | int gridArrayOffset = i*d->nCols + pos; | - |
| 490 | do { | - |
| 491 | cell = d->grid[gridArrayOffset]; | - |
| 492 | logicalGridIndex = d->findCellIndex(cell); | - |
| 493 | gridArrayOffset++; | - |
| 494 | } while (logicalGridIndex < logicalGridIndexBeforePosition evaluated: logicalGridIndex < logicalGridIndexBeforePosition| yes Evaluation Count:26 | yes Evaluation Count:38 |
executed: }Execution Count:64 | 26-64 |
| 495 | && gridArrayOffset < d->nRows*d->nCols); evaluated: gridArrayOffset < d->nRows*d->nCols| yes Evaluation Count:23 | yes Evaluation Count:3 |
| 3-23 |
| 496 | | - |
| 497 | if (logicalGridIndex < logicalGridIndexBeforePosition evaluated: logicalGridIndex < logicalGridIndexBeforePosition| yes Evaluation Count:3 | yes Evaluation Count:38 |
| 3-38 |
| 498 | && gridArrayOffset == d->nRows*d->nCols) partially evaluated: gridArrayOffset == d->nRows*d->nCols| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 499 | cell = d->fragment_end; executed: cell = d->fragment_end;Execution Count:3 | 3 |
| 500 | } executed: }Execution Count:41 | 41 |
| 501 | | - |
| 502 | if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) { evaluated: pos > 0| yes Evaluation Count:44 | yes Evaluation Count:2 |
evaluated: pos < d->nCols| yes Evaluation Count:31 | yes Evaluation Count:13 |
evaluated: cell == d->grid[i*d->nCols + pos - 1]| yes Evaluation Count:2 | yes Evaluation Count:29 |
| 2-44 |
| 503 | | - |
| 504 | if (!extendedSpans.contains(cell)) { partially evaluated: !extendedSpans.contains(cell)| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 505 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); | - |
| 506 | QTextCharFormat fmt = c->charFormat(it->format); | - |
| 507 | fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); | - |
| 508 | p->setCharFormat(it.position(), 1, fmt); | - |
| 509 | d->dirty = true; | - |
| 510 | extendedSpans << cell; | - |
| 511 | } executed: }Execution Count:2 | 2 |
| 512 | } else { executed: }Execution Count:2 | 2 |
| 513 | | - |
| 514 | | - |
| 515 | if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) { evaluated: i > 0| yes Evaluation Count:29 | yes Evaluation Count:15 |
evaluated: pos < d->nCols| yes Evaluation Count:21 | yes Evaluation Count:8 |
partially evaluated: cell == d->grid[(i-1) * d->nCols + pos]| no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-29 |
| 516 | int gridIndex = i*d->nCols + pos; | - |
| 517 | const int gridEnd = d->nRows * d->nCols - 1; | - |
| 518 | while (gridIndex < gridEnd && cell == d->grid[gridIndex]) { never evaluated: gridIndex < gridEnd never evaluated: cell == d->grid[gridIndex] | 0 |
| 519 | ++gridIndex; | - |
| 520 | } | 0 |
| 521 | if (gridIndex == gridEnd) never evaluated: gridIndex == gridEnd | 0 |
| 522 | cell = d->fragment_end; never executed: cell = d->fragment_end; | 0 |
| 523 | else | - |
| 524 | cell = d->grid[gridIndex]; never executed: cell = d->grid[gridIndex]; | 0 |
| 525 | } | - |
| 526 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); | - |
| 527 | QTextCharFormat fmt = c->charFormat(it->format); | - |
| 528 | fmt.setTableCellRowSpan(1); | - |
| 529 | fmt.setTableCellColumnSpan(1); | - |
| 530 | qt_noop(); | - |
| 531 | int position = it.position(); | - |
| 532 | int cfmt = p->formatCollection()->indexForFormat(fmt); | - |
| 533 | int bfmt = p->formatCollection()->indexForFormat(QTextBlockFormat()); | - |
| 534 | for (int i = 0; i < num; ++i) evaluated: i < num| yes Evaluation Count:54 | yes Evaluation Count:44 |
| 44-54 |
| 535 | p->insertBlock(QChar(0xfdd0), position, bfmt, cfmt, QTextUndoCommand::MoveCursor); executed: p->insertBlock(QChar(0xfdd0), position, bfmt, cfmt, QTextUndoCommand::MoveCursor);Execution Count:54 | 54 |
| 536 | } executed: }Execution Count:44 | 44 |
| 537 | } | - |
| 538 | | - |
| 539 | QTextTableFormat tfmt = format(); | - |
| 540 | tfmt.setColumns(tfmt.columns()+num); | - |
| 541 | QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints(); | - |
| 542 | if (! columnWidths.isEmpty()) { partially evaluated: ! columnWidths.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 543 | for (int i = num; i > 0; --i) | 0 |
| 544 | columnWidths.insert(pos, columnWidths[qMax(0, pos-1)]); never executed: columnWidths.insert(pos, columnWidths[qMax(0, pos-1)]); | 0 |
| 545 | } | 0 |
| 546 | tfmt.setColumnWidthConstraints (columnWidths); | - |
| 547 | QTextObject::setFormat(tfmt); | - |
| 548 | | - |
| 549 | | - |
| 550 | p->endEditBlock(); | - |
| 551 | } executed: }Execution Count:16 | 16 |
| 552 | | - |
| 553 | | - |
| 554 | | - |
| 555 | | - |
| 556 | | - |
| 557 | | - |
| 558 | | - |
| 559 | void QTextTable::appendRows(int count) | - |
| 560 | { | - |
| 561 | insertRows(rows(), count); | - |
| 562 | } executed: }Execution Count:3 | 3 |
| 563 | | - |
| 564 | | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | void QTextTable::appendColumns(int count) | - |
| 571 | { | - |
| 572 | insertColumns(columns(), count); | - |
| 573 | } executed: }Execution Count:2 | 2 |
| 574 | void QTextTable::removeRows(int pos, int num) | - |
| 575 | { | - |
| 576 | QTextTablePrivate * const d = d_func(); | - |
| 577 | | - |
| 578 | | - |
| 579 | if (num <= 0 || pos < 0) partially evaluated: num <= 0| no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 580 | return; | 0 |
| 581 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
| 582 | d->update(); executed: d->update();Execution Count:2 | 2 |
| 583 | if (pos >= d->nRows) partially evaluated: pos >= d->nRows| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 584 | return; | 0 |
| 585 | if (pos+num > d->nRows) partially evaluated: pos+num > d->nRows| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 586 | num = d->nRows - pos; never executed: num = d->nRows - pos; | 0 |
| 587 | | - |
| 588 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 589 | QTextFormatCollection *collection = p->formatCollection(); | - |
| 590 | p->beginEditBlock(); | - |
| 591 | | - |
| 592 | | - |
| 593 | if (pos == 0 && num == d->nRows) { evaluated: pos == 0| yes Evaluation Count:3 | yes Evaluation Count:10 |
evaluated: num == d->nRows| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-10 |
| 594 | const int pos = p->fragmentMap().position(d->fragment_start); | - |
| 595 | p->remove(pos, p->fragmentMap().position(d->fragment_end) - pos + 1); | - |
| 596 | p->endEditBlock(); | - |
| 597 | return; executed: return;Execution Count:1 | 1 |
| 598 | } | - |
| 599 | | - |
| 600 | p->aboutToRemoveCell(cellAt(pos, 0).firstPosition(), cellAt(pos + num - 1, d->nCols - 1).lastPosition()); | - |
| 601 | | - |
| 602 | QList<int> touchedCells; | - |
| 603 | for (int r = pos; r < pos + num; ++r) { evaluated: r < pos + num| yes Evaluation Count:13 | yes Evaluation Count:12 |
| 12-13 |
| 604 | for (int c = 0; c < d->nCols; ++c) { evaluated: c < d->nCols| yes Evaluation Count:40 | yes Evaluation Count:13 |
| 13-40 |
| 605 | int cell = d->grid[r*d->nCols + c]; | - |
| 606 | if (touchedCells.contains(cell)) evaluated: touchedCells.contains(cell)| yes Evaluation Count:1 | yes Evaluation Count:39 |
| 1-39 |
| 607 | continue; executed: continue;Execution Count:1 | 1 |
| 608 | touchedCells << cell; | - |
| 609 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); | - |
| 610 | QTextCharFormat fmt = collection->charFormat(it->format); | - |
| 611 | int span = fmt.tableCellRowSpan(); | - |
| 612 | if (span > 1) { partially evaluated: span > 1| no Evaluation Count:0 | yes Evaluation Count:39 |
| 0-39 |
| 613 | fmt.setTableCellRowSpan(span - 1); | - |
| 614 | p->setCharFormat(it.position(), 1, fmt); | - |
| 615 | } else { | 0 |
| 616 | | - |
| 617 | int index = d->cells.indexOf(cell) + 1; | - |
| 618 | int f_end = index < d->cells.size() ? d->cells.at(index) : d->fragment_end; evaluated: index < d->cells.size()| yes Evaluation Count:35 | yes Evaluation Count:4 |
| 4-35 |
| 619 | p->remove(it.position(), p->fragmentMap().position(f_end) - it.position()); | - |
| 620 | } executed: }Execution Count:39 | 39 |
| 621 | } | - |
| 622 | } executed: }Execution Count:13 | 13 |
| 623 | | - |
| 624 | p->endEditBlock(); | - |
| 625 | | - |
| 626 | } executed: }Execution Count:12 | 12 |
| 627 | void QTextTable::removeColumns(int pos, int num) | - |
| 628 | { | - |
| 629 | QTextTablePrivate * const d = d_func(); | - |
| 630 | | - |
| 631 | | - |
| 632 | if (num <= 0 || pos < 0) partially evaluated: num <= 0| no Evaluation Count:0 | yes Evaluation Count:14 |
partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
| 633 | return; | 0 |
| 634 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:1 | yes Evaluation Count:13 |
| 1-13 |
| 635 | d->update(); executed: d->update();Execution Count:1 | 1 |
| 636 | if (pos >= d->nCols) partially evaluated: pos >= d->nCols| no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
| 637 | return; | 0 |
| 638 | if (pos + num > d->nCols) partially evaluated: pos + num > d->nCols| no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
| 639 | pos = d->nCols - num; never executed: pos = d->nCols - num; | 0 |
| 640 | | - |
| 641 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 642 | QTextFormatCollection *collection = p->formatCollection(); | - |
| 643 | p->beginEditBlock(); | - |
| 644 | | - |
| 645 | | - |
| 646 | if (pos == 0 && num == d->nCols) { evaluated: pos == 0| yes Evaluation Count:5 | yes Evaluation Count:9 |
evaluated: num == d->nCols| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-9 |
| 647 | const int pos = p->fragmentMap().position(d->fragment_start); | - |
| 648 | p->remove(pos, p->fragmentMap().position(d->fragment_end) - pos + 1); | - |
| 649 | p->endEditBlock(); | - |
| 650 | return; executed: return;Execution Count:1 | 1 |
| 651 | } | - |
| 652 | | - |
| 653 | p->aboutToRemoveCell(cellAt(0, pos).firstPosition(), cellAt(d->nRows - 1, pos + num - 1).lastPosition()); | - |
| 654 | | - |
| 655 | QList<int> touchedCells; | - |
| 656 | for (int r = 0; r < d->nRows; ++r) { evaluated: r < d->nRows| yes Evaluation Count:34 | yes Evaluation Count:13 |
| 13-34 |
| 657 | for (int c = pos; c < pos + num; ++c) { evaluated: c < pos + num| yes Evaluation Count:44 | yes Evaluation Count:34 |
| 34-44 |
| 658 | int cell = d->grid[r*d->nCols + c]; | - |
| 659 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); | - |
| 660 | QTextCharFormat fmt = collection->charFormat(it->format); | - |
| 661 | int span = fmt.tableCellColumnSpan(); | - |
| 662 | if (touchedCells.contains(cell) && span <= 1) evaluated: touchedCells.contains(cell)| yes Evaluation Count:3 | yes Evaluation Count:41 |
evaluated: span <= 1| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-41 |
| 663 | continue; executed: continue;Execution Count:1 | 1 |
| 664 | touchedCells << cell; | - |
| 665 | | - |
| 666 | if (span > 1) { evaluated: span > 1| yes Evaluation Count:4 | yes Evaluation Count:39 |
| 4-39 |
| 667 | fmt.setTableCellColumnSpan(span - 1); | - |
| 668 | p->setCharFormat(it.position(), 1, fmt); | - |
| 669 | } else { executed: }Execution Count:4 | 4 |
| 670 | | - |
| 671 | int index = d->cells.indexOf(cell) + 1; | - |
| 672 | int f_end = index < d->cells.size() ? d->cells.at(index) : d->fragment_end; evaluated: index < d->cells.size()| yes Evaluation Count:36 | yes Evaluation Count:3 |
| 3-36 |
| 673 | p->remove(it.position(), p->fragmentMap().position(f_end) - it.position()); | - |
| 674 | } executed: }Execution Count:39 | 39 |
| 675 | } | - |
| 676 | } executed: }Execution Count:34 | 34 |
| 677 | | - |
| 678 | QTextTableFormat tfmt = format(); | - |
| 679 | tfmt.setColumns(tfmt.columns()-num); | - |
| 680 | QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints(); | - |
| 681 | if (columnWidths.count() > pos) { partially evaluated: columnWidths.count() > pos| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 682 | columnWidths.remove(pos, num); | - |
| 683 | tfmt.setColumnWidthConstraints (columnWidths); | - |
| 684 | } | 0 |
| 685 | QTextObject::setFormat(tfmt); | - |
| 686 | | - |
| 687 | p->endEditBlock(); | - |
| 688 | | - |
| 689 | } executed: }Execution Count:13 | 13 |
| 690 | void QTextTable::mergeCells(int row, int column, int numRows, int numCols) | - |
| 691 | { | - |
| 692 | QTextTablePrivate * const d = d_func(); | - |
| 693 | | - |
| 694 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:20 | yes Evaluation Count:36 |
| 20-36 |
| 695 | d->update(); executed: d->update();Execution Count:20 | 20 |
| 696 | | - |
| 697 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 698 | QTextFormatCollection *fc = p->formatCollection(); | - |
| 699 | | - |
| 700 | const QTextTableCell cell = cellAt(row, column); | - |
| 701 | if (!cell.isValid() || row != cell.row() || column != cell.column()) partially evaluated: !cell.isValid()| no Evaluation Count:0 | yes Evaluation Count:56 |
partially evaluated: row != cell.row()| no Evaluation Count:0 | yes Evaluation Count:56 |
partially evaluated: column != cell.column()| no Evaluation Count:0 | yes Evaluation Count:56 |
| 0-56 |
| 702 | return; | 0 |
| 703 | | - |
| 704 | QTextCharFormat fmt = cell.format(); | - |
| 705 | const int rowSpan = fmt.tableCellRowSpan(); | - |
| 706 | const int colSpan = fmt.tableCellColumnSpan(); | - |
| 707 | | - |
| 708 | numRows = qMin(numRows, rows() - cell.row()); | - |
| 709 | numCols = qMin(numCols, columns() - cell.column()); | - |
| 710 | | - |
| 711 | | - |
| 712 | if (numRows < rowSpan || numCols < colSpan) evaluated: numRows < rowSpan| yes Evaluation Count:1 | yes Evaluation Count:55 |
partially evaluated: numCols < colSpan| no Evaluation Count:0 | yes Evaluation Count:55 |
| 0-55 |
| 713 | return; executed: return;Execution Count:1 | 1 |
| 714 | | - |
| 715 | | - |
| 716 | for (int r = row; r < row + numRows; ++r) { evaluated: r < row + numRows| yes Evaluation Count:97 | yes Evaluation Count:55 |
| 55-97 |
| 717 | if (cellAt(r, column) == cellAt(r, column - 1)) partially evaluated: cellAt(r, column) == cellAt(r, column - 1)| no Evaluation Count:0 | yes Evaluation Count:97 |
| 0-97 |
| 718 | return; | 0 |
| 719 | if (cellAt(r, column + numCols) == cellAt(r, column + numCols - 1)) partially evaluated: cellAt(r, column + numCols) == cellAt(r, column + numCols - 1)| no Evaluation Count:0 | yes Evaluation Count:97 |
| 0-97 |
| 720 | return; | 0 |
| 721 | } executed: }Execution Count:97 | 97 |
| 722 | | - |
| 723 | for (int c = column; c < column + numCols; ++c) { evaluated: c < column + numCols| yes Evaluation Count:106 | yes Evaluation Count:54 |
| 54-106 |
| 724 | if (cellAt(row, c) == cellAt(row - 1, c)) partially evaluated: cellAt(row, c) == cellAt(row - 1, c)| no Evaluation Count:0 | yes Evaluation Count:106 |
| 0-106 |
| 725 | return; | 0 |
| 726 | if (cellAt(row + numRows, c) == cellAt(row + numRows - 1, c)) evaluated: cellAt(row + numRows, c) == cellAt(row + numRows - 1, c)| yes Evaluation Count:1 | yes Evaluation Count:105 |
| 1-105 |
| 727 | return; executed: return;Execution Count:1 | 1 |
| 728 | } executed: }Execution Count:105 | 105 |
| 729 | | - |
| 730 | p->beginEditBlock(); | - |
| 731 | | - |
| 732 | const int origCellPosition = cell.firstPosition() - 1; | - |
| 733 | | - |
| 734 | const int cellFragment = d->grid[row * d->nCols + column]; | - |
| 735 | | - |
| 736 | | - |
| 737 | QFragmentFindHelper helper(origCellPosition, p->fragmentMap()); | - |
| 738 | QList<int>::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); | - |
| 739 | qt_noop(); | - |
| 740 | qt_noop(); | - |
| 741 | const int insertCellIndex = it - d->cells.begin(); | - |
| 742 | int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end); | - |
| 743 | uint insertPos = p->fragmentMap().position(insertFragment); | - |
| 744 | | - |
| 745 | d->blockFragmentUpdates = true; | - |
| 746 | | - |
| 747 | bool rowHasText = cell.firstCursorPosition().block().length(); | - |
| 748 | bool needsParagraph = rowHasText && colSpan == numCols; partially evaluated: rowHasText| yes Evaluation Count:54 | no Evaluation Count:0 |
evaluated: colSpan == numCols| yes Evaluation Count:20 | yes Evaluation Count:34 |
| 0-54 |
| 749 | | - |
| 750 | | - |
| 751 | for (int r = row; r < row + numRows; ++r) { evaluated: r < row + numRows| yes Evaluation Count:96 | yes Evaluation Count:54 |
| 54-96 |
| 752 | int firstColumn = r < row + rowSpan ? column + colSpan : column; evaluated: r < row + rowSpan| yes Evaluation Count:58 | yes Evaluation Count:38 |
| 38-58 |
| 753 | | - |
| 754 | | - |
| 755 | int firstCellIndex = r == row ? insertCellIndex + 1 : -1; evaluated: r == row| yes Evaluation Count:54 | yes Evaluation Count:42 |
| 42-54 |
| 756 | int cellIndex = firstCellIndex; | - |
| 757 | | - |
| 758 | for (int c = firstColumn; c < column + numCols; ++c) { evaluated: c < column + numCols| yes Evaluation Count:108 | yes Evaluation Count:96 |
| 96-108 |
| 759 | const int fragment = d->grid[r * d->nCols + c]; | - |
| 760 | | - |
| 761 | | - |
| 762 | if (fragment == cellFragment) evaluated: fragment == cellFragment| yes Evaluation Count:2 | yes Evaluation Count:106 |
| 2-106 |
| 763 | continue; executed: continue;Execution Count:2 | 2 |
| 764 | | - |
| 765 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment); | - |
| 766 | uint pos = it.position(); | - |
| 767 | | - |
| 768 | if (firstCellIndex == -1) { evaluated: firstCellIndex == -1| yes Evaluation Count:41 | yes Evaluation Count:65 |
| 41-65 |
| 769 | QFragmentFindHelper helper(pos, p->fragmentMap()); | - |
| 770 | QList<int>::Iterator it = qBinaryFind(d->cells.begin(), d->cells.end(), helper); | - |
| 771 | qt_noop(); | - |
| 772 | qt_noop(); | - |
| 773 | firstCellIndex = cellIndex = it - d->cells.begin(); | - |
| 774 | } executed: }Execution Count:41 | 41 |
| 775 | | - |
| 776 | ++cellIndex; | - |
| 777 | | - |
| 778 | QTextCharFormat fmt = fc->charFormat(it->format); | - |
| 779 | | - |
| 780 | const int cellRowSpan = fmt.tableCellRowSpan(); | - |
| 781 | const int cellColSpan = fmt.tableCellColumnSpan(); | - |
| 782 | | - |
| 783 | | - |
| 784 | for (int i = r; i < r + cellRowSpan; ++i) evaluated: i < r + cellRowSpan| yes Evaluation Count:107 | yes Evaluation Count:106 |
| 106-107 |
| 785 | for (int j = c; j < c + cellColSpan; ++j) evaluated: j < c + cellColSpan| yes Evaluation Count:108 | yes Evaluation Count:107 |
| 107-108 |
| 786 | d->grid[i * d->nCols + j] = cellFragment; executed: d->grid[i * d->nCols + j] = cellFragment;Execution Count:108 | 108 |
| 787 | | - |
| 788 | | - |
| 789 | p->remove(pos, 1); | - |
| 790 | | - |
| 791 | const int nextFragment = d->cells.value(cellIndex, d->fragment_end); | - |
| 792 | const uint nextPos = p->fragmentMap().position(nextFragment); | - |
| 793 | | - |
| 794 | qt_noop(); | - |
| 795 | | - |
| 796 | | - |
| 797 | if (nextPos > pos) { evaluated: nextPos > pos| yes Evaluation Count:5 | yes Evaluation Count:101 |
| 5-101 |
| 798 | if (needsParagraph) { evaluated: needsParagraph| yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
| 799 | needsParagraph = false; | - |
| 800 | QTextCursor(p, insertPos++).insertBlock(); | - |
| 801 | p->move(pos + 1, insertPos, nextPos - pos); | - |
| 802 | } else if (rowHasText) { executed: }Execution Count:4 partially evaluated: rowHasText| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-4 |
| 803 | QTextCursor(p, insertPos++).insertText(QLatin1String(" ")); | - |
| 804 | p->move(pos + 1, insertPos, nextPos - pos); | - |
| 805 | } else { executed: }Execution Count:1 | 1 |
| 806 | p->move(pos, insertPos, nextPos - pos); | - |
| 807 | } | 0 |
| 808 | | - |
| 809 | insertPos += nextPos - pos; | - |
| 810 | rowHasText = true; | - |
| 811 | } executed: }Execution Count:5 | 5 |
| 812 | } executed: }Execution Count:106 | 106 |
| 813 | | - |
| 814 | if (rowHasText) { evaluated: rowHasText| yes Evaluation Count:58 | yes Evaluation Count:38 |
| 38-58 |
| 815 | needsParagraph = true; | - |
| 816 | rowHasText = false; | - |
| 817 | } executed: }Execution Count:58 | 58 |
| 818 | | - |
| 819 | | - |
| 820 | if (firstCellIndex >= 0) { evaluated: firstCellIndex >= 0| yes Evaluation Count:95 | yes Evaluation Count:1 |
| 1-95 |
| 821 | d->cellIndices.remove(firstCellIndex, cellIndex - firstCellIndex); | - |
| 822 | d->cells.erase(d->cells.begin() + firstCellIndex, d->cells.begin() + cellIndex); | - |
| 823 | } executed: }Execution Count:95 | 95 |
| 824 | } executed: }Execution Count:96 | 96 |
| 825 | | - |
| 826 | d->fragment_start = d->cells.first(); | - |
| 827 | | - |
| 828 | fmt.setTableCellRowSpan(numRows); | - |
| 829 | fmt.setTableCellColumnSpan(numCols); | - |
| 830 | p->setCharFormat(origCellPosition, 1, fmt); | - |
| 831 | | - |
| 832 | d->blockFragmentUpdates = false; | - |
| 833 | d->dirty = false; | - |
| 834 | | - |
| 835 | p->endEditBlock(); | - |
| 836 | } executed: }Execution Count:54 | 54 |
| 837 | void QTextTable::mergeCells(const QTextCursor &cursor) | - |
| 838 | { | - |
| 839 | if (!cursor.hasComplexSelection()) partially evaluated: !cursor.hasComplexSelection()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 840 | return; | 0 |
| 841 | | - |
| 842 | int firstRow, numRows, firstColumn, numColumns; | - |
| 843 | cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns); | - |
| 844 | mergeCells(firstRow, firstColumn, numRows, numColumns); | - |
| 845 | } executed: }Execution Count:1 | 1 |
| 846 | void QTextTable::splitCell(int row, int column, int numRows, int numCols) | - |
| 847 | { | - |
| 848 | QTextTablePrivate * const d = d_func(); | - |
| 849 | | - |
| 850 | if (d->dirty) partially evaluated: d->dirty| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 851 | d->update(); never executed: d->update(); | 0 |
| 852 | | - |
| 853 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 854 | QTextFormatCollection *c = p->formatCollection(); | - |
| 855 | | - |
| 856 | const QTextTableCell cell = cellAt(row, column); | - |
| 857 | if (!cell.isValid()) partially evaluated: !cell.isValid()| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 858 | return; | 0 |
| 859 | row = cell.row(); | - |
| 860 | column = cell.column(); | - |
| 861 | | - |
| 862 | QTextCharFormat fmt = cell.format(); | - |
| 863 | const int rowSpan = fmt.tableCellRowSpan(); | - |
| 864 | const int colSpan = fmt.tableCellColumnSpan(); | - |
| 865 | | - |
| 866 | | - |
| 867 | if (numRows > rowSpan || numCols > colSpan) partially evaluated: numRows > rowSpan| no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: numCols > colSpan| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 868 | return; | 0 |
| 869 | | - |
| 870 | p->beginEditBlock(); | - |
| 871 | | - |
| 872 | const int origCellPosition = cell.firstPosition() - 1; | - |
| 873 | | - |
| 874 | QVarLengthArray<int> rowPositions(rowSpan); | - |
| 875 | | - |
| 876 | rowPositions[0] = cell.lastPosition(); | - |
| 877 | | - |
| 878 | for (int r = row + 1; r < row + rowSpan; ++r) { evaluated: r < row + rowSpan| yes Evaluation Count:6 | yes Evaluation Count:7 |
| 6-7 |
| 879 | | - |
| 880 | int gridIndex = r * d->nCols + column; | - |
| 881 | QVector<int>::iterator it = std::upper_bound(d->cellIndices.begin(), d->cellIndices.end(), gridIndex); | - |
| 882 | int cellIndex = it - d->cellIndices.begin(); | - |
| 883 | int fragment = d->cells.value(cellIndex, d->fragment_end); | - |
| 884 | rowPositions[r - row] = p->fragmentMap().position(fragment); | - |
| 885 | } executed: }Execution Count:6 | 6 |
| 886 | | - |
| 887 | fmt.setTableCellColumnSpan(1); | - |
| 888 | fmt.setTableCellRowSpan(1); | - |
| 889 | const int fmtIndex = c->indexForFormat(fmt); | - |
| 890 | const int blockIndex = p->blockMap().find(cell.lastPosition())->format; | - |
| 891 | | - |
| 892 | int insertAdjustement = 0; | - |
| 893 | for (int i = 0; i < numRows; ++i) { evaluated: i < numRows| yes Evaluation Count:8 | yes Evaluation Count:7 |
| 7-8 |
| 894 | for (int c = 0; c < colSpan - numCols; ++c) evaluated: c < colSpan - numCols| yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
| 895 | p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex); executed: p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);Execution Count:4 | 4 |
| 896 | insertAdjustement += colSpan - numCols; | - |
| 897 | } executed: }Execution Count:8 | 8 |
| 898 | | - |
| 899 | for (int i = numRows; i < rowSpan; ++i) { evaluated: i < rowSpan| yes Evaluation Count:5 | yes Evaluation Count:7 |
| 5-7 |
| 900 | for (int c = 0; c < colSpan; ++c) evaluated: c < colSpan| yes Evaluation Count:7 | yes Evaluation Count:5 |
| 5-7 |
| 901 | p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex); executed: p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);Execution Count:7 | 7 |
| 902 | insertAdjustement += colSpan; | - |
| 903 | } executed: }Execution Count:5 | 5 |
| 904 | | - |
| 905 | fmt.setTableCellRowSpan(numRows); | - |
| 906 | fmt.setTableCellColumnSpan(numCols); | - |
| 907 | p->setCharFormat(origCellPosition, 1, fmt); | - |
| 908 | | - |
| 909 | p->endEditBlock(); | - |
| 910 | } executed: }Execution Count:7 | 7 |
| 911 | | - |
| 912 | | - |
| 913 | | - |
| 914 | | - |
| 915 | | - |
| 916 | | - |
| 917 | int QTextTable::rows() const | - |
| 918 | { | - |
| 919 | const QTextTablePrivate * const d = d_func(); | - |
| 920 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:133 | yes Evaluation Count:1592 |
| 133-1592 |
| 921 | d->update(); executed: d->update();Execution Count:133 | 133 |
| 922 | | - |
| 923 | return d->nRows; executed: return d->nRows;Execution Count:1725 | 1725 |
| 924 | } | - |
| 925 | | - |
| 926 | | - |
| 927 | | - |
| 928 | | - |
| 929 | | - |
| 930 | | - |
| 931 | int QTextTable::columns() const | - |
| 932 | { | - |
| 933 | const QTextTablePrivate * const d = d_func(); | - |
| 934 | if (d->dirty) evaluated: d->dirty| yes Evaluation Count:24 | yes Evaluation Count:504 |
| 24-504 |
| 935 | d->update(); executed: d->update();Execution Count:24 | 24 |
| 936 | | - |
| 937 | return d->nCols; executed: return d->nCols;Execution Count:528 | 528 |
| 938 | } | - |
| 939 | QTextCursor QTextTable::rowStart(const QTextCursor &c) const | - |
| 940 | { | - |
| 941 | const QTextTablePrivate * const d = d_func(); | - |
| 942 | QTextTableCell cell = cellAt(c); | - |
| 943 | if (!cell.isValid()) never evaluated: !cell.isValid() | 0 |
| 944 | return QTextCursor(); never executed: return QTextCursor(); | 0 |
| 945 | | - |
| 946 | int row = cell.row(); | - |
| 947 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 948 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]); | - |
| 949 | return QTextCursor(p, it.position()); never executed: return QTextCursor(p, it.position()); | 0 |
| 950 | } | - |
| 951 | QTextCursor QTextTable::rowEnd(const QTextCursor &c) const | - |
| 952 | { | - |
| 953 | const QTextTablePrivate * const d = d_func(); | - |
| 954 | QTextTableCell cell = cellAt(c); | - |
| 955 | if (!cell.isValid()) never evaluated: !cell.isValid() | 0 |
| 956 | return QTextCursor(); never executed: return QTextCursor(); | 0 |
| 957 | | - |
| 958 | int row = cell.row() + 1; | - |
| 959 | int fragment = row < d->nRows ? d->grid[row*d->nCols] : d->fragment_end; never evaluated: row < d->nRows | 0 |
| 960 | QTextDocumentPrivate *p = d->pieceTable; | - |
| 961 | QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment); | - |
| 962 | return QTextCursor(p, it.position() - 1); never executed: return QTextCursor(p, it.position() - 1); | 0 |
| 963 | } | - |
| 964 | void QTextTable::setFormat(const QTextTableFormat &format) | - |
| 965 | { | - |
| 966 | QTextTableFormat fmt = format; | - |
| 967 | | - |
| 968 | fmt.setColumns(columns()); | - |
| 969 | QTextObject::setFormat(fmt); | - |
| 970 | } executed: }Execution Count:3 | 3 |
| 971 | | - |
| 972 | | - |
| | |