| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | QTextObject::QTextObject(QTextDocument *doc) | - |
| 9 | : QObject(*new QTextObjectPrivate(doc), doc) | - |
| 10 | { | - |
| 11 | } | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | QTextObject::QTextObject(QTextObjectPrivate &p, QTextDocument *doc) | - |
| 19 | : QObject(p, doc) | - |
| 20 | { | - |
| 21 | } | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | QTextObject::~QTextObject() | - |
| 30 | { | - |
| 31 | } | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | QTextFormat QTextObject::format() const | - |
| 39 | { | - |
| 40 | const QTextObjectPrivate * const d = d_func(); | - |
| 41 | return d->pieceTable->formatCollection()->objectFormat(d->objectIndex); | - |
| 42 | } | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | int QTextObject::formatIndex() const | - |
| 51 | { | - |
| 52 | const QTextObjectPrivate * const d = d_func(); | - |
| 53 | return d->pieceTable->formatCollection()->objectFormatIndex(d->objectIndex); | - |
| 54 | } | - |
| 55 | | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | | - |
| 60 | | - |
| 61 | | - |
| 62 | void QTextObject::setFormat(const QTextFormat &format) | - |
| 63 | { | - |
| 64 | QTextObjectPrivate * const d = d_func(); | - |
| 65 | int idx = d->pieceTable->formatCollection()->indexForFormat(format); | - |
| 66 | d->pieceTable->changeObjectFormat(this, idx); | - |
| 67 | } | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | int QTextObject::objectIndex() const | - |
| 74 | { | - |
| 75 | const QTextObjectPrivate * const d = d_func(); | - |
| 76 | return d->objectIndex; | - |
| 77 | } | - |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | | - |
| 82 | | - |
| 83 | | - |
| 84 | QTextDocument *QTextObject::document() const | - |
| 85 | { | - |
| 86 | return static_cast<QTextDocument *>(parent()); | - |
| 87 | } | - |
| 88 | | - |
| 89 | | - |
| 90 | | - |
| 91 | | - |
| 92 | QTextDocumentPrivate *QTextObject::docHandle() const | - |
| 93 | { | - |
| 94 | return static_cast<const QTextDocument *>(parent())->docHandle(); | - |
| 95 | } | - |
| 96 | void QTextBlockGroupPrivate::markBlocksDirty() | - |
| 97 | { | - |
| 98 | for (int i = 0; i < blocks.count(); ++i) { | - |
| 99 | const QTextBlock &block = blocks.at(i); | - |
| 100 | pieceTable->documentChange(block.position(), block.length()); | - |
| 101 | } | - |
| 102 | } | - |
| 103 | QTextBlockGroup::QTextBlockGroup(QTextDocument *doc) | - |
| 104 | : QTextObject(*new QTextBlockGroupPrivate(doc), doc) | - |
| 105 | { | - |
| 106 | } | - |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | | - |
| 111 | QTextBlockGroup::QTextBlockGroup(QTextBlockGroupPrivate &p, QTextDocument *doc) | - |
| 112 | : QTextObject(p, doc) | - |
| 113 | { | - |
| 114 | } | - |
| 115 | | - |
| 116 | | - |
| 117 | | - |
| 118 | | - |
| 119 | | - |
| 120 | QTextBlockGroup::~QTextBlockGroup() | - |
| 121 | { | - |
| 122 | } | - |
| 123 | void QTextBlockGroup::blockInserted(const QTextBlock &block) | - |
| 124 | { | - |
| 125 | QTextBlockGroupPrivate * const d = d_func(); | - |
| 126 | QTextBlockGroupPrivate::BlockList::Iterator it = std::lower_bound(d->blocks.begin(), d->blocks.end(), block); | - |
| 127 | d->blocks.insert(it, block); | - |
| 128 | d->markBlocksDirty(); | - |
| 129 | } | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | void QTextBlockGroup::blockRemoved(const QTextBlock &block) | - |
| 137 | { | - |
| 138 | QTextBlockGroupPrivate * const d = d_func(); | - |
| 139 | d->blocks.removeAll(block); | - |
| 140 | d->markBlocksDirty(); | - |
| 141 | if (d->blocks.isEmpty()) { | - |
| 142 | document()->docHandle()->deleteObject(this); | - |
| 143 | return; | - |
| 144 | } | - |
| 145 | } | - |
| 146 | | - |
| 147 | | - |
| 148 | | - |
| 149 | | - |
| 150 | | - |
| 151 | | - |
| 152 | | - |
| 153 | void QTextBlockGroup::blockFormatChanged(const QTextBlock &) | - |
| 154 | { | - |
| 155 | } | - |
| 156 | | - |
| 157 | | - |
| 158 | | - |
| 159 | | - |
| 160 | | - |
| 161 | QList<QTextBlock> QTextBlockGroup::blockList() const | - |
| 162 | { | - |
| 163 | const QTextBlockGroupPrivate * const d = d_func(); | - |
| 164 | return d->blocks; | - |
| 165 | } | - |
| 166 | | - |
| 167 | | - |
| 168 | | - |
| 169 | QTextFrameLayoutData::~QTextFrameLayoutData() | - |
| 170 | { | - |
| 171 | } | - |
| 172 | QTextFrame::QTextFrame(QTextDocument *doc) | - |
| 173 | : QTextObject(*new QTextFramePrivate(doc), doc) | - |
| 174 | { | - |
| 175 | } | - |
| 176 | QTextFrame::~QTextFrame() | - |
| 177 | { | - |
| 178 | QTextFramePrivate * const d = d_func(); | - |
| 179 | delete d->layoutData; | - |
| 180 | } | - |
| 181 | | - |
| 182 | | - |
| 183 | | - |
| 184 | | - |
| 185 | QTextFrame::QTextFrame(QTextFramePrivate &p, QTextDocument *doc) | - |
| 186 | : QTextObject(p, doc) | - |
| 187 | { | - |
| 188 | } | - |
| 189 | | - |
| 190 | | - |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | QList<QTextFrame *> QTextFrame::childFrames() const | - |
| 196 | { | - |
| 197 | const QTextFramePrivate * const d = d_func(); | - |
| 198 | return d->childFrames; | - |
| 199 | } | - |
| 200 | | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | | - |
| 207 | QTextFrame *QTextFrame::parentFrame() const | - |
| 208 | { | - |
| 209 | const QTextFramePrivate * const d = d_func(); | - |
| 210 | return d->parentFrame; | - |
| 211 | } | - |
| 212 | | - |
| 213 | | - |
| 214 | | - |
| 215 | | - |
| 216 | | - |
| 217 | | - |
| 218 | | - |
| 219 | QTextCursor QTextFrame::firstCursorPosition() const | - |
| 220 | { | - |
| 221 | const QTextFramePrivate * const d = d_func(); | - |
| 222 | return QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition()); | - |
| 223 | } | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | | - |
| 228 | | - |
| 229 | | - |
| 230 | QTextCursor QTextFrame::lastCursorPosition() const | - |
| 231 | { | - |
| 232 | const QTextFramePrivate * const d = d_func(); | - |
| 233 | return QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition()); | - |
| 234 | } | - |
| 235 | | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | int QTextFrame::firstPosition() const | - |
| 242 | { | - |
| 243 | const QTextFramePrivate * const d = d_func(); | - |
| 244 | if (!d->fragment_start) | - |
| 245 | return 0; | - |
| 246 | return d->pieceTable->fragmentMap().position(d->fragment_start) + 1; | - |
| 247 | } | - |
| 248 | | - |
| 249 | | - |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | int QTextFrame::lastPosition() const | - |
| 255 | { | - |
| 256 | const QTextFramePrivate * const d = d_func(); | - |
| 257 | if (!d->fragment_end) | - |
| 258 | return d->pieceTable->length() - 1; | - |
| 259 | return d->pieceTable->fragmentMap().position(d->fragment_end); | - |
| 260 | } | - |
| 261 | | - |
| 262 | | - |
| 263 | | - |
| 264 | | - |
| 265 | QTextFrameLayoutData *QTextFrame::layoutData() const | - |
| 266 | { | - |
| 267 | const QTextFramePrivate * const d = d_func(); | - |
| 268 | return d->layoutData; | - |
| 269 | } | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| 274 | void QTextFrame::setLayoutData(QTextFrameLayoutData *data) | - |
| 275 | { | - |
| 276 | QTextFramePrivate * const d = d_func(); | - |
| 277 | delete d->layoutData; | - |
| 278 | d->layoutData = data; | - |
| 279 | } | - |
| 280 | | - |
| 281 | | - |
| 282 | | - |
| 283 | void QTextFramePrivate::fragmentAdded(QChar type, uint fragment) | - |
| 284 | { | - |
| 285 | if (type == QChar(0xfdd0)) { | - |
| 286 | ((!(!fragment_start)) ? qt_assert("!fragment_start",__FILE__,532538) : qt_noop()); | - |
| 287 | fragment_start = fragment; | - |
| 288 | } else if (type == QChar(0xfdd1)) { | - |
| 289 | ((!(!fragment_end)) ? qt_assert("!fragment_end",__FILE__,535541) : qt_noop()); | - |
| 290 | fragment_end = fragment; | - |
| 291 | } else if (type == QChar::ObjectReplacementCharacter) { | - |
| 292 | ((!(!fragment_start)) ? qt_assert("!fragment_start",__FILE__,538544) : qt_noop()); | - |
| 293 | ((!(!fragment_end)) ? qt_assert("!fragment_end",__FILE__,539545) : qt_noop()); | - |
| 294 | fragment_start = fragment; | - |
| 295 | fragment_end = fragment; | - |
| 296 | } else { | - |
| 297 | ((!(false)) ? qt_assert("false",__FILE__,543549) : qt_noop()); | - |
| 298 | } | - |
| 299 | } | - |
| 300 | | - |
| 301 | void QTextFramePrivate::fragmentRemoved(QChar type, uint fragment) | - |
| 302 | { | - |
| 303 | (void)fragment;; | - |
| 304 | if (type == QChar(0xfdd0)) { | - |
| 305 | ((!(fragment_start == fragment)) ? qt_assert("fragment_start == fragment",__FILE__,551557) : qt_noop()); | - |
| 306 | fragment_start = 0; | - |
| 307 | } else if (type == QChar(0xfdd1)) { | - |
| 308 | ((!(fragment_end == fragment)) ? qt_assert("fragment_end == fragment",__FILE__,554560) : qt_noop()); | - |
| 309 | fragment_end = 0; | - |
| 310 | } else if (type == QChar::ObjectReplacementCharacter) { | - |
| 311 | ((!(fragment_start == fragment)) ? qt_assert("fragment_start == fragment",__FILE__,557563) : qt_noop()); | - |
| 312 | ((!(fragment_end == fragment)) ? qt_assert("fragment_end == fragment",__FILE__,558564) : qt_noop()); | - |
| 313 | fragment_start = 0; | - |
| 314 | fragment_end = 0; | - |
| 315 | } else { | - |
| 316 | ((!(false)) ? qt_assert("false",__FILE__,562568) : qt_noop()); | - |
| 317 | } | - |
| 318 | remove_me(); | - |
| 319 | } | - |
| 320 | | - |
| 321 | | - |
| 322 | void QTextFramePrivate::remove_me() | - |
| 323 | { | - |
| 324 | QTextFrame * const q = q_func(); | - |
| 325 | if (fragment_start == 0 && fragment_end == 0 | - |
| 326 | && !parentFrame) { | - |
| 327 | q->document()->docHandle()->deleteObject(q); | - |
| 328 | return; | - |
| 329 | } | - |
| 330 | | - |
| 331 | if (!parentFrame) | - |
| 332 | return; | - |
| 333 | | - |
| 334 | int index = parentFrame->d_func()->childFrames.indexOf(q); | - |
| 335 | | - |
| 336 | | - |
| 337 | for (int i = 0; i < childFrames.size(); ++i) { | - |
| 338 | QTextFrame *c = childFrames.at(i); | - |
| 339 | parentFrame->d_func()->childFrames.insert(index, c); | - |
| 340 | c->d_func()->parentFrame = parentFrame; | - |
| 341 | ++index; | - |
| 342 | } | - |
| 343 | ((!(parentFrame->d_func()->childFrames.at(index) == q)) ? qt_assert("parentFrame->d_func()->childFrames.at(index) == q",__FILE__,589595) : qt_noop()); | - |
| 344 | parentFrame->d_func()->childFrames.removeAt(index); | - |
| 345 | | - |
| 346 | childFrames.clear(); | - |
| 347 | parentFrame = 0; | - |
| 348 | } | - |
| 349 | QTextFrame::iterator QTextFrame::begin() const | - |
| 350 | { | - |
| 351 | const QTextDocumentPrivate *priv = docHandle(); | - |
| 352 | int b = priv->blockMap().findNode(firstPosition()); | - |
| 353 | int e = priv->blockMap().findNode(lastPosition()+1); | - |
| 354 | return iterator(const_cast<QTextFrame *>(this), b, b, e); | - |
| 355 | } | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | | - |
| 360 | | - |
| 361 | | - |
| 362 | QTextFrame::iterator QTextFrame::end() const | - |
| 363 | { | - |
| 364 | const QTextDocumentPrivate *priv = docHandle(); | - |
| 365 | int b = priv->blockMap().findNode(firstPosition()); | - |
| 366 | int e = priv->blockMap().findNode(lastPosition()+1); | - |
| 367 | return iterator(const_cast<QTextFrame *>(this), e, b, e); | - |
| 368 | } | - |
| 369 | | - |
| 370 | | - |
| 371 | | - |
| 372 | | - |
| 373 | QTextFrame::iterator::iterator() | - |
| 374 | { | - |
| 375 | f = 0; | - |
| 376 | b = 0; | - |
| 377 | e = 0; | - |
| 378 | cf = 0; | - |
| 379 | cb = 0; | - |
| 380 | } | - |
| 381 | | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end) | - |
| 386 | { | - |
| 387 | f = frame; | - |
| 388 | b = begin; | - |
| 389 | e = end; | - |
| 390 | cf = 0; | - |
| 391 | cb = block; | - |
| 392 | } | - |
| 393 | | - |
| 394 | | - |
| 395 | | - |
| 396 | | - |
| 397 | | - |
| 398 | | - |
| 399 | QTextFrame::iterator::iterator(const iterator &other) noexcept | - |
| 400 | { | - |
| 401 | f = other.f; | - |
| 402 | b = other.b; | - |
| 403 | e = other.e; | - |
| 404 | cf = other.cf; | - |
| 405 | cb = other.cb; | - |
| 406 | } never executed: end of block | 0 |
| 407 | | - |
| 408 | | - |
| 409 | | - |
| 410 | | - |
| 411 | | - |
| 412 | QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) noexcept | - |
| 413 | { | - |
| 414 | f = other.f; | - |
| 415 | b = other.b; | - |
| 416 | e = other.e; | - |
| 417 | cf = other.cf; | - |
| 418 | cb = other.cb; | - |
| 419 | return never executed: return *this; *this;never executed: return *this; | 0 |
| 420 | } | - |
| 421 | QTextFrame *QTextFrame::iterator::currentFrame() const | - |
| 422 | { | - |
| 423 | return cf; | - |
| 424 | } | - |
| 425 | | - |
| 426 | | - |
| 427 | | - |
| 428 | | - |
| 429 | | - |
| 430 | | - |
| 431 | | - |
| 432 | QTextBlock QTextFrame::iterator::currentBlock() const | - |
| 433 | { | - |
| 434 | if (!f) | - |
| 435 | return QTextBlock(); | - |
| 436 | return QTextBlock(f->docHandle(), cb); | - |
| 437 | } | - |
| 438 | | - |
| 439 | | - |
| 440 | | - |
| 441 | | - |
| 442 | | - |
| 443 | | - |
| 444 | QTextFrame::iterator &QTextFrame::iterator::operator++() | - |
| 445 | { | - |
| 446 | const QTextDocumentPrivate *priv = f->docHandle(); | - |
| 447 | const QTextDocumentPrivate::BlockMap &map = priv->blockMap(); | - |
| 448 | if (cf) { | - |
| 449 | int end = cf->lastPosition() + 1; | - |
| 450 | cb = map.findNode(end); | - |
| 451 | cf = 0; | - |
| 452 | } else if (cb) { | - |
| 453 | cb = map.next(cb); | - |
| 454 | if (cb == e) | - |
| 455 | return *this; | - |
| 456 | | - |
| 457 | if (!f->d_func()->childFrames.isEmpty()) { | - |
| 458 | int pos = map.position(cb); | - |
| 459 | | - |
| 460 | QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1); | - |
| 461 | if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator) { | - |
| 462 | QTextFrame *nf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format)); | - |
| 463 | if (nf) { | - |
| 464 | if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd0) && nf != f) { | - |
| 465 | cf = nf; | - |
| 466 | cb = 0; | - |
| 467 | } else { | - |
| 468 | ((!(priv->buffer().at(frag->stringPosition) != QChar(0xfdd1))) ? qt_assert("priv->buffer().at(frag->stringPosition) != QTextEndOfFrame",__FILE__,749759) : qt_noop()); | - |
| 469 | } | - |
| 470 | } | - |
| 471 | } | - |
| 472 | } | - |
| 473 | } | - |
| 474 | return *this; | - |
| 475 | } | - |
| 476 | | - |
| 477 | | - |
| 478 | | - |
| 479 | | - |
| 480 | | - |
| 481 | | - |
| 482 | QTextFrame::iterator &QTextFrame::iterator::operator--() | - |
| 483 | { | - |
| 484 | const QTextDocumentPrivate *priv = f->docHandle(); | - |
| 485 | const QTextDocumentPrivate::BlockMap &map = priv->blockMap(); | - |
| 486 | if (cf) { | - |
| 487 | int start = cf->firstPosition() - 1; | - |
| 488 | cb = map.findNode(start); | - |
| 489 | cf = 0; | - |
| 490 | } else { | - |
| 491 | if (cb == b) | - |
| 492 | goto end; | - |
| 493 | if (cb != e) { | - |
| 494 | int pos = map.position(cb); | - |
| 495 | | - |
| 496 | QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1); | - |
| 497 | if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator) { | - |
| 498 | QTextFrame *pf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format)); | - |
| 499 | if (pf) { | - |
| 500 | if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd0)) { | - |
| 501 | ((!(pf == f)) ? qt_assert("pf == f",__FILE__,782792) : qt_noop()); | - |
| 502 | } else if (priv->buffer().at(frag->stringPosition) == QChar(0xfdd1)) { | - |
| 503 | ((!(pf != f)) ? qt_assert("pf != f",__FILE__,784794) : qt_noop()); | - |
| 504 | cf = pf; | - |
| 505 | cb = 0; | - |
| 506 | goto end; | - |
| 507 | } | - |
| 508 | } | - |
| 509 | } | - |
| 510 | } | - |
| 511 | cb = map.previous(cb); | - |
| 512 | } | - |
| 513 | end: | - |
| 514 | return *this; | - |
| 515 | } | - |
| 516 | QTextBlockUserData::~QTextBlockUserData() | - |
| 517 | { | - |
| 518 | } | - |
| 519 | bool QTextBlock::isValid() const | - |
| 520 | { | - |
| 521 | return p != 0 && p->blockMap().isValid(n); | - |
| 522 | } | - |
| 523 | int QTextBlock::position() const | - |
| 524 | { | - |
| 525 | if (!p || !n) | - |
| 526 | return 0; | - |
| 527 | | - |
| 528 | return p->blockMap().position(n); | - |
| 529 | } | - |
| 530 | int QTextBlock::length() const | - |
| 531 | { | - |
| 532 | if (!p || !n) | - |
| 533 | return 0; | - |
| 534 | | - |
| 535 | return p->blockMap().size(n); | - |
| 536 | } | - |
| 537 | | - |
| 538 | | - |
| 539 | | - |
| 540 | | - |
| 541 | | - |
| 542 | bool QTextBlock::contains(int position) const | - |
| 543 | { | - |
| 544 | if (!p || !n) | - |
| 545 | return false; | - |
| 546 | | - |
| 547 | int pos = p->blockMap().position(n); | - |
| 548 | int len = p->blockMap().size(n); | - |
| 549 | return position >= pos && position < pos + len; | - |
| 550 | } | - |
| 551 | QTextLayout *QTextBlock::layout() const | - |
| 552 | { | - |
| 553 | if (!p || !n) | - |
| 554 | return 0; | - |
| 555 | | - |
| 556 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 557 | if (!b->layout) | - |
| 558 | b->layout = new QTextLayout(*this); | - |
| 559 | return b->layout; | - |
| 560 | } | - |
| 561 | void QTextBlock::clearLayout() | - |
| 562 | { | - |
| 563 | if (!p || !n) | - |
| 564 | return; | - |
| 565 | | - |
| 566 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 567 | if (b->layout) | - |
| 568 | b->layout->clearLayout(); | - |
| 569 | } | - |
| 570 | | - |
| 571 | | - |
| 572 | | - |
| 573 | | - |
| 574 | | - |
| 575 | | - |
| 576 | QTextBlockFormat QTextBlock::blockFormat() const | - |
| 577 | { | - |
| 578 | if (!p || !n) | - |
| 579 | return QTextFormat().toBlockFormat(); | - |
| 580 | | - |
| 581 | return p->formatCollection()->blockFormat(p->blockMap().fragment(n)->format); | - |
| 582 | } | - |
| 583 | | - |
| 584 | | - |
| 585 | | - |
| 586 | | - |
| 587 | | - |
| 588 | | - |
| 589 | | - |
| 590 | int QTextBlock::blockFormatIndex() const | - |
| 591 | { | - |
| 592 | if (!p || !n) | - |
| 593 | return -1; | - |
| 594 | | - |
| 595 | return p->blockMap().fragment(n)->format; | - |
| 596 | } | - |
| 597 | QTextCharFormat QTextBlock::charFormat() const | - |
| 598 | { | - |
| 599 | if (!p || !n) | - |
| 600 | return QTextFormat().toCharFormat(); | - |
| 601 | | - |
| 602 | return p->formatCollection()->charFormat(charFormatIndex()); | - |
| 603 | } | - |
| 604 | | - |
| 605 | | - |
| 606 | | - |
| 607 | | - |
| 608 | | - |
| 609 | | - |
| 610 | | - |
| 611 | int QTextBlock::charFormatIndex() const | - |
| 612 | { | - |
| 613 | if (!p || !n) | - |
| 614 | return -1; | - |
| 615 | | - |
| 616 | return p->blockCharFormatIndex(n); | - |
| 617 | } | - |
| 618 | Qt::LayoutDirection QTextBlock::textDirection() const | - |
| 619 | { | - |
| 620 | Qt::LayoutDirection dir = blockFormat().layoutDirection(); | - |
| 621 | if (dir != Qt::LayoutDirectionAuto) | - |
| 622 | return dir; | - |
| 623 | | - |
| 624 | dir = p->defaultTextOption.textDirection(); | - |
| 625 | if (dir != Qt::LayoutDirectionAuto) | - |
| 626 | return dir; | - |
| 627 | | - |
| 628 | const QString buffer = p->buffer(); | - |
| 629 | | - |
| 630 | const int pos = position(); | - |
| 631 | QTextDocumentPrivate::FragmentIterator it = p->find(pos); | - |
| 632 | QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); | - |
| 633 | for (; it != end; ++it) { | - |
| 634 | const QTextFragmentData * const frag = it.value(); | - |
| 635 | const QChar *p = buffer.constData() + frag->stringPosition; | - |
| 636 | const QChar * const end = p + frag->size_array[0]; | - |
| 637 | while (p < end) { | - |
| 638 | uint ucs4 = p->unicode(); | - |
| 639 | if (QChar::isHighSurrogate(ucs4) && p + 1 < end) { | - |
| 640 | ushort low = p[1].unicode(); | - |
| 641 | if (QChar::isLowSurrogate(low)) { | - |
| 642 | ucs4 = QChar::surrogateToUcs4(ucs4, low); | - |
| 643 | ++p; | - |
| 644 | } | - |
| 645 | } | - |
| 646 | switch (QChar::direction(ucs4)) { | - |
| 647 | case QChar::DirL: | - |
| 648 | return Qt::LeftToRight; | - |
| 649 | case QChar::DirR: | - |
| 650 | case QChar::DirAL: | - |
| 651 | return Qt::RightToLeft; | - |
| 652 | default: | - |
| 653 | break; | - |
| 654 | } | - |
| 655 | ++p; | - |
| 656 | } | - |
| 657 | } | - |
| 658 | return Qt::LeftToRight; | - |
| 659 | } | - |
| 660 | | - |
| 661 | | - |
| 662 | | - |
| 663 | | - |
| 664 | | - |
| 665 | | - |
| 666 | QString QTextBlock::text() const | - |
| 667 | { | - |
| 668 | if (!p || !n) | - |
| 669 | return QString(); | - |
| 670 | | - |
| 671 | const QString buffer = p->buffer(); | - |
| 672 | QString text; | - |
| 673 | text.reserve(length()); | - |
| 674 | | - |
| 675 | const int pos = position(); | - |
| 676 | QTextDocumentPrivate::FragmentIterator it = p->find(pos); | - |
| 677 | QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); | - |
| 678 | for (; it != end; ++it) { | - |
| 679 | const QTextFragmentData * const frag = it.value(); | - |
| 680 | text += QString::fromRawData(buffer.constData() + frag->stringPosition, frag->size_array[0]); | - |
| 681 | } | - |
| 682 | | - |
| 683 | return text; | - |
| 684 | } | - |
| 685 | QVector<QTextLayout::FormatRange> QTextBlock::textFormats() const | - |
| 686 | { | - |
| 687 | QVector<QTextLayout::FormatRange> formats; | - |
| 688 | if (!p || !n) | - |
| 689 | return formats; | - |
| 690 | | - |
| 691 | const QTextFormatCollection *formatCollection = p->formatCollection(); | - |
| 692 | | - |
| 693 | int start = 0; | - |
| 694 | int cur = start; | - |
| 695 | int format = -1; | - |
| 696 | | - |
| 697 | const int pos = position(); | - |
| 698 | QTextDocumentPrivate::FragmentIterator it = p->find(pos); | - |
| 699 | QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); | - |
| 700 | for (; it != end; ++it) { | - |
| 701 | const QTextFragmentData * const frag = it.value(); | - |
| 702 | if (format != it.value()->format) { | - |
| 703 | if (cur - start > 0) { | - |
| 704 | QTextLayout::FormatRange range; | - |
| 705 | range.start = start; | - |
| 706 | range.length = cur - start; | - |
| 707 | range.format = formatCollection->charFormat(format); | - |
| 708 | formats.append(range); | - |
| 709 | } | - |
| 710 | | - |
| 711 | format = frag->format; | - |
| 712 | start = cur; | - |
| 713 | } | - |
| 714 | cur += frag->size_array[0]; | - |
| 715 | } | - |
| 716 | if (cur - start > 0) { | - |
| 717 | QTextLayout::FormatRange range; | - |
| 718 | range.start = start; | - |
| 719 | range.length = cur - start; | - |
| 720 | range.format = formatCollection->charFormat(format); | - |
| 721 | formats.append(range); | - |
| 722 | } | - |
| 723 | | - |
| 724 | return formats; | - |
| 725 | } | - |
| 726 | | - |
| 727 | | - |
| 728 | | - |
| 729 | | - |
| 730 | | - |
| 731 | const QTextDocument *QTextBlock::document() const | - |
| 732 | { | - |
| 733 | return p ? p->document() : 0; | - |
| 734 | } | - |
| 735 | | - |
| 736 | | - |
| 737 | | - |
| 738 | | - |
| 739 | | - |
| 740 | QTextList *QTextBlock::textList() const | - |
| 741 | { | - |
| 742 | if (!isValid()) | - |
| 743 | return 0; | - |
| 744 | | - |
| 745 | const QTextBlockFormat fmt = blockFormat(); | - |
| 746 | QTextObject *obj = p->document()->objectForFormat(fmt); | - |
| 747 | return qobject_cast<QTextList *>(obj); | - |
| 748 | } | - |
| 749 | | - |
| 750 | | - |
| 751 | | - |
| 752 | | - |
| 753 | | - |
| 754 | | - |
| 755 | | - |
| 756 | QTextBlockUserData *QTextBlock::userData() const | - |
| 757 | { | - |
| 758 | if (!p || !n) | - |
| 759 | return 0; | - |
| 760 | | - |
| 761 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 762 | return b->userData; | - |
| 763 | } | - |
| 764 | void QTextBlock::setUserData(QTextBlockUserData *data) | - |
| 765 | { | - |
| 766 | if (!p || !n) | - |
| 767 | return; | - |
| 768 | | - |
| 769 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 770 | if (data != b->userData) | - |
| 771 | delete b->userData; | - |
| 772 | b->userData = data; | - |
| 773 | } | - |
| 774 | | - |
| 775 | | - |
| 776 | | - |
| 777 | | - |
| 778 | | - |
| 779 | | - |
| 780 | int QTextBlock::userState() const | - |
| 781 | { | - |
| 782 | if (!p || !n) | - |
| 783 | return -1; | - |
| 784 | | - |
| 785 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 786 | return b->userState; | - |
| 787 | } | - |
| 788 | | - |
| 789 | | - |
| 790 | | - |
| 791 | | - |
| 792 | | - |
| 793 | | - |
| 794 | | - |
| 795 | void QTextBlock::setUserState(int state) | - |
| 796 | { | - |
| 797 | if (!p || !n) | - |
| 798 | return; | - |
| 799 | | - |
| 800 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 801 | b->userState = state; | - |
| 802 | } | - |
| 803 | int QTextBlock::revision() const | - |
| 804 | { | - |
| 805 | if (!p || !n) | - |
| 806 | return -1; | - |
| 807 | | - |
| 808 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 809 | return b->revision; | - |
| 810 | } | - |
| 811 | void QTextBlock::setRevision(int rev) | - |
| 812 | { | - |
| 813 | if (!p || !n) | - |
| 814 | return; | - |
| 815 | | - |
| 816 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 817 | b->revision = rev; | - |
| 818 | } | - |
| 819 | bool QTextBlock::isVisible() const | - |
| 820 | { | - |
| 821 | if (!p || !n) | - |
| 822 | return true; | - |
| 823 | | - |
| 824 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 825 | return !b->hidden; | - |
| 826 | } | - |
| 827 | void QTextBlock::setVisible(bool visible) | - |
| 828 | { | - |
| 829 | if (!p || !n) | - |
| 830 | return; | - |
| 831 | | - |
| 832 | const QTextBlockData *b = p->blockMap().fragment(n); | - |
| 833 | b->hidden = !visible; | - |
| 834 | } | - |
| 835 | int QTextBlock::blockNumber() const | - |
| 836 | { | - |
| 837 | if (!p || !n) | - |
| 838 | return -1; | - |
| 839 | return p->blockMap().position(n, 1); | - |
| 840 | } | - |
| 841 | int QTextBlock::firstLineNumber() const | - |
| 842 | { | - |
| 843 | if (!p || !n) | - |
| 844 | return -1; | - |
| 845 | return p->blockMap().position(n, 2); | - |
| 846 | } | - |
| 847 | void QTextBlock::setLineCount(int count) | - |
| 848 | { | - |
| 849 | if (!p || !n) | - |
| 850 | return; | - |
| 851 | p->blockMap().setSize(n, count, 2); | - |
| 852 | } | - |
| 853 | | - |
| 854 | | - |
| 855 | | - |
| 856 | | - |
| 857 | | - |
| 858 | | - |
| 859 | | - |
| 860 | int QTextBlock::lineCount() const | - |
| 861 | { | - |
| 862 | if (!p || !n) | - |
| 863 | return -1; | - |
| 864 | return p->blockMap().size(n, 2); | - |
| 865 | } | - |
| 866 | QTextBlock::iterator QTextBlock::begin() const | - |
| 867 | { | - |
| 868 | if (!p || !n) | - |
| 869 | return iterator(); | - |
| 870 | | - |
| 871 | int pos = position(); | - |
| 872 | int len = length() - 1; | - |
| 873 | int b = p->fragmentMap().findNode(pos); | - |
| 874 | int e = p->fragmentMap().findNode(pos+len); | - |
| 875 | return iterator(p, b, e, b); | - |
| 876 | } | - |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | QTextBlock::iterator QTextBlock::end() const | - |
| 885 | { | - |
| 886 | if (!p || !n) | - |
| 887 | return iterator(); | - |
| 888 | | - |
| 889 | int pos = position(); | - |
| 890 | int len = length() - 1; | - |
| 891 | int b = p->fragmentMap().findNode(pos); | - |
| 892 | int e = p->fragmentMap().findNode(pos+len); | - |
| 893 | return iterator(p, b, e, e); | - |
| 894 | } | - |
| 895 | QTextBlock QTextBlock::next() const | - |
| 896 | { | - |
| 897 | if (!isValid()) | - |
| 898 | return QTextBlock(); | - |
| 899 | | - |
| 900 | return QTextBlock(p, p->blockMap().next(n)); | - |
| 901 | } | - |
| 902 | QTextBlock QTextBlock::previous() const | - |
| 903 | { | - |
| 904 | if (!p) | - |
| 905 | return QTextBlock(); | - |
| 906 | | - |
| 907 | return QTextBlock(p, p->blockMap().previous(n)); | - |
| 908 | } | - |
| 909 | | - |
| 910 | | - |
| 911 | | - |
| 912 | | - |
| 913 | | - |
| 914 | QTextFragment QTextBlock::iterator::fragment() const | - |
| 915 | { | - |
| 916 | int ne = n; | - |
| 917 | int formatIndex = p->fragmentMap().fragment(n)->format; | - |
| 918 | do { | - |
| 919 | ne = p->fragmentMap().next(ne); | - |
| 920 | } while (ne != e && p->fragmentMap().fragment(ne)->format == formatIndex); | - |
| 921 | return QTextFragment(p, n, ne); | - |
| 922 | } | - |
| 923 | | - |
| 924 | | - |
| 925 | | - |
| 926 | | - |
| 927 | | - |
| 928 | | - |
| 929 | | - |
| 930 | QTextBlock::iterator &QTextBlock::iterator::operator++() | - |
| 931 | { | - |
| 932 | int ne = n; | - |
| 933 | int formatIndex = p->fragmentMap().fragment(n)->format; | - |
| 934 | do { | - |
| 935 | ne = p->fragmentMap().next(ne); | - |
| 936 | } while (ne != e && p->fragmentMap().fragment(ne)->format == formatIndex); | - |
| 937 | n = ne; | - |
| 938 | return *this; | - |
| 939 | } | - |
| 940 | | - |
| 941 | | - |
| 942 | | - |
| 943 | | - |
| 944 | | - |
| 945 | | - |
| 946 | QTextBlock::iterator &QTextBlock::iterator::operator--() | - |
| 947 | { | - |
| 948 | n = p->fragmentMap().previous(n); | - |
| 949 | | - |
| 950 | if (n == b) | - |
| 951 | return *this; | - |
| 952 | | - |
| 953 | int formatIndex = p->fragmentMap().fragment(n)->format; | - |
| 954 | int last = n; | - |
| 955 | | - |
| 956 | while (n != b && p->fragmentMap().fragment(n)->format != formatIndex) { | - |
| 957 | last = n; | - |
| 958 | n = p->fragmentMap().previous(n); | - |
| 959 | } | - |
| 960 | | - |
| 961 | n = last; | - |
| 962 | return *this; | - |
| 963 | } | - |
| 964 | QList<QGlyphRun> QTextFragment::glyphRuns(int pos, int len) const | - |
| 965 | { | - |
| 966 | if (!p || !n) | - |
| 967 | return QList<QGlyphRun>(); | - |
| 968 | | - |
| 969 | int blockNode = p->blockMap().findNode(position()); | - |
| 970 | | - |
| 971 | const QTextBlockData *blockData = p->blockMap().fragment(blockNode); | - |
| 972 | QTextLayout *layout = blockData->layout; | - |
| 973 | | - |
| 974 | int blockPosition = p->blockMap().position(blockNode); | - |
| 975 | if (pos < 0) | - |
| 976 | pos = position() - blockPosition; | - |
| 977 | if (len < 0) | - |
| 978 | len = length(); | - |
| 979 | if (len == 0) | - |
| 980 | return QList<QGlyphRun>(); | - |
| 981 | | - |
| 982 | QList<QGlyphRun> ret; | - |
| 983 | for (int i=0; i<layout->lineCount(); ++i) { | - |
| 984 | QTextLine textLine = layout->lineAt(i); | - |
| 985 | ret += textLine.glyphRuns(pos, len); | - |
| 986 | } | - |
| 987 | | - |
| 988 | return ret; | - |
| 989 | } | - |
| 990 | | - |
| 991 | | - |
| 992 | | - |
| 993 | | - |
| 994 | | - |
| 995 | int QTextFragment::position() const | - |
| 996 | { | - |
| 997 | if (!p || !n) | - |
| 998 | return 0; | - |
| 999 | | - |
| 1000 | return p->fragmentMap().position(n); | - |
| 1001 | } | - |
| 1002 | | - |
| 1003 | | - |
| 1004 | | - |
| 1005 | | - |
| 1006 | | - |
| 1007 | | - |
| 1008 | int QTextFragment::length() const | - |
| 1009 | { | - |
| 1010 | if (!p || !n) | - |
| 1011 | return 0; | - |
| 1012 | | - |
| 1013 | int len = 0; | - |
| 1014 | int f = n; | - |
| 1015 | while (f != ne) { | - |
| 1016 | len += p->fragmentMap().size(f); | - |
| 1017 | f = p->fragmentMap().next(f); | - |
| 1018 | } | - |
| 1019 | return len; | - |
| 1020 | } | - |
| 1021 | | - |
| 1022 | | - |
| 1023 | | - |
| 1024 | | - |
| 1025 | | - |
| 1026 | bool QTextFragment::contains(int position) const | - |
| 1027 | { | - |
| 1028 | if (!p || !n) | - |
| 1029 | return false; | - |
| 1030 | int pos = this->position(); | - |
| 1031 | return position >= pos && position < pos + length(); | - |
| 1032 | } | - |
| 1033 | | - |
| 1034 | | - |
| 1035 | | - |
| 1036 | | - |
| 1037 | | - |
| 1038 | | - |
| 1039 | QTextCharFormat QTextFragment::charFormat() const | - |
| 1040 | { | - |
| 1041 | if (!p || !n) | - |
| 1042 | return QTextCharFormat(); | - |
| 1043 | const QTextFragmentData *data = p->fragmentMap().fragment(n); | - |
| 1044 | return p->formatCollection()->charFormat(data->format); | - |
| 1045 | } | - |
| 1046 | | - |
| 1047 | | - |
| 1048 | | - |
| 1049 | | - |
| 1050 | | - |
| 1051 | | - |
| 1052 | | - |
| 1053 | int QTextFragment::charFormatIndex() const | - |
| 1054 | { | - |
| 1055 | if (!p || !n) | - |
| 1056 | return -1; | - |
| 1057 | const QTextFragmentData *data = p->fragmentMap().fragment(n); | - |
| 1058 | return data->format; | - |
| 1059 | } | - |
| 1060 | | - |
| 1061 | | - |
| 1062 | | - |
| 1063 | | - |
| 1064 | | - |
| 1065 | | - |
| 1066 | QString QTextFragment::text() const | - |
| 1067 | { | - |
| 1068 | if (!p || !n) | - |
| 1069 | return QString(); | - |
| 1070 | | - |
| 1071 | QString result; | - |
| 1072 | QString buffer = p->buffer(); | - |
| 1073 | int f = n; | - |
| 1074 | while (f != ne) { | - |
| 1075 | const QTextFragmentData * const frag = p->fragmentMap().fragment(f); | - |
| 1076 | result += QString(buffer.constData() + frag->stringPosition, frag->size_array[0]); | - |
| 1077 | f = p->fragmentMap().next(f); | - |
| 1078 | } | - |
| 1079 | return result; | - |
| 1080 | } | - |
| 1081 | | - |
| 1082 | | - |
| | |