qtexttable.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtexttable.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6void 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}
never executed: end of block
0
21-
22-
23-
24-
25QTextCharFormat 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
never executed: return fmt;
fmt;
never executed: return fmt;
0
33}-
34int QTextTableCell::tableCellFormatIndex() const-
35{-
36 QTextDocumentPrivate *p = table->docHandle();-
37 return
never executed: return QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format;
QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format;
never executed: return QTextDocumentPrivate::FragmentIterator(&p->fragmentMap(), fragment)->format;
0
38}-
39-
40-
41-
42-
43-
44-
45int QTextTableCell::row() const-
46{-
47 const QTextTablePrivate *tp = table->d_func();-
48 if (tp->dirty
tp->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
49 tp->update();
never executed: tp->update();
0
50-
51 int idx = tp->findCellIndex(fragment);-
52 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
53 return
never executed: return idx;
idx;
never executed: return idx;
0
54 return
never executed: return tp->cellIndices.at(idx) / tp->nCols;
tp->cellIndices.at(idx) / tp->nCols;
never executed: return tp->cellIndices.at(idx) / tp->nCols;
0
55}-
56-
57-
58-
59-
60-
61-
62int QTextTableCell::column() const-
63{-
64 const QTextTablePrivate *tp = table->d_func();-
65 if (tp->dirty
tp->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
66 tp->update();
never executed: tp->update();
0
67-
68 int idx = tp->findCellIndex(fragment);-
69 if (idx == -1
idx == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 return
never executed: return idx;
idx;
never executed: return idx;
0
71 return
never executed: return tp->cellIndices.at(idx) % tp->nCols;
tp->cellIndices.at(idx) % tp->nCols;
never executed: return tp->cellIndices.at(idx) % tp->nCols;
0
72}-
73-
74-
75-
76-
77-
78-
79int QTextTableCell::rowSpan() const-
80{-
81 return
never executed: return format().tableCellRowSpan();
format().tableCellRowSpan();
never executed: return format().tableCellRowSpan();
0
82}-
83-
84-
85-
86-
87-
88-
89int QTextTableCell::columnSpan() const-
90{-
91 return
never executed: return format().tableCellColumnSpan();
format().tableCellColumnSpan();
never executed: return format().tableCellColumnSpan();
0
92}-
93QTextCursor QTextTableCell::firstCursorPosition() const-
94{-
95 return
never executed: return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, firstPosition());
QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, firstPosition());
never executed: return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, firstPosition());
0
96}-
97-
98-
99-
100-
101-
102-
103QTextCursor QTextTableCell::lastCursorPosition() const-
104{-
105 return
never executed: return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, lastPosition());
QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, lastPosition());
never executed: return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, lastPosition());
0
106}-
107-
108-
109-
110-
111-
112-
113-
114int QTextTableCell::firstPosition() const-
115{-
116 QTextDocumentPrivate *p = table->docHandle();-
117 return
never executed: return p->fragmentMap().position(fragment) + 1;
p->fragmentMap().position(fragment) + 1;
never executed: return p->fragmentMap().position(fragment) + 1;
0
118}-
119-
120-
121-
122-
123-
124-
125int 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
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
132 f = td->cells.value(index + 1, td->fragment_end);
never executed: f = td->cells.value(index + 1, td->fragment_end);
0
133 else-
134 f = td->fragment_end;
never executed: f = td->fragment_end;
0
135 return
never executed: return p->fragmentMap().position(f);
p->fragmentMap().position(f);
never executed: return p->fragmentMap().position(f);
0
136}-
137-
138-
139-
140-
141-
142-
143-
144QTextFrame::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
never executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e);
QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e);
never executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), b, b, e);
0
150}-
151-
152-
153-
154-
155-
156-
157QTextFrame::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
never executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
never executed: return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
0
163}-
164QTextTablePrivate::~QTextTablePrivate()-
165{-
166 if (grid
gridDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
167 free(grid);
never executed: free(grid);
0
168}
never executed: end of block
0
169-
170-
171QTextTable *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 ((!(table)) ? qt_assert("table",__FILE__,333) : 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 < rows*colsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
198 d->cells.append(pieceTable->insertBlock(QChar(0xfdd0), pos, cellIdx, charIdx));-
199-
200 ++pos;-
201 }
never executed: end of block
0
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
never executed: return table;
table;
never executed: return table;
0
213}-
214-
215struct QFragmentFindHelper-
216{-
217 inline QFragmentFindHelper(int _pos, const QTextDocumentPrivate::FragmentMap &map)-
218 : pos(_pos), fragmentMap(map) {}
never executed: end of block
0
219 uint pos;-
220 const QTextDocumentPrivate::FragmentMap &fragmentMap;-
221};-
222-
223static inline bool operator<(int fragment, const QFragmentFindHelper &helper)-
224{-
225 return
never executed: return helper.fragmentMap.position(fragment) < helper.pos;
helper.fragmentMap.position(fragment) < helper.pos;
never executed: return helper.fragmentMap.position(fragment) < helper.pos;
0
226}-
227-
228static inline bool operator<(const QFragmentFindHelper &helper, int fragment)-
229{-
230 return
never executed: return helper.pos < helper.fragmentMap.position(fragment);
helper.pos < helper.fragmentMap.position(fragment);
never executed: return helper.pos < helper.fragmentMap.position(fragment);
0
231}-
232-
233int QTextTablePrivate::findCellIndex(int fragment) const-
234{-
235 QFragmentFindHelper helper(pieceTable->fragmentMap().position(fragment),-
236 pieceTable->fragmentMap());-
237 const auto it = std::lower_bound(cells.constBegin(), cells.constEnd(), helper);-
238 if ((
(it == cells.constEnd())Description
TRUEnever evaluated
FALSEnever evaluated
it == cells.constEnd())
(it == cells.constEnd())Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(helper < *it)Description
TRUEnever evaluated
FALSEnever evaluated
helper < *it)
(helper < *it)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
239 return
never executed: return -1;
-1;
never executed: return -1;
0
240 return
never executed: return it - cells.constBegin();
it - cells.constBegin();
never executed: return it - cells.constBegin();
0
241}-
242-
243void QTextTablePrivate::fragmentAdded(QChar type, uint fragment)-
244{-
245 dirty = true;-
246 if (blockFragmentUpdates
blockFragmentUpdatesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
247 return;
never executed: return;
0
248 if (type == QChar(0xfdd0)
type == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
249 ((!(cells.indexOf(fragment) == -1)) ? qt_assert("cells.indexOf(fragment) == -1",__FILE__,406) : qt_noop());-
250 const uint pos = pieceTable->fragmentMap().position(fragment);-
251 QFragmentFindHelper helper(pos, pieceTable->fragmentMap());-
252 auto it = std::lower_bound(cells.begin(), cells.end(), helper);-
253 cells.insert(it, fragment);-
254 if (!fragment_start
!fragment_startDescription
TRUEnever evaluated
FALSEnever evaluated
|| pos < pieceTable->fragmentMap().position(fragment_start)
pos < pieceTab...ragment_start)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
255 fragment_start = fragment;
never executed: fragment_start = fragment;
0
256 return;
never executed: return;
0
257 }-
258 QTextFramePrivate::fragmentAdded(type, fragment);-
259}
never executed: end of block
0
260-
261void QTextTablePrivate::fragmentRemoved(QChar type, uint fragment)-
262{-
263 dirty = true;-
264 if (blockFragmentUpdates
blockFragmentUpdatesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
265 return;
never executed: return;
0
266 if (type == QChar(0xfdd0)
type == QChar(0xfdd0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
267 ((!(cells.indexOf(fragment) != -1)) ? qt_assert("cells.indexOf(fragment) != -1",__FILE__,424) : qt_noop());-
268 cells.removeAll(fragment);-
269 if (fragment_start == fragment
fragment_start == fragmentDescription
TRUEnever evaluated
FALSEnever evaluated
&& cells.size()
cells.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
270 fragment_start = cells.at(0);-
271 }
never executed: end of block
0
272 if (fragment_start != fragment
fragment_start != fragmentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
273 return;
never executed: return;
0
274 }
never executed: end of block
0
275 QTextFramePrivate::fragmentRemoved(type, fragment);-
276}
never executed: end of block
0
277void 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 < cells.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
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
cell < nRows*nColsDescription
TRUEnever evaluated
FALSEnever evaluated
&& grid[cell]
grid[cell]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
301 ++
never executed: ++cell;
cell;
never executed: ++cell;
0
302-
303 int r = cell/nCols;-
304 int c = cell%nCols;-
305 cellIndices[i] = cell;-
306-
307 if (r + rowspan > nRows
r + rowspan > nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
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 }
never executed: end of block
0
312-
313 ((!(c + colspan <= nCols)) ? qt_assert("c + colspan <= nCols",__FILE__,478) : qt_noop());-
314 for (int ii = 0; ii < rowspan
ii < rowspanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++ii) {
0
315 for (int jj = 0; jj < colspan
jj < colspanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++jj) {
0
316 ((!(grid[(r+ii)*nCols + c+jj] == 0)) ? qt_assert("grid[(r+ii)*nCols + c+jj] == 0",__FILE__,481) : qt_noop());-
317 grid[(r+ii)*nCols + c+jj] = fragment;-
318-
319 }
never executed: end of block
0
320 }
never executed: end of block
0
321 }
never executed: end of block
0
322-
323-
324 dirty = false;-
325}
never executed: end of block
0
326QTextTable::QTextTable(QTextDocument *doc)-
327 : QTextFrame(*new QTextTablePrivate(doc), doc)-
328{-
329}
never executed: end of block
0
330-
331-
332-
333-
334-
335QTextTable::~QTextTable()-
336{-
337}-
338QTextTableCell QTextTable::cellAt(int row, int col) const-
339{-
340 const QTextTablePrivate * const d = d_func();-
341 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
342 d->update();
never executed: d->update();
0
343-
344 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| row >= d->nRows
row >= d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
|| col < 0
col < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| col >= d->nCols
col >= d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
345 return
never executed: return QTextTableCell();
QTextTableCell();
never executed: return QTextTableCell();
0
346-
347 return
never executed: return QTextTableCell(this, d->grid[row*d->nCols + col]);
QTextTableCell(this, d->grid[row*d->nCols + col]);
never executed: return QTextTableCell(this, d->grid[row*d->nCols + col]);
0
348}-
349-
350-
351-
352-
353-
354-
355-
356QTextTableCell QTextTable::cellAt(int position) const-
357{-
358 const QTextTablePrivate * const d = d_func();-
359 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
360 d->update();
never executed: d->update();
0
361-
362 uint pos = (uint)position;-
363 const QTextDocumentPrivate::FragmentMap &map = d->pieceTable->fragmentMap();-
364 if (position < 0
position < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| map.position(d->fragment_start) >= pos
map.position(d..._start) >= posDescription
TRUEnever evaluated
FALSEnever evaluated
|| map.position(d->fragment_end) < pos
map.position(d...ent_end) < posDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
365 return
never executed: return QTextTableCell();
QTextTableCell();
never executed: return QTextTableCell();
0
366-
367 QFragmentFindHelper helper(position, map);-
368 auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper);-
369 if (it != d->cells.begin()
it != d->cells.begin()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
370 --
never executed: --it;
it;
never executed: --it;
0
371-
372 return
never executed: return QTextTableCell(this, *it);
QTextTableCell(this, *it);
never executed: return QTextTableCell(this, *it);
0
373}-
374QTextTableCell QTextTable::cellAt(const QTextCursor &c) const-
375{-
376 return
never executed: return cellAt(c.position());
cellAt(c.position());
never executed: return cellAt(c.position());
0
377}-
378void QTextTable::resize(int rows, int cols)-
379{-
380 QTextTablePrivate * const d = d_func();-
381 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
382 d->update();
never executed: d->update();
0
383-
384 int nRows = this->rows();-
385 int nCols = this->columns();-
386-
387 if (rows == nRows
rows == nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
&& cols == nCols
cols == nColsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
388 return;
never executed: return;
0
389-
390 d->pieceTable->beginEditBlock();-
391-
392 if (nCols < cols
nCols < colsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
393 insertColumns(nCols, cols - nCols);
never executed: insertColumns(nCols, cols - nCols);
0
394 else if (nCols > cols
nCols > colsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
395 removeColumns(cols, nCols - cols);
never executed: removeColumns(cols, nCols - cols);
0
396-
397 if (nRows < rows
nRows < rowsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
398 insertRows(nRows, rows-nRows);
never executed: insertRows(nRows, rows-nRows);
0
399 else if (nRows > rows
nRows > rowsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
400 removeRows(rows, nRows-rows);
never executed: removeRows(rows, nRows-rows);
0
401-
402 d->pieceTable->endEditBlock();-
403}
never executed: end of block
0
404void QTextTable::insertRows(int pos, int num)-
405{-
406 QTextTablePrivate * const d = d_func();-
407 if (num <= 0
num <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
408 return;
never executed: return;
0
409-
410 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
411 d->update();
never executed: d->update();
0
412-
413 if (pos > d->nRows
pos > d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
|| pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
414 pos = d->nRows;
never executed: pos = d->nRows;
0
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 > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& pos < d->nRows
pos < d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 for (int i = 0; i < d->nCols
i < d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
425 int cell = d->grid[pos*d->nCols + i];-
426 if (cell == d->grid[(pos-1)*d->nCols+i]
cell == d->gri...1)*d->nCols+i]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
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 }
never executed: end of block
else if (!insert_before
!insert_beforeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
434 insert_before = cell;-
435 }
never executed: end of block
0
436 }
never executed: end of block
0
437 }
never executed: end of block
else {
0
438 insert_before = (pos == 0
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
? d->grid[0] : d->fragment_end);
0
439 }
never executed: end of block
0
440 if (extended < d->nCols
extended < d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
441 ((!(insert_before)) ? qt_assert("insert_before",__FILE__,716) : 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 ((!(fmt.objectIndex() == objectIndex())) ? qt_assert("fmt.objectIndex() == objectIndex()",__FILE__,721) : 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 < num*(d->nCols-extended)Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
452 p->insertBlock(QChar(0xfdd0), pos, bfmt, cfmt, QTextUndoCommand::MoveCursor);
never executed: p->insertBlock(QChar(0xfdd0), pos, bfmt, cfmt, QTextUndoCommand::MoveCursor);
0
453 }
never executed: end of block
0
454-
455-
456 p->endEditBlock();-
457}
never executed: end of block
0
458void QTextTable::insertColumns(int pos, int num)-
459{-
460 QTextTablePrivate * const d = d_func();-
461 if (num <= 0
num <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
462 return;
never executed: return;
0
463-
464 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
465 d->update();
never executed: d->update();
0
466-
467 if (pos > d->nCols
pos > d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
|| pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
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 QVector<int> extendedSpans;-
476 for (int i = 0; i < d->nRows
i < d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
477 int cell;-
478 if (i == d->nRows - 1
i == d->nRows - 1Description
TRUEnever evaluated
FALSEnever evaluated
&& pos == d->nCols
pos == d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
479 cell = d->fragment_end;-
480 }
never executed: end of block
else {
0
481 int logicalGridIndexBeforePosition = pos > 0
pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
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 }
never executed: end of block
while (logicalGridIndex < logicalGridIndexBeforePosition
logicalGridInd...BeforePositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
495 && gridArrayOffset < d->nRows*d->nCols
gridArrayOffse...nRows*d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
496-
497 if (logicalGridIndex < logicalGridIndexBeforePosition
logicalGridInd...BeforePositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
498 && gridArrayOffset == d->nRows*d->nCols
gridArrayOffse...nRows*d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
499 cell = d->fragment_end;
never executed: cell = d->fragment_end;
0
500 }
never executed: end of block
0
501-
502 if (pos > 0
pos > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& pos < d->nCols
pos < d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
&& cell == d->grid[i*d->nCols + pos - 1]
cell == d->gri...ols + pos - 1]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
503-
504 if (!extendedSpans.contains(cell)
!extendedSpans.contains(cell)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
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 }
never executed: end of block
0
512 }
never executed: end of block
else {
0
513-
514-
515 if (i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& pos < d->nCols
pos < d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
&& cell == d->grid[(i-1) * d->nCols + pos]
cell == d->gri...->nCols + pos]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
516 int gridIndex = i*d->nCols + pos;-
517 const int gridEnd = d->nRows * d->nCols - 1;-
518 while (gridIndex < gridEnd
gridIndex < gridEndDescription
TRUEnever evaluated
FALSEnever evaluated
&& cell == d->grid[gridIndex]
cell == d->grid[gridIndex]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
519 ++gridIndex;-
520 }
never executed: end of block
0
521 if (gridIndex == gridEnd
gridIndex == gridEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
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 ((!(fmt.objectIndex() == objectIndex())) ? qt_assert("fmt.objectIndex() == objectIndex()",__FILE__,813) : 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 < numDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
535 p->insertBlock(QChar(0xfdd0), position, bfmt, cfmt, QTextUndoCommand::MoveCursor);
never executed: p->insertBlock(QChar(0xfdd0), position, bfmt, cfmt, QTextUndoCommand::MoveCursor);
0
536 }
never executed: end of block
0
537 }-
538-
539 QTextTableFormat tfmt = format();-
540 tfmt.setColumns(tfmt.columns()+num);-
541 QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints();-
542 if (! columnWidths.isEmpty()
! columnWidths.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
543 for (int i = num; i > 0
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i)
0
544 columnWidths.insert(pos, columnWidths.at(qMax(0, pos - 1)));
never executed: columnWidths.insert(pos, columnWidths.at(qMax(0, pos - 1)));
0
545 }
never executed: end of block
0
546 tfmt.setColumnWidthConstraints (columnWidths);-
547 QTextObject::setFormat(tfmt);-
548-
549-
550 p->endEditBlock();-
551}
never executed: end of block
0
552-
553-
554-
555-
556-
557-
558-
559void QTextTable::appendRows(int count)-
560{-
561 insertRows(rows(), count);-
562}
never executed: end of block
0
563-
564-
565-
566-
567-
568-
569-
570void QTextTable::appendColumns(int count)-
571{-
572 insertColumns(columns(), count);-
573}
never executed: end of block
0
574void QTextTable::removeRows(int pos, int num)-
575{-
576 QTextTablePrivate * const d = d_func();-
577-
578-
579 if (num <= 0
num <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
580 return;
never executed: return;
0
581 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
582 d->update();
never executed: d->update();
0
583 if (pos >= d->nRows
pos >= d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
584 return;
never executed: return;
0
585 if (pos+num > d->nRows
pos+num > d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
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
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num == d->nRows
num == d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
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;
never executed: return;
0
598 }-
599-
600 p->aboutToRemoveCell(cellAt(pos, 0).firstPosition(), cellAt(pos + num - 1, d->nCols - 1).lastPosition());-
601-
602 QVector<int> touchedCells;-
603 for (int r = pos; r < pos + num
r < pos + numDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
604 for (int c = 0; c < d->nCols
c < d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c) {
0
605 int cell = d->grid[r*d->nCols + c];-
606 if (touchedCells.contains(cell)
touchedCells.contains(cell)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
607 continue;
never executed: continue;
0
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
span > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
613 fmt.setTableCellRowSpan(span - 1);-
614 p->setCharFormat(it.position(), 1, fmt);-
615 }
never executed: end of block
else {
0
616-
617 int index = d->cells.indexOf(cell) + 1;-
618 int f_end = index < d->cells.size()
index < d->cells.size()Description
TRUEnever evaluated
FALSEnever evaluated
? d->cells.at(index) : d->fragment_end;
0
619 p->remove(it.position(), p->fragmentMap().position(f_end) - it.position());-
620 }
never executed: end of block
0
621 }-
622 }
never executed: end of block
0
623-
624 p->endEditBlock();-
625-
626}
never executed: end of block
0
627void QTextTable::removeColumns(int pos, int num)-
628{-
629 QTextTablePrivate * const d = d_func();-
630-
631-
632 if (num <= 0
num <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| pos < 0
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
633 return;
never executed: return;
0
634 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
635 d->update();
never executed: d->update();
0
636 if (pos >= d->nCols
pos >= d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
637 return;
never executed: return;
0
638 if (pos + num > d->nCols
pos + num > d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
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
pos == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& num == d->nCols
num == d->nColsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
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;
never executed: return;
0
651 }-
652-
653 p->aboutToRemoveCell(cellAt(0, pos).firstPosition(), cellAt(d->nRows - 1, pos + num - 1).lastPosition());-
654-
655 QVector<int> touchedCells;-
656 for (int r = 0; r < d->nRows
r < d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
657 for (int c = pos; c < pos + num
c < pos + numDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c) {
0
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)
touchedCells.contains(cell)Description
TRUEnever evaluated
FALSEnever evaluated
&& span <= 1
span <= 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
663 continue;
never executed: continue;
0
664 touchedCells << cell;-
665-
666 if (span > 1
span > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
667 fmt.setTableCellColumnSpan(span - 1);-
668 p->setCharFormat(it.position(), 1, fmt);-
669 }
never executed: end of block
else {
0
670-
671 int index = d->cells.indexOf(cell) + 1;-
672 int f_end = index < d->cells.size()
index < d->cells.size()Description
TRUEnever evaluated
FALSEnever evaluated
? d->cells.at(index) : d->fragment_end;
0
673 p->remove(it.position(), p->fragmentMap().position(f_end) - it.position());-
674 }
never executed: end of block
0
675 }-
676 }
never executed: end of block
0
677-
678 QTextTableFormat tfmt = format();-
679 tfmt.setColumns(tfmt.columns()-num);-
680 QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints();-
681 if (columnWidths.count() > pos
columnWidths.count() > posDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
682 columnWidths.remove(pos, num);-
683 tfmt.setColumnWidthConstraints (columnWidths);-
684 }
never executed: end of block
0
685 QTextObject::setFormat(tfmt);-
686-
687 p->endEditBlock();-
688-
689}
never executed: end of block
0
690void QTextTable::mergeCells(int row, int column, int numRows, int numCols)-
691{-
692 QTextTablePrivate * const d = d_func();-
693-
694 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
695 d->update();
never executed: d->update();
0
696-
697 QTextDocumentPrivate *p = d->pieceTable;-
698 QTextFormatCollection *fc = p->formatCollection();-
699-
700 const QTextTableCell cell = cellAt(row, column);-
701 if (!cell.isValid()
!cell.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| row != cell.row()
row != cell.row()Description
TRUEnever evaluated
FALSEnever evaluated
|| column != cell.column()
column != cell.column()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
702 return;
never executed: 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
numRows < rowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
|| numCols < colSpan
numCols < colSpanDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
713 return;
never executed: return;
0
714-
715-
716 for (int r = row; r < row + numRows
r < row + numRowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
717 if (cellAt(r, column) == cellAt(r, column - 1)
cellAt(r, colu...r, column - 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
718 return;
never executed: return;
0
719 if (cellAt(r, column + numCols) == cellAt(r, column + numCols - 1)
cellAt(r, colu...+ numCols - 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
720 return;
never executed: return;
0
721 }
never executed: end of block
0
722-
723 for (int c = column; c < column + numCols
c < column + numColsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c) {
0
724 if (cellAt(row, c) == cellAt(row - 1, c)
cellAt(row, c)...At(row - 1, c)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
725 return;
never executed: return;
0
726 if (cellAt(row + numRows, c) == cellAt(row + numRows - 1, c)
cellAt(row + n...umRows - 1, c)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
727 return;
never executed: return;
0
728 }
never executed: end of block
0
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 const auto begin = d->cells.cbegin();-
739 const auto it = std::lower_bound(begin, d->cells.cend(), helper);-
740 ((!(it != d->cells.end())) ? qt_assert("it != d->cells.end()",__FILE__,1051) : qt_noop());-
741 ((!(!(helper < *it))) ? qt_assert("!(helper < *it)",__FILE__,1052) : qt_noop());-
742 ((!(*it == cellFragment)) ? qt_assert("*it == cellFragment",__FILE__,1053) : qt_noop());-
743 const int insertCellIndex = it - begin;-
744 int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end);-
745 uint insertPos = p->fragmentMap().position(insertFragment);-
746-
747 d->blockFragmentUpdates = true;-
748-
749 bool rowHasText = cell.firstCursorPosition().block().length();-
750 bool needsParagraph = rowHasText
rowHasTextDescription
TRUEnever evaluated
FALSEnever evaluated
&& colSpan == numCols
colSpan == numColsDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
751-
752-
753 for (int r = row; r < row + numRows
r < row + numRowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
754 int firstColumn = r < row + rowSpan
r < row + rowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
? column + colSpan : column;
0
755-
756-
757 int firstCellIndex = r == row
r == rowDescription
TRUEnever evaluated
FALSEnever evaluated
? insertCellIndex + 1 : -1;
0
758 int cellIndex = firstCellIndex;-
759-
760 for (int c = firstColumn; c < column + numCols
c < column + numColsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c) {
0
761 const int fragment = d->grid[r * d->nCols + c];-
762-
763-
764 if (fragment == cellFragment
fragment == cellFragmentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
765 continue;
never executed: continue;
0
766-
767 QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment);-
768 uint pos = it.position();-
769-
770 if (firstCellIndex == -1
firstCellIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
771 QFragmentFindHelper helper(pos, p->fragmentMap());-
772 const auto begin = d->cells.cbegin();-
773 const auto it = std::lower_bound(begin, d->cells.cend(), helper);-
774 ((!(it != d->cells.end())) ? qt_assert("it != d->cells.end()",__FILE__,1085) : qt_noop());-
775 ((!(!(helper < *it))) ? qt_assert("!(helper < *it)",__FILE__,1086) : qt_noop());-
776 ((!(*it == fragment)) ? qt_assert("*it == fragment",__FILE__,1087) : qt_noop());-
777 firstCellIndex = cellIndex = it - begin;-
778 }
never executed: end of block
0
779-
780 ++cellIndex;-
781-
782 QTextCharFormat fmt = fc->charFormat(it->format);-
783-
784 const int cellRowSpan = fmt.tableCellRowSpan();-
785 const int cellColSpan = fmt.tableCellColumnSpan();-
786-
787-
788 for (int i = r; i < r + cellRowSpan
i < r + cellRowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
789 for (int j = c; j < c + cellColSpan
j < c + cellColSpanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++j)
0
790 d->grid[i * d->nCols + j] = cellFragment;
never executed: d->grid[i * d->nCols + j] = cellFragment;
0
791-
792-
793 p->remove(pos, 1);-
794-
795 const int nextFragment = d->cells.value(cellIndex, d->fragment_end);-
796 const uint nextPos = p->fragmentMap().position(nextFragment);-
797-
798 ((!(nextPos >= pos)) ? qt_assert("nextPos >= pos",__FILE__,1109) : qt_noop());-
799-
800-
801 if (nextPos > pos
nextPos > posDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
802 if (needsParagraph
needsParagraphDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
803 needsParagraph = false;-
804 QTextCursorPrivate::fromPosition(p, insertPos++).insertBlock();-
805 p->move(pos + 1, insertPos, nextPos - pos);-
806 }
never executed: end of block
else if (rowHasText
rowHasTextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
807 QTextCursorPrivate::fromPosition(p, insertPos++).insertText(QLatin1String(" "));-
808 p->move(pos + 1, insertPos, nextPos - pos);-
809 }
never executed: end of block
else {
0
810 p->move(pos, insertPos, nextPos - pos);-
811 }
never executed: end of block
0
812-
813 insertPos += nextPos - pos;-
814 rowHasText = true;-
815 }
never executed: end of block
0
816 }
never executed: end of block
0
817-
818 if (rowHasText
rowHasTextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
819 needsParagraph = true;-
820 rowHasText = false;-
821 }
never executed: end of block
0
822-
823-
824 if (firstCellIndex >= 0
firstCellIndex >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
825 d->cellIndices.remove(firstCellIndex, cellIndex - firstCellIndex);-
826 d->cells.erase(d->cells.begin() + firstCellIndex, d->cells.begin() + cellIndex);-
827 }
never executed: end of block
0
828 }
never executed: end of block
0
829-
830 d->fragment_start = d->cells.constFirst();-
831-
832 fmt.setTableCellRowSpan(numRows);-
833 fmt.setTableCellColumnSpan(numCols);-
834 p->setCharFormat(origCellPosition, 1, fmt);-
835-
836 d->blockFragmentUpdates = false;-
837 d->dirty = false;-
838-
839 p->endEditBlock();-
840}
never executed: end of block
0
841void QTextTable::mergeCells(const QTextCursor &cursor)-
842{-
843 if (!cursor.hasComplexSelection()
!cursor.hasComplexSelection()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
844 return;
never executed: return;
0
845-
846 int firstRow, numRows, firstColumn, numColumns;-
847 cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns);-
848 mergeCells(firstRow, firstColumn, numRows, numColumns);-
849}
never executed: end of block
0
850void QTextTable::splitCell(int row, int column, int numRows, int numCols)-
851{-
852 QTextTablePrivate * const d = d_func();-
853-
854 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
855 d->update();
never executed: d->update();
0
856-
857 QTextDocumentPrivate *p = d->pieceTable;-
858 QTextFormatCollection *c = p->formatCollection();-
859-
860 const QTextTableCell cell = cellAt(row, column);-
861 if (!cell.isValid()
!cell.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
862 return;
never executed: return;
0
863 row = cell.row();-
864 column = cell.column();-
865-
866 QTextCharFormat fmt = cell.format();-
867 const int rowSpan = fmt.tableCellRowSpan();-
868 const int colSpan = fmt.tableCellColumnSpan();-
869-
870-
871 if (numRows > rowSpan
numRows > rowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
|| numCols > colSpan
numCols > colSpanDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
872 return;
never executed: return;
0
873-
874 p->beginEditBlock();-
875-
876 const int origCellPosition = cell.firstPosition() - 1;-
877-
878 QVarLengthArray<int> rowPositions(rowSpan);-
879-
880 rowPositions[0] = cell.lastPosition();-
881-
882 for (int r = row + 1; r < row + rowSpan
r < row + rowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
883-
884 int gridIndex = r * d->nCols + column;-
885 const auto begin = d->cellIndices.cbegin();-
886 const auto it = std::upper_bound(begin, d->cellIndices.cend(), gridIndex);-
887 int fragment = d->cells.value(it - begin, d->fragment_end);-
888 rowPositions[r - row] = p->fragmentMap().position(fragment);-
889 }
never executed: end of block
0
890-
891 fmt.setTableCellColumnSpan(1);-
892 fmt.setTableCellRowSpan(1);-
893 const int fmtIndex = c->indexForFormat(fmt);-
894 const int blockIndex = p->blockMap().find(cell.lastPosition())->format;-
895-
896 int insertAdjustement = 0;-
897 for (int i = 0; i < numRows
i < numRowsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
898 for (int c = 0; c < colSpan - numCols
c < colSpan - numColsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c)
0
899 p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
never executed: p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
0
900 insertAdjustement += colSpan - numCols;-
901 }
never executed: end of block
0
902-
903 for (int i = numRows; i < rowSpan
i < rowSpanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
904 for (int c = 0; c < colSpan
c < colSpanDescription
TRUEnever evaluated
FALSEnever evaluated
; ++c)
0
905 p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
never executed: p->insertBlock(QChar(0xfdd0), rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
0
906 insertAdjustement += colSpan;-
907 }
never executed: end of block
0
908-
909 fmt.setTableCellRowSpan(numRows);-
910 fmt.setTableCellColumnSpan(numCols);-
911 p->setCharFormat(origCellPosition, 1, fmt);-
912-
913 p->endEditBlock();-
914}
never executed: end of block
0
915-
916-
917-
918-
919-
920-
921int QTextTable::rows() const-
922{-
923 const QTextTablePrivate * const d = d_func();-
924 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
925 d->update();
never executed: d->update();
0
926-
927 return
never executed: return d->nRows;
d->nRows;
never executed: return d->nRows;
0
928}-
929-
930-
931-
932-
933-
934-
935int QTextTable::columns() const-
936{-
937 const QTextTablePrivate * const d = d_func();-
938 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
939 d->update();
never executed: d->update();
0
940-
941 return
never executed: return d->nCols;
d->nCols;
never executed: return d->nCols;
0
942}-
943QTextCursor QTextTable::rowStart(const QTextCursor &c) const-
944{-
945 const QTextTablePrivate * const d = d_func();-
946 QTextTableCell cell = cellAt(c);-
947 if (!cell.isValid()
!cell.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
948 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
949-
950 int row = cell.row();-
951 QTextDocumentPrivate *p = d->pieceTable;-
952 QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]);-
953 return
never executed: return QTextCursorPrivate::fromPosition(p, it.position());
QTextCursorPrivate::fromPosition(p, it.position());
never executed: return QTextCursorPrivate::fromPosition(p, it.position());
0
954}-
955QTextCursor QTextTable::rowEnd(const QTextCursor &c) const-
956{-
957 const QTextTablePrivate * const d = d_func();-
958 QTextTableCell cell = cellAt(c);-
959 if (!cell.isValid()
!cell.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
960 return
never executed: return QTextCursor();
QTextCursor();
never executed: return QTextCursor();
0
961-
962 int row = cell.row() + 1;-
963 int fragment = row < d->nRows
row < d->nRowsDescription
TRUEnever evaluated
FALSEnever evaluated
? d->grid[row*d->nCols] : d->fragment_end;
0
964 QTextDocumentPrivate *p = d->pieceTable;-
965 QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment);-
966 return
never executed: return QTextCursorPrivate::fromPosition(p, it.position() - 1);
QTextCursorPrivate::fromPosition(p, it.position() - 1);
never executed: return QTextCursorPrivate::fromPosition(p, it.position() - 1);
0
967}-
968void QTextTable::setFormat(const QTextTableFormat &format)-
969{-
970 QTextTableFormat fmt = format;-
971-
972 fmt.setColumns(columns());-
973 QTextObject::setFormat(fmt);-
974}
never executed: end of block
0
975-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9