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