text/qtextdocument_p.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <private/qtools_p.h> -
43#include <qdebug.h> -
44 -
45#include "qtextdocument_p.h" -
46#include "qtextdocument.h" -
47#include <qtextformat.h> -
48#include "qtextformat_p.h" -
49#include "qtextobject_p.h" -
50#include "qtextcursor.h" -
51#include "qtextimagehandler_p.h" -
52#include "qtextcursor_p.h" -
53#include "qtextdocumentlayout_p.h" -
54#include "qtexttable.h" -
55#include "qtextengine_p.h" -
56 -
57#include <stdlib.h> -
58 -
59QT_BEGIN_NAMESPACE -
60 -
61#define PMDEBUG if(0) qDebug -
62 -
63// The VxWorks DIAB compiler crashes when initializing the anonymouse union with { a7 } -
64#if !defined(Q_CC_DIAB) -
65# define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \ -
66 QTextUndoCommand c = { a1, a2, 0, 0, quint8(a3), a4, quint32(a5), quint32(a6), { int(a7) }, quint32(a8) } -
67#else -
68# define QT_INIT_TEXTUNDOCOMMAND(c, a1, a2, a3, a4, a5, a6, a7, a8) \ -
69 QTextUndoCommand c = { a1, a2, 0, 0, a3, a4, a5, a6 }; c.blockFormat = a7; c.revision = a8 -
70#endif -
71 -
72/* -
73 Structure of a document: -
74 -
75 DOCUMENT :== FRAME_CONTENTS -
76 FRAME :== START_OF_FRAME FRAME_CONTENTS END_OF_FRAME -
77 FRAME_CONTENTS = LIST_OF_BLOCKS ((FRAME | TABLE) LIST_OF_BLOCKS)* -
78 TABLE :== (START_OF_FRAME TABLE_CELL)+ END_OF_FRAME -
79 TABLE_CELL = FRAME_CONTENTS -
80 LIST_OF_BLOCKS :== (BLOCK END_OF_PARA)* BLOCK -
81 BLOCK :== (FRAGMENT)* -
82 FRAGMENT :== String of characters -
83 -
84 END_OF_PARA :== 0x2029 # Paragraph separator in Unicode -
85 START_OF_FRAME :== 0xfdd0 -
86 END_OF_FRAME := 0xfdd1 -
87 -
88 Note also that LIST_OF_BLOCKS can be empty. Nevertheless, there is -
89 at least one valid cursor position there where you could start -
90 typing. The block format is in this case determined by the last -
91 END_OF_PARA/START_OF_FRAME/END_OF_FRAME (see below). -
92 -
93 Lists are not in here, as they are treated specially. A list is just -
94 a collection of (not necessarily connected) blocks, that share the -
95 same objectIndex() in the format that refers to the list format and -
96 object. -
97 -
98 The above does not clearly note where formats are. Here's -
99 how it looks currently: -
100 -
101 FRAGMENT: one charFormat associated -
102 -
103 END_OF_PARA: one charFormat, and a blockFormat for the _next_ block. -
104 -
105 START_OF_FRAME: one char format, and a blockFormat (for the next -
106 block). The format associated with the objectIndex() of the -
107 charFormat decides whether this is a frame or table and its -
108 properties -
109 -
110 END_OF_FRAME: one charFormat and a blockFormat (for the next -
111 block). The object() of the charFormat is the same as for the -
112 corresponding START_OF_BLOCK. -
113 -
114 -
115 The document is independent of the layout with certain restrictions: -
116 -
117 * Cursor movement (esp. up and down) depend on the layout. -
118 * You cannot have more than one layout, as the layout data of QTextObjects -
119 is stored in the text object itself. -
120 -
121*/ -
122 -
123void QTextBlockData::invalidate() const -
124{ -
125 if (layout)
evaluated: layout
TRUEFALSE
yes
Evaluation Count:4235
yes
Evaluation Count:10547
4235-10547
126 layout->engine()->invalidate();
executed: layout->engine()->invalidate();
Execution Count:4235
4235
127}
executed: }
Execution Count:14782
14782
128 -
129static bool isValidBlockSeparator(QChar ch) -
130{ -
131 return ch == QChar::ParagraphSeparator
executed: return ch == QChar::ParagraphSeparator || ch == QChar(0xfdd0) || ch == QChar(0xfdd1);
Execution Count:3849
3849
132 || ch == QTextBeginningOfFrame
executed: return ch == QChar::ParagraphSeparator || ch == QChar(0xfdd0) || ch == QChar(0xfdd1);
Execution Count:3849
3849
133 || ch == QTextEndOfFrame;
executed: return ch == QChar::ParagraphSeparator || ch == QChar(0xfdd0) || ch == QChar(0xfdd1);
Execution Count:3849
3849
134} -
135 -
136#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) -
137static bool noBlockInString(const QString &str) -
138{ -
139 return !str.contains(QChar::ParagraphSeparator) -
140 && !str.contains(QTextBeginningOfFrame) -
141 && !str.contains(QTextEndOfFrame); -
142} -
143#endif -
144 -
145bool QTextUndoCommand::tryMerge(const QTextUndoCommand &other) -
146{ -
147 if (command != other.command)
evaluated: command != other.command
TRUEFALSE
yes
Evaluation Count:240
yes
Evaluation Count:496
240-496
148 return false;
executed: return false;
Execution Count:240
240
149 -
150 if (command == Inserted
evaluated: command == Inserted
TRUEFALSE
yes
Evaluation Count:204
yes
Evaluation Count:292
204-292
151 && (pos + length == other.pos)
evaluated: (pos + length == other.pos)
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:126
78-126
152 && (strPos + length == other.strPos)
evaluated: (strPos + length == other.strPos)
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:1
1-77
153 && format == other.format) {
evaluated: format == other.format
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:6
6-71
154 -
155 length += other.length;
executed (the execution status of this line is deduced): length += other.length;
-
156 return true;
executed: return true;
Execution Count:71
71
157 } -
158 -
159 // removal to the 'right' using 'Delete' key -
160 if (command == Removed
evaluated: command == Removed
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:412
13-412
161 && pos == other.pos
evaluated: pos == other.pos
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
162 && (strPos + length == other.strPos)
partially evaluated: (strPos + length == other.strPos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
163 && format == other.format) {
never evaluated: format == other.format
0
164 -
165 length += other.length;
never executed (the execution status of this line is deduced): length += other.length;
-
166 return true;
never executed: return true;
0
167 } -
168 -
169 // removal to the 'left' using 'Backspace' -
170 if (command == Removed
evaluated: command == Removed
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:412
13-412
171 && (other.pos + other.length == pos)
evaluated: (other.pos + other.length == pos)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
172 && (other.strPos + other.length == strPos)
partially evaluated: (other.strPos + other.length == strPos)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
173 && (format == other.format)) {
partially evaluated: (format == other.format)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
174 -
175 int l = length;
executed (the execution status of this line is deduced): int l = length;
-
176 (*this) = other;
executed (the execution status of this line is deduced): (*this) = other;
-
177 -
178 length += l;
executed (the execution status of this line is deduced): length += l;
-
179 return true;
executed: return true;
Execution Count:7
7
180 } -
181 -
182 return false;
executed: return false;
Execution Count:418
418
183} -
184 -
185QTextDocumentPrivate::QTextDocumentPrivate() -
186 : wasUndoAvailable(false), -
187 wasRedoAvailable(false), -
188 docChangeOldLength(0), -
189 docChangeLength(0), -
190 framesDirty(true), -
191 rtFrame(0), -
192 initialBlockCharFormatIndex(-1) // set correctly later in init() -
193{ -
194 editBlock = 0;
executed (the execution status of this line is deduced): editBlock = 0;
-
195 editBlockCursorPosition = -1;
executed (the execution status of this line is deduced): editBlockCursorPosition = -1;
-
196 docChangeFrom = -1;
executed (the execution status of this line is deduced): docChangeFrom = -1;
-
197 -
198 undoState = 0;
executed (the execution status of this line is deduced): undoState = 0;
-
199 revision = -1; // init() inserts a block, bringing it to 0
executed (the execution status of this line is deduced): revision = -1;
-
200 -
201 lout = 0;
executed (the execution status of this line is deduced): lout = 0;
-
202 -
203 modified = false;
executed (the execution status of this line is deduced): modified = false;
-
204 modifiedState = 0;
executed (the execution status of this line is deduced): modifiedState = 0;
-
205 -
206 undoEnabled = true;
executed (the execution status of this line is deduced): undoEnabled = true;
-
207 inContentsChange = false;
executed (the execution status of this line is deduced): inContentsChange = false;
-
208 blockCursorAdjustment = false;
executed (the execution status of this line is deduced): blockCursorAdjustment = false;
-
209 -
210 defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
executed (the execution status of this line is deduced): defaultTextOption.setTabStop(80);
-
211 defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
executed (the execution status of this line is deduced): defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-
212 defaultCursorMoveStyle = Qt::LogicalMoveStyle;
executed (the execution status of this line is deduced): defaultCursorMoveStyle = Qt::LogicalMoveStyle;
-
213 -
214 indentWidth = 40;
executed (the execution status of this line is deduced): indentWidth = 40;
-
215 documentMargin = 4;
executed (the execution status of this line is deduced): documentMargin = 4;
-
216 -
217 maximumBlockCount = 0;
executed (the execution status of this line is deduced): maximumBlockCount = 0;
-
218 needsEnsureMaximumBlockCount = false;
executed (the execution status of this line is deduced): needsEnsureMaximumBlockCount = false;
-
219 unreachableCharacterCount = 0;
executed (the execution status of this line is deduced): unreachableCharacterCount = 0;
-
220 lastBlockCount = 0;
executed (the execution status of this line is deduced): lastBlockCount = 0;
-
221}
executed: }
Execution Count:1941
1941
222 -
223void QTextDocumentPrivate::init() -
224{ -
225 framesDirty = false;
executed (the execution status of this line is deduced): framesDirty = false;
-
226 -
227 bool undoState = undoEnabled;
executed (the execution status of this line is deduced): bool undoState = undoEnabled;
-
228 undoEnabled = false;
executed (the execution status of this line is deduced): undoEnabled = false;
-
229 initialBlockCharFormatIndex = formats.indexForFormat(QTextCharFormat());
executed (the execution status of this line is deduced): initialBlockCharFormatIndex = formats.indexForFormat(QTextCharFormat());
-
230 insertBlock(0, formats.indexForFormat(QTextBlockFormat()), formats.indexForFormat(QTextCharFormat()));
executed (the execution status of this line is deduced): insertBlock(0, formats.indexForFormat(QTextBlockFormat()), formats.indexForFormat(QTextCharFormat()));
-
231 undoEnabled = undoState;
executed (the execution status of this line is deduced): undoEnabled = undoState;
-
232 modified = false;
executed (the execution status of this line is deduced): modified = false;
-
233 modifiedState = 0;
executed (the execution status of this line is deduced): modifiedState = 0;
-
234 -
235 qRegisterMetaType<QTextDocument *>();
executed (the execution status of this line is deduced): qRegisterMetaType<QTextDocument *>();
-
236}
executed: }
Execution Count:3140
3140
237 -
238void QTextDocumentPrivate::clear() -
239{ -
240 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
241 -
242 foreach (QTextCursorPrivate *curs, cursors) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
243 curs->setPosition(0);
executed (the execution status of this line is deduced): curs->setPosition(0);
-
244 curs->currentCharFormat = -1;
executed (the execution status of this line is deduced): curs->currentCharFormat = -1;
-
245 curs->anchor = 0;
executed (the execution status of this line is deduced): curs->anchor = 0;
-
246 curs->adjusted_anchor = 0;
executed (the execution status of this line is deduced): curs->adjusted_anchor = 0;
-
247 }
executed: }
Execution Count:1117
1117
248 -
249 QList<QTextCursorPrivate *>oldCursors = cursors;
executed (the execution status of this line is deduced): QList<QTextCursorPrivate *>oldCursors = cursors;
-
250 QT_TRY{
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:1199
no
Evaluation Count:0
0-1199
251 cursors.clear();
executed (the execution status of this line is deduced): cursors.clear();
-
252 -
253 QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
executed (the execution status of this line is deduced): QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
-
254 while (objectIt != objects.end()) {
evaluated: objectIt != objects.end()
TRUEFALSE
yes
Evaluation Count:574
yes
Evaluation Count:1199
574-1199
255 if (*objectIt != rtFrame) {
evaluated: *objectIt != rtFrame
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:545
29-545
256 delete *objectIt;
executed (the execution status of this line is deduced): delete *objectIt;
-
257 objectIt = objects.erase(objectIt);
executed (the execution status of this line is deduced): objectIt = objects.erase(objectIt);
-
258 } else {
executed: }
Execution Count:29
29
259 ++objectIt;
executed (the execution status of this line is deduced): ++objectIt;
-
260 }
executed: }
Execution Count:545
545
261 } -
262 // also clear out the remaining root frame pointer -
263 // (we're going to delete the object further down) -
264 objects.clear();
executed (the execution status of this line is deduced): objects.clear();
-
265 -
266 title.clear();
executed (the execution status of this line is deduced): title.clear();
-
267 clearUndoRedoStacks(QTextDocument::UndoAndRedoStacks);
executed (the execution status of this line is deduced): clearUndoRedoStacks(QTextDocument::UndoAndRedoStacks);
-
268 text = QString();
executed (the execution status of this line is deduced): text = QString();
-
269 unreachableCharacterCount = 0;
executed (the execution status of this line is deduced): unreachableCharacterCount = 0;
-
270 modifiedState = 0;
executed (the execution status of this line is deduced): modifiedState = 0;
-
271 modified = false;
executed (the execution status of this line is deduced): modified = false;
-
272 formats = QTextFormatCollection();
executed (the execution status of this line is deduced): formats = QTextFormatCollection();
-
273 int len = fragments.length();
executed (the execution status of this line is deduced): int len = fragments.length();
-
274 fragments.clear();
executed (the execution status of this line is deduced): fragments.clear();
-
275 blocks.clear();
executed (the execution status of this line is deduced): blocks.clear();
-
276 cachedResources.clear();
executed (the execution status of this line is deduced): cachedResources.clear();
-
277 delete rtFrame;
executed (the execution status of this line is deduced): delete rtFrame;
-
278 rtFrame = 0;
executed (the execution status of this line is deduced): rtFrame = 0;
-
279 init();
executed (the execution status of this line is deduced): init();
-
280 cursors = oldCursors;
executed (the execution status of this line is deduced): cursors = oldCursors;
-
281 inContentsChange = true;
executed (the execution status of this line is deduced): inContentsChange = true;
-
282 q->contentsChange(0, len, 0);
executed (the execution status of this line is deduced): q->contentsChange(0, len, 0);
-
283 inContentsChange = false;
executed (the execution status of this line is deduced): inContentsChange = false;
-
284 if (lout)
evaluated: lout
TRUEFALSE
yes
Evaluation Count:584
yes
Evaluation Count:615
584-615
285 lout->documentChanged(0, len, 0);
executed: lout->documentChanged(0, len, 0);
Execution Count:584
584
286 } QT_CATCH(...) {
executed: }
Execution Count:1199
1199
287 cursors = oldCursors; // at least recover the cursors
never executed (the execution status of this line is deduced): cursors = oldCursors;
-
288 QT_RETHROW;
never executed (the execution status of this line is deduced): qt_noop();
-
289 }
never executed: }
0
290} -
291 -
292QTextDocumentPrivate::~QTextDocumentPrivate() -
293{ -
294 foreach (QTextCursorPrivate *curs, cursors)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
295 curs->priv = 0;
executed: curs->priv = 0;
Execution Count:403
403
296 cursors.clear();
executed (the execution status of this line is deduced): cursors.clear();
-
297 undoState = 0;
executed (the execution status of this line is deduced): undoState = 0;
-
298 undoEnabled = true;
executed (the execution status of this line is deduced): undoEnabled = true;
-
299 clearUndoRedoStacks(QTextDocument::RedoStack);
executed (the execution status of this line is deduced): clearUndoRedoStacks(QTextDocument::RedoStack);
-
300}
executed: }
Execution Count:1937
1937
301 -
302void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout) -
303{ -
304 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
305 if (lout == layout)
partially evaluated: lout == layout
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:453
0-453
306 return;
never executed: return;
0
307 const bool firstLayout = !lout;
executed (the execution status of this line is deduced): const bool firstLayout = !lout;
-
308 delete lout;
executed (the execution status of this line is deduced): delete lout;
-
309 lout = layout;
executed (the execution status of this line is deduced): lout = layout;
-
310 -
311 if (!firstLayout)
evaluated: !firstLayout
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:451
2-451
312 for (BlockMap::Iterator it = blocks.begin(); !it.atEnd(); ++it)
evaluated: !it.atEnd()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
313 it->free();
executed: it->free();
Execution Count:2
2
314 -
315 emit q->documentLayoutChanged();
executed (the execution status of this line is deduced): q->documentLayoutChanged();
-
316 inContentsChange = true;
executed (the execution status of this line is deduced): inContentsChange = true;
-
317 emit q->contentsChange(0, 0, length());
executed (the execution status of this line is deduced): q->contentsChange(0, 0, length());
-
318 inContentsChange = false;
executed (the execution status of this line is deduced): inContentsChange = false;
-
319 if (lout)
evaluated: lout
TRUEFALSE
yes
Evaluation Count:452
yes
Evaluation Count:1
1-452
320 lout->documentChanged(0, 0, length());
executed: lout->documentChanged(0, 0, length());
Execution Count:452
452
321}
executed: }
Execution Count:453
453
322 -
323 -
324void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op) -
325{ -
326 // ##### optimize when only appending to the fragment! -
327 Q_ASSERT(noBlockInString(text.mid(strPos, length)));
executed (the execution status of this line is deduced): qt_noop();
-
328 -
329 split(pos);
executed (the execution status of this line is deduced): split(pos);
-
330 uint x = fragments.insert_single(pos, length);
executed (the execution status of this line is deduced): uint x = fragments.insert_single(pos, length);
-
331 QTextFragmentData *X = fragments.fragment(x);
executed (the execution status of this line is deduced): QTextFragmentData *X = fragments.fragment(x);
-
332 X->format = format;
executed (the execution status of this line is deduced): X->format = format;
-
333 X->stringPosition = strPos;
executed (the execution status of this line is deduced): X->stringPosition = strPos;
-
334 uint w = fragments.previous(x);
executed (the execution status of this line is deduced): uint w = fragments.previous(x);
-
335 if (w)
evaluated: w
TRUEFALSE
yes
Evaluation Count:5092
yes
Evaluation Count:1576
1576-5092
336 unite(w);
executed: unite(w);
Execution Count:5092
5092
337 -
338 int b = blocks.findNode(pos);
executed (the execution status of this line is deduced): int b = blocks.findNode(pos);
-
339 blocks.setSize(b, blocks.size(b)+length);
executed (the execution status of this line is deduced): blocks.setSize(b, blocks.size(b)+length);
-
340 -
341 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
342 -
343 QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(format));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(format));
-
344 if (frame) {
evaluated: frame
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:6635
33-6635
345 frame->d_func()->fragmentAdded(text.at(strPos), x);
executed (the execution status of this line is deduced): frame->d_func()->fragmentAdded(text.at(strPos), x);
-
346 framesDirty = true;
executed (the execution status of this line is deduced): framesDirty = true;
-
347 }
executed: }
Execution Count:33
33
348 -
349 adjustDocumentChangesAndCursors(pos, length, op);
executed (the execution status of this line is deduced): adjustDocumentChangesAndCursors(pos, length, op);
-
350}
executed: }
Execution Count:6668
6668
351 -
352int QTextDocumentPrivate::insert_block(int pos, uint strPos, int format, int blockFormat, QTextUndoCommand::Operation op, int command) -
353{ -
354 split(pos);
executed (the execution status of this line is deduced): split(pos);
-
355 uint x = fragments.insert_single(pos, 1);
executed (the execution status of this line is deduced): uint x = fragments.insert_single(pos, 1);
-
356 QTextFragmentData *X = fragments.fragment(x);
executed (the execution status of this line is deduced): QTextFragmentData *X = fragments.fragment(x);
-
357 X->format = format;
executed (the execution status of this line is deduced): X->format = format;
-
358 X->stringPosition = strPos;
executed (the execution status of this line is deduced): X->stringPosition = strPos;
-
359 // no need trying to unite, since paragraph separators are always in a fragment of their own -
360 -
361 Q_ASSERT(isValidBlockSeparator(text.at(strPos)));
executed (the execution status of this line is deduced): qt_noop();
-
362 Q_ASSERT(blocks.length()+1 == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
363 -
364 int block_pos = pos;
executed (the execution status of this line is deduced): int block_pos = pos;
-
365 if (blocks.length() && command == QTextUndoCommand::BlockRemoved)
evaluated: blocks.length()
TRUEFALSE
yes
Evaluation Count:16670
yes
Evaluation Count:3140
partially evaluated: command == QTextUndoCommand::BlockRemoved
TRUEFALSE
yes
Evaluation Count:16670
no
Evaluation Count:0
0-16670
366 ++block_pos;
executed: ++block_pos;
Execution Count:16670
16670
367 int size = 1;
executed (the execution status of this line is deduced): int size = 1;
-
368 int n = blocks.findNode(block_pos);
executed (the execution status of this line is deduced): int n = blocks.findNode(block_pos);
-
369 int key = n ? blocks.position(n) : blocks.length();
evaluated: n
TRUEFALSE
yes
Evaluation Count:2174
yes
Evaluation Count:17636
2174-17636
370 -
371 Q_ASSERT(n || (!n && block_pos == blocks.length()));
executed (the execution status of this line is deduced): qt_noop();
-
372 if (key != block_pos) {
evaluated: key != block_pos
TRUEFALSE
yes
Evaluation Count:2028
yes
Evaluation Count:17782
2028-17782
373 Q_ASSERT(key < block_pos);
executed (the execution status of this line is deduced): qt_noop();
-
374 int oldSize = blocks.size(n);
executed (the execution status of this line is deduced): int oldSize = blocks.size(n);
-
375 blocks.setSize(n, block_pos-key);
executed (the execution status of this line is deduced): blocks.setSize(n, block_pos-key);
-
376 size += oldSize - (block_pos-key);
executed (the execution status of this line is deduced): size += oldSize - (block_pos-key);
-
377 }
executed: }
Execution Count:2028
2028
378 int b = blocks.insert_single(block_pos, size);
executed (the execution status of this line is deduced): int b = blocks.insert_single(block_pos, size);
-
379 QTextBlockData *B = blocks.fragment(b);
executed (the execution status of this line is deduced): QTextBlockData *B = blocks.fragment(b);
-
380 B->format = blockFormat;
executed (the execution status of this line is deduced): B->format = blockFormat;
-
381 -
382 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
383 -
384 QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blockFormat));
executed (the execution status of this line is deduced): QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blockFormat));
-
385 if (group)
evaluated: group
TRUEFALSE
yes
Evaluation Count:10953
yes
Evaluation Count:8857
8857-10953
386 group->blockInserted(QTextBlock(this, b));
executed: group->blockInserted(QTextBlock(this, b));
Execution Count:10953
10953
387 -
388 QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(formats.format(format)));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(formats.format(format)));
-
389 if (frame) {
evaluated: frame
TRUEFALSE
yes
Evaluation Count:1447
yes
Evaluation Count:18363
1447-18363
390 frame->d_func()->fragmentAdded(text.at(strPos), x);
executed (the execution status of this line is deduced): frame->d_func()->fragmentAdded(text.at(strPos), x);
-
391 framesDirty = true;
executed (the execution status of this line is deduced): framesDirty = true;
-
392 }
executed: }
Execution Count:1447
1447
393 -
394 adjustDocumentChangesAndCursors(pos, 1, op);
executed (the execution status of this line is deduced): adjustDocumentChangesAndCursors(pos, 1, op);
-
395 return x;
executed: return x;
Execution Count:19810
19810
396} -
397 -
398int QTextDocumentPrivate::insertBlock(QChar blockSeparator, -
399 int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation op) -
400{ -
401 Q_ASSERT(formats.format(blockFormat).isBlockFormat());
executed (the execution status of this line is deduced): qt_noop();
-
402 Q_ASSERT(formats.format(charFormat).isCharFormat());
executed (the execution status of this line is deduced): qt_noop();
-
403 Q_ASSERT(pos >= 0 && (pos < fragments.length() || (pos == 0 && fragments.length() == 0)));
executed (the execution status of this line is deduced): qt_noop();
-
404 Q_ASSERT(isValidBlockSeparator(blockSeparator));
executed (the execution status of this line is deduced): qt_noop();
-
405 -
406 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
407 -
408 int strPos = text.length();
executed (the execution status of this line is deduced): int strPos = text.length();
-
409 text.append(blockSeparator);
executed (the execution status of this line is deduced): text.append(blockSeparator);
-
410 -
411 int ob = blocks.findNode(pos);
executed (the execution status of this line is deduced): int ob = blocks.findNode(pos);
-
412 bool atBlockEnd = true;
executed (the execution status of this line is deduced): bool atBlockEnd = true;
-
413 bool atBlockStart = true;
executed (the execution status of this line is deduced): bool atBlockStart = true;
-
414 int oldRevision = 0;
executed (the execution status of this line is deduced): int oldRevision = 0;
-
415 if (ob) {
evaluated: ob
TRUEFALSE
yes
Evaluation Count:16652
yes
Evaluation Count:3140
3140-16652
416 atBlockEnd = (pos - blocks.position(ob) == blocks.size(ob)-1);
executed (the execution status of this line is deduced): atBlockEnd = (pos - blocks.position(ob) == blocks.size(ob)-1);
-
417 atBlockStart = ((int)blocks.position(ob) == pos);
executed (the execution status of this line is deduced): atBlockStart = ((int)blocks.position(ob) == pos);
-
418 oldRevision = blocks.fragment(ob)->revision;
executed (the execution status of this line is deduced): oldRevision = blocks.fragment(ob)->revision;
-
419 }
executed: }
Execution Count:16652
16652
420 -
421 const int fragment = insert_block(pos, strPos, charFormat, blockFormat, op, QTextUndoCommand::BlockRemoved);
executed (the execution status of this line is deduced): const int fragment = insert_block(pos, strPos, charFormat, blockFormat, op, QTextUndoCommand::BlockRemoved);
-
422 -
423 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
424 -
425 int b = blocks.findNode(pos);
executed (the execution status of this line is deduced): int b = blocks.findNode(pos);
-
426 QTextBlockData *B = blocks.fragment(b);
executed (the execution status of this line is deduced): QTextBlockData *B = blocks.fragment(b);
-
427 -
428 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::BlockInserted, (editBlock != 0),
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::BlockInserted, (editBlock != 0), 0, 0, quint8(op), charFormat, quint32(strPos), quint32(pos), { int(blockFormat) }, quint32(B->revision) };
-
429 op, charFormat, strPos, pos, blockFormat, -
430 B->revision); -
431 -
432 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
433 Q_ASSERT(undoState == undoStack.size());
executed (the execution status of this line is deduced): qt_noop();
-
434 -
435 // update revision numbers of the modified blocks. -
436 B->revision = (atBlockEnd && !atBlockStart)? oldRevision : revision;
evaluated: atBlockEnd
TRUEFALSE
yes
Evaluation Count:17766
yes
Evaluation Count:2026
evaluated: !atBlockStart
TRUEFALSE
yes
Evaluation Count:2274
yes
Evaluation Count:15492
2026-17766
437 b = blocks.next(b);
executed (the execution status of this line is deduced): b = blocks.next(b);
-
438 if (b) {
evaluated: b
TRUEFALSE
yes
Evaluation Count:16652
yes
Evaluation Count:3140
3140-16652
439 B = blocks.fragment(b);
executed (the execution status of this line is deduced): B = blocks.fragment(b);
-
440 B->revision = atBlockStart ? oldRevision : revision;
evaluated: atBlockStart
TRUEFALSE
yes
Evaluation Count:12372
yes
Evaluation Count:4280
4280-12372
441 }
executed: }
Execution Count:16652
16652
442 -
443 if (formats.charFormat(charFormat).objectIndex() == -1)
evaluated: formats.charFormat(charFormat).objectIndex() == -1
TRUEFALSE
yes
Evaluation Count:18354
yes
Evaluation Count:1438
1438-18354
444 needsEnsureMaximumBlockCount = true;
executed: needsEnsureMaximumBlockCount = true;
Execution Count:18354
18354
445 -
446 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
447 return fragment;
executed: return fragment;
Execution Count:19792
19792
448} -
449 -
450int QTextDocumentPrivate::insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation op) -
451{ -
452 return insertBlock(QChar::ParagraphSeparator, pos, blockFormat, charFormat, op);
executed: return insertBlock(QChar::ParagraphSeparator, pos, blockFormat, charFormat, op);
Execution Count:18241
18241
453} -
454 -
455void QTextDocumentPrivate::insert(int pos, int strPos, int strLength, int format) -
456{ -
457 if (strLength <= 0)
partially evaluated: strLength <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6644
0-6644
458 return;
never executed: return;
0
459 -
460 Q_ASSERT(pos >= 0 && pos < fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
461 Q_ASSERT(formats.format(format).isCharFormat());
executed (the execution status of this line is deduced): qt_noop();
-
462 -
463 insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor);
executed (the execution status of this line is deduced): insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor);
-
464 if (undoEnabled) {
evaluated: undoEnabled
TRUEFALSE
yes
Evaluation Count:3247
yes
Evaluation Count:3397
3247-3397
465 int b = blocks.findNode(pos);
executed (the execution status of this line is deduced): int b = blocks.findNode(pos);
-
466 QTextBlockData *B = blocks.fragment(b);
executed (the execution status of this line is deduced): QTextBlockData *B = blocks.fragment(b);
-
467 -
468 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Inserted, (editBlock != 0),
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::Inserted, (editBlock != 0), 0, 0, quint8(QTextUndoCommand::MoveCursor), format, quint32(strPos), quint32(pos), { int(strLength) }, quint32(B->revision) };
-
469 QTextUndoCommand::MoveCursor, format, strPos, pos, strLength, -
470 B->revision); -
471 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
472 B->revision = revision;
executed (the execution status of this line is deduced): B->revision = revision;
-
473 Q_ASSERT(undoState == undoStack.size());
executed (the execution status of this line is deduced): qt_noop();
-
474 }
executed: }
Execution Count:3247
3247
475 finishEdit();
executed (the execution status of this line is deduced): finishEdit();
-
476}
executed: }
Execution Count:6644
6644
477 -
478void QTextDocumentPrivate::insert(int pos, const QString &str, int format) -
479{ -
480 if (str.size() == 0)
partially evaluated: str.size() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:822
0-822
481 return;
never executed: return;
0
482 -
483 Q_ASSERT(noBlockInString(str));
executed (the execution status of this line is deduced): qt_noop();
-
484 -
485 int strPos = text.length();
executed (the execution status of this line is deduced): int strPos = text.length();
-
486 text.append(str);
executed (the execution status of this line is deduced): text.append(str);
-
487 insert(pos, strPos, str.length(), format);
executed (the execution status of this line is deduced): insert(pos, strPos, str.length(), format);
-
488}
executed: }
Execution Count:822
822
489 -
490int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand::Operation op) -
491{ -
492 Q_ASSERT(pos >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
493 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
494 Q_ASSERT(blocks.length() >= pos+(int)length);
executed (the execution status of this line is deduced): qt_noop();
-
495 -
496 int b = blocks.findNode(pos);
executed (the execution status of this line is deduced): int b = blocks.findNode(pos);
-
497 uint x = fragments.findNode(pos);
executed (the execution status of this line is deduced): uint x = fragments.findNode(pos);
-
498 -
499 Q_ASSERT(blocks.size(b) > length);
executed (the execution status of this line is deduced): qt_noop();
-
500 Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length);
executed (the execution status of this line is deduced): qt_noop();
-
501 Q_ASSERT(noBlockInString(text.mid(fragments.fragment(x)->stringPosition, length)));
executed (the execution status of this line is deduced): qt_noop();
-
502 -
503 blocks.setSize(b, blocks.size(b)-length);
executed (the execution status of this line is deduced): blocks.setSize(b, blocks.size(b)-length);
-
504 -
505 QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format));
-
506 if (frame) {
partially evaluated: frame
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1146
0-1146
507 frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x);
never executed (the execution status of this line is deduced): frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x);
-
508 framesDirty = true;
never executed (the execution status of this line is deduced): framesDirty = true;
-
509 }
never executed: }
0
510 -
511 const int w = fragments.erase_single(x);
executed (the execution status of this line is deduced): const int w = fragments.erase_single(x);
-
512 -
513 if (!undoEnabled)
evaluated: !undoEnabled
TRUEFALSE
yes
Evaluation Count:1070
yes
Evaluation Count:76
76-1070
514 unreachableCharacterCount += length;
executed: unreachableCharacterCount += length;
Execution Count:1070
1070
515 -
516 adjustDocumentChangesAndCursors(pos, -int(length), op);
executed (the execution status of this line is deduced): adjustDocumentChangesAndCursors(pos, -int(length), op);
-
517 -
518 return w;
executed: return w;
Execution Count:1146
1146
519} -
520 -
521int QTextDocumentPrivate::remove_block(int pos, int *blockFormat, int command, QTextUndoCommand::Operation op) -
522{ -
523 Q_ASSERT(pos >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
524 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
525 Q_ASSERT(blocks.length() > pos);
executed (the execution status of this line is deduced): qt_noop();
-
526 -
527 int b = blocks.findNode(pos);
executed (the execution status of this line is deduced): int b = blocks.findNode(pos);
-
528 uint x = fragments.findNode(pos);
executed (the execution status of this line is deduced): uint x = fragments.findNode(pos);
-
529 -
530 Q_ASSERT(x && (int)fragments.position(x) == pos);
executed (the execution status of this line is deduced): qt_noop();
-
531 Q_ASSERT(fragments.size(x) == 1);
executed (the execution status of this line is deduced): qt_noop();
-
532 Q_ASSERT(isValidBlockSeparator(text.at(fragments.fragment(x)->stringPosition)));
executed (the execution status of this line is deduced): qt_noop();
-
533 Q_ASSERT(b);
executed (the execution status of this line is deduced): qt_noop();
-
534 -
535 if (blocks.size(b) == 1 && command == QTextUndoCommand::BlockAdded) {
evaluated: blocks.size(b) == 1
TRUEFALSE
yes
Evaluation Count:1212
yes
Evaluation Count:47
evaluated: command == QTextUndoCommand::BlockAdded
TRUEFALSE
yes
Evaluation Count:1200
yes
Evaluation Count:12
12-1212
536 Q_ASSERT((int)blocks.position(b) == pos);
executed (the execution status of this line is deduced): qt_noop();
-
537 // qDebug("removing empty block"); -
538 // empty block remove the block itself -
539 } else {
executed: }
Execution Count:1200
1200
540 // non empty block, merge with next one into this block -
541 // qDebug("merging block with next"); -
542 int n = blocks.next(b);
executed (the execution status of this line is deduced): int n = blocks.next(b);
-
543 Q_ASSERT((int)blocks.position(n) == pos + 1);
executed (the execution status of this line is deduced): qt_noop();
-
544 blocks.setSize(b, blocks.size(b) + blocks.size(n) - 1);
executed (the execution status of this line is deduced): blocks.setSize(b, blocks.size(b) + blocks.size(n) - 1);
-
545 blocks.fragment(b)->userState = blocks.fragment(n)->userState;
executed (the execution status of this line is deduced): blocks.fragment(b)->userState = blocks.fragment(n)->userState;
-
546 b = n;
executed (the execution status of this line is deduced): b = n;
-
547 }
executed: }
Execution Count:59
59
548 *blockFormat = blocks.fragment(b)->format;
executed (the execution status of this line is deduced): *blockFormat = blocks.fragment(b)->format;
-
549 -
550 QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blocks.fragment(b)->format));
executed (the execution status of this line is deduced): QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blocks.fragment(b)->format));
-
551 if (group)
evaluated: group
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1256
3-1256
552 group->blockRemoved(QTextBlock(this, b));
executed: group->blockRemoved(QTextBlock(this, b));
Execution Count:3
3
553 -
554 QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(fragments.fragment(x)->format));
-
555 if (frame) {
evaluated: frame
TRUEFALSE
yes
Evaluation Count:229
yes
Evaluation Count:1030
229-1030
556 frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x);
executed (the execution status of this line is deduced): frame->d_func()->fragmentRemoved(text.at(fragments.fragment(x)->stringPosition), x);
-
557 framesDirty = true;
executed (the execution status of this line is deduced): framesDirty = true;
-
558 }
executed: }
Execution Count:229
229
559 -
560 blocks.erase_single(b);
executed (the execution status of this line is deduced): blocks.erase_single(b);
-
561 const int w = fragments.erase_single(x);
executed (the execution status of this line is deduced): const int w = fragments.erase_single(x);
-
562 -
563 adjustDocumentChangesAndCursors(pos, -1, op);
executed (the execution status of this line is deduced): adjustDocumentChangesAndCursors(pos, -1, op);
-
564 -
565 return w;
executed: return w;
Execution Count:1259
1259
566} -
567 -
568#if !defined(QT_NO_DEBUG) -
569static bool isAncestorFrame(QTextFrame *possibleAncestor, QTextFrame *child) -
570{ -
571 while (child) { -
572 if (child == possibleAncestor) -
573 return true; -
574 child = child->parentFrame(); -
575 } -
576 return false; -
577} -
578#endif -
579 -
580void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::Operation op) -
581{ -
582 Q_ASSERT(to <= fragments.length() && to <= pos);
executed (the execution status of this line is deduced): qt_noop();
-
583 Q_ASSERT(pos >= 0 && pos+length <= fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
584 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
585 -
586 if (pos == to)
evaluated: pos == to
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1212
2-1212
587 return;
executed: return;
Execution Count:2
2
588 -
589 const bool needsInsert = to != -1;
executed (the execution status of this line is deduced): const bool needsInsert = to != -1;
-
590 -
591#if !defined(QT_NO_DEBUG) -
592 const bool startAndEndInSameFrame = (frameAt(pos) == frameAt(pos + length - 1)); -
593 -
594 const bool endIsEndOfChildFrame = (isAncestorFrame(frameAt(pos), frameAt(pos + length - 1)) -
595 && text.at(find(pos + length - 1)->stringPosition) == QTextEndOfFrame); -
596 -
597 const bool startIsStartOfFrameAndEndIsEndOfFrameWithCommonParent -
598 = (text.at(find(pos)->stringPosition) == QTextBeginningOfFrame -
599 && text.at(find(pos + length - 1)->stringPosition) == QTextEndOfFrame -
600 && frameAt(pos)->parentFrame() == frameAt(pos + length - 1)->parentFrame()); -
601 -
602 const bool isFirstTableCell = (qobject_cast<QTextTable *>(frameAt(pos + length - 1)) -
603 && frameAt(pos + length - 1)->parentFrame() == frameAt(pos)); -
604 -
605 Q_ASSERT(startAndEndInSameFrame || endIsEndOfChildFrame || startIsStartOfFrameAndEndIsEndOfFrameWithCommonParent || isFirstTableCell); -
606#endif -
607 -
608 split(pos);
executed (the execution status of this line is deduced): split(pos);
-
609 split(pos+length);
executed (the execution status of this line is deduced): split(pos+length);
-
610 -
611 uint dst = needsInsert ? fragments.findNode(to) : 0;
evaluated: needsInsert
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1209
3-1209
612 uint dstKey = needsInsert ? fragments.position(dst) : 0;
evaluated: needsInsert
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1209
3-1209
613 -
614 uint x = fragments.findNode(pos);
executed (the execution status of this line is deduced): uint x = fragments.findNode(pos);
-
615 uint end = fragments.findNode(pos+length);
executed (the execution status of this line is deduced): uint end = fragments.findNode(pos+length);
-
616 -
617 uint w = 0;
executed (the execution status of this line is deduced): uint w = 0;
-
618 while (x != end) {
evaluated: x != end
TRUEFALSE
yes
Evaluation Count:2378
yes
Evaluation Count:1212
1212-2378
619 uint n = fragments.next(x);
executed (the execution status of this line is deduced): uint n = fragments.next(x);
-
620 -
621 uint key = fragments.position(x);
executed (the execution status of this line is deduced): uint key = fragments.position(x);
-
622 uint b = blocks.findNode(key+1);
executed (the execution status of this line is deduced): uint b = blocks.findNode(key+1);
-
623 QTextBlockData *B = blocks.fragment(b);
executed (the execution status of this line is deduced): QTextBlockData *B = blocks.fragment(b);
-
624 int blockRevision = B->revision;
executed (the execution status of this line is deduced): int blockRevision = B->revision;
-
625 -
626 QTextFragmentData *X = fragments.fragment(x);
executed (the execution status of this line is deduced): QTextFragmentData *X = fragments.fragment(x);
-
627 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::Removed, (editBlock != 0),
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::Removed, (editBlock != 0), 0, 0, quint8(op), X->format, quint32(X->stringPosition), quint32(key), { int(X->size_array[0]) }, quint32(blockRevision) };
-
628 op, X->format, X->stringPosition, key, X->size_array[0], -
629 blockRevision); -
630 QT_INIT_TEXTUNDOCOMMAND(cInsert, QTextUndoCommand::Inserted, (editBlock != 0),
executed (the execution status of this line is deduced): QTextUndoCommand cInsert = { QTextUndoCommand::Inserted, (editBlock != 0), 0, 0, quint8(op), X->format, quint32(X->stringPosition), quint32(dstKey), { int(X->size_array[0]) }, quint32(blockRevision) };
-
631 op, X->format, X->stringPosition, dstKey, X->size_array[0], -
632 blockRevision); -
633 -
634 if (key+1 != blocks.position(b)) {
evaluated: key+1 != blocks.position(b)
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1232
1146-1232
635// qDebug("remove_string from %d length %d", key, X->size_array[0]); -
636 Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0])));
executed (the execution status of this line is deduced): qt_noop();
-
637 w = remove_string(key, X->size_array[0], op);
executed (the execution status of this line is deduced): w = remove_string(key, X->size_array[0], op);
-
638 -
639 if (needsInsert) {
evaluated: needsInsert
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1143
3-1143
640 insert_string(dstKey, X->stringPosition, X->size_array[0], X->format, op);
executed (the execution status of this line is deduced): insert_string(dstKey, X->stringPosition, X->size_array[0], X->format, op);
-
641 dstKey += X->size_array[0];
executed (the execution status of this line is deduced): dstKey += X->size_array[0];
-
642 }
executed: }
Execution Count:3
3
643 } else {
executed: }
Execution Count:1146
1146
644// qDebug("remove_block at %d", key); -
645 Q_ASSERT(X->size_array[0] == 1 && isValidBlockSeparator(text.at(X->stringPosition)));
executed (the execution status of this line is deduced): qt_noop();
-
646 b = blocks.previous(b);
executed (the execution status of this line is deduced): b = blocks.previous(b);
-
647 B = 0;
executed (the execution status of this line is deduced): B = 0;
-
648 c.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockDeleted : QTextUndoCommand::BlockRemoved;
evaluated: blocks.size(b) == 1
TRUEFALSE
yes
Evaluation Count:1200
yes
Evaluation Count:32
32-1200
649 w = remove_block(key, &c.blockFormat, QTextUndoCommand::BlockAdded, op);
executed (the execution status of this line is deduced): w = remove_block(key, &c.blockFormat, QTextUndoCommand::BlockAdded, op);
-
650 -
651 if (needsInsert) {
evaluated: needsInsert
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1227
5-1227
652 insert_block(dstKey++, X->stringPosition, X->format, c.blockFormat, op, QTextUndoCommand::BlockRemoved);
executed (the execution status of this line is deduced): insert_block(dstKey++, X->stringPosition, X->format, c.blockFormat, op, QTextUndoCommand::BlockRemoved);
-
653 cInsert.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockAdded : QTextUndoCommand::BlockInserted;
partially evaluated: blocks.size(b) == 1
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
654 cInsert.blockFormat = c.blockFormat;
executed (the execution status of this line is deduced): cInsert.blockFormat = c.blockFormat;
-
655 }
executed: }
Execution Count:5
5
656 }
executed: }
Execution Count:1232
1232
657 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
658 if (B)
evaluated: B
TRUEFALSE
yes
Evaluation Count:1146
yes
Evaluation Count:1232
1146-1232
659 B->revision = revision;
executed: B->revision = revision;
Execution Count:1146
1146
660 x = n;
executed (the execution status of this line is deduced): x = n;
-
661 -
662 if (needsInsert)
evaluated: needsInsert
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2370
8-2370
663 appendUndoItem(cInsert);
executed: appendUndoItem(cInsert);
Execution Count:8
8
664 }
executed: }
Execution Count:2378
2378
665 if (w)
evaluated: w
TRUEFALSE
yes
Evaluation Count:259
yes
Evaluation Count:953
259-953
666 unite(w);
executed: unite(w);
Execution Count:259
259
667 -
668 Q_ASSERT(blocks.length() == fragments.length());
executed (the execution status of this line is deduced): qt_noop();
-
669 -
670 if (!blockCursorAdjustment)
evaluated: !blockCursorAdjustment
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1209
3-1209
671 finishEdit();
executed: finishEdit();
Execution Count:3
3
672}
executed: }
Execution Count:1212
1212
673 -
674void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op) -
675{ -
676 if (length == 0)
evaluated: length == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1209
2-1209
677 return;
executed: return;
Execution Count:2
2
678 blockCursorAdjustment = true;
executed (the execution status of this line is deduced): blockCursorAdjustment = true;
-
679 move(pos, -1, length, op);
executed (the execution status of this line is deduced): move(pos, -1, length, op);
-
680 blockCursorAdjustment = false;
executed (the execution status of this line is deduced): blockCursorAdjustment = false;
-
681 foreach (QTextCursorPrivate *curs, cursors) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
682 if (curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved) {
evaluated: curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved
TRUEFALSE
yes
Evaluation Count:2036
yes
Evaluation Count:193
193-2036
683 curs->changed = true;
executed (the execution status of this line is deduced): curs->changed = true;
-
684 }
executed: }
Execution Count:2036
2036
685 }
executed: }
Execution Count:2229
2229
686 finishEdit();
executed (the execution status of this line is deduced): finishEdit();
-
687}
executed: }
Execution Count:1209
1209
688 -
689void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode) -
690{ -
691 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
692 -
693 Q_ASSERT(newFormat.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
694 -
695 int newFormatIdx = -1;
executed (the execution status of this line is deduced): int newFormatIdx = -1;
-
696 if (mode == SetFormatAndPreserveObjectIndices) {
evaluated: mode == SetFormatAndPreserveObjectIndices
TRUEFALSE
yes
Evaluation Count:1599
yes
Evaluation Count:643
643-1599
697 QTextCharFormat cleanFormat = newFormat;
executed (the execution status of this line is deduced): QTextCharFormat cleanFormat = newFormat;
-
698 cleanFormat.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): cleanFormat.clearProperty(QTextFormat::ObjectIndex);
-
699 newFormatIdx = formats.indexForFormat(cleanFormat);
executed (the execution status of this line is deduced): newFormatIdx = formats.indexForFormat(cleanFormat);
-
700 } else if (mode == SetFormat) {
executed: }
Execution Count:1599
evaluated: mode == SetFormat
TRUEFALSE
yes
Evaluation Count:593
yes
Evaluation Count:50
50-1599
701 newFormatIdx = formats.indexForFormat(newFormat);
executed (the execution status of this line is deduced): newFormatIdx = formats.indexForFormat(newFormat);
-
702 }
executed: }
Execution Count:593
593
703 -
704 if (pos == -1) {
evaluated: pos == -1
TRUEFALSE
yes
Evaluation Count:1766
yes
Evaluation Count:476
476-1766
705 if (mode == MergeFormat) {
evaluated: mode == MergeFormat
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1765
1-1765
706 QTextFormat format = formats.format(initialBlockCharFormatIndex);
executed (the execution status of this line is deduced): QTextFormat format = formats.format(initialBlockCharFormatIndex);
-
707 format.merge(newFormat);
executed (the execution status of this line is deduced): format.merge(newFormat);
-
708 initialBlockCharFormatIndex = formats.indexForFormat(format);
executed (the execution status of this line is deduced): initialBlockCharFormatIndex = formats.indexForFormat(format);
-
709 } else if (mode == SetFormatAndPreserveObjectIndices
executed: }
Execution Count:1
evaluated: mode == SetFormatAndPreserveObjectIndices
TRUEFALSE
yes
Evaluation Count:1245
yes
Evaluation Count:520
1-1245
710 && formats.format(initialBlockCharFormatIndex).objectIndex() != -1) {
partially evaluated: formats.format(initialBlockCharFormatIndex).objectIndex() != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1245
0-1245
711 QTextCharFormat f = newFormat;
never executed (the execution status of this line is deduced): QTextCharFormat f = newFormat;
-
712 f.setObjectIndex(formats.format(initialBlockCharFormatIndex).objectIndex());
never executed (the execution status of this line is deduced): f.setObjectIndex(formats.format(initialBlockCharFormatIndex).objectIndex());
-
713 initialBlockCharFormatIndex = formats.indexForFormat(f);
never executed (the execution status of this line is deduced): initialBlockCharFormatIndex = formats.indexForFormat(f);
-
714 } else {
never executed: }
0
715 initialBlockCharFormatIndex = newFormatIdx;
executed (the execution status of this line is deduced): initialBlockCharFormatIndex = newFormatIdx;
-
716 }
executed: }
Execution Count:1765
1765
717 -
718 ++pos;
executed (the execution status of this line is deduced): ++pos;
-
719 --length;
executed (the execution status of this line is deduced): --length;
-
720 }
executed: }
Execution Count:1766
1766
721 -
722 const int startPos = pos;
executed (the execution status of this line is deduced): const int startPos = pos;
-
723 const int endPos = pos + length;
executed (the execution status of this line is deduced): const int endPos = pos + length;
-
724 -
725 split(startPos);
executed (the execution status of this line is deduced): split(startPos);
-
726 split(endPos);
executed (the execution status of this line is deduced): split(endPos);
-
727 -
728 while (pos < endPos) {
evaluated: pos < endPos
TRUEFALSE
yes
Evaluation Count:2124
yes
Evaluation Count:2242
2124-2242
729 FragmentMap::Iterator it = fragments.find(pos);
executed (the execution status of this line is deduced): FragmentMap::Iterator it = fragments.find(pos);
-
730 Q_ASSERT(!it.atEnd());
executed (the execution status of this line is deduced): qt_noop();
-
731 -
732 QTextFragmentData *fragment = it.value();
executed (the execution status of this line is deduced): QTextFragmentData *fragment = it.value();
-
733 -
734 Q_ASSERT(formats.format(fragment->format).type() == QTextFormat::CharFormat);
executed (the execution status of this line is deduced): qt_noop();
-
735 -
736 int offset = pos - it.position();
executed (the execution status of this line is deduced): int offset = pos - it.position();
-
737 int length = qMin(endPos - pos, int(fragment->size_array[0] - offset));
executed (the execution status of this line is deduced): int length = qMin(endPos - pos, int(fragment->size_array[0] - offset));
-
738 int oldFormat = fragment->format;
executed (the execution status of this line is deduced): int oldFormat = fragment->format;
-
739 -
740 if (mode == MergeFormat) {
evaluated: mode == MergeFormat
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:2069
55-2069
741 QTextFormat format = formats.format(fragment->format);
executed (the execution status of this line is deduced): QTextFormat format = formats.format(fragment->format);
-
742 format.merge(newFormat);
executed (the execution status of this line is deduced): format.merge(newFormat);
-
743 fragment->format = formats.indexForFormat(format);
executed (the execution status of this line is deduced): fragment->format = formats.indexForFormat(format);
-
744 } else if (mode == SetFormatAndPreserveObjectIndices
executed: }
Execution Count:55
evaluated: mode == SetFormatAndPreserveObjectIndices
TRUEFALSE
yes
Evaluation Count:1996
yes
Evaluation Count:73
55-1996
745 && formats.format(oldFormat).objectIndex() != -1) {
evaluated: formats.format(oldFormat).objectIndex() != -1
TRUEFALSE
yes
Evaluation Count:188
yes
Evaluation Count:1808
188-1808
746 QTextCharFormat f = newFormat;
executed (the execution status of this line is deduced): QTextCharFormat f = newFormat;
-
747 f.setObjectIndex(formats.format(oldFormat).objectIndex());
executed (the execution status of this line is deduced): f.setObjectIndex(formats.format(oldFormat).objectIndex());
-
748 fragment->format = formats.indexForFormat(f);
executed (the execution status of this line is deduced): fragment->format = formats.indexForFormat(f);
-
749 } else {
executed: }
Execution Count:188
188
750 fragment->format = newFormatIdx;
executed (the execution status of this line is deduced): fragment->format = newFormatIdx;
-
751 }
executed: }
Execution Count:1881
1881
752 -
753 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::CharFormatChanged, true, QTextUndoCommand::MoveCursor, oldFormat,
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::CharFormatChanged, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormat, quint32(0), quint32(pos), { int(length) }, quint32(0) };
-
754 0, pos, length, 0); -
755 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
756 -
757 pos += length;
executed (the execution status of this line is deduced): pos += length;
-
758 Q_ASSERT(pos == (int)(it.position() + fragment->size_array[0]) || pos >= endPos);
executed (the execution status of this line is deduced): qt_noop();
-
759 }
executed: }
Execution Count:2124
2124
760 -
761 int n = fragments.findNode(startPos - 1);
executed (the execution status of this line is deduced): int n = fragments.findNode(startPos - 1);
-
762 if (n)
evaluated: n
TRUEFALSE
yes
Evaluation Count:173
yes
Evaluation Count:2069
173-2069
763 unite(n);
executed: unite(n);
Execution Count:173
173
764 -
765 n = fragments.findNode(endPos);
executed (the execution status of this line is deduced): n = fragments.findNode(endPos);
-
766 if (n)
partially evaluated: n
TRUEFALSE
yes
Evaluation Count:2242
no
Evaluation Count:0
0-2242
767 unite(n);
executed: unite(n);
Execution Count:2242
2242
768 -
769 QTextBlock blockIt = blocksFind(startPos);
executed (the execution status of this line is deduced): QTextBlock blockIt = blocksFind(startPos);
-
770 QTextBlock endIt = blocksFind(endPos);
executed (the execution status of this line is deduced): QTextBlock endIt = blocksFind(endPos);
-
771 if (endIt.isValid())
partially evaluated: endIt.isValid()
TRUEFALSE
yes
Evaluation Count:2242
no
Evaluation Count:0
0-2242
772 endIt = endIt.next();
executed: endIt = endIt.next();
Execution Count:2242
2242
773 for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next())
evaluated: blockIt.isValid()
TRUEFALSE
yes
Evaluation Count:4515
yes
Evaluation Count:1067
evaluated: blockIt != endIt
TRUEFALSE
yes
Evaluation Count:3340
yes
Evaluation Count:1175
1067-4515
774 QTextDocumentPrivate::block(blockIt)->invalidate();
executed: QTextDocumentPrivate::block(blockIt)->invalidate();
Execution Count:3340
3340
775 -
776 documentChange(startPos, length);
executed (the execution status of this line is deduced): documentChange(startPos, length);
-
777 -
778 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
779}
executed: }
Execution Count:2242
2242
780 -
781void QTextDocumentPrivate::setBlockFormat(const QTextBlock &from, const QTextBlock &to, -
782 const QTextBlockFormat &newFormat, FormatChangeMode mode) -
783{ -
784 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
785 -
786 Q_ASSERT(mode != SetFormatAndPreserveObjectIndices); // only implemented for setCharFormat
executed (the execution status of this line is deduced): qt_noop();
-
787 -
788 Q_ASSERT(newFormat.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
789 -
790 int newFormatIdx = -1;
executed (the execution status of this line is deduced): int newFormatIdx = -1;
-
791 if (mode == SetFormat)
evaluated: mode == SetFormat
TRUEFALSE
yes
Evaluation Count:1407
yes
Evaluation Count:131
131-1407
792 newFormatIdx = formats.indexForFormat(newFormat);
executed: newFormatIdx = formats.indexForFormat(newFormat);
Execution Count:1407
1407
793 QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(newFormat));
executed (the execution status of this line is deduced): QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(newFormat));
-
794 -
795 QTextBlock it = from;
executed (the execution status of this line is deduced): QTextBlock it = from;
-
796 QTextBlock end = to;
executed (the execution status of this line is deduced): QTextBlock end = to;
-
797 if (end.isValid())
partially evaluated: end.isValid()
TRUEFALSE
yes
Evaluation Count:1538
no
Evaluation Count:0
0-1538
798 end = end.next();
executed: end = end.next();
Execution Count:1538
1538
799 -
800 for (; it != end; it = it.next()) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:1541
yes
Evaluation Count:1538
1538-1541
801 int oldFormat = block(it)->format;
executed (the execution status of this line is deduced): int oldFormat = block(it)->format;
-
802 QTextBlockFormat format = formats.blockFormat(oldFormat);
executed (the execution status of this line is deduced): QTextBlockFormat format = formats.blockFormat(oldFormat);
-
803 QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(format));
executed (the execution status of this line is deduced): QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(format));
-
804 if (mode == MergeFormat) {
evaluated: mode == MergeFormat
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:1407
134-1407
805 format.merge(newFormat);
executed (the execution status of this line is deduced): format.merge(newFormat);
-
806 newFormatIdx = formats.indexForFormat(format);
executed (the execution status of this line is deduced): newFormatIdx = formats.indexForFormat(format);
-
807 group = qobject_cast<QTextBlockGroup *>(objectForFormat(format));
executed (the execution status of this line is deduced): group = qobject_cast<QTextBlockGroup *>(objectForFormat(format));
-
808 }
executed: }
Execution Count:134
134
809 block(it)->format = newFormatIdx;
executed (the execution status of this line is deduced): block(it)->format = newFormatIdx;
-
810 -
811 block(it)->invalidate();
executed (the execution status of this line is deduced): block(it)->invalidate();
-
812 -
813 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::BlockFormatChanged, true, QTextUndoCommand::MoveCursor, oldFormat,
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::BlockFormatChanged, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormat, quint32(0), quint32(it.position()), { int(1) }, quint32(0) };
-
814 0, it.position(), 1, 0); -
815 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
816 -
817 if (group != oldGroup) {
evaluated: group != oldGroup
TRUEFALSE
yes
Evaluation Count:119
yes
Evaluation Count:1422
119-1422
818 if (oldGroup)
evaluated: oldGroup
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:112
7-112
819 oldGroup->blockRemoved(it);
executed: oldGroup->blockRemoved(it);
Execution Count:7
7
820 if (group)
evaluated: group
TRUEFALSE
yes
Evaluation Count:115
yes
Evaluation Count:4
4-115
821 group->blockInserted(it);
executed: group->blockInserted(it);
Execution Count:115
115
822 } else if (group) {
executed: }
Execution Count:119
evaluated: group
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:1365
57-1365
823 group->blockFormatChanged(it);
executed (the execution status of this line is deduced): group->blockFormatChanged(it);
-
824 }
executed: }
Execution Count:57
57
825 } -
826 -
827 documentChange(from.position(), to.position() + to.length() - from.position());
executed (the execution status of this line is deduced): documentChange(from.position(), to.position() + to.length() - from.position());
-
828 -
829 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
830}
executed: }
Execution Count:1538
1538
831 -
832 -
833bool QTextDocumentPrivate::split(int pos) -
834{ -
835 uint x = fragments.findNode(pos);
executed (the execution status of this line is deduced): uint x = fragments.findNode(pos);
-
836 if (x) {
evaluated: x
TRUEFALSE
yes
Evaluation Count:30246
yes
Evaluation Count:3140
3140-30246
837 int k = fragments.position(x);
executed (the execution status of this line is deduced): int k = fragments.position(x);
-
838// qDebug("found fragment with key %d, size_left=%d, size=%d to split at %d", -
839// k, (*it)->size_left[0], (*it)->size_array[0], pos); -
840 if (k != pos) {
evaluated: k != pos
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:30145
101-30145
841 Q_ASSERT(k <= pos);
executed (the execution status of this line is deduced): qt_noop();
-
842 // need to resize the first fragment and add a new one -
843 QTextFragmentData *X = fragments.fragment(x);
executed (the execution status of this line is deduced): QTextFragmentData *X = fragments.fragment(x);
-
844 int oldsize = X->size_array[0];
executed (the execution status of this line is deduced): int oldsize = X->size_array[0];
-
845 fragments.setSize(x, pos-k);
executed (the execution status of this line is deduced): fragments.setSize(x, pos-k);
-
846 uint n = fragments.insert_single(pos, oldsize-(pos-k));
executed (the execution status of this line is deduced): uint n = fragments.insert_single(pos, oldsize-(pos-k));
-
847 X = fragments.fragment(x);
executed (the execution status of this line is deduced): X = fragments.fragment(x);
-
848 QTextFragmentData *N = fragments.fragment(n);
executed (the execution status of this line is deduced): QTextFragmentData *N = fragments.fragment(n);
-
849 N->stringPosition = X->stringPosition + pos-k;
executed (the execution status of this line is deduced): N->stringPosition = X->stringPosition + pos-k;
-
850 N->format = X->format;
executed (the execution status of this line is deduced): N->format = X->format;
-
851 return true;
executed: return true;
Execution Count:101
101
852 } -
853 }
executed: }
Execution Count:30145
30145
854 return false;
executed: return false;
Execution Count:33285
33285
855} -
856 -
857bool QTextDocumentPrivate::unite(uint f) -
858{ -
859 uint n = fragments.next(f);
executed (the execution status of this line is deduced): uint n = fragments.next(f);
-
860 if (!n)
evaluated: !n
TRUEFALSE
yes
Evaluation Count:1053
yes
Evaluation Count:6713
1053-6713
861 return false;
executed: return false;
Execution Count:1053
1053
862 -
863 QTextFragmentData *ff = fragments.fragment(f);
executed (the execution status of this line is deduced): QTextFragmentData *ff = fragments.fragment(f);
-
864 QTextFragmentData *nf = fragments.fragment(n);
executed (the execution status of this line is deduced): QTextFragmentData *nf = fragments.fragment(n);
-
865 -
866 if (nf->format == ff->format && (ff->stringPosition + (int)ff->size_array[0] == nf->stringPosition)) {
evaluated: nf->format == ff->format
TRUEFALSE
yes
Evaluation Count:5778
yes
Evaluation Count:935
evaluated: (ff->stringPosition + (int)ff->size_array[0] == nf->stringPosition)
TRUEFALSE
yes
Evaluation Count:2632
yes
Evaluation Count:3146
935-5778
867 if (isValidBlockSeparator(text.at(ff->stringPosition))
evaluated: isValidBlockSeparator(text.at(ff->stringPosition))
TRUEFALSE
yes
Evaluation Count:1415
yes
Evaluation Count:1217
1217-1415
868 || isValidBlockSeparator(text.at(nf->stringPosition)))
evaluated: isValidBlockSeparator(text.at(nf->stringPosition))
TRUEFALSE
yes
Evaluation Count:904
yes
Evaluation Count:313
313-904
869 return false;
executed: return false;
Execution Count:2319
2319
870 -
871 fragments.setSize(f, ff->size_array[0] + nf->size_array[0]);
executed (the execution status of this line is deduced): fragments.setSize(f, ff->size_array[0] + nf->size_array[0]);
-
872 fragments.erase_single(n);
executed (the execution status of this line is deduced): fragments.erase_single(n);
-
873 return true;
executed: return true;
Execution Count:313
313
874 } -
875 return false;
executed: return false;
Execution Count:4081
4081
876} -
877 -
878 -
879int QTextDocumentPrivate::undoRedo(bool undo) -
880{ -
881 PMDEBUG("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size());
never executed: QMessageLogger("text/qtextdocument_p.cpp", 881, __PRETTY_FUNCTION__).debug("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size());
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76
0-76
882 if (!undoEnabled || (undo && undoState == 0) || (!undo && undoState == undoStack.size()))
evaluated: !undoEnabled
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:71
evaluated: undo
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:14
partially evaluated: undoState == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:57
evaluated: !undo
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:57
partially evaluated: undoState == undoStack.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-71
883 return -1;
executed: return -1;
Execution Count:5
5
884 -
885 undoEnabled = false;
executed (the execution status of this line is deduced): undoEnabled = false;
-
886 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
887 int editPos = -1;
executed (the execution status of this line is deduced): int editPos = -1;
-
888 int editLength = -1;
executed (the execution status of this line is deduced): int editLength = -1;
-
889 while (1) {
partially evaluated: 1
TRUEFALSE
yes
Evaluation Count:131
no
Evaluation Count:0
0-131
890 if (undo)
evaluated: undo
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:31
31-100
891 --undoState;
executed: --undoState;
Execution Count:100
100
892 QTextUndoCommand &c = undoStack[undoState];
executed (the execution status of this line is deduced): QTextUndoCommand &c = undoStack[undoState];
-
893 int resetBlockRevision = c.pos;
executed (the execution status of this line is deduced): int resetBlockRevision = c.pos;
-
894 -
895 switch(c.command) { -
896 case QTextUndoCommand::Inserted: -
897 remove(c.pos, c.length, (QTextUndoCommand::Operation)c.operation);
executed (the execution status of this line is deduced): remove(c.pos, c.length, (QTextUndoCommand::Operation)c.operation);
-
898 PMDEBUG(" erase: from %d, length %d", c.pos, c.length);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 898, __PRETTY_FUNCTION__).debug(" erase: from %d, length %d", c.pos, c.length);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:58
0-58
899 c.command = QTextUndoCommand::Removed;
executed (the execution status of this line is deduced): c.command = QTextUndoCommand::Removed;
-
900 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
901 editLength = 0;
executed (the execution status of this line is deduced): editLength = 0;
-
902 break;
executed: break;
Execution Count:58
58
903 case QTextUndoCommand::Removed: -
904 PMDEBUG(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 904, __PRETTY_FUNCTION__).debug(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
905 insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation);
executed (the execution status of this line is deduced): insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation);
-
906 c.command = QTextUndoCommand::Inserted;
executed (the execution status of this line is deduced): c.command = QTextUndoCommand::Inserted;
-
907 if (editPos != (int)c.pos)
evaluated: editPos != (int)c.pos
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:4
4-17
908 editLength = 0;
executed: editLength = 0;
Execution Count:17
17
909 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
910 editLength += c.length;
executed (the execution status of this line is deduced): editLength += c.length;
-
911 break;
executed: break;
Execution Count:21
21
912 case QTextUndoCommand::BlockInserted: -
913 case QTextUndoCommand::BlockAdded: -
914 remove_block(c.pos, &c.blockFormat, c.command, (QTextUndoCommand::Operation)c.operation);
executed (the execution status of this line is deduced): remove_block(c.pos, &c.blockFormat, c.command, (QTextUndoCommand::Operation)c.operation);
-
915 PMDEBUG(" blockremove: from %d", c.pos);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 915, __PRETTY_FUNCTION__).debug(" blockremove: from %d", c.pos);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
916 if (c.command == QTextUndoCommand::BlockInserted)
partially evaluated: c.command == QTextUndoCommand::BlockInserted
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
917 c.command = QTextUndoCommand::BlockRemoved;
executed: c.command = QTextUndoCommand::BlockRemoved;
Execution Count:27
27
918 else -
919 c.command = QTextUndoCommand::BlockDeleted;
never executed: c.command = QTextUndoCommand::BlockDeleted;
0
920 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
921 editLength = 0;
executed (the execution status of this line is deduced): editLength = 0;
-
922 break;
executed: break;
Execution Count:27
27
923 case QTextUndoCommand::BlockRemoved: -
924 case QTextUndoCommand::BlockDeleted: -
925 PMDEBUG(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 925, __PRETTY_FUNCTION__).debug(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
926 insert_block(c.pos, c.strPos, c.format, c.blockFormat, (QTextUndoCommand::Operation)c.operation, c.command);
executed (the execution status of this line is deduced): insert_block(c.pos, c.strPos, c.format, c.blockFormat, (QTextUndoCommand::Operation)c.operation, c.command);
-
927 resetBlockRevision += 1;
executed (the execution status of this line is deduced): resetBlockRevision += 1;
-
928 if (c.command == QTextUndoCommand::BlockRemoved)
partially evaluated: c.command == QTextUndoCommand::BlockRemoved
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
929 c.command = QTextUndoCommand::BlockInserted;
executed: c.command = QTextUndoCommand::BlockInserted;
Execution Count:13
13
930 else -
931 c.command = QTextUndoCommand::BlockAdded;
never executed: c.command = QTextUndoCommand::BlockAdded;
0
932 if (editPos != (int)c.pos)
evaluated: editPos != (int)c.pos
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
933 editLength = 0;
executed: editLength = 0;
Execution Count:12
12
934 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
935 editLength += 1;
executed (the execution status of this line is deduced): editLength += 1;
-
936 break;
executed: break;
Execution Count:13
13
937 case QTextUndoCommand::CharFormatChanged: { -
938 resetBlockRevision = -1; // ## TODO
executed (the execution status of this line is deduced): resetBlockRevision = -1;
-
939 PMDEBUG(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 939, __PRETTY_FUNCTION__).debug(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
940 FragmentIterator it = find(c.pos);
executed (the execution status of this line is deduced): FragmentIterator it = find(c.pos);
-
941 Q_ASSERT(!it.atEnd());
executed (the execution status of this line is deduced): qt_noop();
-
942 -
943 int oldFormat = it.value()->format;
executed (the execution status of this line is deduced): int oldFormat = it.value()->format;
-
944 setCharFormat(c.pos, c.length, formats.charFormat(c.format));
executed (the execution status of this line is deduced): setCharFormat(c.pos, c.length, formats.charFormat(c.format));
-
945 c.format = oldFormat;
executed (the execution status of this line is deduced): c.format = oldFormat;
-
946 if (editPos != (int)c.pos)
partially evaluated: editPos != (int)c.pos
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
947 editLength = 0;
executed: editLength = 0;
Execution Count:6
6
948 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
949 editLength += c.length;
executed (the execution status of this line is deduced): editLength += c.length;
-
950 break;
executed: break;
Execution Count:6
6
951 } -
952 case QTextUndoCommand::BlockFormatChanged: { -
953 resetBlockRevision = -1; // ## TODO
never executed (the execution status of this line is deduced): resetBlockRevision = -1;
-
954 PMDEBUG(" blockformat: format %d pos %d", c.format, c.pos);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 954, __PRETTY_FUNCTION__).debug(" blockformat: format %d pos %d", c.format, c.pos);
never evaluated: 0
0
955 QTextBlock it = blocksFind(c.pos);
never executed (the execution status of this line is deduced): QTextBlock it = blocksFind(c.pos);
-
956 Q_ASSERT(it.isValid());
never executed (the execution status of this line is deduced): qt_noop();
-
957 -
958 int oldFormat = block(it)->format;
never executed (the execution status of this line is deduced): int oldFormat = block(it)->format;
-
959 block(it)->format = c.format;
never executed (the execution status of this line is deduced): block(it)->format = c.format;
-
960 QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(oldFormat)));
never executed (the execution status of this line is deduced): QTextBlockGroup *oldGroup = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(oldFormat)));
-
961 QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(c.format)));
never executed (the execution status of this line is deduced): QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(formats.blockFormat(c.format)));
-
962 c.format = oldFormat;
never executed (the execution status of this line is deduced): c.format = oldFormat;
-
963 if (group != oldGroup) {
never evaluated: group != oldGroup
0
964 if (oldGroup)
never evaluated: oldGroup
0
965 oldGroup->blockRemoved(it);
never executed: oldGroup->blockRemoved(it);
0
966 if (group)
never evaluated: group
0
967 group->blockInserted(it);
never executed: group->blockInserted(it);
0
968 } else if (group) {
never executed: }
never evaluated: group
0
969 group->blockFormatChanged(it);
never executed (the execution status of this line is deduced): group->blockFormatChanged(it);
-
970 }
never executed: }
0
971 documentChange(it.position(), it.length());
never executed (the execution status of this line is deduced): documentChange(it.position(), it.length());
-
972 editPos = -1;
never executed (the execution status of this line is deduced): editPos = -1;
-
973 break;
never executed: break;
0
974 } -
975 case QTextUndoCommand::GroupFormatChange: { -
976 resetBlockRevision = -1; // ## TODO
executed (the execution status of this line is deduced): resetBlockRevision = -1;
-
977 PMDEBUG(" group format change");
never executed: QMessageLogger("text/qtextdocument_p.cpp", 977, __PRETTY_FUNCTION__).debug(" group format change");
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
978 QTextObject *object = objectForIndex(c.objectIndex);
executed (the execution status of this line is deduced): QTextObject *object = objectForIndex(c.objectIndex);
-
979 int oldFormat = formats.objectFormatIndex(c.objectIndex);
executed (the execution status of this line is deduced): int oldFormat = formats.objectFormatIndex(c.objectIndex);
-
980 changeObjectFormat(object, c.format);
executed (the execution status of this line is deduced): changeObjectFormat(object, c.format);
-
981 c.format = oldFormat;
executed (the execution status of this line is deduced): c.format = oldFormat;
-
982 editPos = -1;
executed (the execution status of this line is deduced): editPos = -1;
-
983 break;
executed: break;
Execution Count:1
1
984 } -
985 case QTextUndoCommand::CursorMoved: -
986 editPos = c.pos;
executed (the execution status of this line is deduced): editPos = c.pos;
-
987 editLength = 0;
executed (the execution status of this line is deduced): editLength = 0;
-
988 break;
executed: break;
Execution Count:5
5
989 case QTextUndoCommand::Custom: -
990 resetBlockRevision = -1; // ## TODO
never executed (the execution status of this line is deduced): resetBlockRevision = -1;
-
991 if (undo)
never evaluated: undo
0
992 c.custom->undo();
never executed: c.custom->undo();
0
993 else -
994 c.custom->redo();
never executed: c.custom->redo();
0
995 editPos = -1;
never executed (the execution status of this line is deduced): editPos = -1;
-
996 break;
never executed: break;
0
997 default: -
998 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
999 }
never executed: }
0
1000 -
1001 if (resetBlockRevision >= 0) {
evaluated: resetBlockRevision >= 0
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:7
7-124
1002 int b = blocks.findNode(resetBlockRevision);
executed (the execution status of this line is deduced): int b = blocks.findNode(resetBlockRevision);
-
1003 QTextBlockData *B = blocks.fragment(b);
executed (the execution status of this line is deduced): QTextBlockData *B = blocks.fragment(b);
-
1004 B->revision = c.revision;
executed (the execution status of this line is deduced): B->revision = c.revision;
-
1005 }
executed: }
Execution Count:124
124
1006 -
1007 if (!undo)
evaluated: !undo
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:100
31-100
1008 ++undoState;
executed: ++undoState;
Execution Count:31
31
1009 -
1010 bool inBlock = (
executed (the execution status of this line is deduced): bool inBlock = (
-
1011 undoState > 0
evaluated: undoState > 0
TRUEFALSE
yes
Evaluation Count:114
yes
Evaluation Count:17
17-114
1012 && undoState < undoStack.size()
evaluated: undoState < undoStack.size()
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:10
10-104
1013 && undoStack[undoState].block_part
evaluated: undoStack[undoState].block_part
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:23
23-81
1014 && undoStack[undoState-1].block_part
evaluated: undoStack[undoState-1].block_part
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:11
11-70
1015 && !undoStack[undoState-1].block_end
evaluated: !undoStack[undoState-1].block_end
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:10
10-60
1016 );
executed (the execution status of this line is deduced): );
-
1017 if (!inBlock)
evaluated: !inBlock
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:60
60-71
1018 break;
executed: break;
Execution Count:71
71
1019 }
executed: }
Execution Count:60
60
1020 undoEnabled = true;
executed (the execution status of this line is deduced): undoEnabled = true;
-
1021 -
1022 int newCursorPos = -1;
executed (the execution status of this line is deduced): int newCursorPos = -1;
-
1023 -
1024 if (editPos >=0)
evaluated: editPos >=0
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:1
1-70
1025 newCursorPos = editPos + editLength;
executed: newCursorPos = editPos + editLength;
Execution Count:70
70
1026 else if (docChangeFrom >= 0)
partially evaluated: docChangeFrom >= 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1027 newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1);
executed: newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1);
Execution Count:1
1
1028 -
1029 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
1030 emitUndoAvailable(isUndoAvailable());
executed (the execution status of this line is deduced): emitUndoAvailable(isUndoAvailable());
-
1031 emitRedoAvailable(isRedoAvailable());
executed (the execution status of this line is deduced): emitRedoAvailable(isRedoAvailable());
-
1032 -
1033 return newCursorPos;
executed: return newCursorPos;
Execution Count:71
71
1034} -
1035 -
1036/*! -
1037 Appends a custom undo \a item to the undo stack. -
1038*/ -
1039void QTextDocumentPrivate::appendUndoItem(QAbstractUndoItem *item) -
1040{ -
1041 if (!undoEnabled) {
never evaluated: !undoEnabled
0
1042 delete item;
never executed (the execution status of this line is deduced): delete item;
-
1043 return;
never executed: return;
0
1044 } -
1045 -
1046 QTextUndoCommand c;
never executed (the execution status of this line is deduced): QTextUndoCommand c;
-
1047 c.command = QTextUndoCommand::Custom;
never executed (the execution status of this line is deduced): c.command = QTextUndoCommand::Custom;
-
1048 c.block_part = editBlock != 0;
never executed (the execution status of this line is deduced): c.block_part = editBlock != 0;
-
1049 c.block_end = 0;
never executed (the execution status of this line is deduced): c.block_end = 0;
-
1050 c.operation = QTextUndoCommand::MoveCursor;
never executed (the execution status of this line is deduced): c.operation = QTextUndoCommand::MoveCursor;
-
1051 c.format = 0;
never executed (the execution status of this line is deduced): c.format = 0;
-
1052 c.strPos = 0;
never executed (the execution status of this line is deduced): c.strPos = 0;
-
1053 c.pos = 0;
never executed (the execution status of this line is deduced): c.pos = 0;
-
1054 c.blockFormat = 0;
never executed (the execution status of this line is deduced): c.blockFormat = 0;
-
1055 -
1056 c.custom = item;
never executed (the execution status of this line is deduced): c.custom = item;
-
1057 appendUndoItem(c);
never executed (the execution status of this line is deduced): appendUndoItem(c);
-
1058}
never executed: }
0
1059 -
1060void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) -
1061{ -
1062 PMDEBUG("appendUndoItem, command=%d enabled=%d", c.command, undoEnabled);
never executed: QMessageLogger("text/qtextdocument_p.cpp", 1062, __PRETTY_FUNCTION__).debug("appendUndoItem, command=%d enabled=%d", c.command, undoEnabled);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29195
0-29195
1063 if (!undoEnabled)
evaluated: !undoEnabled
TRUEFALSE
yes
Evaluation Count:10758
yes
Evaluation Count:18437
10758-18437
1064 return;
executed: return;
Execution Count:10758
10758
1065 if (undoState < undoStack.size())
evaluated: undoState < undoStack.size()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:18417
20-18417
1066 clearUndoRedoStacks(QTextDocument::RedoStack);
executed: clearUndoRedoStacks(QTextDocument::RedoStack);
Execution Count:20
20
1067 -
1068 if (editBlock != 0 && editBlockCursorPosition >= 0) { // we had a beginEditBlock() with a cursor position
evaluated: editBlock != 0
TRUEFALSE
yes
Evaluation Count:17921
yes
Evaluation Count:516
evaluated: editBlockCursorPosition >= 0
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:17879
42-17921
1069 if (c.pos != (quint32) editBlockCursorPosition) { // and that cursor position is different from the command
evaluated: c.pos != (quint32) editBlockCursorPosition
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:22
20-22
1070 // generate a CursorMoved undo item -
1071 QT_INIT_TEXTUNDOCOMMAND(cc, QTextUndoCommand::CursorMoved, true, QTextUndoCommand::MoveCursor,
executed (the execution status of this line is deduced): QTextUndoCommand cc = { QTextUndoCommand::CursorMoved, true, 0, 0, quint8(QTextUndoCommand::MoveCursor), 0, quint32(0), quint32(editBlockCursorPosition), { int(0) }, quint32(0) };
-
1072 0, 0, editBlockCursorPosition, 0, 0); -
1073 undoStack.append(cc);
executed (the execution status of this line is deduced): undoStack.append(cc);
-
1074 undoState++;
executed (the execution status of this line is deduced): undoState++;
-
1075 editBlockCursorPosition = -1;
executed (the execution status of this line is deduced): editBlockCursorPosition = -1;
-
1076 }
executed: }
Execution Count:20
20
1077 }
executed: }
Execution Count:42
42
1078 -
1079 -
1080 if (!undoStack.isEmpty() && modified) {
evaluated: !undoStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:17558
yes
Evaluation Count:879
evaluated: modified
TRUEFALSE
yes
Evaluation Count:12069
yes
Evaluation Count:5489
879-17558
1081 QTextUndoCommand &last = undoStack[undoState - 1];
executed (the execution status of this line is deduced): QTextUndoCommand &last = undoStack[undoState - 1];
-
1082 -
1083 if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge
evaluated: last.block_part
TRUEFALSE
yes
Evaluation Count:11728
yes
Evaluation Count:341
evaluated: c.block_part
TRUEFALSE
yes
Evaluation Count:11603
yes
Evaluation Count:125
evaluated: !last.block_end
TRUEFALSE
yes
Evaluation Count:511
yes
Evaluation Count:11092
125-11728
1084 || (!c.block_part && !last.block_part)) { // two single undo items => can merge
evaluated: !c.block_part
TRUEFALSE
yes
Evaluation Count:350
yes
Evaluation Count:11208
evaluated: !last.block_part
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:125
125-11208
1085 -
1086 if (last.tryMerge(c))
evaluated: last.tryMerge(c)
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:658
78-658
1087 return;
executed: return;
Execution Count:78
78
1088 }
executed: }
Execution Count:658
658
1089 }
executed: }
Execution Count:11991
11991
1090 if (modifiedState > undoState)
evaluated: modifiedState > undoState
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18358
1-18358
1091 modifiedState = -1;
executed: modifiedState = -1;
Execution Count:1
1
1092 undoStack.append(c);
executed (the execution status of this line is deduced): undoStack.append(c);
-
1093 undoState++;
executed (the execution status of this line is deduced): undoState++;
-
1094 emitUndoAvailable(true);
executed (the execution status of this line is deduced): emitUndoAvailable(true);
-
1095 emitRedoAvailable(false);
executed (the execution status of this line is deduced): emitRedoAvailable(false);
-
1096 -
1097 if (!c.block_part)
evaluated: !c.block_part
TRUEFALSE
yes
Evaluation Count:439
yes
Evaluation Count:17920
439-17920
1098 emit document()->undoCommandAdded();
executed: document()->undoCommandAdded();
Execution Count:439
439
1099}
executed: }
Execution Count:18359
18359
1100 -
1101void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToClear, -
1102 bool emitSignals) -
1103{ -
1104 bool undoCommandsAvailable = undoState != 0;
executed (the execution status of this line is deduced): bool undoCommandsAvailable = undoState != 0;
-
1105 bool redoCommandsAvailable = undoState != undoStack.size();
executed (the execution status of this line is deduced): bool redoCommandsAvailable = undoState != undoStack.size();
-
1106 if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) {
partially evaluated: stacksToClear == QTextDocument::UndoStack
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5448
never evaluated: undoCommandsAvailable
0-5448
1107 for (int i = 0; i < undoState; ++i) {
never evaluated: i < undoState
0
1108 QTextUndoCommand c = undoStack[undoState];
never executed (the execution status of this line is deduced): QTextUndoCommand c = undoStack[undoState];
-
1109 if (c.command & QTextUndoCommand::Custom)
never evaluated: c.command & QTextUndoCommand::Custom
0
1110 delete c.custom;
never executed: delete c.custom;
0
1111 }
never executed: }
0
1112 undoStack.remove(0, undoState);
never executed (the execution status of this line is deduced): undoStack.remove(0, undoState);
-
1113 undoStack.resize(undoStack.size() - undoState);
never executed (the execution status of this line is deduced): undoStack.resize(undoStack.size() - undoState);
-
1114 undoState = 0;
never executed (the execution status of this line is deduced): undoState = 0;
-
1115 if (emitSignals)
never evaluated: emitSignals
0
1116 emitUndoAvailable(false);
never executed: emitUndoAvailable(false);
0
1117 } else if (stacksToClear == QTextDocument::RedoStack
never executed: }
evaluated: stacksToClear == QTextDocument::RedoStack
TRUEFALSE
yes
Evaluation Count:4249
yes
Evaluation Count:1199
0-4249
1118 && redoCommandsAvailable) {
evaluated: redoCommandsAvailable
TRUEFALSE
yes
Evaluation Count:847
yes
Evaluation Count:3402
847-3402
1119 for (int i = undoState; i < undoStack.size(); ++i) {
evaluated: i < undoStack.size()
TRUEFALSE
yes
Evaluation Count:18256
yes
Evaluation Count:847
847-18256
1120 QTextUndoCommand c = undoStack[i];
executed (the execution status of this line is deduced): QTextUndoCommand c = undoStack[i];
-
1121 if (c.command & QTextUndoCommand::Custom)
partially evaluated: c.command & QTextUndoCommand::Custom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18256
0-18256
1122 delete c.custom;
never executed: delete c.custom;
0
1123 }
executed: }
Execution Count:18256
18256
1124 undoStack.resize(undoState);
executed (the execution status of this line is deduced): undoStack.resize(undoState);
-
1125 if (emitSignals)
partially evaluated: emitSignals
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:847
0-847
1126 emitRedoAvailable(false);
never executed: emitRedoAvailable(false);
0
1127 } else if (stacksToClear == QTextDocument::UndoAndRedoStacks
executed: }
Execution Count:847
evaluated: stacksToClear == QTextDocument::UndoAndRedoStacks
TRUEFALSE
yes
Evaluation Count:1199
yes
Evaluation Count:3402
847-3402
1128 && !undoStack.isEmpty()) {
evaluated: !undoStack.isEmpty()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:1151
48-1151
1129 for (int i = 0; i < undoStack.size(); ++i) {
evaluated: i < undoStack.size()
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:48
48-122
1130 QTextUndoCommand c = undoStack[i];
executed (the execution status of this line is deduced): QTextUndoCommand c = undoStack[i];
-
1131 if (c.command & QTextUndoCommand::Custom)
partially evaluated: c.command & QTextUndoCommand::Custom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:122
0-122
1132 delete c.custom;
never executed: delete c.custom;
0
1133 }
executed: }
Execution Count:122
122
1134 undoState = 0;
executed (the execution status of this line is deduced): undoState = 0;
-
1135 undoStack.resize(0);
executed (the execution status of this line is deduced): undoStack.resize(0);
-
1136 if (emitSignals && undoCommandsAvailable)
partially evaluated: emitSignals
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
never evaluated: undoCommandsAvailable
0-48
1137 emitUndoAvailable(false);
never executed: emitUndoAvailable(false);
0
1138 if (emitSignals && redoCommandsAvailable)
partially evaluated: emitSignals
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
never evaluated: redoCommandsAvailable
0-48
1139 emitRedoAvailable(false);
never executed: emitRedoAvailable(false);
0
1140 }
executed: }
Execution Count:48
48
1141} -
1142 -
1143void QTextDocumentPrivate::emitUndoAvailable(bool available) -
1144{ -
1145 if (available != wasUndoAvailable) {
evaluated: available != wasUndoAvailable
TRUEFALSE
yes
Evaluation Count:866
yes
Evaluation Count:19856
866-19856
1146 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
1147 emit q->undoAvailable(available);
executed (the execution status of this line is deduced): q->undoAvailable(available);
-
1148 wasUndoAvailable = available;
executed (the execution status of this line is deduced): wasUndoAvailable = available;
-
1149 }
executed: }
Execution Count:866
866
1150}
executed: }
Execution Count:20722
20722
1151 -
1152void QTextDocumentPrivate::emitRedoAvailable(bool available) -
1153{ -
1154 if (available != wasRedoAvailable) {
evaluated: available != wasRedoAvailable
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:20646
76-20646
1155 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
1156 emit q->redoAvailable(available);
executed (the execution status of this line is deduced): q->redoAvailable(available);
-
1157 wasRedoAvailable = available;
executed (the execution status of this line is deduced): wasRedoAvailable = available;
-
1158 }
executed: }
Execution Count:76
76
1159}
executed: }
Execution Count:20722
20722
1160 -
1161void QTextDocumentPrivate::enableUndoRedo(bool enable) -
1162{ -
1163 if (enable && maximumBlockCount > 0)
evaluated: enable
TRUEFALSE
yes
Evaluation Count:1066
yes
Evaluation Count:2292
partially evaluated: maximumBlockCount > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1066
0-2292
1164 return;
never executed: return;
0
1165 -
1166 if (!enable) {
evaluated: !enable
TRUEFALSE
yes
Evaluation Count:2292
yes
Evaluation Count:1066
1066-2292
1167 undoState = 0;
executed (the execution status of this line is deduced): undoState = 0;
-
1168 clearUndoRedoStacks(QTextDocument::RedoStack);
executed (the execution status of this line is deduced): clearUndoRedoStacks(QTextDocument::RedoStack);
-
1169 emitUndoAvailable(false);
executed (the execution status of this line is deduced): emitUndoAvailable(false);
-
1170 emitRedoAvailable(false);
executed (the execution status of this line is deduced): emitRedoAvailable(false);
-
1171 }
executed: }
Execution Count:2292
2292
1172 modifiedState = modified ? -1 : undoState;
evaluated: modified
TRUEFALSE
yes
Evaluation Count:685
yes
Evaluation Count:2673
685-2673
1173 undoEnabled = enable;
executed (the execution status of this line is deduced): undoEnabled = enable;
-
1174 if (!undoEnabled)
evaluated: !undoEnabled
TRUEFALSE
yes
Evaluation Count:2292
yes
Evaluation Count:1066
1066-2292
1175 compressPieceTable();
executed: compressPieceTable();
Execution Count:2292
2292
1176}
executed: }
Execution Count:3358
3358
1177 -
1178void QTextDocumentPrivate::joinPreviousEditBlock() -
1179{ -
1180 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
1181 -
1182 if (undoEnabled && undoState)
partially evaluated: undoEnabled
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: undoState
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1183 undoStack[undoState - 1].block_end = false;
executed: undoStack[undoState - 1].block_end = false;
Execution Count:1
1
1184}
executed: }
Execution Count:1
1
1185 -
1186void QTextDocumentPrivate::endEditBlock() -
1187{ -
1188 Q_ASSERT(editBlock > 0);
executed (the execution status of this line is deduced): qt_noop();
-
1189 if (--editBlock)
evaluated: --editBlock
TRUEFALSE
yes
Evaluation Count:24284
yes
Evaluation Count:17724
17724-24284
1190 return;
executed: return;
Execution Count:24284
24284
1191 -
1192 if (undoEnabled && undoState > 0) {
evaluated: undoEnabled
TRUEFALSE
yes
Evaluation Count:12021
yes
Evaluation Count:5703
evaluated: undoState > 0
TRUEFALSE
yes
Evaluation Count:11996
yes
Evaluation Count:25
25-12021
1193 const bool wasBlocking = !undoStack[undoState - 1].block_end;
executed (the execution status of this line is deduced): const bool wasBlocking = !undoStack[undoState - 1].block_end;
-
1194 if (undoStack[undoState - 1].block_part) {
evaluated: undoStack[undoState - 1].block_part
TRUEFALSE
yes
Evaluation Count:11959
yes
Evaluation Count:37
37-11959
1195 undoStack[undoState - 1].block_end = true;
executed (the execution status of this line is deduced): undoStack[undoState - 1].block_end = true;
-
1196 if (wasBlocking)
evaluated: wasBlocking
TRUEFALSE
yes
Evaluation Count:11935
yes
Evaluation Count:24
24-11935
1197 emit document()->undoCommandAdded();
executed: document()->undoCommandAdded();
Execution Count:11935
11935
1198 }
executed: }
Execution Count:11959
11959
1199 }
executed: }
Execution Count:11996
11996
1200 -
1201 editBlockCursorPosition = -1;
executed (the execution status of this line is deduced): editBlockCursorPosition = -1;
-
1202 -
1203 finishEdit();
executed (the execution status of this line is deduced): finishEdit();
-
1204}
executed: }
Execution Count:17724
17724
1205 -
1206void QTextDocumentPrivate::finishEdit() -
1207{ -
1208 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
1209 -
1210 if (editBlock)
evaluated: editBlock
TRUEFALSE
yes
Evaluation Count:7262
yes
Evaluation Count:19281
7262-19281
1211 return;
executed: return;
Execution Count:7262
7262
1212 -
1213 if (framesDirty)
evaluated: framesDirty
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:18900
381-18900
1214 scan_frames(docChangeFrom, docChangeOldLength, docChangeLength);
executed: scan_frames(docChangeFrom, docChangeOldLength, docChangeLength);
Execution Count:381
381
1215 -
1216 if (lout && docChangeFrom >= 0) {
evaluated: lout
TRUEFALSE
yes
Evaluation Count:11840
yes
Evaluation Count:7441
evaluated: docChangeFrom >= 0
TRUEFALSE
yes
Evaluation Count:11826
yes
Evaluation Count:14
14-11840
1217 if (!inContentsChange) {
evaluated: !inContentsChange
TRUEFALSE
yes
Evaluation Count:11825
yes
Evaluation Count:1
1-11825
1218 inContentsChange = true;
executed (the execution status of this line is deduced): inContentsChange = true;
-
1219 emit q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength);
executed (the execution status of this line is deduced): q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength);
-
1220 inContentsChange = false;
executed (the execution status of this line is deduced): inContentsChange = false;
-
1221 }
executed: }
Execution Count:11825
11825
1222 lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength);
executed (the execution status of this line is deduced): lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength);
-
1223 }
executed: }
Execution Count:11826
11826
1224 -
1225 docChangeFrom = -1;
executed (the execution status of this line is deduced): docChangeFrom = -1;
-
1226 -
1227 if (needsEnsureMaximumBlockCount) {
evaluated: needsEnsureMaximumBlockCount
TRUEFALSE
yes
Evaluation Count:15365
yes
Evaluation Count:3916
3916-15365
1228 needsEnsureMaximumBlockCount = false;
executed (the execution status of this line is deduced): needsEnsureMaximumBlockCount = false;
-
1229 if (ensureMaximumBlockCount()) {
evaluated: ensureMaximumBlockCount()
TRUEFALSE
yes
Evaluation Count:906
yes
Evaluation Count:14459
906-14459
1230 // if ensureMaximumBlockCount() returns true -
1231 // it will have called endEditBlock() and -
1232 // compressPieceTable() itself, so we return here -
1233 // to prevent getting two contentsChanged emits -
1234 return;
executed: return;
Execution Count:906
906
1235 } -
1236 }
executed: }
Execution Count:14459
14459
1237 -
1238 QList<QTextCursor> changedCursors;
executed (the execution status of this line is deduced): QList<QTextCursor> changedCursors;
-
1239 foreach (QTextCursorPrivate *curs, cursors) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1240 if (curs->changed) {
evaluated: curs->changed
TRUEFALSE
yes
Evaluation Count:16784
yes
Evaluation Count:481
481-16784
1241 curs->changed = false;
executed (the execution status of this line is deduced): curs->changed = false;
-
1242 changedCursors.append(QTextCursor(curs));
executed (the execution status of this line is deduced): changedCursors.append(QTextCursor(curs));
-
1243 }
executed: }
Execution Count:16784
16784
1244 }
executed: }
Execution Count:17265
17265
1245 foreach (const QTextCursor &cursor, changedCursors)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(changedCursors)> _container_(changedCursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QTextCursor &cursor = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
1246 emit q->cursorPositionChanged(cursor);
executed: q->cursorPositionChanged(cursor);
Execution Count:16784
16784
1247 -
1248 contentsChanged();
executed (the execution status of this line is deduced): contentsChanged();
-
1249 -
1250 if (blocks.numNodes() != lastBlockCount) {
evaluated: blocks.numNodes() != lastBlockCount
TRUEFALSE
yes
Evaluation Count:13702
yes
Evaluation Count:4673
4673-13702
1251 lastBlockCount = blocks.numNodes();
executed (the execution status of this line is deduced): lastBlockCount = blocks.numNodes();
-
1252 emit q->blockCountChanged(lastBlockCount);
executed (the execution status of this line is deduced): q->blockCountChanged(lastBlockCount);
-
1253 }
executed: }
Execution Count:13702
13702
1254 -
1255 if (!undoEnabled && unreachableCharacterCount)
evaluated: !undoEnabled
TRUEFALSE
yes
Evaluation Count:5818
yes
Evaluation Count:12557
evaluated: unreachableCharacterCount
TRUEFALSE
yes
Evaluation Count:2036
yes
Evaluation Count:3782
2036-12557
1256 compressPieceTable();
executed: compressPieceTable();
Execution Count:2036
2036
1257}
executed: }
Execution Count:18375
18375
1258 -
1259void QTextDocumentPrivate::documentChange(int from, int length) -
1260{ -
1261// qDebug("QTextDocumentPrivate::documentChange: from=%d,length=%d", from, length); -
1262 if (docChangeFrom < 0) {
evaluated: docChangeFrom < 0
TRUEFALSE
yes
Evaluation Count:11989
yes
Evaluation Count:25262565
11989-25262565
1263 docChangeFrom = from;
executed (the execution status of this line is deduced): docChangeFrom = from;
-
1264 docChangeOldLength = length;
executed (the execution status of this line is deduced): docChangeOldLength = length;
-
1265 docChangeLength = length;
executed (the execution status of this line is deduced): docChangeLength = length;
-
1266 return;
executed: return;
Execution Count:11989
11989
1267 } -
1268 int start = qMin(from, docChangeFrom);
executed (the execution status of this line is deduced): int start = qMin(from, docChangeFrom);
-
1269 int end = qMax(from + length, docChangeFrom + docChangeLength);
executed (the execution status of this line is deduced): int end = qMax(from + length, docChangeFrom + docChangeLength);
-
1270 int diff = qMax(0, end - start - docChangeLength);
executed (the execution status of this line is deduced): int diff = qMax(0, end - start - docChangeLength);
-
1271 docChangeFrom = start;
executed (the execution status of this line is deduced): docChangeFrom = start;
-
1272 docChangeOldLength += diff;
executed (the execution status of this line is deduced): docChangeOldLength += diff;
-
1273 docChangeLength += diff;
executed (the execution status of this line is deduced): docChangeLength += diff;
-
1274}
executed: }
Execution Count:25262565
25262565
1275 -
1276/* -
1277 adjustDocumentChangesAndCursors is called whenever there is an insert or remove of characters. -
1278 param from is the cursor position in the document -
1279 param addedOrRemoved is the amount of characters added or removed. A negative number means characters are removed. -
1280 -
1281 The function stores information to be emitted when finishEdit() is called. -
1282*/ -
1283void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op) -
1284{ -
1285 if (!editBlock)
evaluated: !editBlock
TRUEFALSE
yes
Evaluation Count:1537
yes
Evaluation Count:27346
1537-27346
1286 ++revision;
executed: ++revision;
Execution Count:1537
1537
1287 -
1288 if (blockCursorAdjustment) {
evaluated: blockCursorAdjustment
TRUEFALSE
yes
Evaluation Count:2370
yes
Evaluation Count:26513
2370-26513
1289 ; // postpone, will be called again from QTextDocumentPrivate::remove() -
1290 } else {
executed: }
Execution Count:2370
2370
1291 foreach (QTextCursorPrivate *curs, cursors) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1292 if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
evaluated: curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved
TRUEFALSE
yes
Evaluation Count:30357
yes
Evaluation Count:255
255-30357
1293 curs->changed = true;
executed (the execution status of this line is deduced): curs->changed = true;
-
1294 }
executed: }
Execution Count:30357
30357
1295 }
executed: }
Execution Count:30612
30612
1296 }
executed: }
Execution Count:26513
26513
1297 -
1298// qDebug("QTextDocumentPrivate::adjustDocumentChanges: from=%d,addedOrRemoved=%d", from, addedOrRemoved); -
1299 if (docChangeFrom < 0) {
evaluated: docChangeFrom < 0
TRUEFALSE
yes
Evaluation Count:7265
yes
Evaluation Count:21618
7265-21618
1300 docChangeFrom = from;
executed (the execution status of this line is deduced): docChangeFrom = from;
-
1301 if (addedOrRemoved > 0) {
evaluated: addedOrRemoved > 0
TRUEFALSE
yes
Evaluation Count:6187
yes
Evaluation Count:1078
1078-6187
1302 docChangeOldLength = 0;
executed (the execution status of this line is deduced): docChangeOldLength = 0;
-
1303 docChangeLength = addedOrRemoved;
executed (the execution status of this line is deduced): docChangeLength = addedOrRemoved;
-
1304 } else {
executed: }
Execution Count:6187
6187
1305 docChangeOldLength = -addedOrRemoved;
executed (the execution status of this line is deduced): docChangeOldLength = -addedOrRemoved;
-
1306 docChangeLength = 0;
executed (the execution status of this line is deduced): docChangeLength = 0;
-
1307 }
executed: }
Execution Count:1078
1078
1308// qDebug("adjustDocumentChanges:"); -
1309// qDebug(" -> %d %d %d", docChangeFrom, docChangeOldLength, docChangeLength); -
1310 return;
executed: return;
Execution Count:7265
7265
1311 } -
1312 -
1313 // have to merge the new change with the already existing one. -
1314 int added = qMax(0, addedOrRemoved);
executed (the execution status of this line is deduced): int added = qMax(0, addedOrRemoved);
-
1315 int removed = qMax(0, -addedOrRemoved);
executed (the execution status of this line is deduced): int removed = qMax(0, -addedOrRemoved);
-
1316 -
1317 int diff = 0;
executed (the execution status of this line is deduced): int diff = 0;
-
1318 if(from + removed < docChangeFrom)
evaluated: from + removed < docChangeFrom
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:21591
27-21591
1319 diff = docChangeFrom - from - removed;
executed: diff = docChangeFrom - from - removed;
Execution Count:27
27
1320 else if(from > docChangeFrom + docChangeLength)
evaluated: from > docChangeFrom + docChangeLength
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:21512
79-21512
1321 diff = from - (docChangeFrom + docChangeLength);
executed: diff = from - (docChangeFrom + docChangeLength);
Execution Count:79
79
1322 -
1323 int overlap_start = qMax(from, docChangeFrom);
executed (the execution status of this line is deduced): int overlap_start = qMax(from, docChangeFrom);
-
1324 int overlap_end = qMin(from + removed, docChangeFrom + docChangeLength);
executed (the execution status of this line is deduced): int overlap_end = qMin(from + removed, docChangeFrom + docChangeLength);
-
1325 int removedInside = qMax(0, overlap_end - overlap_start);
executed (the execution status of this line is deduced): int removedInside = qMax(0, overlap_end - overlap_start);
-
1326 removed -= removedInside;
executed (the execution status of this line is deduced): removed -= removedInside;
-
1327 -
1328// qDebug("adjustDocumentChanges: from=%d, addedOrRemoved=%d, diff=%d, removedInside=%d", from, addedOrRemoved, diff, removedInside); -
1329 docChangeFrom = qMin(docChangeFrom, from);
executed (the execution status of this line is deduced): docChangeFrom = qMin(docChangeFrom, from);
-
1330 docChangeOldLength += removed + diff;
executed (the execution status of this line is deduced): docChangeOldLength += removed + diff;
-
1331 docChangeLength += added - removedInside + diff;
executed (the execution status of this line is deduced): docChangeLength += added - removedInside + diff;
-
1332// qDebug(" -> %d %d %d", docChangeFrom, docChangeOldLength, docChangeLength); -
1333 -
1334}
executed: }
Execution Count:21618
21618
1335 -
1336 -
1337QString QTextDocumentPrivate::plainText() const -
1338{ -
1339 QString result;
executed (the execution status of this line is deduced): QString result;
-
1340 result.resize(length());
executed (the execution status of this line is deduced): result.resize(length());
-
1341 const QChar *text_unicode = text.unicode();
executed (the execution status of this line is deduced): const QChar *text_unicode = text.unicode();
-
1342 QChar *data = result.data();
executed (the execution status of this line is deduced): QChar *data = result.data();
-
1343 for (QTextDocumentPrivate::FragmentIterator it = begin(); it != end(); ++it) {
evaluated: it != end()
TRUEFALSE
yes
Evaluation Count:636
yes
Evaluation Count:210
210-636
1344 const QTextFragmentData *f = *it;
executed (the execution status of this line is deduced): const QTextFragmentData *f = *it;
-
1345 ::memcpy(data, text_unicode + f->stringPosition, f->size_array[0] * sizeof(QChar));
executed (the execution status of this line is deduced): ::memcpy(data, text_unicode + f->stringPosition, f->size_array[0] * sizeof(QChar));
-
1346 data += f->size_array[0];
executed (the execution status of this line is deduced): data += f->size_array[0];
-
1347 }
executed: }
Execution Count:636
636
1348 // remove trailing block separator -
1349 result.chop(1);
executed (the execution status of this line is deduced): result.chop(1);
-
1350 return result;
executed: return result;
Execution Count:210
210
1351} -
1352 -
1353int QTextDocumentPrivate::blockCharFormatIndex(int node) const -
1354{ -
1355 int pos = blocks.position(node);
executed (the execution status of this line is deduced): int pos = blocks.position(node);
-
1356 if (pos == 0)
evaluated: pos == 0
TRUEFALSE
yes
Evaluation Count:6132
yes
Evaluation Count:2076
2076-6132
1357 return initialBlockCharFormatIndex;
executed: return initialBlockCharFormatIndex;
Execution Count:6132
6132
1358 -
1359 return fragments.find(pos - 1)->format;
executed: return fragments.find(pos - 1)->format;
Execution Count:2076
2076
1360} -
1361 -
1362int QTextDocumentPrivate::nextCursorPosition(int position, QTextLayout::CursorMode mode) const -
1363{ -
1364 if (position == length()-1)
evaluated: position == length()-1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:139
5-139
1365 return position;
executed: return position;
Execution Count:5
5
1366 -
1367 QTextBlock it = blocksFind(position);
executed (the execution status of this line is deduced): QTextBlock it = blocksFind(position);
-
1368 int start = it.position();
executed (the execution status of this line is deduced): int start = it.position();
-
1369 int end = start + it.length() - 1;
executed (the execution status of this line is deduced): int end = start + it.length() - 1;
-
1370 if (position == end)
evaluated: position == end
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:132
7-132
1371 return end + 1;
executed: return end + 1;
Execution Count:7
7
1372 -
1373 return it.layout()->nextCursorPosition(position-start, mode) + start;
executed: return it.layout()->nextCursorPosition(position-start, mode) + start;
Execution Count:132
132
1374} -
1375 -
1376int QTextDocumentPrivate::previousCursorPosition(int position, QTextLayout::CursorMode mode) const -
1377{ -
1378 if (position == 0)
evaluated: position == 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:107
4-107
1379 return position;
executed: return position;
Execution Count:4
4
1380 -
1381 QTextBlock it = blocksFind(position);
executed (the execution status of this line is deduced): QTextBlock it = blocksFind(position);
-
1382 int start = it.position();
executed (the execution status of this line is deduced): int start = it.position();
-
1383 if (position == start)
evaluated: position == start
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:78
29-78
1384 return start - 1;
executed: return start - 1;
Execution Count:29
29
1385 -
1386 return it.layout()->previousCursorPosition(position-start, mode) + start;
executed: return it.layout()->previousCursorPosition(position-start, mode) + start;
Execution Count:78
78
1387} -
1388 -
1389int QTextDocumentPrivate::leftCursorPosition(int position) const -
1390{ -
1391 QTextBlock it = blocksFind(position);
never executed (the execution status of this line is deduced): QTextBlock it = blocksFind(position);
-
1392 int start = it.position();
never executed (the execution status of this line is deduced): int start = it.position();
-
1393 return it.layout()->leftCursorPosition(position-start) + start;
never executed: return it.layout()->leftCursorPosition(position-start) + start;
0
1394} -
1395 -
1396int QTextDocumentPrivate::rightCursorPosition(int position) const -
1397{ -
1398 QTextBlock it = blocksFind(position);
never executed (the execution status of this line is deduced): QTextBlock it = blocksFind(position);
-
1399 int start = it.position();
never executed (the execution status of this line is deduced): int start = it.position();
-
1400 return it.layout()->rightCursorPosition(position-start) + start;
never executed: return it.layout()->rightCursorPosition(position-start) + start;
0
1401} -
1402 -
1403void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format) -
1404{ -
1405 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
1406 int objectIndex = obj->objectIndex();
executed (the execution status of this line is deduced): int objectIndex = obj->objectIndex();
-
1407 int oldFormatIndex = formats.objectFormatIndex(objectIndex);
executed (the execution status of this line is deduced): int oldFormatIndex = formats.objectFormatIndex(objectIndex);
-
1408 formats.setObjectFormatIndex(objectIndex, format);
executed (the execution status of this line is deduced): formats.setObjectFormatIndex(objectIndex, format);
-
1409 -
1410 QTextBlockGroup *b = qobject_cast<QTextBlockGroup *>(obj);
executed (the execution status of this line is deduced): QTextBlockGroup *b = qobject_cast<QTextBlockGroup *>(obj);
-
1411 if (b) {
evaluated: b
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:104
1-104
1412 b->d_func()->markBlocksDirty();
executed (the execution status of this line is deduced): b->d_func()->markBlocksDirty();
-
1413 }
executed: }
Execution Count:1
1
1414 QTextFrame *f = qobject_cast<QTextFrame *>(obj);
executed (the execution status of this line is deduced): QTextFrame *f = qobject_cast<QTextFrame *>(obj);
-
1415 if (f)
evaluated: f
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:1
1-104
1416 documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition());
executed: documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition());
Execution Count:104
104
1417 -
1418 QT_INIT_TEXTUNDOCOMMAND(c, QTextUndoCommand::GroupFormatChange, (editBlock != 0), QTextUndoCommand::MoveCursor, oldFormatIndex,
executed (the execution status of this line is deduced): QTextUndoCommand c = { QTextUndoCommand::GroupFormatChange, (editBlock != 0), 0, 0, quint8(QTextUndoCommand::MoveCursor), oldFormatIndex, quint32(0), quint32(0), { int(obj->d_func()->objectIndex) }, quint32(0) };
-
1419 0, 0, obj->d_func()->objectIndex, 0); -
1420 appendUndoItem(c);
executed (the execution status of this line is deduced): appendUndoItem(c);
-
1421 -
1422 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
1423}
executed: }
Execution Count:105
105
1424 -
1425static QTextFrame *findChildFrame(QTextFrame *f, int pos) -
1426{ -
1427 /* Binary search for frame at pos */ -
1428 const QList<QTextFrame *> children = f->childFrames();
executed (the execution status of this line is deduced): const QList<QTextFrame *> children = f->childFrames();
-
1429 int first = 0;
executed (the execution status of this line is deduced): int first = 0;
-
1430 int last = children.size() - 1;
executed (the execution status of this line is deduced): int last = children.size() - 1;
-
1431 while (first <= last) {
evaluated: first <= last
TRUEFALSE
yes
Evaluation Count:1155
yes
Evaluation Count:10991
1155-10991
1432 int mid = (first + last) / 2;
executed (the execution status of this line is deduced): int mid = (first + last) / 2;
-
1433 QTextFrame *c = children.at(mid);
executed (the execution status of this line is deduced): QTextFrame *c = children.at(mid);
-
1434 if (pos > c->lastPosition())
evaluated: pos > c->lastPosition()
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:960
195-960
1435 first = mid + 1;
executed: first = mid + 1;
Execution Count:195
195
1436 else if (pos < c->firstPosition())
evaluated: pos < c->firstPosition()
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:724
236-724
1437 last = mid - 1;
executed: last = mid - 1;
Execution Count:236
236
1438 else -
1439 return c;
executed: return c;
Execution Count:724
724
1440 } -
1441 return 0;
executed: return 0;
Execution Count:10991
10991
1442} -
1443 -
1444QTextFrame *QTextDocumentPrivate::rootFrame() const -
1445{ -
1446 if (!rtFrame) {
evaluated: !rtFrame
TRUEFALSE
yes
Evaluation Count:1821
yes
Evaluation Count:21393
1821-21393
1447 QTextFrameFormat defaultRootFrameFormat;
executed (the execution status of this line is deduced): QTextFrameFormat defaultRootFrameFormat;
-
1448 defaultRootFrameFormat.setMargin(documentMargin);
executed (the execution status of this line is deduced): defaultRootFrameFormat.setMargin(documentMargin);
-
1449 rtFrame = qobject_cast<QTextFrame *>(const_cast<QTextDocumentPrivate *>(this)->createObject(defaultRootFrameFormat));
executed (the execution status of this line is deduced): rtFrame = qobject_cast<QTextFrame *>(const_cast<QTextDocumentPrivate *>(this)->createObject(defaultRootFrameFormat));
-
1450 }
executed: }
Execution Count:1821
1821
1451 return rtFrame;
executed: return rtFrame;
Execution Count:23214
23214
1452} -
1453 -
1454QTextFrame *QTextDocumentPrivate::frameAt(int pos) const -
1455{ -
1456 QTextFrame *f = rootFrame();
executed (the execution status of this line is deduced): QTextFrame *f = rootFrame();
-
1457 -
1458 while (1) {
partially evaluated: 1
TRUEFALSE
yes
Evaluation Count:11715
no
Evaluation Count:0
0-11715
1459 QTextFrame *c = findChildFrame(f, pos);
executed (the execution status of this line is deduced): QTextFrame *c = findChildFrame(f, pos);
-
1460 if (!c)
evaluated: !c
TRUEFALSE
yes
Evaluation Count:10991
yes
Evaluation Count:724
724-10991
1461 return f;
executed: return f;
Execution Count:10991
10991
1462 f = c;
executed (the execution status of this line is deduced): f = c;
-
1463 }
executed: }
Execution Count:724
724
1464}
never executed: }
0
1465 -
1466void QTextDocumentPrivate::clearFrame(QTextFrame *f) -
1467{ -
1468 for (int i = 0; i < f->d_func()->childFrames.count(); ++i)
evaluated: i < f->d_func()->childFrames.count()
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:505
124-505
1469 clearFrame(f->d_func()->childFrames.at(i));
executed: clearFrame(f->d_func()->childFrames.at(i));
Execution Count:124
124
1470 f->d_func()->childFrames.clear();
executed (the execution status of this line is deduced): f->d_func()->childFrames.clear();
-
1471 f->d_func()->parentFrame = 0;
executed (the execution status of this line is deduced): f->d_func()->parentFrame = 0;
-
1472}
executed: }
Execution Count:505
505
1473 -
1474void QTextDocumentPrivate::scan_frames(int pos, int charsRemoved, int charsAdded) -
1475{ -
1476 // ###### optimize -
1477 Q_UNUSED(pos);
executed (the execution status of this line is deduced): (void)pos;;
-
1478 Q_UNUSED(charsRemoved);
executed (the execution status of this line is deduced): (void)charsRemoved;;
-
1479 Q_UNUSED(charsAdded);
executed (the execution status of this line is deduced): (void)charsAdded;;
-
1480 -
1481 QTextFrame *f = rootFrame();
executed (the execution status of this line is deduced): QTextFrame *f = rootFrame();
-
1482 clearFrame(f);
executed (the execution status of this line is deduced): clearFrame(f);
-
1483 -
1484 for (FragmentIterator it = begin(); it != end(); ++it) {
evaluated: it != end()
TRUEFALSE
yes
Evaluation Count:3402
yes
Evaluation Count:381
381-3402
1485 // QTextFormat fmt = formats.format(it->format); -
1486 QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(it->format));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(it->format));
-
1487 if (!frame)
evaluated: !frame
TRUEFALSE
yes
Evaluation Count:827
yes
Evaluation Count:2575
827-2575
1488 continue;
executed: continue;
Execution Count:827
827
1489 -
1490 Q_ASSERT(it.size() == 1);
executed (the execution status of this line is deduced): qt_noop();
-
1491 QChar ch = text.at(it->stringPosition);
executed (the execution status of this line is deduced): QChar ch = text.at(it->stringPosition);
-
1492 -
1493 if (ch == QTextBeginningOfFrame) {
evaluated: ch == QChar(0xfdd0)
TRUEFALSE
yes
Evaluation Count:2169
yes
Evaluation Count:406
406-2169
1494 if (f != frame) {
evaluated: f != frame
TRUEFALSE
yes
Evaluation Count:373
yes
Evaluation Count:1796
373-1796
1495 // f == frame happens for tables -
1496 Q_ASSERT(frame->d_func()->fragment_start == it.n || frame->d_func()->fragment_start == 0);
executed (the execution status of this line is deduced): qt_noop();
-
1497 frame->d_func()->parentFrame = f;
executed (the execution status of this line is deduced): frame->d_func()->parentFrame = f;
-
1498 f->d_func()->childFrames.append(frame);
executed (the execution status of this line is deduced): f->d_func()->childFrames.append(frame);
-
1499 f = frame;
executed (the execution status of this line is deduced): f = frame;
-
1500 }
executed: }
Execution Count:373
373
1501 } else if (ch == QTextEndOfFrame) {
executed: }
Execution Count:2169
evaluated: ch == QChar(0xfdd1)
TRUEFALSE
yes
Evaluation Count:373
yes
Evaluation Count:33
33-2169
1502 Q_ASSERT(f == frame);
executed (the execution status of this line is deduced): qt_noop();
-
1503 Q_ASSERT(frame->d_func()->fragment_end == it.n || frame->d_func()->fragment_end == 0);
executed (the execution status of this line is deduced): qt_noop();
-
1504 f = frame->d_func()->parentFrame;
executed (the execution status of this line is deduced): f = frame->d_func()->parentFrame;
-
1505 } else if (ch == QChar::ObjectReplacementCharacter) {
executed: }
Execution Count:373
partially evaluated: ch == QChar::ObjectReplacementCharacter
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-373
1506 Q_ASSERT(f != frame);
executed (the execution status of this line is deduced): qt_noop();
-
1507 Q_ASSERT(frame->d_func()->fragment_start == it.n || frame->d_func()->fragment_start == 0);
executed (the execution status of this line is deduced): qt_noop();
-
1508 Q_ASSERT(frame->d_func()->fragment_end == it.n || frame->d_func()->fragment_end == 0);
executed (the execution status of this line is deduced): qt_noop();
-
1509 frame->d_func()->parentFrame = f;
executed (the execution status of this line is deduced): frame->d_func()->parentFrame = f;
-
1510 f->d_func()->childFrames.append(frame);
executed (the execution status of this line is deduced): f->d_func()->childFrames.append(frame);
-
1511 } else {
executed: }
Execution Count:33
33
1512 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
1513 }
never executed: }
0
1514 } -
1515 Q_ASSERT(f == rtFrame);
executed (the execution status of this line is deduced): qt_noop();
-
1516 framesDirty = false;
executed (the execution status of this line is deduced): framesDirty = false;
-
1517}
executed: }
Execution Count:381
381
1518 -
1519void QTextDocumentPrivate::insert_frame(QTextFrame *f) -
1520{ -
1521 int start = f->firstPosition();
executed (the execution status of this line is deduced): int start = f->firstPosition();
-
1522 int end = f->lastPosition();
executed (the execution status of this line is deduced): int end = f->lastPosition();
-
1523 QTextFrame *parent = frameAt(start-1);
executed (the execution status of this line is deduced): QTextFrame *parent = frameAt(start-1);
-
1524 Q_ASSERT(parent == frameAt(end+1));
executed (the execution status of this line is deduced): qt_noop();
-
1525 -
1526 if (start != end) {
evaluated: start != end
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
1527 // iterator over the parent and move all children contained in my frame to myself -
1528 for (int i = 0; i < parent->d_func()->childFrames.size(); ++i) {
partially evaluated: i < parent->d_func()->childFrames.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1529 QTextFrame *c = parent->d_func()->childFrames.at(i);
never executed (the execution status of this line is deduced): QTextFrame *c = parent->d_func()->childFrames.at(i);
-
1530 if (start < c->firstPosition() && end > c->lastPosition()) {
never evaluated: start < c->firstPosition()
never evaluated: end > c->lastPosition()
0
1531 parent->d_func()->childFrames.removeAt(i);
never executed (the execution status of this line is deduced): parent->d_func()->childFrames.removeAt(i);
-
1532 f->d_func()->childFrames.append(c);
never executed (the execution status of this line is deduced): f->d_func()->childFrames.append(c);
-
1533 c->d_func()->parentFrame = f;
never executed (the execution status of this line is deduced): c->d_func()->parentFrame = f;
-
1534 }
never executed: }
0
1535 }
never executed: }
0
1536 }
executed: }
Execution Count:1
1
1537 // insert at the correct position -
1538 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1539 for (; i < parent->d_func()->childFrames.size(); ++i) {
partially evaluated: i < parent->d_func()->childFrames.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
1540 QTextFrame *c = parent->d_func()->childFrames.at(i);
never executed (the execution status of this line is deduced): QTextFrame *c = parent->d_func()->childFrames.at(i);
-
1541 if (c->firstPosition() > end)
never evaluated: c->firstPosition() > end
0
1542 break;
never executed: break;
0
1543 }
never executed: }
0
1544 parent->d_func()->childFrames.insert(i, f);
executed (the execution status of this line is deduced): parent->d_func()->childFrames.insert(i, f);
-
1545 f->d_func()->parentFrame = parent;
executed (the execution status of this line is deduced): f->d_func()->parentFrame = parent;
-
1546}
executed: }
Execution Count:9
9
1547 -
1548QTextFrame *QTextDocumentPrivate::insertFrame(int start, int end, const QTextFrameFormat &format) -
1549{ -
1550 Q_ASSERT(start >= 0 && start < length());
executed (the execution status of this line is deduced): qt_noop();
-
1551 Q_ASSERT(end >= 0 && end < length());
executed (the execution status of this line is deduced): qt_noop();
-
1552 Q_ASSERT(start <= end || end == -1);
executed (the execution status of this line is deduced): qt_noop();
-
1553 -
1554 if (start != end && frameAt(start) != frameAt(end))
evaluated: start != end
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
partially evaluated: frameAt(start) != frameAt(end)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-8
1555 return 0;
never executed: return 0;
0
1556 -
1557 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
1558 -
1559 QTextFrame *frame = qobject_cast<QTextFrame *>(createObject(format));
executed (the execution status of this line is deduced): QTextFrame *frame = qobject_cast<QTextFrame *>(createObject(format));
-
1560 Q_ASSERT(frame);
executed (the execution status of this line is deduced): qt_noop();
-
1561 -
1562 // #### using the default block and char format below might be wrong -
1563 int idx = formats.indexForFormat(QTextBlockFormat());
executed (the execution status of this line is deduced): int idx = formats.indexForFormat(QTextBlockFormat());
-
1564 QTextCharFormat cfmt;
executed (the execution status of this line is deduced): QTextCharFormat cfmt;
-
1565 cfmt.setObjectIndex(frame->objectIndex());
executed (the execution status of this line is deduced): cfmt.setObjectIndex(frame->objectIndex());
-
1566 int charIdx = formats.indexForFormat(cfmt);
executed (the execution status of this line is deduced): int charIdx = formats.indexForFormat(cfmt);
-
1567 -
1568 insertBlock(QTextBeginningOfFrame, start, idx, charIdx, QTextUndoCommand::MoveCursor);
executed (the execution status of this line is deduced): insertBlock(QChar(0xfdd0), start, idx, charIdx, QTextUndoCommand::MoveCursor);
-
1569 insertBlock(QTextEndOfFrame, ++end, idx, charIdx, QTextUndoCommand::KeepCursor);
executed (the execution status of this line is deduced): insertBlock(QChar(0xfdd1), ++end, idx, charIdx, QTextUndoCommand::KeepCursor);
-
1570 -
1571 frame->d_func()->fragment_start = find(start).n;
executed (the execution status of this line is deduced): frame->d_func()->fragment_start = find(start).n;
-
1572 frame->d_func()->fragment_end = find(end).n;
executed (the execution status of this line is deduced): frame->d_func()->fragment_end = find(end).n;
-
1573 -
1574 insert_frame(frame);
executed (the execution status of this line is deduced): insert_frame(frame);
-
1575 -
1576 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
1577 -
1578 return frame;
executed: return frame;
Execution Count:9
9
1579} -
1580 -
1581void QTextDocumentPrivate::removeFrame(QTextFrame *frame) -
1582{ -
1583 QTextFrame *parent = frame->d_func()->parentFrame;
never executed (the execution status of this line is deduced): QTextFrame *parent = frame->d_func()->parentFrame;
-
1584 if (!parent)
never evaluated: !parent
0
1585 return;
never executed: return;
0
1586 -
1587 int start = frame->firstPosition();
never executed (the execution status of this line is deduced): int start = frame->firstPosition();
-
1588 int end = frame->lastPosition();
never executed (the execution status of this line is deduced): int end = frame->lastPosition();
-
1589 Q_ASSERT(end >= start);
never executed (the execution status of this line is deduced): qt_noop();
-
1590 -
1591 beginEditBlock();
never executed (the execution status of this line is deduced): beginEditBlock();
-
1592 -
1593 // remove already removes the frames from the tree -
1594 remove(end, 1);
never executed (the execution status of this line is deduced): remove(end, 1);
-
1595 remove(start-1, 1);
never executed (the execution status of this line is deduced): remove(start-1, 1);
-
1596 -
1597 endEditBlock();
never executed (the execution status of this line is deduced): endEditBlock();
-
1598}
never executed: }
0
1599 -
1600QTextObject *QTextDocumentPrivate::objectForIndex(int objectIndex) const -
1601{ -
1602 if (objectIndex < 0)
evaluated: objectIndex < 0
TRUEFALSE
yes
Evaluation Count:45953
yes
Evaluation Count:15873
15873-45953
1603 return 0;
executed: return 0;
Execution Count:45953
45953
1604 -
1605 QTextObject *object = objects.value(objectIndex, 0);
executed (the execution status of this line is deduced): QTextObject *object = objects.value(objectIndex, 0);
-
1606 if (!object) {
evaluated: !object
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:15730
143-15730
1607 QTextDocumentPrivate *that = const_cast<QTextDocumentPrivate *>(this);
executed (the execution status of this line is deduced): QTextDocumentPrivate *that = const_cast<QTextDocumentPrivate *>(this);
-
1608 QTextFormat fmt = formats.objectFormat(objectIndex);
executed (the execution status of this line is deduced): QTextFormat fmt = formats.objectFormat(objectIndex);
-
1609 object = that->createObject(fmt, objectIndex);
executed (the execution status of this line is deduced): object = that->createObject(fmt, objectIndex);
-
1610 }
executed: }
Execution Count:143
143
1611 return object;
executed: return object;
Execution Count:15873
15873
1612} -
1613 -
1614QTextObject *QTextDocumentPrivate::objectForFormat(int formatIndex) const -
1615{ -
1616 int objectIndex = formats.format(formatIndex).objectIndex();
executed (the execution status of this line is deduced): int objectIndex = formats.format(formatIndex).objectIndex();
-
1617 return objectForIndex(objectIndex);
executed: return objectForIndex(objectIndex);
Execution Count:33635
33635
1618} -
1619 -
1620QTextObject *QTextDocumentPrivate::objectForFormat(const QTextFormat &f) const -
1621{ -
1622 return objectForIndex(f.objectIndex());
executed: return objectForIndex(f.objectIndex());
Execution Count:28190
28190
1623} -
1624 -
1625QTextObject *QTextDocumentPrivate::createObject(const QTextFormat &f, int objectIndex) -
1626{ -
1627 QTextObject *obj = document()->createObject(f);
executed (the execution status of this line is deduced): QTextObject *obj = document()->createObject(f);
-
1628 -
1629 if (obj) {
partially evaluated: obj
TRUEFALSE
yes
Evaluation Count:2216
no
Evaluation Count:0
0-2216
1630 obj->d_func()->objectIndex = objectIndex == -1 ? formats.createObjectIndex(f) : objectIndex;
evaluated: objectIndex == -1
TRUEFALSE
yes
Evaluation Count:2073
yes
Evaluation Count:143
143-2073
1631 objects[obj->d_func()->objectIndex] = obj;
executed (the execution status of this line is deduced): objects[obj->d_func()->objectIndex] = obj;
-
1632 }
executed: }
Execution Count:2216
2216
1633 -
1634 return obj;
executed: return obj;
Execution Count:2216
2216
1635} -
1636 -
1637void QTextDocumentPrivate::deleteObject(QTextObject *object) -
1638{ -
1639 const int objIdx = object->d_func()->objectIndex;
executed (the execution status of this line is deduced): const int objIdx = object->d_func()->objectIndex;
-
1640 objects.remove(objIdx);
executed (the execution status of this line is deduced): objects.remove(objIdx);
-
1641 delete object;
executed (the execution status of this line is deduced): delete object;
-
1642}
executed: }
Execution Count:11
11
1643 -
1644void QTextDocumentPrivate::contentsChanged() -
1645{ -
1646 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
1647 if (editBlock)
partially evaluated: editBlock
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18375
0-18375
1648 return;
never executed: return;
0
1649 -
1650 bool m = undoEnabled ? (modifiedState != undoState) : true;
evaluated: undoEnabled
TRUEFALSE
yes
Evaluation Count:12557
yes
Evaluation Count:5818
5818-12557
1651 if (modified != m) {
evaluated: modified != m
TRUEFALSE
yes
Evaluation Count:4630
yes
Evaluation Count:13745
4630-13745
1652 modified = m;
executed (the execution status of this line is deduced): modified = m;
-
1653 emit q->modificationChanged(modified);
executed (the execution status of this line is deduced): q->modificationChanged(modified);
-
1654 }
executed: }
Execution Count:4630
4630
1655 -
1656 emit q->contentsChanged();
executed (the execution status of this line is deduced): q->contentsChanged();
-
1657}
executed: }
Execution Count:18375
18375
1658 -
1659void QTextDocumentPrivate::compressPieceTable() -
1660{ -
1661 if (undoEnabled)
evaluated: undoEnabled
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5235
1-5235
1662 return;
executed: return;
Execution Count:1
1
1663 -
1664 const uint garbageCollectionThreshold = 96 * 1024; // bytes
executed (the execution status of this line is deduced): const uint garbageCollectionThreshold = 96 * 1024;
-
1665 -
1666 //qDebug() << "unreachable bytes:" << unreachableCharacterCount * sizeof(QChar) << " -- limit" << garbageCollectionThreshold << "text size =" << text.size() << "capacity:" << text.capacity(); -
1667 -
1668 bool compressTable = unreachableCharacterCount * sizeof(QChar) > garbageCollectionThreshold
partially evaluated: unreachableCharacterCount * sizeof(QChar) > garbageCollectionThreshold
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5235
0-5235
1669 && text.size() >= text.capacity() * 0.9;
never evaluated: text.size() >= text.capacity() * 0.9
0
1670 if (!compressTable)
partially evaluated: !compressTable
TRUEFALSE
yes
Evaluation Count:5235
no
Evaluation Count:0
0-5235
1671 return;
executed: return;
Execution Count:5235
5235
1672 -
1673 QString newText;
never executed (the execution status of this line is deduced): QString newText;
-
1674 newText.resize(text.size());
never executed (the execution status of this line is deduced): newText.resize(text.size());
-
1675 QChar *newTextPtr = newText.data();
never executed (the execution status of this line is deduced): QChar *newTextPtr = newText.data();
-
1676 int newLen = 0;
never executed (the execution status of this line is deduced): int newLen = 0;
-
1677 -
1678 for (FragmentMap::Iterator it = fragments.begin(); !it.atEnd(); ++it) {
never evaluated: !it.atEnd()
0
1679 memcpy(newTextPtr, text.constData() + it->stringPosition, it->size_array[0] * sizeof(QChar));
never executed (the execution status of this line is deduced): memcpy(newTextPtr, text.constData() + it->stringPosition, it->size_array[0] * sizeof(QChar));
-
1680 it->stringPosition = newLen;
never executed (the execution status of this line is deduced): it->stringPosition = newLen;
-
1681 newTextPtr += it->size_array[0];
never executed (the execution status of this line is deduced): newTextPtr += it->size_array[0];
-
1682 newLen += it->size_array[0];
never executed (the execution status of this line is deduced): newLen += it->size_array[0];
-
1683 }
never executed: }
0
1684 -
1685 newText.resize(newLen);
never executed (the execution status of this line is deduced): newText.resize(newLen);
-
1686 newText.squeeze();
never executed (the execution status of this line is deduced): newText.squeeze();
-
1687 //qDebug() << "removed" << text.size() - newText.size() << "characters"; -
1688 text = newText;
never executed (the execution status of this line is deduced): text = newText;
-
1689 unreachableCharacterCount = 0;
never executed (the execution status of this line is deduced): unreachableCharacterCount = 0;
-
1690}
never executed: }
0
1691 -
1692void QTextDocumentPrivate::setModified(bool m) -
1693{ -
1694 Q_Q(QTextDocument);
executed (the execution status of this line is deduced): QTextDocument * const q = q_func();
-
1695 if (m == modified)
evaluated: m == modified
TRUEFALSE
yes
Evaluation Count:326
yes
Evaluation Count:235
235-326
1696 return;
executed: return;
Execution Count:326
326
1697 -
1698 modified = m;
executed (the execution status of this line is deduced): modified = m;
-
1699 if (!modified)
partially evaluated: !modified
TRUEFALSE
yes
Evaluation Count:235
no
Evaluation Count:0
0-235
1700 modifiedState = undoState;
executed: modifiedState = undoState;
Execution Count:235
235
1701 else -
1702 modifiedState = -1;
never executed: modifiedState = -1;
0
1703 -
1704 emit q->modificationChanged(modified);
executed (the execution status of this line is deduced): q->modificationChanged(modified);
-
1705}
executed: }
Execution Count:235
235
1706 -
1707bool QTextDocumentPrivate::ensureMaximumBlockCount() -
1708{ -
1709 if (maximumBlockCount <= 0)
evaluated: maximumBlockCount <= 0
TRUEFALSE
yes
Evaluation Count:14351
yes
Evaluation Count:1019
1019-14351
1710 return false;
executed: return false;
Execution Count:14351
14351
1711 if (blocks.numNodes() <= maximumBlockCount)
evaluated: blocks.numNodes() <= maximumBlockCount
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:908
111-908
1712 return false;
executed: return false;
Execution Count:111
111
1713 -
1714 beginEditBlock();
executed (the execution status of this line is deduced): beginEditBlock();
-
1715 -
1716 const int blocksToRemove = blocks.numNodes() - maximumBlockCount;
executed (the execution status of this line is deduced): const int blocksToRemove = blocks.numNodes() - maximumBlockCount;
-
1717 QTextCursor cursor(this, 0);
executed (the execution status of this line is deduced): QTextCursor cursor(this, 0);
-
1718 cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove);
executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove);
-
1719 -
1720 unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart();
executed (the execution status of this line is deduced): unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart();
-
1721 -
1722 // preserve the char format of the paragraph that is to become the new first one -
1723 QTextCharFormat charFmt = cursor.blockCharFormat();
executed (the execution status of this line is deduced): QTextCharFormat charFmt = cursor.blockCharFormat();
-
1724 cursor.removeSelectedText();
executed (the execution status of this line is deduced): cursor.removeSelectedText();
-
1725 cursor.setBlockCharFormat(charFmt);
executed (the execution status of this line is deduced): cursor.setBlockCharFormat(charFmt);
-
1726 -
1727 endEditBlock();
executed (the execution status of this line is deduced): endEditBlock();
-
1728 -
1729 compressPieceTable();
executed (the execution status of this line is deduced): compressPieceTable();
-
1730 -
1731 return true;
executed: return true;
Execution Count:908
908
1732} -
1733 -
1734/// This method is called from QTextTable when it is about to remove a table-cell to allow cursors to update their selection. -
1735void QTextDocumentPrivate::aboutToRemoveCell(int from, int to) -
1736{ -
1737 Q_ASSERT(from <= to);
executed (the execution status of this line is deduced): qt_noop();
-
1738 foreach (QTextCursorPrivate *curs, cursors)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cursors)> _container_(cursors); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QTextCursorPrivate *curs = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
1739 curs->aboutToRemoveCell(from, to);
executed: curs->aboutToRemoveCell(from, to);
Execution Count:32
32
1740}
executed: }
Execution Count:25
25
1741 -
1742QT_END_NAMESPACE -
1743 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial