qtextdocument_p.cpp

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

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