| Line | Source | Count | 
| 1 |  | - | 
| 2 |  | - | 
| 3 |  | - | 
| 4 |  | - | 
| 5 |  | - | 
| 6 |  | - | 
| 7 |  | - | 
| 8 |  | - | 
| 9 |  | - | 
| 10 |  | - | 
| 11 |  | - | 
| 12 |  | - | 
| 13 |  | - | 
| 14 |  | - | 
| 15 |  | - | 
| 16 |  | - | 
| 17 |  | - | 
| 18 |  | - | 
| 19 |  | - | 
| 20 |  | - | 
| 21 |  | - | 
| 22 |  | - | 
| 23 |  | - | 
| 24 |  | - | 
| 25 |  | - | 
| 26 |  | - | 
| 27 |  | - | 
| 28 |  | - | 
| 29 |  | - | 
| 30 |  | - | 
| 31 |  | - | 
| 32 |  | - | 
| 33 |  | - | 
| 34 |  | - | 
| 35 |  | - | 
| 36 |  | - | 
| 37 |  | - | 
| 38 |  | - | 
| 39 |  | - | 
| 40 | #include "qtextdocument.h" | - | 
| 41 | #include <qtextformat.h> | - | 
| 42 | #include "qtextcursor_p.h" | - | 
| 43 | #include "qtextdocumentlayout_p.h" | - | 
| 44 | #include "qtextdocumentfragment.h" | - | 
| 45 | #include "qtextdocumentfragment_p.h" | - | 
| 46 | #include "qtexttable.h" | - | 
| 47 | #include "qtextlist.h" | - | 
| 48 | #include <qdebug.h> | - | 
| 49 | #include <qregexp.h> | - | 
| 50 | #include <qregularexpression.h> | - | 
| 51 | #include <qvarlengtharray.h> | - | 
| 52 | #include <qtextcodec.h> | - | 
| 53 | #include <qthread.h> | - | 
| 54 | #include <qcoreapplication.h> | - | 
| 55 | #include <qmetaobject.h> | - | 
| 56 |  | - | 
| 57 | #include "qtexthtmlparser_p.h" | - | 
| 58 | #include "qpainter.h" | - | 
| 59 | #include <qfile.h> | - | 
| 60 | #include <qfileinfo.h> | - | 
| 61 | #include <qdir.h> | - | 
| 62 | #include "qfont_p.h" | - | 
| 63 | #include "private/qdataurl_p.h" | - | 
| 64 |  | - | 
| 65 | #include "qtextdocument_p.h" | - | 
| 66 | #include <private/qabstracttextdocumentlayout_p.h> | - | 
| 67 | #include "qpagedpaintdevice.h" | - | 
| 68 | #include "private/qpagedpaintdevice_p.h" | - | 
| 69 |  | - | 
| 70 | #include <limits.h> | - | 
| 71 |  | - | 
| 72 | QT_BEGIN_NAMESPACE | - | 
| 73 |  | - | 
| 74 | Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n); | - | 
| 75 |  | - | 
| 76 |  | - | 
| 77 |  | - | 
| 78 |  | - | 
| 79 |  | - | 
| 80 |  | - | 
| 81 |  | - | 
| 82 |  | - | 
| 83 |  | - | 
| 84 |  | - | 
| 85 |  | - | 
| 86 |  | - | 
| 87 | bool Qt::mightBeRichText(const QString& text) | - | 
| 88 | { | - | 
| 89 |     if (text.isEmpty()) | - | 
| 90 |         return false; | - | 
| 91 |     int start = 0; | - | 
| 92 |  | - | 
| 93 |     while (start < text.length() && text.at(start).isSpace()) | - | 
| 94 |         ++start; | - | 
| 95 |  | - | 
| 96 |      | - | 
| 97 |     if (text.mid(start, 5) == QLatin1String("<?xml")) { | - | 
| 98 |         while (start < text.length()) { | - | 
| 99 |             if (text.at(start) == QLatin1Char('?') | - | 
| 100 |                 && start + 2 < text.length() | - | 
| 101 |                 && text.at(start + 1) == QLatin1Char('>')) { | - | 
| 102 |                 start += 2; | - | 
| 103 |                 break; | - | 
| 104 |             } | - | 
| 105 |             ++start; | - | 
| 106 |         } | - | 
| 107 |  | - | 
| 108 |         while (start < text.length() && text.at(start).isSpace()) | - | 
| 109 |             ++start; | - | 
| 110 |     } | - | 
| 111 |  | - | 
| 112 |     if (text.mid(start, 5).toLower() == QLatin1String("<!doc")) | - | 
| 113 |         return true; | - | 
| 114 |     int open = start; | - | 
| 115 |     while (open < text.length() && text.at(open) != QLatin1Char('<') | - | 
| 116 |             && text.at(open) != QLatin1Char('\n')) { | - | 
| 117 |         if (text.at(open) == QLatin1Char('&') &&  text.mid(open+1,3) == QLatin1String("lt;")) | - | 
| 118 |             return true;  | - | 
| 119 |         ++open; | - | 
| 120 |     } | - | 
| 121 |     if (open < text.length() && text.at(open) == QLatin1Char('<')) { | - | 
| 122 |         const int close = text.indexOf(QLatin1Char('>'), open); | - | 
| 123 |         if (close > -1) { | - | 
| 124 |             QString tag; | - | 
| 125 |             for (int i = open+1; i < close; ++i) { | - | 
| 126 |                 if (text[i].isDigit() || text[i].isLetter()) | - | 
| 127 |                     tag += text[i]; | - | 
| 128 |                 else if (!tag.isEmpty() && text[i].isSpace()) | - | 
| 129 |                     break; | - | 
| 130 |                 else if (!tag.isEmpty() && text[i] == QLatin1Char('/') && i + 1 == close) | - | 
| 131 |                     break; | - | 
| 132 |                 else if (!text[i].isSpace() && (!tag.isEmpty() || text[i] != QLatin1Char('!'))) | - | 
| 133 |                     return false;  | - | 
| 134 |             } | - | 
| 135 | #ifndef QT_NO_TEXTHTMLPARSER | - | 
| 136 |             return QTextHtmlParser::lookupElement(tag.toLower()) != -1; | - | 
| 137 | #else | - | 
| 138 |             return false; | - | 
| 139 | #endif // QT_NO_TEXTHTMLPARSER | - | 
| 140 |         } | - | 
| 141 |     } | - | 
| 142 |     return false; | - | 
| 143 | } | - | 
| 144 |  | - | 
| 145 |  | - | 
| 146 |  | - | 
| 147 |  | - | 
| 148 |  | - | 
| 149 |  | - | 
| 150 |  | - | 
| 151 |  | - | 
| 152 |  | - | 
| 153 |  | - | 
| 154 |  | - | 
| 155 |  | - | 
| 156 | QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode) | - | 
| 157 | { | - | 
| 158 |     int col = 0; | - | 
| 159 |     QString rich; | - | 
| 160 |     rich += QLatin1String("<p>"); | - | 
| 161 |     for (int i = 0; i < plain.length(); ++i) { | - | 
| 162 |         if (plain[i] == QLatin1Char('\n')){ | - | 
| 163 |             int c = 1; | - | 
| 164 |             while (i+1 < plain.length() && plain[i+1] == QLatin1Char('\n')) { | - | 
| 165 |                 i++; | - | 
| 166 |                 c++; | - | 
| 167 |             } | - | 
| 168 |             if (c == 1) | - | 
| 169 |                 rich += QLatin1String("<br>\n"); | - | 
| 170 |             else { | - | 
| 171 |                 rich += QLatin1String("</p>\n"); | - | 
| 172 |                 while (--c > 1) | - | 
| 173 |                     rich += QLatin1String("<br>\n"); | - | 
| 174 |                 rich += QLatin1String("<p>"); | - | 
| 175 |             } | - | 
| 176 |             col = 0; | - | 
| 177 |         } else { | - | 
| 178 |             if (mode == Qt::WhiteSpacePre && plain[i] == QLatin1Char('\t')){ | - | 
| 179 |                 rich += QChar(0x00a0U); | - | 
| 180 |                 ++col; | - | 
| 181 |                 while (col % 8) { | - | 
| 182 |                     rich += QChar(0x00a0U); | - | 
| 183 |                     ++col; | - | 
| 184 |                 } | - | 
| 185 |             } | - | 
| 186 |             else if (mode == Qt::WhiteSpacePre && plain[i].isSpace()) | - | 
| 187 |                 rich += QChar(0x00a0U); | - | 
| 188 |             else if (plain[i] == QLatin1Char('<')) | - | 
| 189 |                 rich += QLatin1String("<"); | - | 
| 190 |             else if (plain[i] == QLatin1Char('>')) | - | 
| 191 |                 rich += QLatin1String(">"); | - | 
| 192 |             else if (plain[i] == QLatin1Char('&')) | - | 
| 193 |                 rich += QLatin1String("&"); | - | 
| 194 |             else | - | 
| 195 |                 rich += plain[i]; | - | 
| 196 |             ++col; | - | 
| 197 |         } | - | 
| 198 |     } | - | 
| 199 |     if (col != 0) | - | 
| 200 |         rich += QLatin1String("</p>"); | - | 
| 201 |     return rich; | - | 
| 202 | } | - | 
| 203 |  | - | 
| 204 | #ifndef QT_NO_TEXTCODEC | - | 
| 205 |  | - | 
| 206 |  | - | 
| 207 |  | - | 
| 208 |  | - | 
| 209 |  | - | 
| 210 | QTextCodec *Qt::codecForHtml(const QByteArray &ba) | - | 
| 211 | { | - | 
| 212 |     return QTextCodec::codecForHtml(ba); | - | 
| 213 | } | - | 
| 214 | #endif | - | 
| 215 |  | - | 
| 216 |  | - | 
| 217 |  | - | 
| 218 |  | - | 
| 219 |  | - | 
| 220 |  | - | 
| 221 |  | - | 
| 222 |  | - | 
| 223 |  | - | 
| 224 |  | - | 
| 225 |  | - | 
| 226 |  | - | 
| 227 |  | - | 
| 228 |  | - | 
| 229 |  | - | 
| 230 |  | - | 
| 231 |  | - | 
| 232 |  | - | 
| 233 |  | - | 
| 234 |  | - | 
| 235 |  | - | 
| 236 |  | - | 
| 237 |  | - | 
| 238 |  | - | 
| 239 |  | - | 
| 240 |  | - | 
| 241 |  | - | 
| 242 |  | - | 
| 243 |  | - | 
| 244 |  | - | 
| 245 |  | - | 
| 246 |  | - | 
| 247 |  | - | 
| 248 |  | - | 
| 249 |  | - | 
| 250 |  | - | 
| 251 |  | - | 
| 252 |  | - | 
| 253 |  | - | 
| 254 |  | - | 
| 255 |  | - | 
| 256 |  | - | 
| 257 |  | - | 
| 258 |  | - | 
| 259 |  | - | 
| 260 |  | - | 
| 261 |  | - | 
| 262 |  | - | 
| 263 |  | - | 
| 264 |  | - | 
| 265 |  | - | 
| 266 |  | - | 
| 267 |  | - | 
| 268 |  | - | 
| 269 |  | - | 
| 270 |  | - | 
| 271 |  | - | 
| 272 |  | - | 
| 273 |  | - | 
| 274 |  | - | 
| 275 |  | - | 
| 276 |  | - | 
| 277 |  | - | 
| 278 |  | - | 
| 279 |  | - | 
| 280 |  | - | 
| 281 |  | - | 
| 282 |  | - | 
| 283 |  | - | 
| 284 |  | - | 
| 285 |  | - | 
| 286 |  | - | 
| 287 |  | - | 
| 288 |  | - | 
| 289 |  | - | 
| 290 |  | - | 
| 291 |  | - | 
| 292 |  | - | 
| 293 |  | - | 
| 294 | QTextDocument::QTextDocument(QObject *parent) | - | 
| 295 |     : QObject(*new QTextDocumentPrivate, parent) | - | 
| 296 | { | - | 
| 297 |     Q_D(QTextDocument); | - | 
| 298 |     d->init(); | - | 
| 299 | } | - | 
| 300 |  | - | 
| 301 |  | - | 
| 302 |  | - | 
| 303 |  | - | 
| 304 |  | - | 
| 305 | QTextDocument::QTextDocument(const QString &text, QObject *parent) | - | 
| 306 |     : QObject(*new QTextDocumentPrivate, parent) | - | 
| 307 | { | - | 
| 308 |     Q_D(QTextDocument); | - | 
| 309 |     d->init(); | - | 
| 310 |     QTextCursor(this).insertText(text); | - | 
| 311 | } | - | 
| 312 |  | - | 
| 313 |  | - | 
| 314 |  | - | 
| 315 |  | - | 
| 316 | QTextDocument::QTextDocument(QTextDocumentPrivate &dd, QObject *parent) | - | 
| 317 |     : QObject(dd, parent) | - | 
| 318 | { | - | 
| 319 |     Q_D(QTextDocument); | - | 
| 320 |     d->init(); | - | 
| 321 | } | - | 
| 322 |  | - | 
| 323 |  | - | 
| 324 |  | - | 
| 325 |  | - | 
| 326 | QTextDocument::~QTextDocument() | - | 
| 327 | { | - | 
| 328 | } | - | 
| 329 |  | - | 
| 330 |  | - | 
| 331 |  | - | 
| 332 |  | - | 
| 333 |  | - | 
| 334 |  | - | 
| 335 | QTextDocument *QTextDocument::clone(QObject *parent) const | - | 
| 336 | { | - | 
| 337 |     Q_D(const QTextDocument); | - | 
| 338 |     QTextDocument *doc = new QTextDocument(parent); | - | 
| 339 |     QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); | - | 
| 340 |     doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat()); | - | 
| 341 |     QTextDocumentPrivate *priv = doc->d_func(); | - | 
| 342 |     priv->title = d->title; | - | 
| 343 |     priv->url = d->url; | - | 
| 344 |     priv->pageSize = d->pageSize; | - | 
| 345 |     priv->indentWidth = d->indentWidth; | - | 
| 346 |     priv->defaultTextOption = d->defaultTextOption; | - | 
| 347 |     priv->setDefaultFont(d->defaultFont()); | - | 
| 348 |     priv->resources = d->resources; | - | 
| 349 |     priv->cachedResources.clear(); | - | 
| 350 | #ifndef QT_NO_CSSPARSER | - | 
| 351 |     priv->defaultStyleSheet = d->defaultStyleSheet; | - | 
| 352 |     priv->parsedDefaultStyleSheet = d->parsedDefaultStyleSheet; | - | 
| 353 | #endif | - | 
| 354 |     return doc; | - | 
| 355 | } | - | 
| 356 |  | - | 
| 357 |  | - | 
| 358 |  | - | 
| 359 |  | - | 
| 360 | bool QTextDocument::isEmpty() const | - | 
| 361 | { | - | 
| 362 |     Q_D(const QTextDocument); | - | 
| 363 |      | - | 
| 364 |  | - | 
| 365 |     return d->length() <= 1; | - | 
| 366 | } | - | 
| 367 |  | - | 
| 368 |  | - | 
| 369 |  | - | 
| 370 |  | - | 
| 371 | void QTextDocument::clear() | - | 
| 372 | { | - | 
| 373 |     Q_D(QTextDocument); | - | 
| 374 |     d->clear(); | - | 
| 375 |     d->resources.clear(); | - | 
| 376 | } | - | 
| 377 |  | - | 
| 378 |  | - | 
| 379 |  | - | 
| 380 |  | - | 
| 381 |  | - | 
| 382 |  | - | 
| 383 |  | - | 
| 384 |  | - | 
| 385 |  | - | 
| 386 |  | - | 
| 387 |  | - | 
| 388 |  | - | 
| 389 |  | - | 
| 390 | void QTextDocument::undo(QTextCursor *cursor) | - | 
| 391 | { | - | 
| 392 |     Q_D(QTextDocument); | - | 
| 393 |     const int pos = d->undoRedo(true); | - | 
| 394 |     if (cursor && pos >= 0) { | - | 
| 395 |         *cursor = QTextCursor(this); | - | 
| 396 |         cursor->setPosition(pos); | - | 
| 397 |     } | - | 
| 398 | } | - | 
| 399 |  | - | 
| 400 |  | - | 
| 401 |  | - | 
| 402 |  | - | 
| 403 |  | - | 
| 404 |  | - | 
| 405 |  | - | 
| 406 |  | - | 
| 407 | void QTextDocument::redo(QTextCursor *cursor) | - | 
| 408 | { | - | 
| 409 |     Q_D(QTextDocument); | - | 
| 410 |     const int pos = d->undoRedo(false); | - | 
| 411 |     if (cursor && pos >= 0) { | - | 
| 412 |         *cursor = QTextCursor(this); | - | 
| 413 |         cursor->setPosition(pos); | - | 
| 414 |     } | - | 
| 415 | } | - | 
| 416 |  | - | 
| 417 |  | - | 
| 418 |  | - | 
| 419 |  | - | 
| 420 |  | - | 
| 421 |  | - | 
| 422 |  | - | 
| 423 |  | - | 
| 424 |  | - | 
| 425 |  | - | 
| 426 |  | - | 
| 427 |  | - | 
| 428 |  | - | 
| 429 |  | - | 
| 430 |  | - | 
| 431 |  | - | 
| 432 |  | - | 
| 433 |  | - | 
| 434 |  | - | 
| 435 | void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear) | - | 
| 436 | { | - | 
| 437 |     Q_D(QTextDocument); | - | 
| 438 |     d->clearUndoRedoStacks(stacksToClear, true); | - | 
| 439 | } | - | 
| 440 |  | - | 
| 441 |  | - | 
| 442 |  | - | 
| 443 |  | - | 
| 444 |  | - | 
| 445 | void QTextDocument::undo() | - | 
| 446 | { | - | 
| 447 |     Q_D(QTextDocument); | - | 
| 448 |     d->undoRedo(true); | - | 
| 449 | } | - | 
| 450 |  | - | 
| 451 |  | - | 
| 452 |  | - | 
| 453 |  | - | 
| 454 |  | - | 
| 455 | void QTextDocument::redo() | - | 
| 456 | { | - | 
| 457 |     Q_D(QTextDocument); | - | 
| 458 |     d->undoRedo(false); | - | 
| 459 | } | - | 
| 460 |  | - | 
| 461 |  | - | 
| 462 |  | - | 
| 463 |  | - | 
| 464 |  | - | 
| 465 |  | - | 
| 466 | void QTextDocument::appendUndoItem(QAbstractUndoItem *item) | - | 
| 467 | { | - | 
| 468 |     Q_D(QTextDocument); | - | 
| 469 |     d->appendUndoItem(item); | - | 
| 470 | } | - | 
| 471 |  | - | 
| 472 |  | - | 
| 473 |  | - | 
| 474 |  | - | 
| 475 |  | - | 
| 476 |  | - | 
| 477 |  | - | 
| 478 |  | - | 
| 479 | void QTextDocument::setUndoRedoEnabled(bool enable) | - | 
| 480 | { | - | 
| 481 |     Q_D(QTextDocument); | - | 
| 482 |     d->enableUndoRedo(enable); | - | 
| 483 | } | - | 
| 484 |  | - | 
| 485 | bool QTextDocument::isUndoRedoEnabled() const | - | 
| 486 | { | - | 
| 487 |     Q_D(const QTextDocument); | - | 
| 488 |     return d->isUndoRedoEnabled(); | - | 
| 489 | } | - | 
| 490 |  | - | 
| 491 |  | - | 
| 492 |  | - | 
| 493 |  | - | 
| 494 |  | - | 
| 495 |  | - | 
| 496 |  | - | 
| 497 |  | - | 
| 498 |  | - | 
| 499 |  | - | 
| 500 |  | - | 
| 501 |  | - | 
| 502 |  | - | 
| 503 |  | - | 
| 504 |  | - | 
| 505 |  | - | 
| 506 |  | - | 
| 507 |  | - | 
| 508 |  | - | 
| 509 |  | - | 
| 510 |  | - | 
| 511 |  | - | 
| 512 | int QTextDocument::maximumBlockCount() const | - | 
| 513 | { | - | 
| 514 |     Q_D(const QTextDocument); | - | 
| 515 |     return d->maximumBlockCount; | - | 
| 516 | } | - | 
| 517 |  | - | 
| 518 | void QTextDocument::setMaximumBlockCount(int maximum) | - | 
| 519 | { | - | 
| 520 |     Q_D(QTextDocument); | - | 
| 521 |     d->maximumBlockCount = maximum; | - | 
| 522 |     d->ensureMaximumBlockCount(); | - | 
| 523 |     setUndoRedoEnabled(false); | - | 
| 524 | } | - | 
| 525 |  | - | 
| 526 |  | - | 
| 527 |  | - | 
| 528 |  | - | 
| 529 |  | - | 
| 530 |  | - | 
| 531 |  | - | 
| 532 |  | - | 
| 533 | QTextOption QTextDocument::defaultTextOption() const | - | 
| 534 | { | - | 
| 535 |     Q_D(const QTextDocument); | - | 
| 536 |     return d->defaultTextOption; | - | 
| 537 | } | - | 
| 538 |  | - | 
| 539 |  | - | 
| 540 |  | - | 
| 541 |  | - | 
| 542 |  | - | 
| 543 |  | - | 
| 544 | void QTextDocument::setDefaultTextOption(const QTextOption &option) | - | 
| 545 | { | - | 
| 546 |     Q_D(QTextDocument); | - | 
| 547 |     d->defaultTextOption = option; | - | 
| 548 |     if (d->lout) | - | 
| 549 |         d->lout->documentChanged(0, 0, d->length()); | - | 
| 550 | } | - | 
| 551 |  | - | 
| 552 |  | - | 
| 553 |  | - | 
| 554 |  | - | 
| 555 |  | - | 
| 556 |  | - | 
| 557 |  | - | 
| 558 |  | - | 
| 559 |  | - | 
| 560 |  | - | 
| 561 |  | - | 
| 562 |  | - | 
| 563 |  | - | 
| 564 |  | - | 
| 565 |  | - | 
| 566 |  | - | 
| 567 |  | - | 
| 568 | QUrl QTextDocument::baseUrl() const | - | 
| 569 | { | - | 
| 570 |     Q_D(const QTextDocument); | - | 
| 571 |     return d->baseUrl; | - | 
| 572 | } | - | 
| 573 |  | - | 
| 574 | void QTextDocument::setBaseUrl(const QUrl &url) | - | 
| 575 | { | - | 
| 576 |     Q_D(QTextDocument); | - | 
| 577 |     if (d->baseUrl != url) { | - | 
| 578 |         d->baseUrl = url; | - | 
| 579 |         if (d->lout) | - | 
| 580 |             d->lout->documentChanged(0, 0, d->length()); | - | 
| 581 |         emit baseUrlChanged(url); | - | 
| 582 |     } | - | 
| 583 | } | - | 
| 584 |  | - | 
| 585 |  | - | 
| 586 |  | - | 
| 587 |  | - | 
| 588 |  | - | 
| 589 |  | - | 
| 590 |  | - | 
| 591 | Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const | - | 
| 592 | { | - | 
| 593 |     Q_D(const QTextDocument); | - | 
| 594 |     return d->defaultCursorMoveStyle; | - | 
| 595 | } | - | 
| 596 |  | - | 
| 597 |  | - | 
| 598 |  | - | 
| 599 |  | - | 
| 600 |  | - | 
| 601 |  | - | 
| 602 | void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style) | - | 
| 603 | { | - | 
| 604 |     Q_D(QTextDocument); | - | 
| 605 |     d->defaultCursorMoveStyle = style; | - | 
| 606 | } | - | 
| 607 |  | - | 
| 608 |  | - | 
| 609 |  | - | 
| 610 |  | - | 
| 611 |  | - | 
| 612 |  | - | 
| 613 |  | - | 
| 614 |  | - | 
| 615 | void QTextDocument::markContentsDirty(int from, int length) | - | 
| 616 | { | - | 
| 617 |     Q_D(QTextDocument); | - | 
| 618 |     d->documentChange(from, length); | - | 
| 619 |     if (!d->inContentsChange) { | - | 
| 620 |         if (d->lout) { | - | 
| 621 |             d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength); | - | 
| 622 |             d->docChangeFrom = -1; | - | 
| 623 |         } | - | 
| 624 |     } | - | 
| 625 | } | - | 
| 626 |  | - | 
| 627 |  | - | 
| 628 |  | - | 
| 629 |  | - | 
| 630 |  | - | 
| 631 |  | - | 
| 632 |  | - | 
| 633 |  | - | 
| 634 |  | - | 
| 635 |  | - | 
| 636 |  | - | 
| 637 |  | - | 
| 638 |  | - | 
| 639 |  | - | 
| 640 |  | - | 
| 641 |  | - | 
| 642 |  | - | 
| 643 | void QTextDocument::setUseDesignMetrics(bool b) | - | 
| 644 | { | - | 
| 645 |     Q_D(QTextDocument); | - | 
| 646 |     if (b == d->defaultTextOption.useDesignMetrics()) | - | 
| 647 |         return; | - | 
| 648 |     d->defaultTextOption.setUseDesignMetrics(b); | - | 
| 649 |     if (d->lout) | - | 
| 650 |         d->lout->documentChanged(0, 0, d->length()); | - | 
| 651 | } | - | 
| 652 |  | - | 
| 653 | bool QTextDocument::useDesignMetrics() const | - | 
| 654 | { | - | 
| 655 |     Q_D(const QTextDocument); | - | 
| 656 |     return d->defaultTextOption.useDesignMetrics(); | - | 
| 657 | } | - | 
| 658 |  | - | 
| 659 |  | - | 
| 660 |  | - | 
| 661 |  | - | 
| 662 |  | - | 
| 663 |  | - | 
| 664 |  | - | 
| 665 | void QTextDocument::drawContents(QPainter *p, const QRectF &rect) | - | 
| 666 | { | - | 
| 667 |     p->save(); | - | 
| 668 |     QAbstractTextDocumentLayout::PaintContext ctx; | - | 
| 669 |     if (rect.isValid()) { | - | 
| 670 |         p->setClipRect(rect); | - | 
| 671 |         ctx.clip = rect; | - | 
| 672 |     } | - | 
| 673 |     documentLayout()->draw(p, ctx); | - | 
| 674 |     p->restore(); | - | 
| 675 | } | - | 
| 676 |  | - | 
| 677 |  | - | 
| 678 |  | - | 
| 679 |  | - | 
| 680 |  | - | 
| 681 |  | - | 
| 682 |  | - | 
| 683 |  | - | 
| 684 |  | - | 
| 685 |  | - | 
| 686 |  | - | 
| 687 |  | - | 
| 688 |  | - | 
| 689 |  | - | 
| 690 |  | - | 
| 691 |  | - | 
| 692 |  | - | 
| 693 |  | - | 
| 694 |  | - | 
| 695 |  | - | 
| 696 |  | - | 
| 697 |  | - | 
| 698 | void QTextDocument::setTextWidth(qreal width) | - | 
| 699 | { | - | 
| 700 |     Q_D(QTextDocument); | - | 
| 701 |     QSizeF sz = d->pageSize; | - | 
| 702 |     sz.setWidth(width); | - | 
| 703 |     sz.setHeight(-1); | - | 
| 704 |     setPageSize(sz); | - | 
| 705 | } | - | 
| 706 |  | - | 
| 707 | qreal QTextDocument::textWidth() const | - | 
| 708 | { | - | 
| 709 |     Q_D(const QTextDocument); | - | 
| 710 |     return d->pageSize.width(); | - | 
| 711 | } | - | 
| 712 |  | - | 
| 713 |  | - | 
| 714 |  | - | 
| 715 |  | - | 
| 716 |  | - | 
| 717 |  | - | 
| 718 |  | - | 
| 719 |  | - | 
| 720 |  | - | 
| 721 | qreal QTextDocument::idealWidth() const | - | 
| 722 | { | - | 
| 723 |     if (QTextDocumentLayout *lout = qobject_cast<QTextDocumentLayout *>(documentLayout())) | - | 
| 724 |         return lout->idealWidth(); | - | 
| 725 |     return textWidth(); | - | 
| 726 | } | - | 
| 727 |  | - | 
| 728 |  | - | 
| 729 |  | - | 
| 730 |  | - | 
| 731 |  | - | 
| 732 |  | - | 
| 733 |  | - | 
| 734 | qreal QTextDocument::documentMargin() const | - | 
| 735 | { | - | 
| 736 |     Q_D(const QTextDocument); | - | 
| 737 |     return d->documentMargin; | - | 
| 738 | } | - | 
| 739 |  | - | 
| 740 | void QTextDocument::setDocumentMargin(qreal margin) | - | 
| 741 | { | - | 
| 742 |     Q_D(QTextDocument); | - | 
| 743 |     if (d->documentMargin != margin) { | - | 
| 744 |         d->documentMargin = margin; | - | 
| 745 |  | - | 
| 746 |         QTextFrame* root = rootFrame(); | - | 
| 747 |         QTextFrameFormat format = root->frameFormat(); | - | 
| 748 |         format.setMargin(margin); | - | 
| 749 |         root->setFrameFormat(format); | - | 
| 750 |  | - | 
| 751 |         if (d->lout) | - | 
| 752 |             d->lout->documentChanged(0, 0, d->length()); | - | 
| 753 |     } | - | 
| 754 | } | - | 
| 755 |  | - | 
| 756 |  | - | 
| 757 |  | - | 
| 758 |  | - | 
| 759 |  | - | 
| 760 |  | - | 
| 761 |  | - | 
| 762 |  | - | 
| 763 |  | - | 
| 764 |  | - | 
| 765 |  | - | 
| 766 | qreal QTextDocument::indentWidth() const | - | 
| 767 | { | - | 
| 768 |     Q_D(const QTextDocument); | - | 
| 769 |     return d->indentWidth; | - | 
| 770 | } | - | 
| 771 |  | - | 
| 772 |  | - | 
| 773 |  | - | 
| 774 |  | - | 
| 775 |  | - | 
| 776 |  | - | 
| 777 |  | - | 
| 778 |  | - | 
| 779 |  | - | 
| 780 |  | - | 
| 781 |  | - | 
| 782 |  | - | 
| 783 | void QTextDocument::setIndentWidth(qreal width) | - | 
| 784 | { | - | 
| 785 |     Q_D(QTextDocument); | - | 
| 786 |     if (d->indentWidth != width) { | - | 
| 787 |         d->indentWidth = width; | - | 
| 788 |         if (d->lout) | - | 
| 789 |             d->lout->documentChanged(0, 0, d->length()); | - | 
| 790 |     } | - | 
| 791 | } | - | 
| 792 |  | - | 
| 793 |  | - | 
| 794 |  | - | 
| 795 |  | - | 
| 796 |  | - | 
| 797 |  | - | 
| 798 |  | - | 
| 799 |  | - | 
| 800 |  | - | 
| 801 |  | - | 
| 802 |  | - | 
| 803 | void QTextDocument::adjustSize() | - | 
| 804 | { | - | 
| 805 |      | - | 
| 806 |     QFont f = defaultFont(); | - | 
| 807 |     QFontMetrics fm(f); | - | 
| 808 |     int mw =  fm.width(QLatin1Char('x')) * 80; | - | 
| 809 |     int w = mw; | - | 
| 810 |     setTextWidth(w); | - | 
| 811 |     QSizeF size = documentLayout()->documentSize(); | - | 
| 812 |     if (size.width() != 0) { | - | 
| 813 |         w = qt_int_sqrt((uint)(5 * size.height() * size.width() / 3)); | - | 
| 814 |         setTextWidth(qMin(w, mw)); | - | 
| 815 |  | - | 
| 816 |         size = documentLayout()->documentSize(); | - | 
| 817 |         if (w*3 < 5*size.height()) { | - | 
| 818 |             w = qt_int_sqrt((uint)(2 * size.height() * size.width())); | - | 
| 819 |             setTextWidth(qMin(w, mw)); | - | 
| 820 |         } | - | 
| 821 |     } | - | 
| 822 |     setTextWidth(idealWidth()); | - | 
| 823 | } | - | 
| 824 |  | - | 
| 825 |  | - | 
| 826 |  | - | 
| 827 |  | - | 
| 828 |  | - | 
| 829 |  | - | 
| 830 |  | - | 
| 831 |  | - | 
| 832 |  | - | 
| 833 |  | - | 
| 834 |  | - | 
| 835 |  | - | 
| 836 |  | - | 
| 837 |  | - | 
| 838 |  | - | 
| 839 |  | - | 
| 840 |  | - | 
| 841 |  | - | 
| 842 | QSizeF QTextDocument::size() const | - | 
| 843 | { | - | 
| 844 |     return documentLayout()->documentSize(); | - | 
| 845 | } | - | 
| 846 |  | - | 
| 847 |  | - | 
| 848 |  | - | 
| 849 |  | - | 
| 850 |  | - | 
| 851 |  | - | 
| 852 |  | - | 
| 853 |  | - | 
| 854 |  | - | 
| 855 |  | - | 
| 856 |  | - | 
| 857 |  | - | 
| 858 | int QTextDocument::blockCount() const | - | 
| 859 | { | - | 
| 860 |     Q_D(const QTextDocument); | - | 
| 861 |     return d->blockMap().numNodes(); | - | 
| 862 | } | - | 
| 863 |  | - | 
| 864 |  | - | 
| 865 |  | - | 
| 866 |  | - | 
| 867 |  | - | 
| 868 |  | - | 
| 869 |  | - | 
| 870 |  | - | 
| 871 |  | - | 
| 872 |  | - | 
| 873 | int QTextDocument::lineCount() const | - | 
| 874 | { | - | 
| 875 |     Q_D(const QTextDocument); | - | 
| 876 |     return d->blockMap().length(2); | - | 
| 877 | } | - | 
| 878 |  | - | 
| 879 |  | - | 
| 880 |  | - | 
| 881 |  | - | 
| 882 |  | - | 
| 883 |  | - | 
| 884 |  | - | 
| 885 |  | - | 
| 886 | int QTextDocument::characterCount() const | - | 
| 887 | { | - | 
| 888 |     Q_D(const QTextDocument); | - | 
| 889 |     return d->length(); | - | 
| 890 | } | - | 
| 891 |  | - | 
| 892 |  | - | 
| 893 |  | - | 
| 894 |  | - | 
| 895 |  | - | 
| 896 |  | - | 
| 897 |  | - | 
| 898 |  | - | 
| 899 |  | - | 
| 900 | QChar QTextDocument::characterAt(int pos) const | - | 
| 901 | { | - | 
| 902 |     Q_D(const QTextDocument); | - | 
| 903 |     if (pos < 0 || pos >= d->length()) | - | 
| 904 |         return QChar(); | - | 
| 905 |     QTextDocumentPrivate::FragmentIterator fragIt = d->find(pos); | - | 
| 906 |     const QTextFragmentData * const frag = fragIt.value(); | - | 
| 907 |     const int offsetInFragment = qMax(0, pos - fragIt.position()); | - | 
| 908 |     return d->text.at(frag->stringPosition + offsetInFragment); | - | 
| 909 | } | - | 
| 910 |  | - | 
| 911 |  | - | 
| 912 |  | - | 
| 913 |  | - | 
| 914 |  | - | 
| 915 |  | - | 
| 916 |  | - | 
| 917 |  | - | 
| 918 |  | - | 
| 919 |  | - | 
| 920 |  | - | 
| 921 |  | - | 
| 922 |  | - | 
| 923 |  | - | 
| 924 |  | - | 
| 925 |  | - | 
| 926 |  | - | 
| 927 | #ifndef QT_NO_CSSPARSER | - | 
| 928 | void QTextDocument::setDefaultStyleSheet(const QString &sheet) | - | 
| 929 | { | - | 
| 930 |     Q_D(QTextDocument); | - | 
| 931 |     d->defaultStyleSheet = sheet; | - | 
| 932 |     QCss::Parser parser(sheet); | - | 
| 933 |     d->parsedDefaultStyleSheet = QCss::StyleSheet(); | - | 
| 934 |     d->parsedDefaultStyleSheet.origin = QCss::StyleSheetOrigin_UserAgent; | - | 
| 935 |     parser.parse(&d->parsedDefaultStyleSheet); | - | 
| 936 | } | - | 
| 937 |  | - | 
| 938 | QString QTextDocument::defaultStyleSheet() const | - | 
| 939 | { | - | 
| 940 |     Q_D(const QTextDocument); | - | 
| 941 |     return d->defaultStyleSheet; | - | 
| 942 | } | - | 
| 943 | #endif // QT_NO_CSSPARSER | - | 
| 944 |  | - | 
| 945 |  | - | 
| 946 |  | - | 
| 947 |  | - | 
| 948 |  | - | 
| 949 |  | - | 
| 950 |  | - | 
| 951 |  | - | 
| 952 |  | - | 
| 953 |  | - | 
| 954 |  | - | 
| 955 |  | - | 
| 956 |  | - | 
| 957 |  | - | 
| 958 |  | - | 
| 959 |  | - | 
| 960 |  | - | 
| 961 |  | - | 
| 962 |  | - | 
| 963 |  | - | 
| 964 |  | - | 
| 965 |  | - | 
| 966 |  | - | 
| 967 |  | - | 
| 968 |  | - | 
| 969 |  | - | 
| 970 |  | - | 
| 971 |  | - | 
| 972 |  | - | 
| 973 |  | - | 
| 974 |  | - | 
| 975 |  | - | 
| 976 |  | - | 
| 977 |  | - | 
| 978 |  | - | 
| 979 |  | - | 
| 980 |  | - | 
| 981 |  | - | 
| 982 |  | - | 
| 983 |  | - | 
| 984 |  | - | 
| 985 |  | - | 
| 986 |  | - | 
| 987 |  | - | 
| 988 |  | - | 
| 989 |  | - | 
| 990 |  | - | 
| 991 |  | - | 
| 992 |  | - | 
| 993 |  | - | 
| 994 |  | - | 
| 995 |  | - | 
| 996 |  | - | 
| 997 |  | - | 
| 998 |  | - | 
| 999 |  | - | 
| 1000 |  | - | 
| 1001 |  | - | 
| 1002 |  | - | 
| 1003 |  | - | 
| 1004 |  | - | 
| 1005 |  | - | 
| 1006 |  | - | 
| 1007 |  | - | 
| 1008 |  | - | 
| 1009 |  | - | 
| 1010 |  | - | 
| 1011 |  | - | 
| 1012 |  | - | 
| 1013 |  | - | 
| 1014 |  | - | 
| 1015 |  | - | 
| 1016 |  | - | 
| 1017 |  | - | 
| 1018 |  | - | 
| 1019 |  | - | 
| 1020 |  | - | 
| 1021 |  | - | 
| 1022 |  | - | 
| 1023 |  | - | 
| 1024 |  | - | 
| 1025 |  | - | 
| 1026 | bool QTextDocument::isUndoAvailable() const | - | 
| 1027 | { | - | 
| 1028 |     Q_D(const QTextDocument); | - | 
| 1029 |     return d->isUndoAvailable(); | - | 
| 1030 | } | - | 
| 1031 |  | - | 
| 1032 |  | - | 
| 1033 |  | - | 
| 1034 |  | - | 
| 1035 |  | - | 
| 1036 |  | - | 
| 1037 | bool QTextDocument::isRedoAvailable() const | - | 
| 1038 | { | - | 
| 1039 |     Q_D(const QTextDocument); | - | 
| 1040 |     return d->isRedoAvailable(); | - | 
| 1041 | } | - | 
| 1042 |  | - | 
| 1043 |  | - | 
| 1044 |  | - | 
| 1045 |  | - | 
| 1046 |  | - | 
| 1047 |  | - | 
| 1048 |  | - | 
| 1049 | int QTextDocument::availableUndoSteps() const | - | 
| 1050 | { | - | 
| 1051 |     Q_D(const QTextDocument); | - | 
| 1052 |     return d->availableUndoSteps(); | - | 
| 1053 | } | - | 
| 1054 |  | - | 
| 1055 |  | - | 
| 1056 |  | - | 
| 1057 |  | - | 
| 1058 |  | - | 
| 1059 |  | - | 
| 1060 |  | - | 
| 1061 | int QTextDocument::availableRedoSteps() const | - | 
| 1062 | { | - | 
| 1063 |     Q_D(const QTextDocument); | - | 
| 1064 |     return d->availableRedoSteps(); | - | 
| 1065 | } | - | 
| 1066 |  | - | 
| 1067 |  | - | 
| 1068 |  | - | 
| 1069 |  | - | 
| 1070 |  | - | 
| 1071 |  | - | 
| 1072 |  | - | 
| 1073 |  | - | 
| 1074 |  | - | 
| 1075 |  | - | 
| 1076 | int QTextDocument::revision() const | - | 
| 1077 | { | - | 
| 1078 |     Q_D(const QTextDocument); | - | 
| 1079 |     return d->revision; | - | 
| 1080 | } | - | 
| 1081 |  | - | 
| 1082 |  | - | 
| 1083 |  | - | 
| 1084 |  | - | 
| 1085 |  | - | 
| 1086 |  | - | 
| 1087 |  | - | 
| 1088 |  | - | 
| 1089 |  | - | 
| 1090 | void QTextDocument::setDocumentLayout(QAbstractTextDocumentLayout *layout) | - | 
| 1091 | { | - | 
| 1092 |     Q_D(QTextDocument); | - | 
| 1093 |     d->setLayout(layout); | - | 
| 1094 | } | - | 
| 1095 |  | - | 
| 1096 |  | - | 
| 1097 |  | - | 
| 1098 |  | - | 
| 1099 | QAbstractTextDocumentLayout *QTextDocument::documentLayout() const | - | 
| 1100 | { | - | 
| 1101 |     Q_D(const QTextDocument); | - | 
| 1102 |     if (!d->lout) { | - | 
| 1103 |         QTextDocument *that = const_cast<QTextDocument *>(this); | - | 
| 1104 |         that->d_func()->setLayout(new QTextDocumentLayout(that)); | - | 
| 1105 |     } | - | 
| 1106 |     return d->lout; | - | 
| 1107 | } | - | 
| 1108 |  | - | 
| 1109 |  | - | 
| 1110 |  | - | 
| 1111 |  | - | 
| 1112 |  | - | 
| 1113 |  | - | 
| 1114 |  | - | 
| 1115 |  | - | 
| 1116 | QString QTextDocument::metaInformation(MetaInformation info) const | - | 
| 1117 | { | - | 
| 1118 |     Q_D(const QTextDocument); | - | 
| 1119 |     switch (info) { | - | 
| 1120 |     case DocumentTitle: | - | 
| 1121 |         return d->title; | - | 
| 1122 |     case DocumentUrl: | - | 
| 1123 |         return d->url; | - | 
| 1124 |     } | - | 
| 1125 |     return QString(); | - | 
| 1126 | } | - | 
| 1127 |  | - | 
| 1128 |  | - | 
| 1129 |  | - | 
| 1130 |  | - | 
| 1131 |  | - | 
| 1132 |  | - | 
| 1133 |  | - | 
| 1134 | void QTextDocument::setMetaInformation(MetaInformation info, const QString &string) | - | 
| 1135 | { | - | 
| 1136 |     Q_D(QTextDocument); | - | 
| 1137 |     switch (info) { | - | 
| 1138 |     case DocumentTitle: | - | 
| 1139 |         d->title = string; | - | 
| 1140 |         break; | - | 
| 1141 |     case DocumentUrl: | - | 
| 1142 |         d->url = string; | - | 
| 1143 |         break; | - | 
| 1144 |     } | - | 
| 1145 | } | - | 
| 1146 |  | - | 
| 1147 |  | - | 
| 1148 |  | - | 
| 1149 |  | - | 
| 1150 |  | - | 
| 1151 |  | - | 
| 1152 |  | - | 
| 1153 |  | - | 
| 1154 |  | - | 
| 1155 |  | - | 
| 1156 | QString QTextDocument::toPlainText() const | - | 
| 1157 | { | - | 
| 1158 |     Q_D(const QTextDocument); | - | 
| 1159 |     QString txt = d->plainText(); | - | 
| 1160 |  | - | 
| 1161 |     QChar *uc = txt.data(); | - | 
| 1162 |     QChar *e = uc + txt.size(); | - | 
| 1163 |  | - | 
| 1164 |     for (; uc != e; ++uc) { | - | 
| 1165 |         switch (uc->unicode()) { | - | 
| 1166 |         case 0xfdd0:  | - | 
| 1167 |         case 0xfdd1:  | - | 
| 1168 |         case QChar::ParagraphSeparator: | - | 
| 1169 |         case QChar::LineSeparator: | - | 
| 1170 |             *uc = QLatin1Char('\n'); | - | 
| 1171 |             break; | - | 
| 1172 |         case QChar::Nbsp: | - | 
| 1173 |             *uc = QLatin1Char(' '); | - | 
| 1174 |             break; | - | 
| 1175 |         default: | - | 
| 1176 |             ; | - | 
| 1177 |         } | - | 
| 1178 |     } | - | 
| 1179 |     return txt; | - | 
| 1180 | } | - | 
| 1181 |  | - | 
| 1182 |  | - | 
| 1183 |  | - | 
| 1184 |  | - | 
| 1185 |  | - | 
| 1186 |  | - | 
| 1187 |  | - | 
| 1188 | void QTextDocument::setPlainText(const QString &text) | - | 
| 1189 | { | - | 
| 1190 |     Q_D(QTextDocument); | - | 
| 1191 |     bool previousState = d->isUndoRedoEnabled(); | - | 
| 1192 |     d->enableUndoRedo(false); | - | 
| 1193 |     d->beginEditBlock(); | - | 
| 1194 |     d->clear(); | - | 
| 1195 |     QTextCursor(this).insertText(text); | - | 
| 1196 |     d->endEditBlock(); | - | 
| 1197 |     d->enableUndoRedo(previousState); | - | 
| 1198 | } | - | 
| 1199 |  | - | 
| 1200 |  | - | 
| 1201 |  | - | 
| 1202 |  | - | 
| 1203 |  | - | 
| 1204 |  | - | 
| 1205 |  | - | 
| 1206 |  | - | 
| 1207 |  | - | 
| 1208 |  | - | 
| 1209 |  | - | 
| 1210 |  | - | 
| 1211 |  | - | 
| 1212 |  | - | 
| 1213 |  | - | 
| 1214 |  | - | 
| 1215 |  | - | 
| 1216 | #ifndef QT_NO_TEXTHTMLPARSER | - | 
| 1217 |  | - | 
| 1218 | void QTextDocument::setHtml(const QString &html) | - | 
| 1219 | { | - | 
| 1220 |     Q_D(QTextDocument); | - | 
| 1221 |     bool previousState = d->isUndoRedoEnabled(); | - | 
| 1222 |     d->enableUndoRedo(false); | - | 
| 1223 |     d->beginEditBlock(); | - | 
| 1224 |     d->clear(); | - | 
| 1225 |     QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import(); | - | 
| 1226 |     d->endEditBlock(); | - | 
| 1227 |     d->enableUndoRedo(previousState); | - | 
| 1228 | } | - | 
| 1229 |  | - | 
| 1230 | #endif // QT_NO_TEXTHTMLPARSER | - | 
| 1231 |  | - | 
| 1232 |  | - | 
| 1233 |  | - | 
| 1234 |  | - | 
| 1235 |  | - | 
| 1236 |  | - | 
| 1237 |  | - | 
| 1238 |  | - | 
| 1239 |  | - | 
| 1240 |  | - | 
| 1241 |  | - | 
| 1242 |  | - | 
| 1243 |  | - | 
| 1244 |  | - | 
| 1245 |  | - | 
| 1246 |  | - | 
| 1247 |  | - | 
| 1248 |  | - | 
| 1249 |  | - | 
| 1250 |  | - | 
| 1251 |  | - | 
| 1252 |  | - | 
| 1253 |  | - | 
| 1254 |  | - | 
| 1255 |  | - | 
| 1256 |  | - | 
| 1257 | static bool findInBlock(const QTextBlock &block, const QString &expression, int offset, | - | 
| 1258 |                         QTextDocument::FindFlags options, QTextCursor *cursor) | - | 
| 1259 | { | - | 
| 1260 |     QString text = block.text(); | - | 
| 1261 |     text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | 
| 1262 |     Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively ? Qt::CaseSensitive : Qt::CaseInsensitive; | - | 
| 1263 |     int idx = -1; | - | 
| 1264 |  | - | 
| 1265 |     while (offset >= 0 && offset <= text.length()) { | - | 
| 1266 |         idx = (options & QTextDocument::FindBackward) ? | - | 
| 1267 |                text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity); | - | 
| 1268 |         if (idx == -1) | - | 
| 1269 |             return false; | - | 
| 1270 |  | - | 
| 1271 |         if (options & QTextDocument::FindWholeWords) { | - | 
| 1272 |             const int start = idx; | - | 
| 1273 |             const int end = start + expression.length(); | - | 
| 1274 |             if ((start != 0 && text.at(start - 1).isLetterOrNumber()) | - | 
| 1275 |                 || (end != text.length() && text.at(end).isLetterOrNumber())) { | - | 
| 1276 |                  | - | 
| 1277 |                 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1; | - | 
| 1278 |                 idx = -1; | - | 
| 1279 |                 continue; | - | 
| 1280 |             } | - | 
| 1281 |         } | - | 
| 1282 |          | - | 
| 1283 |         *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | 
| 1284 |         cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor); | - | 
| 1285 |         return true; | - | 
| 1286 |     } | - | 
| 1287 |     return false; | - | 
| 1288 | } | - | 
| 1289 |  | - | 
| 1290 |  | - | 
| 1291 |  | - | 
| 1292 |  | - | 
| 1293 |  | - | 
| 1294 |  | - | 
| 1295 |  | - | 
| 1296 |  | - | 
| 1297 |  | - | 
| 1298 |  | - | 
| 1299 |  | - | 
| 1300 |  | - | 
| 1301 |  | - | 
| 1302 |  | - | 
| 1303 |  | - | 
| 1304 |  | - | 
| 1305 |  | - | 
| 1306 | QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags options) const | - | 
| 1307 | { | - | 
| 1308 |     Q_D(const QTextDocument); | - | 
| 1309 |  | - | 
| 1310 |     if (subString.isEmpty()) | - | 
| 1311 |         return QTextCursor(); | - | 
| 1312 |  | - | 
| 1313 |     int pos = from; | - | 
| 1314 |      | - | 
| 1315 |      | - | 
| 1316 |     if (options & FindBackward) { | - | 
| 1317 |         --pos ; | - | 
| 1318 |         if (pos < 0) | - | 
| 1319 |             return QTextCursor(); | - | 
| 1320 |     } | - | 
| 1321 |  | - | 
| 1322 |     QTextCursor cursor; | - | 
| 1323 |     QTextBlock block = d->blocksFind(pos); | - | 
| 1324 |     int blockOffset = pos - block.position(); | - | 
| 1325 |  | - | 
| 1326 |     if (!(options & FindBackward)) { | - | 
| 1327 |         while (block.isValid()) { | - | 
| 1328 |             if (findInBlock(block, subString, blockOffset, options, &cursor)) | - | 
| 1329 |                 return cursor; | - | 
| 1330 |             block = block.next(); | - | 
| 1331 |             blockOffset = 0; | - | 
| 1332 |         } | - | 
| 1333 |     } else { | - | 
| 1334 |         while (block.isValid()) { | - | 
| 1335 |             if (findInBlock(block, subString, blockOffset, options, &cursor)) | - | 
| 1336 |                 return cursor; | - | 
| 1337 |             block = block.previous(); | - | 
| 1338 |             blockOffset = block.length() - 2; | - | 
| 1339 |         } | - | 
| 1340 |     } | - | 
| 1341 |  | - | 
| 1342 |     return QTextCursor(); | - | 
| 1343 | } | - | 
| 1344 |  | - | 
| 1345 |  | - | 
| 1346 |  | - | 
| 1347 |  | - | 
| 1348 |  | - | 
| 1349 |  | - | 
| 1350 |  | - | 
| 1351 |  | - | 
| 1352 |  | - | 
| 1353 |  | - | 
| 1354 |  | - | 
| 1355 |  | - | 
| 1356 |  | - | 
| 1357 |  | - | 
| 1358 |  | - | 
| 1359 |  | - | 
| 1360 | QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const | - | 
| 1361 | { | - | 
| 1362 |     int pos = 0; | - | 
| 1363 |     if (!cursor.isNull()) { | - | 
| 1364 |         if (options & QTextDocument::FindBackward) | - | 
| 1365 |             pos = cursor.selectionStart(); | - | 
| 1366 |         else | - | 
| 1367 |             pos = cursor.selectionEnd(); | - | 
| 1368 |     } | - | 
| 1369 |  | - | 
| 1370 |     return find(subString, pos, options); | - | 
| 1371 | } | - | 
| 1372 |  | - | 
| 1373 |  | - | 
| 1374 | #ifndef QT_NO_REGEXP | - | 
| 1375 | static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset, | - | 
| 1376 |                         QTextDocument::FindFlags options, QTextCursor *cursor) | - | 
| 1377 | { | - | 
| 1378 |     QRegExp expr(expression); | - | 
| 1379 |     QString text = block.text(); | - | 
| 1380 |     text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | 
| 1381 |  | - | 
| 1382 |     int idx = -1; | - | 
| 1383 |     while (offset >=0 && offset <= text.length()) { | - | 
| 1384 |         idx = (options & QTextDocument::FindBackward) ? | - | 
| 1385 |                expr.lastIndexIn(text, offset) : expr.indexIn(text, offset); | - | 
| 1386 |         if (idx == -1) | - | 
| 1387 |             return false; | - | 
| 1388 |  | - | 
| 1389 |         if (options & QTextDocument::FindWholeWords) { | - | 
| 1390 |             const int start = idx; | - | 
| 1391 |             const int end = start + expr.matchedLength(); | - | 
| 1392 |             if ((start != 0 && text.at(start - 1).isLetterOrNumber()) | - | 
| 1393 |                 || (end != text.length() && text.at(end).isLetterOrNumber())) { | - | 
| 1394 |                  | - | 
| 1395 |                 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1; | - | 
| 1396 |                 idx = -1; | - | 
| 1397 |                 continue; | - | 
| 1398 |             } | - | 
| 1399 |         } | - | 
| 1400 |          | - | 
| 1401 |         *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | 
| 1402 |         cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor); | - | 
| 1403 |         return true; | - | 
| 1404 |     } | - | 
| 1405 |     return false; | - | 
| 1406 | } | - | 
| 1407 |  | - | 
| 1408 |  | - | 
| 1409 |  | - | 
| 1410 |  | - | 
| 1411 |  | - | 
| 1412 |  | - | 
| 1413 |  | - | 
| 1414 |  | - | 
| 1415 |  | - | 
| 1416 |  | - | 
| 1417 |  | - | 
| 1418 |  | - | 
| 1419 |  | - | 
| 1420 |  | - | 
| 1421 |  | - | 
| 1422 |  | - | 
| 1423 |  | - | 
| 1424 |  | - | 
| 1425 | QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags options) const | - | 
| 1426 | { | - | 
| 1427 |     Q_D(const QTextDocument); | - | 
| 1428 |  | - | 
| 1429 |     if (expr.isEmpty()) | - | 
| 1430 |         return QTextCursor(); | - | 
| 1431 |  | - | 
| 1432 |     int pos = from; | - | 
| 1433 |      | - | 
| 1434 |      | - | 
| 1435 |     if (options & FindBackward) { | - | 
| 1436 |         --pos ; | - | 
| 1437 |         if(pos < 0) | - | 
| 1438 |             return QTextCursor(); | - | 
| 1439 |     } | - | 
| 1440 |  | - | 
| 1441 |     QTextCursor cursor; | - | 
| 1442 |     QTextBlock block = d->blocksFind(pos); | - | 
| 1443 |     int blockOffset = pos - block.position(); | - | 
| 1444 |     if (!(options & FindBackward)) { | - | 
| 1445 |         while (block.isValid()) { | - | 
| 1446 |             if (findInBlock(block, expr, blockOffset, options, &cursor)) | - | 
| 1447 |                 return cursor; | - | 
| 1448 |             block = block.next(); | - | 
| 1449 |             blockOffset = 0; | - | 
| 1450 |         } | - | 
| 1451 |     } else { | - | 
| 1452 |         while (block.isValid()) { | - | 
| 1453 |             if (findInBlock(block, expr, blockOffset, options, &cursor)) | - | 
| 1454 |                 return cursor; | - | 
| 1455 |             block = block.previous(); | - | 
| 1456 |             blockOffset = block.length() - 1; | - | 
| 1457 |         } | - | 
| 1458 |     } | - | 
| 1459 |  | - | 
| 1460 |     return QTextCursor(); | - | 
| 1461 | } | - | 
| 1462 |  | - | 
| 1463 |  | - | 
| 1464 |  | - | 
| 1465 |  | - | 
| 1466 |  | - | 
| 1467 |  | - | 
| 1468 |  | - | 
| 1469 |  | - | 
| 1470 |  | - | 
| 1471 |  | - | 
| 1472 |  | - | 
| 1473 |  | - | 
| 1474 |  | - | 
| 1475 |  | - | 
| 1476 |  | - | 
| 1477 |  | - | 
| 1478 |  | - | 
| 1479 |  | - | 
| 1480 |  | - | 
| 1481 |  | - | 
| 1482 |  | - | 
| 1483 | QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const | - | 
| 1484 | { | - | 
| 1485 |     int pos = 0; | - | 
| 1486 |     if (!cursor.isNull()) { | - | 
| 1487 |         if (options & QTextDocument::FindBackward) | - | 
| 1488 |             pos = cursor.selectionStart(); | - | 
| 1489 |         else | - | 
| 1490 |             pos = cursor.selectionEnd(); | - | 
| 1491 |     } | - | 
| 1492 |     return find(expr, pos, options); | - | 
| 1493 | } | - | 
| 1494 | #endif // QT_REGEXP | - | 
| 1495 |  | - | 
| 1496 | #ifndef QT_NO_REGULAREXPRESSION | - | 
| 1497 | static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset, | - | 
| 1498 |                         QTextDocument::FindFlags options, QTextCursor *cursor) | - | 
| 1499 | { | - | 
| 1500 |     QRegularExpression expr(expression); | - | 
| 1501 |     if (!(options & QTextDocument::FindCaseSensitively)) | - | 
| 1502 |         expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption); | - | 
| 1503 |     else | - | 
| 1504 |         expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption); | - | 
| 1505 |  | - | 
| 1506 |     QString text = block.text(); | - | 
| 1507 |     text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | 
| 1508 |     QRegularExpressionMatch match; | - | 
| 1509 |     int idx = -1; | - | 
| 1510 |  | - | 
| 1511 |     while (offset >= 0 && offset <= text.length()) { | - | 
| 1512 |         idx = (options & QTextDocument::FindBackward) ? | - | 
| 1513 |                text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match); | - | 
| 1514 |         if (idx == -1) | - | 
| 1515 |             return false; | - | 
| 1516 |  | - | 
| 1517 |         if (options & QTextDocument::FindWholeWords) { | - | 
| 1518 |             const int start = idx; | - | 
| 1519 |             const int end = start + match.capturedLength(); | - | 
| 1520 |             if ((start != 0 && text.at(start - 1).isLetterOrNumber()) | - | 
| 1521 |                 || (end != text.length() && text.at(end).isLetterOrNumber())) { | - | 
| 1522 |                  | - | 
| 1523 |                 offset = (options & QTextDocument::FindBackward) ? idx-1 : end+1; | - | 
| 1524 |                 idx = -1; | - | 
| 1525 |                 continue; | - | 
| 1526 |             } | - | 
| 1527 |         } | - | 
| 1528 |          | - | 
| 1529 |         *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | 
| 1530 |         cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor); | - | 
| 1531 |         return true; | - | 
| 1532 |     } | - | 
| 1533 |     return false; | - | 
| 1534 | } | - | 
| 1535 |  | - | 
| 1536 |  | - | 
| 1537 |  | - | 
| 1538 |  | - | 
| 1539 |  | - | 
| 1540 |  | - | 
| 1541 |  | - | 
| 1542 |  | - | 
| 1543 |  | - | 
| 1544 |  | - | 
| 1545 |  | - | 
| 1546 |  | - | 
| 1547 |  | - | 
| 1548 |  | - | 
| 1549 |  | - | 
| 1550 |  | - | 
| 1551 |  | - | 
| 1552 | QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const | - | 
| 1553 | { | - | 
| 1554 |     Q_D(const QTextDocument); | - | 
| 1555 |  | - | 
| 1556 |     if (!expr.isValid()) | - | 
| 1557 |         return QTextCursor(); | - | 
| 1558 |  | - | 
| 1559 |     int pos = from; | - | 
| 1560 |      | - | 
| 1561 |      | - | 
| 1562 |     if (options & FindBackward) { | - | 
| 1563 |         --pos ; | - | 
| 1564 |         if (pos < 0) | - | 
| 1565 |             return QTextCursor(); | - | 
| 1566 |     } | - | 
| 1567 |  | - | 
| 1568 |     QTextCursor cursor; | - | 
| 1569 |     QTextBlock block = d->blocksFind(pos); | - | 
| 1570 |     int blockOffset = pos - block.position(); | - | 
| 1571 |  | - | 
| 1572 |     if (!(options & FindBackward)) { | - | 
| 1573 |         while (block.isValid()) { | - | 
| 1574 |             if (findInBlock(block, expr, blockOffset, options, &cursor)) | - | 
| 1575 |                 return cursor; | - | 
| 1576 |             block = block.next(); | - | 
| 1577 |             blockOffset = 0; | - | 
| 1578 |         } | - | 
| 1579 |     } else { | - | 
| 1580 |         while (block.isValid()) { | - | 
| 1581 |             if (findInBlock(block, expr, blockOffset, options, &cursor)) | - | 
| 1582 |                 return cursor; | - | 
| 1583 |             block = block.previous(); | - | 
| 1584 |             blockOffset = block.length() - 1; | - | 
| 1585 |         } | - | 
| 1586 |     } | - | 
| 1587 |  | - | 
| 1588 |     return QTextCursor(); | - | 
| 1589 | } | - | 
| 1590 |  | - | 
| 1591 |  | - | 
| 1592 |  | - | 
| 1593 |  | - | 
| 1594 |  | - | 
| 1595 |  | - | 
| 1596 |  | - | 
| 1597 |  | - | 
| 1598 |  | - | 
| 1599 |  | - | 
| 1600 |  | - | 
| 1601 |  | - | 
| 1602 |  | - | 
| 1603 |  | - | 
| 1604 |  | - | 
| 1605 |  | - | 
| 1606 |  | - | 
| 1607 |  | - | 
| 1608 |  | - | 
| 1609 |  | - | 
| 1610 | QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options) const | - | 
| 1611 | { | - | 
| 1612 |     int pos = 0; | - | 
| 1613 |     if (!cursor.isNull()) { | - | 
| 1614 |         if (options & QTextDocument::FindBackward) | - | 
| 1615 |             pos = cursor.selectionStart(); | - | 
| 1616 |         else | - | 
| 1617 |             pos = cursor.selectionEnd(); | - | 
| 1618 |     } | - | 
| 1619 |     return find(expr, pos, options); | - | 
| 1620 | } | - | 
| 1621 | #endif // QT_NO_REGULAREXPRESSION | - | 
| 1622 |  | - | 
| 1623 |  | - | 
| 1624 |  | - | 
| 1625 |  | - | 
| 1626 |  | - | 
| 1627 |  | - | 
| 1628 |  | - | 
| 1629 |  | - | 
| 1630 |  | - | 
| 1631 |  | - | 
| 1632 | QTextObject *QTextDocument::createObject(const QTextFormat &f) | - | 
| 1633 | { | - | 
| 1634 |     QTextObject *obj = 0; | - | 
| 1635 |     if (f.isListFormat()) | - | 
| 1636 |         obj = new QTextList(this); | - | 
| 1637 |     else if (f.isTableFormat()) | - | 
| 1638 |         obj = new QTextTable(this); | - | 
| 1639 |     else if (f.isFrameFormat()) | - | 
| 1640 |         obj = new QTextFrame(this); | - | 
| 1641 |  | - | 
| 1642 |     return obj; | - | 
| 1643 | } | - | 
| 1644 |  | - | 
| 1645 |  | - | 
| 1646 |  | - | 
| 1647 |  | - | 
| 1648 |  | - | 
| 1649 |  | - | 
| 1650 | QTextFrame *QTextDocument::frameAt(int pos) const | - | 
| 1651 | { | - | 
| 1652 |     Q_D(const QTextDocument); | - | 
| 1653 |     return d->frameAt(pos); | - | 
| 1654 | } | - | 
| 1655 |  | - | 
| 1656 |  | - | 
| 1657 |  | - | 
| 1658 |  | - | 
| 1659 | QTextFrame *QTextDocument::rootFrame() const | - | 
| 1660 | { | - | 
| 1661 |     Q_D(const QTextDocument); | - | 
| 1662 |     return d->rootFrame(); | - | 
| 1663 | } | - | 
| 1664 |  | - | 
| 1665 |  | - | 
| 1666 |  | - | 
| 1667 |  | - | 
| 1668 | QTextObject *QTextDocument::object(int objectIndex) const | - | 
| 1669 | { | - | 
| 1670 |     Q_D(const QTextDocument); | - | 
| 1671 |     return d->objectForIndex(objectIndex); | - | 
| 1672 | } | - | 
| 1673 |  | - | 
| 1674 |  | - | 
| 1675 |  | - | 
| 1676 |  | - | 
| 1677 | QTextObject *QTextDocument::objectForFormat(const QTextFormat &f) const | - | 
| 1678 | { | - | 
| 1679 |     Q_D(const QTextDocument); | - | 
| 1680 |     return d->objectForFormat(f); | - | 
| 1681 | } | - | 
| 1682 |  | - | 
| 1683 |  | - | 
| 1684 |  | - | 
| 1685 |  | - | 
| 1686 |  | - | 
| 1687 | QTextBlock QTextDocument::findBlock(int pos) const | - | 
| 1688 | { | - | 
| 1689 |     Q_D(const QTextDocument); | - | 
| 1690 |     return QTextBlock(docHandle(), d->blockMap().findNode(pos)); | - | 
| 1691 | } | - | 
| 1692 |  | - | 
| 1693 |  | - | 
| 1694 |  | - | 
| 1695 |  | - | 
| 1696 |  | - | 
| 1697 |  | - | 
| 1698 |  | - | 
| 1699 | QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const | - | 
| 1700 | { | - | 
| 1701 |     Q_D(const QTextDocument); | - | 
| 1702 |     return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1)); | - | 
| 1703 | } | - | 
| 1704 |  | - | 
| 1705 |  | - | 
| 1706 |  | - | 
| 1707 |  | - | 
| 1708 |  | - | 
| 1709 |  | - | 
| 1710 |  | - | 
| 1711 | QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const | - | 
| 1712 | { | - | 
| 1713 |     Q_D(const QTextDocument); | - | 
| 1714 |     return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2)); | - | 
| 1715 | } | - | 
| 1716 |  | - | 
| 1717 |  | - | 
| 1718 |  | - | 
| 1719 |  | - | 
| 1720 |  | - | 
| 1721 |  | - | 
| 1722 | QTextBlock QTextDocument::begin() const | - | 
| 1723 | { | - | 
| 1724 |     Q_D(const QTextDocument); | - | 
| 1725 |     return QTextBlock(docHandle(), d->blockMap().begin().n); | - | 
| 1726 | } | - | 
| 1727 |  | - | 
| 1728 |  | - | 
| 1729 |  | - | 
| 1730 |  | - | 
| 1731 |  | - | 
| 1732 |  | - | 
| 1733 |  | - | 
| 1734 |  | - | 
| 1735 |  | - | 
| 1736 |  | - | 
| 1737 |  | - | 
| 1738 |  | - | 
| 1739 |  | - | 
| 1740 | QTextBlock QTextDocument::end() const | - | 
| 1741 | { | - | 
| 1742 |     return QTextBlock(docHandle(), 0); | - | 
| 1743 | } | - | 
| 1744 |  | - | 
| 1745 |  | - | 
| 1746 |  | - | 
| 1747 |  | - | 
| 1748 |  | - | 
| 1749 | QTextBlock QTextDocument::firstBlock() const | - | 
| 1750 | { | - | 
| 1751 |     Q_D(const QTextDocument); | - | 
| 1752 |     return QTextBlock(docHandle(), d->blockMap().begin().n); | - | 
| 1753 | } | - | 
| 1754 |  | - | 
| 1755 |  | - | 
| 1756 |  | - | 
| 1757 |  | - | 
| 1758 |  | - | 
| 1759 | QTextBlock QTextDocument::lastBlock() const | - | 
| 1760 | { | - | 
| 1761 |     Q_D(const QTextDocument); | - | 
| 1762 |     return QTextBlock(docHandle(), d->blockMap().last().n); | - | 
| 1763 | } | - | 
| 1764 |  | - | 
| 1765 |  | - | 
| 1766 |  | - | 
| 1767 |  | - | 
| 1768 |  | - | 
| 1769 |  | - | 
| 1770 |  | - | 
| 1771 |  | - | 
| 1772 |  | - | 
| 1773 |  | - | 
| 1774 |  | - | 
| 1775 |  | - | 
| 1776 |  | - | 
| 1777 |  | - | 
| 1778 |  | - | 
| 1779 | void QTextDocument::setPageSize(const QSizeF &size) | - | 
| 1780 | { | - | 
| 1781 |     Q_D(QTextDocument); | - | 
| 1782 |     d->pageSize = size; | - | 
| 1783 |     if (d->lout) | - | 
| 1784 |         d->lout->documentChanged(0, 0, d->length()); | - | 
| 1785 | } | - | 
| 1786 |  | - | 
| 1787 | QSizeF QTextDocument::pageSize() const | - | 
| 1788 | { | - | 
| 1789 |     Q_D(const QTextDocument); | - | 
| 1790 |     return d->pageSize; | - | 
| 1791 | } | - | 
| 1792 |  | - | 
| 1793 |  | - | 
| 1794 |  | - | 
| 1795 |  | - | 
| 1796 | int QTextDocument::pageCount() const | - | 
| 1797 | { | - | 
| 1798 |     return documentLayout()->pageCount(); | - | 
| 1799 | } | - | 
| 1800 |  | - | 
| 1801 |  | - | 
| 1802 |  | - | 
| 1803 |  | - | 
| 1804 | void QTextDocument::setDefaultFont(const QFont &font) | - | 
| 1805 | { | - | 
| 1806 |     Q_D(QTextDocument); | - | 
| 1807 |     d->setDefaultFont(font); | - | 
| 1808 |     if (d->lout) | - | 
| 1809 |         d->lout->documentChanged(0, 0, d->length()); | - | 
| 1810 | } | - | 
| 1811 |  | - | 
| 1812 |  | - | 
| 1813 |  | - | 
| 1814 |  | - | 
| 1815 | QFont QTextDocument::defaultFont() const | - | 
| 1816 | { | - | 
| 1817 |     Q_D(const QTextDocument); | - | 
| 1818 |     return d->defaultFont(); | - | 
| 1819 | } | - | 
| 1820 |  | - | 
| 1821 |  | - | 
| 1822 |  | - | 
| 1823 |  | - | 
| 1824 |  | - | 
| 1825 |  | - | 
| 1826 |  | - | 
| 1827 |  | - | 
| 1828 |  | - | 
| 1829 |  | - | 
| 1830 |  | - | 
| 1831 |  | - | 
| 1832 |  | - | 
| 1833 |  | - | 
| 1834 |  | - | 
| 1835 |  | - | 
| 1836 |  | - | 
| 1837 |  | - | 
| 1838 |  | - | 
| 1839 |  | - | 
| 1840 |  | - | 
| 1841 |  | - | 
| 1842 |  | - | 
| 1843 |  | - | 
| 1844 | bool QTextDocument::isModified() const | - | 
| 1845 | { | - | 
| 1846 |     return docHandle()->isModified(); | - | 
| 1847 | } | - | 
| 1848 |  | - | 
| 1849 | void QTextDocument::setModified(bool m) | - | 
| 1850 | { | - | 
| 1851 |     docHandle()->setModified(m); | - | 
| 1852 | } | - | 
| 1853 |  | - | 
| 1854 | #ifndef QT_NO_PRINTER | - | 
| 1855 | static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos) | - | 
| 1856 | { | - | 
| 1857 |     painter->save(); | - | 
| 1858 |     painter->translate(body.left(), body.top() - (index - 1) * body.height()); | - | 
| 1859 |     QRectF view(0, (index - 1) * body.height(), body.width(), body.height()); | - | 
| 1860 |  | - | 
| 1861 |     QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - | 
| 1862 |     QAbstractTextDocumentLayout::PaintContext ctx; | - | 
| 1863 |  | - | 
| 1864 |     painter->setClipRect(view); | - | 
| 1865 |     ctx.clip = view; | - | 
| 1866 |  | - | 
| 1867 |      | - | 
| 1868 |      | - | 
| 1869 |      | - | 
| 1870 |     ctx.palette.setColor(QPalette::Text, Qt::black); | - | 
| 1871 |  | - | 
| 1872 |     layout->draw(painter, ctx); | - | 
| 1873 |  | - | 
| 1874 |     if (!pageNumberPos.isNull()) { | - | 
| 1875 |         painter->setClipping(false); | - | 
| 1876 |         painter->setFont(QFont(doc->defaultFont())); | - | 
| 1877 |         const QString pageString = QString::number(index); | - | 
| 1878 |  | - | 
| 1879 |         painter->drawText(qRound(pageNumberPos.x() - painter->fontMetrics().width(pageString)), | - | 
| 1880 |                           qRound(pageNumberPos.y() + view.top()), | - | 
| 1881 |                           pageString); | - | 
| 1882 |     } | - | 
| 1883 |  | - | 
| 1884 |     painter->restore(); | - | 
| 1885 | } | - | 
| 1886 |  | - | 
| 1887 |  | - | 
| 1888 |  | - | 
| 1889 |  | - | 
| 1890 |  | - | 
| 1891 |  | - | 
| 1892 |  | - | 
| 1893 |  | - | 
| 1894 |  | - | 
| 1895 |  | - | 
| 1896 |  | - | 
| 1897 |  | - | 
| 1898 |  | - | 
| 1899 |  | - | 
| 1900 |  | - | 
| 1901 |  | - | 
| 1902 |  | - | 
| 1903 |  | - | 
| 1904 |  | - | 
| 1905 | void QTextDocument::print(QPagedPaintDevice *printer) const | - | 
| 1906 | { | - | 
| 1907 |     Q_D(const QTextDocument); | - | 
| 1908 |  | - | 
| 1909 |     if (!printer) | - | 
| 1910 |         return; | - | 
| 1911 |  | - | 
| 1912 |     bool documentPaginated = d->pageSize.isValid() && !d->pageSize.isNull() | - | 
| 1913 |                              && d->pageSize.height() != INT_MAX; | - | 
| 1914 |  | - | 
| 1915 |     QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer); | - | 
| 1916 |  | - | 
| 1917 |      | - | 
| 1918 |     QPagedPaintDevice::Margins m = printer->margins(); | - | 
| 1919 |     if (!documentPaginated && m.left == 0. && m.right == 0. && m.top == 0. && m.bottom == 0.) { | - | 
| 1920 |         m.left = m.right = m.top = m.bottom = 2.; | - | 
| 1921 |         printer->setMargins(m); | - | 
| 1922 |     } | - | 
| 1923 |      | - | 
| 1924 |  | - | 
| 1925 |     QPainter p(printer); | - | 
| 1926 |  | - | 
| 1927 |      | - | 
| 1928 |     if (!p.isActive()) | - | 
| 1929 |         return; | - | 
| 1930 |  | - | 
| 1931 |     const QTextDocument *doc = this; | - | 
| 1932 |     QScopedPointer<QTextDocument> clonedDoc; | - | 
| 1933 |     (void)doc->documentLayout();  | - | 
| 1934 |  | - | 
| 1935 |     QRectF body = QRectF(QPointF(0, 0), d->pageSize); | - | 
| 1936 |     QPointF pageNumberPos; | - | 
| 1937 |  | - | 
| 1938 |     if (documentPaginated) { | - | 
| 1939 |         qreal sourceDpiX = qt_defaultDpi(); | - | 
| 1940 |         qreal sourceDpiY = sourceDpiX; | - | 
| 1941 |  | - | 
| 1942 |         QPaintDevice *dev = doc->documentLayout()->paintDevice(); | - | 
| 1943 |         if (dev) { | - | 
| 1944 |             sourceDpiX = dev->logicalDpiX(); | - | 
| 1945 |             sourceDpiY = dev->logicalDpiY(); | - | 
| 1946 |         } | - | 
| 1947 |  | - | 
| 1948 |         const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX; | - | 
| 1949 |         const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY; | - | 
| 1950 |  | - | 
| 1951 |          | - | 
| 1952 |         p.scale(dpiScaleX, dpiScaleY); | - | 
| 1953 |  | - | 
| 1954 |         QSizeF scaledPageSize = d->pageSize; | - | 
| 1955 |         scaledPageSize.rwidth() *= dpiScaleX; | - | 
| 1956 |         scaledPageSize.rheight() *= dpiScaleY; | - | 
| 1957 |  | - | 
| 1958 |         const QSizeF printerPageSize(printer->width(), printer->height()); | - | 
| 1959 |  | - | 
| 1960 |          | - | 
| 1961 |         p.scale(printerPageSize.width() / scaledPageSize.width(), | - | 
| 1962 |                 printerPageSize.height() / scaledPageSize.height()); | - | 
| 1963 |     } else { | - | 
| 1964 |         doc = clone(const_cast<QTextDocument *>(this)); | - | 
| 1965 |         clonedDoc.reset(const_cast<QTextDocument *>(doc)); | - | 
| 1966 |  | - | 
| 1967 |         for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); | - | 
| 1968 |              srcBlock.isValid() && dstBlock.isValid(); | - | 
| 1969 |              srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { | - | 
| 1970 |             dstBlock.layout()->setFormats(srcBlock.layout()->formats()); | - | 
| 1971 |         } | - | 
| 1972 |  | - | 
| 1973 |         QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - | 
| 1974 |         layout->setPaintDevice(p.device()); | - | 
| 1975 |  | - | 
| 1976 |          | - | 
| 1977 |         layout->d_func()->handlers = documentLayout()->d_func()->handlers; | - | 
| 1978 |  | - | 
| 1979 |         int dpiy = p.device()->logicalDpiY(); | - | 
| 1980 |         int margin = (int) ((2/2.54)*dpiy);  | - | 
| 1981 |         QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); | - | 
| 1982 |         fmt.setMargin(margin); | - | 
| 1983 |         doc->rootFrame()->setFrameFormat(fmt); | - | 
| 1984 |  | - | 
| 1985 |         body = QRectF(0, 0, printer->width(), printer->height()); | - | 
| 1986 |         pageNumberPos = QPointF(body.width() - margin, | - | 
| 1987 |                                 body.height() - margin | - | 
| 1988 |                                 + QFontMetrics(doc->defaultFont(), p.device()).ascent() | - | 
| 1989 |                                 + 5 * dpiy / 72.0); | - | 
| 1990 |         clonedDoc->setPageSize(body.size()); | - | 
| 1991 |     } | - | 
| 1992 |  | - | 
| 1993 |     int fromPage = pd->fromPage; | - | 
| 1994 |     int toPage = pd->toPage; | - | 
| 1995 |     bool ascending = true; | - | 
| 1996 |  | - | 
| 1997 |     if (fromPage == 0 && toPage == 0) { | - | 
| 1998 |         fromPage = 1; | - | 
| 1999 |         toPage = doc->pageCount(); | - | 
| 2000 |     } | - | 
| 2001 |      | - | 
| 2002 |     fromPage = qMax(1, fromPage); | - | 
| 2003 |     toPage = qMin(doc->pageCount(), toPage); | - | 
| 2004 |  | - | 
| 2005 |     if (toPage < fromPage) { | - | 
| 2006 |          | - | 
| 2007 |          | - | 
| 2008 |         return; | - | 
| 2009 |     } | - | 
| 2010 |  | - | 
| 2011 |  | - | 
| 2012 |  | - | 
| 2013 |  | - | 
| 2014 |  | - | 
| 2015 |  | - | 
| 2016 |  | - | 
| 2017 |  | - | 
| 2018 |     int page = fromPage; | - | 
| 2019 |     while (true) { | - | 
| 2020 |         printPage(page, &p, doc, body, pageNumberPos); | - | 
| 2021 |  | - | 
| 2022 |         if (page == toPage) | - | 
| 2023 |             break; | - | 
| 2024 |  | - | 
| 2025 |         if (ascending) | - | 
| 2026 |             ++page; | - | 
| 2027 |         else | - | 
| 2028 |             --page; | - | 
| 2029 |  | - | 
| 2030 |         if (!printer->newPage()) | - | 
| 2031 |             return; | - | 
| 2032 |     } | - | 
| 2033 | } | - | 
| 2034 | #endif | - | 
| 2035 |  | - | 
| 2036 |  | - | 
| 2037 |  | - | 
| 2038 |  | - | 
| 2039 |  | - | 
| 2040 |  | - | 
| 2041 |  | - | 
| 2042 |  | - | 
| 2043 |  | - | 
| 2044 |  | - | 
| 2045 |  | - | 
| 2046 |  | - | 
| 2047 |  | - | 
| 2048 |  | - | 
| 2049 |  | - | 
| 2050 |  | - | 
| 2051 |  | - | 
| 2052 |  | - | 
| 2053 |  | - | 
| 2054 |  | - | 
| 2055 |  | - | 
| 2056 |  | - | 
| 2057 |  | - | 
| 2058 |  | - | 
| 2059 |  | - | 
| 2060 |  | - | 
| 2061 |  | - | 
| 2062 |  | - | 
| 2063 |  | - | 
| 2064 |  | - | 
| 2065 |  | - | 
| 2066 |  | - | 
| 2067 |  | - | 
| 2068 |  | - | 
| 2069 |  | - | 
| 2070 |  | - | 
| 2071 |  | - | 
| 2072 |  | - | 
| 2073 | QVariant QTextDocument::resource(int type, const QUrl &name) const | - | 
| 2074 | { | - | 
| 2075 |     Q_D(const QTextDocument); | - | 
| 2076 |     const QUrl url = d->baseUrl.resolved(name); | - | 
| 2077 |     QVariant r = d->resources.value(url); | - | 
| 2078 |     if (!r.isValid()) { | - | 
| 2079 |         r = d->cachedResources.value(url); | - | 
| 2080 |         if (!r.isValid()) | - | 
| 2081 |             r = const_cast<QTextDocument *>(this)->loadResource(type, url); | - | 
| 2082 |     } | - | 
| 2083 |     return r; | - | 
| 2084 | } | - | 
| 2085 |  | - | 
| 2086 |  | - | 
| 2087 |  | - | 
| 2088 |  | - | 
| 2089 |  | - | 
| 2090 |  | - | 
| 2091 |  | - | 
| 2092 |  | - | 
| 2093 |  | - | 
| 2094 |  | - | 
| 2095 |  | - | 
| 2096 |  | - | 
| 2097 |  | - | 
| 2098 |  | - | 
| 2099 |  | - | 
| 2100 |  | - | 
| 2101 |  | - | 
| 2102 |  | - | 
| 2103 |  | - | 
| 2104 | void QTextDocument::addResource(int type, const QUrl &name, const QVariant &resource) | - | 
| 2105 | { | - | 
| 2106 |     Q_UNUSED(type); | - | 
| 2107 |     Q_D(QTextDocument); | - | 
| 2108 |     d->resources.insert(name, resource); | - | 
| 2109 | } | - | 
| 2110 |  | - | 
| 2111 |  | - | 
| 2112 |  | - | 
| 2113 |  | - | 
| 2114 |  | - | 
| 2115 |  | - | 
| 2116 |  | - | 
| 2117 |  | - | 
| 2118 |  | - | 
| 2119 |  | - | 
| 2120 |  | - | 
| 2121 |  | - | 
| 2122 |  | - | 
| 2123 |  | - | 
| 2124 |  | - | 
| 2125 |  | - | 
| 2126 |  | - | 
| 2127 |  | - | 
| 2128 | QVariant QTextDocument::loadResource(int type, const QUrl &name) | - | 
| 2129 | { | - | 
| 2130 |     Q_D(QTextDocument); | - | 
| 2131 |     QVariant r; | - | 
| 2132 |  | - | 
| 2133 |     QObject *p = parent(); | - | 
| 2134 |     if (p) { | - | 
| 2135 |         const QMetaObject *me = p->metaObject(); | - | 
| 2136 |         int index = me->indexOfMethod("loadResource(int,QUrl)"); | - | 
| 2137 |         if (index >= 0) { | - | 
| 2138 |             QMetaMethod loader = me->method(index); | - | 
| 2139 |             loader.invoke(p, Q_RETURN_ARG(QVariant, r), Q_ARG(int, type), Q_ARG(QUrl, name)); | - | 
| 2140 |         } | - | 
| 2141 |     } | - | 
| 2142 |  | - | 
| 2143 |      | - | 
| 2144 |     if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { | - | 
| 2145 |         QString mimetype; | - | 
| 2146 |         QByteArray payload; | - | 
| 2147 |         if (qDecodeDataUrl(name, mimetype, payload)) | - | 
| 2148 |             r = payload; | - | 
| 2149 |     } | - | 
| 2150 |  | - | 
| 2151 |      | - | 
| 2152 |     if (!qobject_cast<QTextDocument *>(p) && r.isNull()) { | - | 
| 2153 |         QUrl resourceUrl = name; | - | 
| 2154 |  | - | 
| 2155 |         if (name.isRelative()) { | - | 
| 2156 |             QUrl currentURL = d->url; | - | 
| 2157 |              | - | 
| 2158 |              | - | 
| 2159 |             if (!(currentURL.isRelative() | - | 
| 2160 |                   || (currentURL.scheme() == QLatin1String("file") | - | 
| 2161 |                       && !QFileInfo(currentURL.toLocalFile()).isAbsolute())) | - | 
| 2162 |                 || (name.hasFragment() && name.path().isEmpty())) { | - | 
| 2163 |                 resourceUrl =  currentURL.resolved(name); | - | 
| 2164 |             } else { | - | 
| 2165 |                  | - | 
| 2166 |                  | - | 
| 2167 |                  | - | 
| 2168 |                 QFileInfo fi(currentURL.toLocalFile()); | - | 
| 2169 |                 if (fi.exists()) { | - | 
| 2170 |                     resourceUrl = | - | 
| 2171 |                         QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name); | - | 
| 2172 |                 } else if (currentURL.isEmpty()) { | - | 
| 2173 |                     resourceUrl.setScheme(QLatin1String("file")); | - | 
| 2174 |                 } | - | 
| 2175 |             } | - | 
| 2176 |         } | - | 
| 2177 |  | - | 
| 2178 |         QString s = resourceUrl.toLocalFile(); | - | 
| 2179 |         QFile f(s); | - | 
| 2180 |         if (!s.isEmpty() && f.open(QFile::ReadOnly)) { | - | 
| 2181 |             r = f.readAll(); | - | 
| 2182 |             f.close(); | - | 
| 2183 |         } | - | 
| 2184 |     } | - | 
| 2185 |  | - | 
| 2186 |     if (!r.isNull()) { | - | 
| 2187 |         if (type == ImageResource && r.type() == QVariant::ByteArray) { | - | 
| 2188 |             if (qApp->thread() != QThread::currentThread()) { | - | 
| 2189 |                  | - | 
| 2190 |                 QImage image; | - | 
| 2191 |                 image.loadFromData(r.toByteArray()); | - | 
| 2192 |                 if (!image.isNull()) | - | 
| 2193 |                     r = image; | - | 
| 2194 |             } else { | - | 
| 2195 |                 QPixmap pm; | - | 
| 2196 |                 pm.loadFromData(r.toByteArray()); | - | 
| 2197 |                 if (!pm.isNull()) | - | 
| 2198 |                     r = pm; | - | 
| 2199 |             } | - | 
| 2200 |         } | - | 
| 2201 |         d->cachedResources.insert(name, r); | - | 
| 2202 |     } | - | 
| 2203 |     return r; | - | 
| 2204 | } | - | 
| 2205 |  | - | 
| 2206 | static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to) | - | 
| 2207 | { | - | 
| 2208 |     QTextFormat diff = to; | - | 
| 2209 |  | - | 
| 2210 |     const QMap<int, QVariant> props = to.properties(); | - | 
| 2211 |     for (QMap<int, QVariant>::ConstIterator it = props.begin(), end = props.end(); | - | 
| 2212 |          it != end; ++it) | - | 
| 2213 |         if (it.value() == from.property(it.key())) | - | 
| 2214 |             diff.clearProperty(it.key()); | - | 
| 2215 |  | - | 
| 2216 |     return diff; | - | 
| 2217 | } | - | 
| 2218 |  | - | 
| 2219 | static QString colorValue(QColor color) | - | 
| 2220 | { | - | 
| 2221 |     QString result; | - | 
| 2222 |  | - | 
| 2223 |     if (color.alpha() == 255) { | - | 
| 2224 |         result = color.name(); | - | 
| 2225 |     } else if (color.alpha()) { | - | 
| 2226 |         QString alphaValue = QString::number(color.alphaF(), 'f', 6).remove(QRegExp(QLatin1String("\\.?0*$"))); | - | 
| 2227 |         result = QString::fromLatin1("rgba(%1,%2,%3,%4)").arg(color.red()) | - | 
| 2228 |                                                          .arg(color.green()) | - | 
| 2229 |                                                          .arg(color.blue()) | - | 
| 2230 |                                                          .arg(alphaValue); | - | 
| 2231 |     } else { | - | 
| 2232 |         result = QLatin1String("transparent"); | - | 
| 2233 |     } | - | 
| 2234 |  | - | 
| 2235 |     return result; | - | 
| 2236 | } | - | 
| 2237 |  | - | 
| 2238 | QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc) | - | 
| 2239 |     : doc(_doc), fragmentMarkers(false) | - | 
| 2240 | { | - | 
| 2241 |     const QFont defaultFont = doc->defaultFont(); | - | 
| 2242 |     defaultCharFormat.setFont(defaultFont); | - | 
| 2243 |      | - | 
| 2244 |     defaultCharFormat.clearProperty(QTextFormat::FontUnderline); | - | 
| 2245 |     defaultCharFormat.clearProperty(QTextFormat::FontOverline); | - | 
| 2246 |     defaultCharFormat.clearProperty(QTextFormat::FontStrikeOut); | - | 
| 2247 |     defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle); | - | 
| 2248 | } | - | 
| 2249 |  | - | 
| 2250 |  | - | 
| 2251 |  | - | 
| 2252 |  | - | 
| 2253 |  | - | 
| 2254 |  | - | 
| 2255 | QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) | - | 
| 2256 | { | - | 
| 2257 |     html = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" " | - | 
| 2258 |             "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" | - | 
| 2259 |             "<html><head><meta name=\"qrichtext\" content=\"1\" />"); | - | 
| 2260 |     html.reserve(doc->docHandle()->length()); | - | 
| 2261 |  | - | 
| 2262 |     fragmentMarkers = (mode == ExportFragment); | - | 
| 2263 |  | - | 
| 2264 |     if (!encoding.isEmpty()) | - | 
| 2265 |         html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding)); | - | 
| 2266 |  | - | 
| 2267 |     QString title  = doc->metaInformation(QTextDocument::DocumentTitle); | - | 
| 2268 |     if (!title.isEmpty()) | - | 
| 2269 |         html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>"); | - | 
| 2270 |     html += QLatin1String("<style type=\"text/css\">\n"); | - | 
| 2271 |     html += QLatin1String("p, li { white-space: pre-wrap; }\n"); | - | 
| 2272 |     html += QLatin1String("</style>"); | - | 
| 2273 |     html += QLatin1String("</head><body"); | - | 
| 2274 |  | - | 
| 2275 |     if (mode == ExportEntireDocument) { | - | 
| 2276 |         html += QLatin1String(" style=\""); | - | 
| 2277 |  | - | 
| 2278 |         emitFontFamily(defaultCharFormat.fontFamily()); | - | 
| 2279 |  | - | 
| 2280 |         if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) { | - | 
| 2281 |             html += QLatin1String(" font-size:"); | - | 
| 2282 |             html += QString::number(defaultCharFormat.fontPointSize()); | - | 
| 2283 |             html += QLatin1String("pt;"); | - | 
| 2284 |         } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) { | - | 
| 2285 |             html += QLatin1String(" font-size:"); | - | 
| 2286 |             html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize)); | - | 
| 2287 |             html += QLatin1String("px;"); | - | 
| 2288 |         } | - | 
| 2289 |  | - | 
| 2290 |         html += QLatin1String(" font-weight:"); | - | 
| 2291 |         html += QString::number(defaultCharFormat.fontWeight() * 8); | - | 
| 2292 |         html += QLatin1Char(';'); | - | 
| 2293 |  | - | 
| 2294 |         html += QLatin1String(" font-style:"); | - | 
| 2295 |         html += (defaultCharFormat.fontItalic() ? QLatin1String("italic") : QLatin1String("normal")); | - | 
| 2296 |         html += QLatin1Char(';'); | - | 
| 2297 |  | - | 
| 2298 |          | - | 
| 2299 |          | - | 
| 2300 |  | - | 
| 2301 |         html += QLatin1Char('\"'); | - | 
| 2302 |  | - | 
| 2303 |         const QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); | - | 
| 2304 |         emitBackgroundAttribute(fmt); | - | 
| 2305 |  | - | 
| 2306 |     } else { | - | 
| 2307 |         defaultCharFormat = QTextCharFormat(); | - | 
| 2308 |     } | - | 
| 2309 |     html += QLatin1Char('>'); | - | 
| 2310 |  | - | 
| 2311 |     QTextFrameFormat rootFmt = doc->rootFrame()->frameFormat(); | - | 
| 2312 |     rootFmt.clearProperty(QTextFormat::BackgroundBrush); | - | 
| 2313 |  | - | 
| 2314 |     QTextFrameFormat defaultFmt; | - | 
| 2315 |     defaultFmt.setMargin(doc->documentMargin()); | - | 
| 2316 |  | - | 
| 2317 |     if (rootFmt == defaultFmt) | - | 
| 2318 |         emitFrame(doc->rootFrame()->begin()); | - | 
| 2319 |     else | - | 
| 2320 |         emitTextFrame(doc->rootFrame()); | - | 
| 2321 |  | - | 
| 2322 |     html += QLatin1String("</body></html>"); | - | 
| 2323 |     return html; | - | 
| 2324 | } | - | 
| 2325 |  | - | 
| 2326 | void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value) | - | 
| 2327 | { | - | 
| 2328 |     html += QLatin1Char(' '); | - | 
| 2329 |     html += QLatin1String(attribute); | - | 
| 2330 |     html += QLatin1String("=\""); | - | 
| 2331 |     html += value.toHtmlEscaped(); | - | 
| 2332 |     html += QLatin1Char('"'); | - | 
| 2333 | } | - | 
| 2334 |  | - | 
| 2335 | bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) | - | 
| 2336 | { | - | 
| 2337 |     bool attributesEmitted = false; | - | 
| 2338 |  | - | 
| 2339 |     { | - | 
| 2340 |         const QString family = format.fontFamily(); | - | 
| 2341 |         if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2342 |             emitFontFamily(family); | - | 
| 2343 |             attributesEmitted = true; | - | 
| 2344 |         } never executed: end of block  | 0 | 
| 2345 |     } | - | 
| 2346 |  | - | 
| 2347 |     if (format.hasProperty(QTextFormat::FontPointSize)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2348 |         && format.fontPointSize() != defaultCharFormat.fontPointSize()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2349 |         html += QLatin1String(" font-size:"); | - | 
| 2350 |         html += QString::number(format.fontPointSize()); | - | 
| 2351 |         html += QLatin1String("pt;"); | - | 
| 2352 |         attributesEmitted = true; | - | 
| 2353 |     } else if (format.hasProperty(QTextFormat::FontSizeAdjustment)) { never executed: end of block | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2354 |         static const char sizeNameData[] = | - | 
| 2355 |             "small" "\0" | - | 
| 2356 |             "medium" "\0" | - | 
| 2357 |             "xx-large" ; | - | 
| 2358 |         static const quint8 sizeNameOffsets[] = { | - | 
| 2359 |             0,                                          | - | 
| 2360 |             sizeof("small"),                            | - | 
| 2361 |             sizeof("small") + sizeof("medium") + 3,     | - | 
| 2362 |             sizeof("small") + sizeof("medium") + 1,     | - | 
| 2363 |             sizeof("small") + sizeof("medium"),         | - | 
| 2364 |         }; | - | 
| 2365 |         const char *name = 0; | - | 
| 2366 |         const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1; | - | 
| 2367 |         if (idx >= 0 && idx <= 4) {| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2368 |             name = sizeNameData + sizeNameOffsets[idx]; | - | 
| 2369 |         } never executed: end of block  | 0 | 
| 2370 |         if (name) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2371 |             html += QLatin1String(" font-size:"); | - | 
| 2372 |             html += QLatin1String(name); | - | 
| 2373 |             html += QLatin1Char(';'); | - | 
| 2374 |             attributesEmitted = true; | - | 
| 2375 |         } never executed: end of block  | 0 | 
| 2376 |     } else if (format.hasProperty(QTextFormat::FontPixelSize)) { never executed: end of block | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2377 |         html += QLatin1String(" font-size:"); | - | 
| 2378 |         html += QString::number(format.intProperty(QTextFormat::FontPixelSize)); | - | 
| 2379 |         html += QLatin1String("px;"); | - | 
| 2380 |         attributesEmitted = true; | - | 
| 2381 |     } never executed: end of block  | 0 | 
| 2382 |  | - | 
| 2383 |     if (format.hasProperty(QTextFormat::FontWeight)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2384 |         && format.fontWeight() != defaultCharFormat.fontWeight()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2385 |         html += QLatin1String(" font-weight:"); | - | 
| 2386 |         html += QString::number(format.fontWeight() * 8); | - | 
| 2387 |         html += QLatin1Char(';'); | - | 
| 2388 |         attributesEmitted = true; | - | 
| 2389 |     } never executed: end of block  | 0 | 
| 2390 |  | - | 
| 2391 |     if (format.hasProperty(QTextFormat::FontItalic)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2392 |         && format.fontItalic() != defaultCharFormat.fontItalic()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2393 |         html += QLatin1String(" font-style:"); | - | 
| 2394 |         html += (format.fontItalic() ? QLatin1String("italic") : QLatin1String("normal"));| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2395 |         html += QLatin1Char(';'); | - | 
| 2396 |         attributesEmitted = true; | - | 
| 2397 |     } never executed: end of block  | 0 | 
| 2398 |  | - | 
| 2399 |     QLatin1String decorationTag(" text-decoration:"); | - | 
| 2400 |     html += decorationTag; | - | 
| 2401 |     bool hasDecoration = false; | - | 
| 2402 |     bool atLeastOneDecorationSet = false; | - | 
| 2403 |  | - | 
| 2404 |     if ((format.hasProperty(QTextFormat::FontUnderline) || format.hasProperty(QTextFormat::TextUnderlineStyle))| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2405 |         && format.fontUnderline() != defaultCharFormat.fontUnderline()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2406 |         hasDecoration = true; | - | 
| 2407 |         if (format.fontUnderline()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2408 |             html += QLatin1String(" underline"); | - | 
| 2409 |             atLeastOneDecorationSet = true; | - | 
| 2410 |         } never executed: end of block  | 0 | 
| 2411 |     } never executed: end of block  | 0 | 
| 2412 |  | - | 
| 2413 |     if (format.hasProperty(QTextFormat::FontOverline)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2414 |         && format.fontOverline() != defaultCharFormat.fontOverline()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2415 |         hasDecoration = true; | - | 
| 2416 |         if (format.fontOverline()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2417 |             html += QLatin1String(" overline"); | - | 
| 2418 |             atLeastOneDecorationSet = true; | - | 
| 2419 |         } never executed: end of block  | 0 | 
| 2420 |     } never executed: end of block  | 0 | 
| 2421 |  | - | 
| 2422 |     if (format.hasProperty(QTextFormat::FontStrikeOut)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2423 |         && format.fontStrikeOut() != defaultCharFormat.fontStrikeOut()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2424 |         hasDecoration = true; | - | 
| 2425 |         if (format.fontStrikeOut()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2426 |             html += QLatin1String(" line-through"); | - | 
| 2427 |             atLeastOneDecorationSet = true; | - | 
| 2428 |         } never executed: end of block  | 0 | 
| 2429 |     } never executed: end of block  | 0 | 
| 2430 |  | - | 
| 2431 |     if (hasDecoration) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2432 |         if (!atLeastOneDecorationSet)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2433 |             html += QLatin1String("none"); never executed: html += QLatin1String("none");  | 0 | 
| 2434 |         html += QLatin1Char(';'); | - | 
| 2435 |         attributesEmitted = true; | - | 
| 2436 |     } else { never executed: end of block  | 0 | 
| 2437 |         html.chop(qstrlen(decorationTag.latin1()));size()); | - | 
| 2438 |     } never executed: end of block  | 0 | 
| 2439 |  | - | 
| 2440 |     if (format.foreground() != defaultCharFormat.foreground()| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2441 |         && format.foreground().style() != Qt::NoBrush) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2442 |         html += QLatin1String(" color:"); | - | 
| 2443 |         html += colorValue(format.foreground().color()); | - | 
| 2444 |         html += QLatin1Char(';'); | - | 
| 2445 |         attributesEmitted = true; | - | 
| 2446 |     } never executed: end of block  | 0 | 
| 2447 |  | - | 
| 2448 |     if (format.background() != defaultCharFormat.background()| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2449 |         && format.background().style() == Qt::SolidPattern) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2450 |         html += QLatin1String(" background-color:"); | - | 
| 2451 |         html += colorValue(format.background().color()); | - | 
| 2452 |         html += QLatin1Char(';'); | - | 
| 2453 |         attributesEmitted = true; | - | 
| 2454 |     } never executed: end of block  | 0 | 
| 2455 |  | - | 
| 2456 |     if (format.verticalAlignment() != defaultCharFormat.verticalAlignment()| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2457 |         && format.verticalAlignment() != QTextCharFormat::AlignNormal)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2458 |     { | - | 
| 2459 |         html += QLatin1String(" vertical-align:"); | - | 
| 2460 |  | - | 
| 2461 |         QTextCharFormat::VerticalAlignment valign = format.verticalAlignment(); | - | 
| 2462 |         if (valign == QTextCharFormat::AlignSubScript)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2463 |             html += QLatin1String("sub"); never executed: html += QLatin1String("sub");  | 0 | 
| 2464 |         else if (valign == QTextCharFormat::AlignSuperScript)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2465 |             html += QLatin1String("super"); never executed: html += QLatin1String("super");  | 0 | 
| 2466 |         else if (valign == QTextCharFormat::AlignMiddle)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2467 |             html += QLatin1String("middle"); never executed: html += QLatin1String("middle");  | 0 | 
| 2468 |         else if (valign == QTextCharFormat::AlignTop)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2469 |             html += QLatin1String("top"); never executed: html += QLatin1String("top");  | 0 | 
| 2470 |         else if (valign == QTextCharFormat::AlignBottom)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2471 |             html += QLatin1String("bottom"); never executed: html += QLatin1String("bottom");  | 0 | 
| 2472 |  | - | 
| 2473 |         html += QLatin1Char(';'); | - | 
| 2474 |         attributesEmitted = true; | - | 
| 2475 |     } never executed: end of block  | 0 | 
| 2476 |  | - | 
| 2477 |     if (format.fontCapitalization() != QFont::MixedCase) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2478 |         const QFont::Capitalization caps = format.fontCapitalization(); | - | 
| 2479 |         if (caps == QFont::AllUppercase)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2480 |             html += QLatin1String(" text-transform:uppercase;"); never executed: html += QLatin1String(" text-transform:uppercase;");  | 0 | 
| 2481 |         else if (caps == QFont::AllLowercase)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2482 |             html += QLatin1String(" text-transform:lowercase;"); never executed: html += QLatin1String(" text-transform:lowercase;");  | 0 | 
| 2483 |         else if (caps == QFont::SmallCaps)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2484 |             html += QLatin1String(" font-variant:small-caps;"); never executed: html += QLatin1String(" font-variant:small-caps;");  | 0 | 
| 2485 |         attributesEmitted = true; | - | 
| 2486 |     } never executed: end of block  | 0 | 
| 2487 |  | - | 
| 2488 |     if (format.fontWordSpacing() != 0.0) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2489 |         html += QLatin1String(" word-spacing:"); | - | 
| 2490 |         html += QString::number(format.fontWordSpacing()); | - | 
| 2491 |         html += QLatin1String("px;"); | - | 
| 2492 |         attributesEmitted = true; | - | 
| 2493 |     } never executed: end of block  | 0 | 
| 2494 |  | - | 
| 2495 |     return attributesEmitted; never executed: return attributesEmitted;  | 0 | 
| 2496 | } | - | 
| 2497 |  | - | 
| 2498 | void QTextHtmlExporter::emitTextLength(const char *attribute, const QTextLength &length) | - | 
| 2499 | { | - | 
| 2500 |     if (length.type() == QTextLength::VariableLength)  | - | 
| 2501 |         return; | - | 
| 2502 |  | - | 
| 2503 |     html += QLatin1Char(' '); | - | 
| 2504 |     html += QLatin1String(attribute); | - | 
| 2505 |     html += QLatin1String("=\""); | - | 
| 2506 |     html += QString::number(length.rawValue()); | - | 
| 2507 |  | - | 
| 2508 |     if (length.type() == QTextLength::PercentageLength) | - | 
| 2509 |         html += QLatin1String("%\""); | - | 
| 2510 |     else | - | 
| 2511 |         html += QLatin1Char('\"'); | - | 
| 2512 | } | - | 
| 2513 |  | - | 
| 2514 | void QTextHtmlExporter::emitAlignment(Qt::Alignment align) | - | 
| 2515 | { | - | 
| 2516 |     if (align & Qt::AlignLeft) | - | 
| 2517 |         return; | - | 
| 2518 |     else if (align & Qt::AlignRight) | - | 
| 2519 |         html += QLatin1String(" align=\"right\""); | - | 
| 2520 |     else if (align & Qt::AlignHCenter) | - | 
| 2521 |         html += QLatin1String(" align=\"center\""); | - | 
| 2522 |     else if (align & Qt::AlignJustify) | - | 
| 2523 |         html += QLatin1String(" align=\"justify\""); | - | 
| 2524 | } | - | 
| 2525 |  | - | 
| 2526 | void QTextHtmlExporter::emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode) | - | 
| 2527 | { | - | 
| 2528 |     if (pos == QTextFrameFormat::InFlow) | - | 
| 2529 |         return; | - | 
| 2530 |  | - | 
| 2531 |     if (mode == EmitStyleTag) | - | 
| 2532 |         html += QLatin1String(" style=\"float:"); | - | 
| 2533 |     else | - | 
| 2534 |         html += QLatin1String(" float:"); | - | 
| 2535 |  | - | 
| 2536 |     if (pos == QTextFrameFormat::FloatLeft) | - | 
| 2537 |         html += QLatin1String(" left;"); | - | 
| 2538 |     else if (pos == QTextFrameFormat::FloatRight) | - | 
| 2539 |         html += QLatin1String(" right;"); | - | 
| 2540 |     else | - | 
| 2541 |         Q_ASSERT_X(0, "QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type"); | - | 
| 2542 |  | - | 
| 2543 |     if (mode == EmitStyleTag) | - | 
| 2544 |         html += QLatin1Char('\"'); | - | 
| 2545 | } | - | 
| 2546 |  | - | 
| 2547 | void QTextHtmlExporter::emitBorderStyle(QTextFrameFormat::BorderStyle style) | - | 
| 2548 | { | - | 
| 2549 |     Q_ASSERT(style <= QTextFrameFormat::BorderStyle_Outset); | - | 
| 2550 |  | - | 
| 2551 |     html += QLatin1String(" border-style:"); | - | 
| 2552 |  | - | 
| 2553 |     switch (style) { | - | 
| 2554 |     case QTextFrameFormat::BorderStyle_None: | - | 
| 2555 |         html += QLatin1String("none"); | - | 
| 2556 |         break; | - | 
| 2557 |     case QTextFrameFormat::BorderStyle_Dotted: | - | 
| 2558 |         html += QLatin1String("dotted"); | - | 
| 2559 |         break; | - | 
| 2560 |     case QTextFrameFormat::BorderStyle_Dashed: | - | 
| 2561 |         html += QLatin1String("dashed"); | - | 
| 2562 |         break; | - | 
| 2563 |     case QTextFrameFormat::BorderStyle_Solid: | - | 
| 2564 |         html += QLatin1String("solid"); | - | 
| 2565 |         break; | - | 
| 2566 |     case QTextFrameFormat::BorderStyle_Double: | - | 
| 2567 |         html += QLatin1String("double"); | - | 
| 2568 |         break; | - | 
| 2569 |     case QTextFrameFormat::BorderStyle_DotDash: | - | 
| 2570 |         html += QLatin1String("dot-dash"); | - | 
| 2571 |         break; | - | 
| 2572 |     case QTextFrameFormat::BorderStyle_DotDotDash: | - | 
| 2573 |         html += QLatin1String("dot-dot-dash"); | - | 
| 2574 |         break; | - | 
| 2575 |     case QTextFrameFormat::BorderStyle_Groove: | - | 
| 2576 |         html += QLatin1String("groove"); | - | 
| 2577 |         break; | - | 
| 2578 |     case QTextFrameFormat::BorderStyle_Ridge: | - | 
| 2579 |         html += QLatin1String("ridge"); | - | 
| 2580 |         break; | - | 
| 2581 |     case QTextFrameFormat::BorderStyle_Inset: | - | 
| 2582 |         html += QLatin1String("inset"); | - | 
| 2583 |         break; | - | 
| 2584 |     case QTextFrameFormat::BorderStyle_Outset: | - | 
| 2585 |         html += QLatin1String("outset"); | - | 
| 2586 |         break; | - | 
| 2587 |     default: | - | 
| 2588 |         Q_ASSERT(false); | - | 
| 2589 |         break; | - | 
| 2590 |     }; | - | 
| 2591 |  | - | 
| 2592 |     html += QLatin1Char(';'); | - | 
| 2593 | } | - | 
| 2594 |  | - | 
| 2595 | void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy) | - | 
| 2596 | { | - | 
| 2597 |     if (policy & QTextFormat::PageBreak_AlwaysBefore) | - | 
| 2598 |         html += QLatin1String(" page-break-before:always;"); | - | 
| 2599 |  | - | 
| 2600 |     if (policy & QTextFormat::PageBreak_AlwaysAfter) | - | 
| 2601 |         html += QLatin1String(" page-break-after:always;"); | - | 
| 2602 | } | - | 
| 2603 |  | - | 
| 2604 | void QTextHtmlExporter::emitFontFamily(const QString &family) | - | 
| 2605 | { | - | 
| 2606 |     html += QLatin1String(" font-family:"); | - | 
| 2607 |  | - | 
| 2608 |     QLatin1String quote("\'"); | - | 
| 2609 |     if (family.contains(QLatin1Char('\''))) | - | 
| 2610 |         quote = QLatin1String("""); | - | 
| 2611 |  | - | 
| 2612 |     html += quote; | - | 
| 2613 |     html += family.toHtmlEscaped(); | - | 
| 2614 |     html += quote; | - | 
| 2615 |     html += QLatin1Char(';'); | - | 
| 2616 | } | - | 
| 2617 |  | - | 
| 2618 | void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right) | - | 
| 2619 | { | - | 
| 2620 |     html += QLatin1String(" margin-top:"); | - | 
| 2621 |     html += top; | - | 
| 2622 |     html += QLatin1String("px;"); | - | 
| 2623 |  | - | 
| 2624 |     html += QLatin1String(" margin-bottom:"); | - | 
| 2625 |     html += bottom; | - | 
| 2626 |     html += QLatin1String("px;"); | - | 
| 2627 |  | - | 
| 2628 |     html += QLatin1String(" margin-left:"); | - | 
| 2629 |     html += left; | - | 
| 2630 |     html += QLatin1String("px;"); | - | 
| 2631 |  | - | 
| 2632 |     html += QLatin1String(" margin-right:"); | - | 
| 2633 |     html += right; | - | 
| 2634 |     html += QLatin1String("px;"); | - | 
| 2635 | } | - | 
| 2636 |  | - | 
| 2637 | void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) | - | 
| 2638 | { | - | 
| 2639 |     const QTextCharFormat format = fragment.charFormat(); | - | 
| 2640 |  | - | 
| 2641 |     bool closeAnchor = false; | - | 
| 2642 |  | - | 
| 2643 |     if (format.isAnchor()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2644 |         const QString name = format.anchorName(); | - | 
| 2645 |         if (!name.isEmpty()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2646 |             html += QLatin1String("<a name=\""); | - | 
| 2647 |             html += name.toHtmlEscaped(); | - | 
| 2648 |             html += QLatin1String("\"></a>"); | - | 
| 2649 |         } never executed: end of block  | 0 | 
| 2650 |         const QString href = format.anchorHref(); | - | 
| 2651 |         if (!href.isEmpty()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2652 |             html += QLatin1String("<a href=\""); | - | 
| 2653 |             html += href.toHtmlEscaped(); | - | 
| 2654 |             html += QLatin1String("\">"); | - | 
| 2655 |             closeAnchor = true; | - | 
| 2656 |         } never executed: end of block  | 0 | 
| 2657 |     } never executed: end of block  | 0 | 
| 2658 |  | - | 
| 2659 |     QString txt = fragment.text(); | - | 
| 2660 |     const bool isObject = txt.contains(QChar::ObjectReplacementCharacter); | - | 
| 2661 |     const bool isImage = isObject && format.isImageFormat();| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2662 |  | - | 
| 2663 |     QLatin1String styleTag("<span style=\""); | - | 
| 2664 |     html += styleTag; | - | 
| 2665 |  | - | 
| 2666 |     bool attributesEmitted = false; | - | 
| 2667 |     if (!isImage)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2668 |         attributesEmitted = emitCharFormatStyle(format); never executed: attributesEmitted = emitCharFormatStyle(format);  | 0 | 
| 2669 |     if (attributesEmitted)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2670 |         html += QLatin1String("\">"); never executed: html += QLatin1String("\">");  | 0 | 
| 2671 |     else | - | 
| 2672 |         html.chop(qstrlen(styleTag.latin1()));size()); never executed: html.chop(styleTag.size());  | 0 | 
| 2673 |  | - | 
| 2674 |     if (isObject) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2675 |         for (int i = 0; isImage && i < txt.length(); ++i) {| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2676 |             QTextImageFormat imgFmt = format.toImageFormat(); | - | 
| 2677 |  | - | 
| 2678 |             html += QLatin1String("<img"); | - | 
| 2679 |  | - | 
| 2680 |             if (imgFmt.hasProperty(QTextFormat::ImageName))| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2681 |                 emitAttribute("src", imgFmt.name()); never executed: emitAttribute("src", imgFmt.name());  | 0 | 
| 2682 |  | - | 
| 2683 |             if (imgFmt.hasProperty(QTextFormat::ImageWidth))| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2684 |                 emitAttribute("width", QString::number(imgFmt.width())); never executed: emitAttribute("width", QString::number(imgFmt.width()));  | 0 | 
| 2685 |  | - | 
| 2686 |             if (imgFmt.hasProperty(QTextFormat::ImageHeight))| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2687 |                 emitAttribute("height", QString::number(imgFmt.height())); never executed: emitAttribute("height", QString::number(imgFmt.height()));  | 0 | 
| 2688 |  | - | 
| 2689 |             if (imgFmt.verticalAlignment() == QTextCharFormat::AlignMiddle)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2690 |                 html += QLatin1String(" style=\"vertical-align: middle;\""); never executed: html += QLatin1String(" style=\"vertical-align: middle;\"");  | 0 | 
| 2691 |             else if (imgFmt.verticalAlignment() == QTextCharFormat::AlignTop)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2692 |                 html += QLatin1String(" style=\"vertical-align: top;\""); never executed: html += QLatin1String(" style=\"vertical-align: top;\"");  | 0 | 
| 2693 |  | - | 
| 2694 |             if (QTextFrame *imageFrame = qobject_cast<QTextFrame *>(doc->objectForFormat(imgFmt)))| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2695 |                 emitFloatStyle(imageFrame->frameFormat().position()); never executed: emitFloatStyle(imageFrame->frameFormat().position());  | 0 | 
| 2696 |  | - | 
| 2697 |             html += QLatin1String(" />"); | - | 
| 2698 |         } never executed: end of block  | 0 | 
| 2699 |     } else { never executed: end of block  | 0 | 
| 2700 |         Q_ASSERT(!txt.contains(QChar::ObjectReplacementCharacter)); | - | 
| 2701 |  | - | 
| 2702 |         txt = txt.toHtmlEscaped(); | - | 
| 2703 |  | - | 
| 2704 |          | - | 
| 2705 |         QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]"); | - | 
| 2706 |         forcedLineBreakRegExp[3] = QChar::LineSeparator; | - | 
 |  |  | 
 |         const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp)); |  | 
| 2707 |         for (int i = 0; i < lines.count(); ++i) { | - | 
 |             if (i > 0) |  | 
 |                 html += QLatin1String("<br />");  Netscape, Lynx&Co. |  | 
 |              |  | 
| 2708 |         html += linestxt.atreplace(i); | - | 
 |         }QRegExp(forcedLineBreakRegExp), QLatin1String("<br />")); |  | 
| 2709 |     } never executed: end of block  | 0 | 
| 2710 |  | - | 
| 2711 |     if (attributesEmitted)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2712 |         html += QLatin1String("</span>"); never executed: html += QLatin1String("</span>");  | 0 | 
| 2713 |  | - | 
| 2714 |     if (closeAnchor)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2715 |         html += QLatin1String("</a>"); never executed: html += QLatin1String("</a>");  | 0 | 
| 2716 | } never executed: end of block  | 0 | 
| 2717 |  | - | 
| 2718 | static bool isOrderedList(int style) | - | 
| 2719 | { | - | 
| 2720 |     return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha | - | 
| 2721 |            || style == QTextListFormat::ListUpperAlpha | - | 
| 2722 |            || style == QTextListFormat::ListUpperRoman | - | 
| 2723 |            || style == QTextListFormat::ListLowerRoman | - | 
| 2724 |            ; | - | 
| 2725 | } | - | 
| 2726 |  | - | 
| 2727 | void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block) | - | 
| 2728 | { | - | 
| 2729 |     QTextBlockFormat format = block.blockFormat(); | - | 
| 2730 |     emitAlignment(format.alignment()); | - | 
| 2731 |  | - | 
| 2732 |      | - | 
| 2733 |      | - | 
| 2734 |     if (block.textDirection() == Qt::RightToLeft)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2735 |         html += QLatin1String(" dir='rtl'"); never executed: html += QLatin1String(" dir='rtl'");  | 0 | 
| 2736 |  | - | 
| 2737 |     QLatin1String style(" style=\""); | - | 
| 2738 |     html += style; | - | 
| 2739 |  | - | 
| 2740 |     const bool emptyBlock = block.begin().atEnd(); | - | 
| 2741 |     if (emptyBlock) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2742 |         html += QLatin1String("-qt-paragraph-type:empty;"); | - | 
| 2743 |     } never executed: end of block  | 0 | 
| 2744 |  | - | 
| 2745 |     emitMargins(QString::number(format.topMargin()), | - | 
| 2746 |                 QString::number(format.bottomMargin()), | - | 
| 2747 |                 QString::number(format.leftMargin()), | - | 
| 2748 |                 QString::number(format.rightMargin())); | - | 
| 2749 |  | - | 
| 2750 |     html += QLatin1String(" -qt-block-indent:"); | - | 
| 2751 |     html += QString::number(format.indent()); | - | 
| 2752 |     html += QLatin1Char(';'); | - | 
| 2753 |  | - | 
| 2754 |     html += QLatin1String(" text-indent:"); | - | 
| 2755 |     html += QString::number(format.textIndent()); | - | 
| 2756 |     html += QLatin1String("px;"); | - | 
| 2757 |  | - | 
| 2758 |     if (block.userState() != -1) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2759 |         html += QLatin1String(" -qt-user-state:"); | - | 
| 2760 |         html += QString::number(block.userState()); | - | 
| 2761 |         html += QLatin1Char(';'); | - | 
| 2762 |     } never executed: end of block  | 0 | 
| 2763 |  | - | 
| 2764 |     if (format.lineHeightType() != QTextBlockFormat::SingleHeight) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2765 |         html += QLatin1String(" line-height:") | - | 
| 2766 |              + QString::number(format.lineHeight()); | - | 
| 2767 |         switch (format.lineHeightType()) { | - | 
| 2768 |             case QTextBlockFormat::ProportionalHeight: never executed: case QTextBlockFormat::ProportionalHeight:  | 0 | 
| 2769 |                 html += QLatin1String("%;"); | - | 
| 2770 |                 break; never executed: break;  | 0 | 
| 2771 |             case QTextBlockFormat::FixedHeight: never executed: case QTextBlockFormat::FixedHeight:  | 0 | 
| 2772 |                 html += QLatin1String("; -qt-line-height-type: fixed;"); | - | 
| 2773 |                 break; never executed: break;  | 0 | 
| 2774 |             case QTextBlockFormat::MinimumHeight: never executed: case QTextBlockFormat::MinimumHeight:  | 0 | 
| 2775 |                 html += QLatin1String(" min-height:"px;"); | - | 
| 2776 |                 break; never executed: break;  | 0 | 
| 2777 |             case QTextBlockFormat::LineDistanceHeight: never executed: case QTextBlockFormat::LineDistanceHeight:  | 0 | 
| 2778 |                 html += QLatin1String("; -qt-line-spacingheight-type: line-distance;"); | - | 
| 2779 |                 break; never executed: break;  | 0 | 
 |             case QTextBlockFormat::SingleHeight: never executed: break;  |  | 
| 2780 |             default: never executed: default:  | 0 | 
| 2781 |                 html += QLatin1String(";"); | - | 
| 2782 |                 break;  never executed: break;  | 0 | 
| 2783 |         } | - | 
 |         html += QString::number(format.lineHeight()); |  | 
 |         if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight) |  | 
 |             html += QLatin1String("%;"); |  | 
 |         else |  | 
 |             html += QLatin1String("px;"); |  | 
| 2784 |     } | - | 
| 2785 |  | - | 
| 2786 |     emitPageBreakPolicy(format.pageBreakPolicy()); | - | 
| 2787 |  | - | 
| 2788 |     QTextCharFormat diff; | - | 
| 2789 |     if (emptyBlock) { | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2790 |         const QTextCharFormat blockCharFmt = block.charFormat(); | - | 
| 2791 |         diff = formatDifference(defaultCharFormat, blockCharFmt).toCharFormat(); | - | 
| 2792 |     } never executed: end of block  | 0 | 
| 2793 |  | - | 
| 2794 |     diff.clearProperty(QTextFormat::BackgroundBrush); | - | 
| 2795 |     if (format.hasProperty(QTextFormat::BackgroundBrush)) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2796 |         QBrush bg = format.background(); | - | 
| 2797 |         if (bg.style() != Qt::NoBrush)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2798 |             diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush)); never executed: diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush));  | 0 | 
| 2799 |     } never executed: end of block  | 0 | 
| 2800 |  | - | 
| 2801 |     if (!diff.properties().isEmpty())| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 2802 |         emitCharFormatStyle(diff); never executed: emitCharFormatStyle(diff);  | 0 | 
| 2803 |  | - | 
| 2804 |     html += QLatin1Char('"'); | - | 
| 2805 |  | - | 
| 2806 | } never executed: end of block  | 0 | 
| 2807 |  | - | 
| 2808 | void QTextHtmlExporter::emitBlock(const QTextBlock &block) | - | 
| 2809 | { | - | 
| 2810 |     if (block.begin().atEnd()) { | - | 
| 2811 |          | - | 
| 2812 |         int p = block.position(); | - | 
| 2813 |         if (p > 0) | - | 
| 2814 |             --p; | - | 
| 2815 |         QTextDocumentPrivate::FragmentIterator frag = doc->docHandle()->find(p); | - | 
| 2816 |         QChar ch = doc->docHandle()->buffer().at(frag->stringPosition); | - | 
| 2817 |         if (ch == QTextBeginningOfFrame | - | 
| 2818 |             || ch == QTextEndOfFrame) | - | 
| 2819 |             return; | - | 
| 2820 |     } | - | 
| 2821 |  | - | 
| 2822 |     html += QLatin1Char('\n'); | - | 
| 2823 |  | - | 
| 2824 |      | - | 
| 2825 |      | - | 
| 2826 |     QTextCharFormat oldDefaultCharFormat = defaultCharFormat; | - | 
| 2827 |  | - | 
| 2828 |     QTextList *list = block.textList(); | - | 
| 2829 |     if (list) { | - | 
| 2830 |         if (list->itemNumber(block) == 0) {  | - | 
| 2831 |             const QTextListFormat format = list->format(); | - | 
| 2832 |             const int style = format.style(); | - | 
| 2833 |             switch (style) { | - | 
| 2834 |                 case QTextListFormat::ListDecimal: html += QLatin1String("<ol"); break; | - | 
| 2835 |                 case QTextListFormat::ListDisc: html += QLatin1String("<ul"); break; | - | 
| 2836 |                 case QTextListFormat::ListCircle: html += QLatin1String("<ul type=\"circle\""); break; | - | 
| 2837 |                 case QTextListFormat::ListSquare: html += QLatin1String("<ul type=\"square\""); break; | - | 
| 2838 |                 case QTextListFormat::ListLowerAlpha: html += QLatin1String("<ol type=\"a\""); break; | - | 
| 2839 |                 case QTextListFormat::ListUpperAlpha: html += QLatin1String("<ol type=\"A\""); break; | - | 
| 2840 |                 case QTextListFormat::ListLowerRoman: html += QLatin1String("<ol type=\"i\""); break; | - | 
| 2841 |                 case QTextListFormat::ListUpperRoman: html += QLatin1String("<ol type=\"I\""); break; | - | 
| 2842 |                 default: html += QLatin1String("<ul");  | - | 
| 2843 |             } | - | 
| 2844 |  | - | 
| 2845 |             QString styleString = QString::fromLatin1("margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;"); | - | 
| 2846 |  | - | 
| 2847 |             if (format.hasProperty(QTextFormat::ListIndent)) { | - | 
| 2848 |                 styleString += QLatin1String(" -qt-list-indent: "); | - | 
| 2849 |                 styleString += QString::number(format.indent()); | - | 
| 2850 |                 styleString += QLatin1Char(';'); | - | 
| 2851 |             } | - | 
| 2852 |  | - | 
| 2853 |             if (format.hasProperty(QTextFormat::ListNumberPrefix)) { | - | 
| 2854 |                 QString numberPrefix = format.numberPrefix(); | - | 
| 2855 |                 numberPrefix.replace(QLatin1Char('"'), QLatin1String("\\22")); | - | 
| 2856 |                 numberPrefix.replace(QLatin1Char('\''), QLatin1String("\\27"));  | - | 
| 2857 |                 styleString += QLatin1String(" -qt-list-number-prefix: "); | - | 
| 2858 |                 styleString += QLatin1Char('\''); | - | 
| 2859 |                 styleString += numberPrefix; | - | 
| 2860 |                 styleString += QLatin1Char('\''); | - | 
| 2861 |                 styleString += QLatin1Char(';'); | - | 
| 2862 |             } | - | 
| 2863 |  | - | 
| 2864 |             if (format.hasProperty(QTextFormat::ListNumberSuffix)) { | - | 
| 2865 |                 if (format.numberSuffix() != QLatin1String(".")) {  | - | 
| 2866 |                     QString numberSuffix = format.numberSuffix(); | - | 
| 2867 |                     numberSuffix.replace(QLatin1Char('"'), QLatin1String("\\22")); | - | 
| 2868 |                     numberSuffix.replace(QLatin1Char('\''), QLatin1String("\\27"));  | - | 
| 2869 |                     styleString += QLatin1String(" -qt-list-number-suffix: "); | - | 
| 2870 |                     styleString += QLatin1Char('\''); | - | 
| 2871 |                     styleString += numberSuffix; | - | 
| 2872 |                     styleString += QLatin1Char('\''); | - | 
| 2873 |                     styleString += QLatin1Char(';'); | - | 
| 2874 |                 } | - | 
| 2875 |             } | - | 
| 2876 |  | - | 
| 2877 |             html += QLatin1String(" style=\""); | - | 
| 2878 |             html += styleString; | - | 
| 2879 |             html += QLatin1String("\">"); | - | 
| 2880 |         } | - | 
| 2881 |  | - | 
| 2882 |         html += QLatin1String("<li"); | - | 
| 2883 |  | - | 
| 2884 |         const QTextCharFormat blockFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat(); | - | 
| 2885 |         if (!blockFmt.properties().isEmpty()) { | - | 
| 2886 |             html += QLatin1String(" style=\""); | - | 
| 2887 |             emitCharFormatStyle(blockFmt); | - | 
| 2888 |             html += QLatin1Char('\"'); | - | 
| 2889 |  | - | 
| 2890 |             defaultCharFormat.merge(block.charFormat()); | - | 
| 2891 |         } | - | 
| 2892 |     } | - | 
| 2893 |  | - | 
| 2894 |     const QTextBlockFormat blockFormat = block.blockFormat(); | - | 
| 2895 |     if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) { | - | 
| 2896 |         html += QLatin1String("<hr"); | - | 
| 2897 |  | - | 
| 2898 |         QTextLength width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth); | - | 
| 2899 |         if (width.type() != QTextLength::VariableLength) | - | 
| 2900 |             emitTextLength("width", width); | - | 
| 2901 |         else | - | 
| 2902 |             html += QLatin1Char(' '); | - | 
| 2903 |  | - | 
| 2904 |         html += QLatin1String("/>"); | - | 
| 2905 |         return; | - | 
| 2906 |     } | - | 
| 2907 |  | - | 
| 2908 |     const bool pre = blockFormat.nonBreakableLines(); | - | 
| 2909 |     if (pre) { | - | 
| 2910 |         if (list) | - | 
| 2911 |             html += QLatin1Char('>'); | - | 
| 2912 |         html += QLatin1String("<pre"); | - | 
| 2913 |     } else if (!list) { | - | 
| 2914 |         html += QLatin1String("<p"); | - | 
| 2915 |     } | - | 
| 2916 |  | - | 
| 2917 |     emitBlockAttributes(block); | - | 
| 2918 |  | - | 
| 2919 |     html += QLatin1Char('>'); | - | 
| 2920 |     if (block.begin().atEnd()) | - | 
| 2921 |         html += QLatin1String("<br />"); | - | 
| 2922 |  | - | 
| 2923 |     QTextBlock::Iterator it = block.begin(); | - | 
| 2924 |     if (fragmentMarkers && !it.atEnd() && block == doc->begin()) | - | 
| 2925 |         html += QLatin1String("<!--StartFragment-->"); | - | 
| 2926 |  | - | 
| 2927 |     for (; !it.atEnd(); ++it) | - | 
| 2928 |         emitFragment(it.fragment()); | - | 
| 2929 |  | - | 
| 2930 |     if (fragmentMarkers && block.position() + block.length() == doc->docHandle()->length()) | - | 
| 2931 |         html += QLatin1String("<!--EndFragment-->"); | - | 
| 2932 |  | - | 
| 2933 |     if (pre) | - | 
| 2934 |         html += QLatin1String("</pre>"); | - | 
| 2935 |     else if (list) | - | 
| 2936 |         html += QLatin1String("</li>"); | - | 
| 2937 |     else | - | 
| 2938 |         html += QLatin1String("</p>"); | - | 
| 2939 |  | - | 
| 2940 |     if (list) { | - | 
| 2941 |         if (list->itemNumber(block) == list->count() - 1) {  | - | 
| 2942 |             if (isOrderedList(list->format().style())) | - | 
| 2943 |                 html += QLatin1String("</ol>"); | - | 
| 2944 |             else | - | 
| 2945 |                 html += QLatin1String("</ul>"); | - | 
| 2946 |         } | - | 
| 2947 |     } | - | 
| 2948 |  | - | 
| 2949 |     defaultCharFormat = oldDefaultCharFormat; | - | 
| 2950 | } | - | 
| 2951 |  | - | 
| 2952 | extern bool qHasPixmapTexture(const QBrush& brush); | - | 
| 2953 |  | - | 
| 2954 | QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap) | - | 
| 2955 | { | - | 
| 2956 |     QString url; | - | 
| 2957 |     if (!doc) | - | 
| 2958 |         return url; | - | 
| 2959 |  | - | 
| 2960 |     if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent())) | - | 
| 2961 |         return findUrlForImage(parent, cacheKey, isPixmap); | - | 
| 2962 |  | - | 
| 2963 |     if (doc && doc->docHandle()) { | - | 
| 2964 |         QTextDocumentPrivate *priv = doc->docHandle(); | - | 
| 2965 |         QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin(); | - | 
| 2966 |         for (; it != priv->cachedResources.constEnd(); ++it) { | - | 
| 2967 |  | - | 
| 2968 |             const QVariant &v = it.value(); | - | 
| 2969 |             if (v.type() == QVariant::Image && !isPixmap) { | - | 
| 2970 |                 if (qvariant_cast<QImage>(v).cacheKey() == cacheKey) | - | 
| 2971 |                     break; | - | 
| 2972 |             } | - | 
| 2973 |  | - | 
| 2974 |             if (v.type() == QVariant::Pixmap && isPixmap) { | - | 
| 2975 |                 if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey) | - | 
| 2976 |                     break; | - | 
| 2977 |             } | - | 
| 2978 |         } | - | 
| 2979 |  | - | 
| 2980 |         if (it != priv->cachedResources.constEnd()) | - | 
| 2981 |             url = it.key().toString(); | - | 
| 2982 |     } | - | 
| 2983 |  | - | 
| 2984 |     return url; | - | 
| 2985 | } | - | 
| 2986 |  | - | 
| 2987 | void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv) | - | 
| 2988 | { | - | 
| 2989 |     if (!priv) | - | 
| 2990 |         return; | - | 
| 2991 |  | - | 
| 2992 |     cachedResources.unite(priv->cachedResources); | - | 
| 2993 | } | - | 
| 2994 |  | - | 
| 2995 | void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format) | - | 
| 2996 | { | - | 
| 2997 |     if (format.hasProperty(QTextFormat::BackgroundImageUrl)) { | - | 
| 2998 |         QString url = format.property(QTextFormat::BackgroundImageUrl).toString(); | - | 
| 2999 |         emitAttribute("background", url); | - | 
| 3000 |     } else { | - | 
| 3001 |         const QBrush &brush = format.background(); | - | 
| 3002 |         if (brush.style() == Qt::SolidPattern) { | - | 
| 3003 |             emitAttribute("bgcolor", colorValue(brush.color())); | - | 
| 3004 |         } else if (brush.style() == Qt::TexturePattern) { | - | 
| 3005 |             const bool isPixmap = qHasPixmapTexture(brush); | - | 
| 3006 |             const qint64 cacheKey = isPixmap ? brush.texture().cacheKey() : brush.textureImage().cacheKey(); | - | 
| 3007 |  | - | 
| 3008 |             const QString url = findUrlForImage(doc, cacheKey, isPixmap); | - | 
| 3009 |  | - | 
| 3010 |             if (!url.isEmpty()) | - | 
| 3011 |                 emitAttribute("background", url); | - | 
| 3012 |         } | - | 
| 3013 |     } | - | 
| 3014 | } | - | 
| 3015 |  | - | 
| 3016 | void QTextHtmlExporter::emitTable(const QTextTable *table) | - | 
| 3017 | { | - | 
| 3018 |     QTextTableFormat format = table->format(); | - | 
| 3019 |  | - | 
| 3020 |     html += QLatin1String("\n<table"); | - | 
| 3021 |  | - | 
| 3022 |     if (format.hasProperty(QTextFormat::FrameBorder)) | - | 
| 3023 |         emitAttribute("border", QString::number(format.border())); | - | 
| 3024 |  | - | 
| 3025 |     emitFrameStyle(format, TableFrame); | - | 
| 3026 |  | - | 
| 3027 |     emitAlignment(format.alignment()); | - | 
| 3028 |     emitTextLength("width", format.width()); | - | 
| 3029 |  | - | 
| 3030 |     if (format.hasProperty(QTextFormat::TableCellSpacing)) | - | 
| 3031 |         emitAttribute("cellspacing", QString::number(format.cellSpacing())); | - | 
| 3032 |     if (format.hasProperty(QTextFormat::TableCellPadding)) | - | 
| 3033 |         emitAttribute("cellpadding", QString::number(format.cellPadding())); | - | 
| 3034 |  | - | 
| 3035 |     emitBackgroundAttribute(format); | - | 
| 3036 |  | - | 
| 3037 |     html += QLatin1Char('>'); | - | 
| 3038 |  | - | 
| 3039 |     const int rows = table->rows(); | - | 
| 3040 |     const int columns = table->columns(); | - | 
| 3041 |  | - | 
| 3042 |     QVector<QTextLength> columnWidths = format.columnWidthConstraints(); | - | 
| 3043 |     if (columnWidths.isEmpty()) { | - | 
| 3044 |         columnWidths.resize(columns); | - | 
| 3045 |         columnWidths.fill(QTextLength()); | - | 
| 3046 |     } | - | 
| 3047 |     Q_ASSERT(columnWidths.count() == columns); | - | 
| 3048 |  | - | 
| 3049 |     QVarLengthArray<bool> widthEmittedForColumn(columns); | - | 
| 3050 |     for (int i = 0; i < columns; ++i) | - | 
| 3051 |         widthEmittedForColumn[i] = false; | - | 
| 3052 |  | - | 
| 3053 |     const int headerRowCount = qMin(format.headerRowCount(), rows); | - | 
| 3054 |     if (headerRowCount > 0) | - | 
| 3055 |         html += QLatin1String("<thead>"); | - | 
| 3056 |  | - | 
| 3057 |     for (int row = 0; row < rows; ++row) { | - | 
| 3058 |         html += QLatin1String("\n<tr>"); | - | 
| 3059 |  | - | 
| 3060 |         for (int col = 0; col < columns; ++col) { | - | 
| 3061 |             const QTextTableCell cell = table->cellAt(row, col); | - | 
| 3062 |  | - | 
| 3063 |              | - | 
| 3064 |             if (cell.row() != row) | - | 
| 3065 |                 continue; | - | 
| 3066 |  | - | 
| 3067 |             if (cell.column() != col) | - | 
| 3068 |                 continue; | - | 
| 3069 |  | - | 
| 3070 |             html += QLatin1String("\n<td"); | - | 
| 3071 |  | - | 
| 3072 |             if (!widthEmittedForColumn[col] && cell.columnSpan() == 1) { | - | 
| 3073 |                 emitTextLength("width", columnWidths.at(col)); | - | 
| 3074 |                 widthEmittedForColumn[col] = true; | - | 
| 3075 |             } | - | 
| 3076 |  | - | 
| 3077 |             if (cell.columnSpan() > 1) | - | 
| 3078 |                 emitAttribute("colspan", QString::number(cell.columnSpan())); | - | 
| 3079 |  | - | 
| 3080 |             if (cell.rowSpan() > 1) | - | 
| 3081 |                 emitAttribute("rowspan", QString::number(cell.rowSpan())); | - | 
| 3082 |  | - | 
| 3083 |             const QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); | - | 
| 3084 |             emitBackgroundAttribute(cellFormat); | - | 
| 3085 |  | - | 
| 3086 |             QTextCharFormat oldDefaultCharFormat = defaultCharFormat; | - | 
| 3087 |  | - | 
| 3088 |             QTextCharFormat::VerticalAlignment valign = cellFormat.verticalAlignment(); | - | 
| 3089 |  | - | 
| 3090 |             QString styleString; | - | 
| 3091 |             if (valign >= QTextCharFormat::AlignMiddle && valign <= QTextCharFormat::AlignBottom) { | - | 
| 3092 |                 styleString += QLatin1String(" vertical-align:"); | - | 
| 3093 |                 switch (valign) { | - | 
| 3094 |                 case QTextCharFormat::AlignMiddle: | - | 
| 3095 |                     styleString += QLatin1String("middle"); | - | 
| 3096 |                     break; | - | 
| 3097 |                 case QTextCharFormat::AlignTop: | - | 
| 3098 |                     styleString += QLatin1String("top"); | - | 
| 3099 |                     break; | - | 
| 3100 |                 case QTextCharFormat::AlignBottom: | - | 
| 3101 |                     styleString += QLatin1String("bottom"); | - | 
| 3102 |                     break; | - | 
| 3103 |                 default: | - | 
| 3104 |                     break; | - | 
| 3105 |                 } | - | 
| 3106 |                 styleString += QLatin1Char(';'); | - | 
| 3107 |  | - | 
| 3108 |                 QTextCharFormat temp; | - | 
| 3109 |                 temp.setVerticalAlignment(valign); | - | 
| 3110 |                 defaultCharFormat.merge(temp); | - | 
| 3111 |             } | - | 
| 3112 |  | - | 
| 3113 |             if (cellFormat.hasProperty(QTextFormat::TableCellLeftPadding)) | - | 
| 3114 |                 styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';'); | - | 
| 3115 |             if (cellFormat.hasProperty(QTextFormat::TableCellRightPadding)) | - | 
| 3116 |                 styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';'); | - | 
| 3117 |             if (cellFormat.hasProperty(QTextFormat::TableCellTopPadding)) | - | 
| 3118 |                 styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';'); | - | 
| 3119 |             if (cellFormat.hasProperty(QTextFormat::TableCellBottomPadding)) | - | 
| 3120 |                 styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';'); | - | 
| 3121 |  | - | 
| 3122 |             if (!styleString.isEmpty()) | - | 
| 3123 |                 html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"'); | - | 
| 3124 |  | - | 
| 3125 |             html += QLatin1Char('>'); | - | 
| 3126 |  | - | 
| 3127 |             emitFrame(cell.begin()); | - | 
| 3128 |  | - | 
| 3129 |             html += QLatin1String("</td>"); | - | 
| 3130 |  | - | 
| 3131 |             defaultCharFormat = oldDefaultCharFormat; | - | 
| 3132 |         } | - | 
| 3133 |  | - | 
| 3134 |         html += QLatin1String("</tr>"); | - | 
| 3135 |         if (headerRowCount > 0 && row == headerRowCount - 1) | - | 
| 3136 |             html += QLatin1String("</thead>"); | - | 
| 3137 |     } | - | 
| 3138 |  | - | 
| 3139 |     html += QLatin1String("</table>"); | - | 
| 3140 | } | - | 
| 3141 |  | - | 
| 3142 | void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt) | - | 
| 3143 | { | - | 
| 3144 |     if (!frameIt.atEnd()) { | - | 
| 3145 |         QTextFrame::Iterator next = frameIt; | - | 
| 3146 |         ++next; | - | 
| 3147 |         if (next.atEnd() | - | 
| 3148 |             && frameIt.currentFrame() == 0 | - | 
| 3149 |             && frameIt.parentFrame() != doc->rootFrame() | - | 
| 3150 |             && frameIt.currentBlock().begin().atEnd()) | - | 
| 3151 |             return; | - | 
| 3152 |     } | - | 
| 3153 |  | - | 
| 3154 |     for (QTextFrame::Iterator it = frameIt; | - | 
| 3155 |          !it.atEnd(); ++it) { | - | 
| 3156 |         if (QTextFrame *f = it.currentFrame()) { | - | 
| 3157 |             if (QTextTable *table = qobject_cast<QTextTable *>(f)) { | - | 
| 3158 |                 emitTable(table); | - | 
| 3159 |             } else { | - | 
| 3160 |                 emitTextFrame(f); | - | 
| 3161 |             } | - | 
| 3162 |         } else if (it.currentBlock().isValid()) { | - | 
| 3163 |             emitBlock(it.currentBlock()); | - | 
| 3164 |         } | - | 
| 3165 |     } | - | 
| 3166 | } | - | 
| 3167 |  | - | 
| 3168 | void QTextHtmlExporter::emitTextFrame(const QTextFrame *f) | - | 
| 3169 | { | - | 
| 3170 |     FrameType frameType = f->parentFrame() ? TextFrame : RootFrame; | - | 
| 3171 |  | - | 
| 3172 |     html += QLatin1String("\n<table"); | - | 
| 3173 |     QTextFrameFormat format = f->frameFormat(); | - | 
| 3174 |  | - | 
| 3175 |     if (format.hasProperty(QTextFormat::FrameBorder)) | - | 
| 3176 |         emitAttribute("border", QString::number(format.border())); | - | 
| 3177 |  | - | 
| 3178 |     emitFrameStyle(format, frameType); | - | 
| 3179 |  | - | 
| 3180 |     emitTextLength("width", format.width()); | - | 
| 3181 |     emitTextLength("height", format.height()); | - | 
| 3182 |  | - | 
| 3183 |      | - | 
| 3184 |     if (frameType != RootFrame) | - | 
| 3185 |         emitBackgroundAttribute(format); | - | 
| 3186 |  | - | 
| 3187 |     html += QLatin1Char('>'); | - | 
| 3188 |     html += QLatin1String("\n<tr>\n<td style=\"border: none;\">"); | - | 
| 3189 |     emitFrame(f->begin()); | - | 
| 3190 |     html += QLatin1String("</td></tr></table>"); | - | 
| 3191 | } | - | 
| 3192 |  | - | 
| 3193 | void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType frameType) | - | 
| 3194 | { | - | 
| 3195 |     QLatin1String styleAttribute(" style=\""); | - | 
| 3196 |     html += styleAttribute; | - | 
| 3197 |     const int originalHtmlLength = html.length(); | - | 
| 3198 |  | - | 
| 3199 |     if (frameType == TextFrame)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3200 |         html += QLatin1String("-qt-table-type: frame;"); never executed: html += QLatin1String("-qt-table-type: frame;");  | 0 | 
| 3201 |     else if (frameType == RootFrame)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3202 |         html += QLatin1String("-qt-table-type: root;"); never executed: html += QLatin1String("-qt-table-type: root;");  | 0 | 
| 3203 |  | - | 
| 3204 |     const QTextFrameFormat defaultFormat; | - | 
| 3205 |  | - | 
| 3206 |     emitFloatStyle(format.position(), OmitStyleTag); | - | 
| 3207 |     emitPageBreakPolicy(format.pageBreakPolicy()); | - | 
| 3208 |  | - | 
| 3209 |     if (format.borderBrush() != defaultFormat.borderBrush()) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3210 |         html += QLatin1String(" border-color:"); | - | 
| 3211 |         html += colorValue(format.borderBrush().color()); | - | 
| 3212 |         html += QLatin1Char(';'); | - | 
| 3213 |     } never executed: end of block  | 0 | 
| 3214 |  | - | 
| 3215 |     if (format.borderStyle() != defaultFormat.borderStyle())| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3216 |         emitBorderStyle(format.borderStyle()); never executed: emitBorderStyle(format.borderStyle());  | 0 | 
| 3217 |  | - | 
| 3218 |     if (format.hasProperty(QTextFormat::FrameMargin)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3219 |         || format.hasProperty(QTextFormat::FrameLeftMargin)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3220 |         || format.hasProperty(QTextFormat::FrameRightMargin)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3221 |         || format.hasProperty(QTextFormat::FrameTopMargin)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3222 |         || format.hasProperty(QTextFormat::FrameBottomMargin))| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3223 |         emitMargins(QString::number(format.topMargin()), never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));  | 0 | 
| 3224 |                     QString::number(format.bottomMargin()), never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));  | 0 | 
| 3225 |                     QString::number(format.leftMargin()), never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));  | 0 | 
| 3226 |                     QString::number(format.rightMargin())); never executed: emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin()));  | 0 | 
| 3227 |  | - | 
| 3228 |     if (html.length() == originalHtmlLength) | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 3229 |         html.chop(qstrlen(styleAttribute.latin1()));size()); never executed: html.chop(styleAttribute.size());  | 0 | 
| 3230 |     else | - | 
| 3231 |         html += QLatin1Char('\"'); never executed: html += QLatin1Char('\"');  | 0 | 
| 3232 | } | - | 
| 3233 |  | - | 
| 3234 |  | - | 
| 3235 |  | - | 
| 3236 |  | - | 
| 3237 |  | - | 
| 3238 |  | - | 
| 3239 |  | - | 
| 3240 |  | - | 
| 3241 |  | - | 
| 3242 |  | - | 
| 3243 |  | - | 
| 3244 |  | - | 
| 3245 |  | - | 
| 3246 |  | - | 
| 3247 |  | - | 
| 3248 |  | - | 
| 3249 |  | - | 
| 3250 | #ifndef QT_NO_TEXTHTMLPARSER | - | 
| 3251 | QString QTextDocument::toHtml(const QByteArray &encoding) const | - | 
| 3252 | { | - | 
| 3253 |     return QTextHtmlExporter(this).toHtml(encoding); | - | 
| 3254 | } | - | 
| 3255 | #endif // QT_NO_TEXTHTMLPARSER | - | 
| 3256 |  | - | 
| 3257 |  | - | 
| 3258 |  | - | 
| 3259 |  | - | 
| 3260 | QVector<QTextFormat> QTextDocument::allFormats() const | - | 
| 3261 | { | - | 
| 3262 |     Q_D(const QTextDocument); | - | 
| 3263 |     return d->formatCollection()->formats; | - | 
| 3264 | } | - | 
| 3265 |  | - | 
| 3266 |  | - | 
| 3267 |  | - | 
| 3268 |  | - | 
| 3269 |  | - | 
| 3270 |  | - | 
| 3271 |  | - | 
| 3272 | QTextDocumentPrivate *QTextDocument::docHandle() const | - | 
| 3273 | { | - | 
| 3274 |     Q_D(const QTextDocument); | - | 
| 3275 |     return const_cast<QTextDocumentPrivate *>(d); | - | 
| 3276 | } | - | 
| 3277 |  | - | 
| 3278 |  | - | 
| 3279 |  | - | 
| 3280 |  | - | 
| 3281 |  | - | 
| 3282 |  | - | 
| 3283 |  | - | 
| 3284 |  | - | 
| 3285 | QT_END_NAMESPACE | - | 
 |  |  |