| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextdocument.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | __attribute__((visibility("default"))) unsigned int qt_int_sqrt(unsigned int n); | - | ||||||||||||||||||||||||||||||
| 9 | bool Qt::mightBeRichText(const QString& text) | - | ||||||||||||||||||||||||||||||
| 10 | { | - | ||||||||||||||||||||||||||||||
| 11 |     if (text.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 12 |         return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 13 | int start = 0; | - | ||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||
| 15 |     while (start < text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 16 |         ++ never executed:  start;++start;never executed:  ++start; | 0 | ||||||||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||
| 19 |     if (text.mid(start, 5) == QLatin1String("<?xml")
  | 0 | ||||||||||||||||||||||||||||||
| 20 |         while (start < text.length()
  | 0 | ||||||||||||||||||||||||||||||
| 21 |             if (text.at(start) == QLatin1Char('?')
  | 0 | ||||||||||||||||||||||||||||||
| 22 |                 && start + 2 < text.length()
  | 0 | ||||||||||||||||||||||||||||||
| 23 |                 && text.at(start + 1) == QLatin1Char('>')
  | 0 | ||||||||||||||||||||||||||||||
| 24 | start += 2; | - | ||||||||||||||||||||||||||||||
| 25 |                 break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 26 | } | - | ||||||||||||||||||||||||||||||
| 27 | ++start; | - | ||||||||||||||||||||||||||||||
| 28 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||
| 30 |         while (start < text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 31 |             ++ never executed:  start;++start;never executed:  ++start; | 0 | ||||||||||||||||||||||||||||||
| 32 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||||||||
| 34 |     if (text.mid(start, 5).toLower() == QLatin1String("<!doc")
  | 0 | ||||||||||||||||||||||||||||||
| 35 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 36 | int open = start; | - | ||||||||||||||||||||||||||||||
| 37 |     while (open < text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 38 |             && text.at(open) != QLatin1Char('\n')
  | 0 | ||||||||||||||||||||||||||||||
| 39 |         if (text.at(open) == QLatin1Char('&')
 
  | 0 | ||||||||||||||||||||||||||||||
| 40 |             return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 41 | ++open; | - | ||||||||||||||||||||||||||||||
| 42 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 43 |     if (open < text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 44 | const int close = text.indexOf(QLatin1Char('>'), open); | - | ||||||||||||||||||||||||||||||
| 45 |         if (close > -1
  | 0 | ||||||||||||||||||||||||||||||
| 46 | QString tag; | - | ||||||||||||||||||||||||||||||
| 47 |             for (int i = open+1; i < close
  | 0 | ||||||||||||||||||||||||||||||
| 48 |                 if (text[i].isDigit()
 
  | 0 | ||||||||||||||||||||||||||||||
| 49 |                     tag += text[i]; never executed:  tag += text[i]; | 0 | ||||||||||||||||||||||||||||||
| 50 |                 else if (!tag.isEmpty()
 
  | 0 | ||||||||||||||||||||||||||||||
| 51 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 52 |                 else if (!tag.isEmpty()
 
 
  | 0 | ||||||||||||||||||||||||||||||
| 53 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 54 |                 else if (!text[i].isSpace()
 
 
  | 0 | ||||||||||||||||||||||||||||||
| 55 |                     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 56 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 |             return never executed:   QTextHtmlParser::lookupElement(tag.toLower()) != -1;return QTextHtmlParser::lookupElement(tag.toLower()) != -1;never executed:  return QTextHtmlParser::lookupElement(tag.toLower()) != -1; | 0 | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | } | - | ||||||||||||||||||||||||||||||
| 63 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 64 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 65 | } | - | ||||||||||||||||||||||||||||||
| 66 | QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode) | - | ||||||||||||||||||||||||||||||
| 67 | { | - | ||||||||||||||||||||||||||||||
| 68 | int col = 0; | - | ||||||||||||||||||||||||||||||
| 69 | QString rich; | - | ||||||||||||||||||||||||||||||
| 70 | rich += QLatin1String("<p>"); | - | ||||||||||||||||||||||||||||||
| 71 |     for (int i = 0; i < plain.length()
  | 0 | ||||||||||||||||||||||||||||||
| 72 |         if (plain[i] == QLatin1Char('\n')
  | 0 | ||||||||||||||||||||||||||||||
| 73 | int c = 1; | - | ||||||||||||||||||||||||||||||
| 74 |             while (i+1 < plain.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 75 | i++; | - | ||||||||||||||||||||||||||||||
| 76 | c++; | - | ||||||||||||||||||||||||||||||
| 77 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 78 |             if (c == 1
  | 0 | ||||||||||||||||||||||||||||||
| 79 |                 rich += QLatin1String("<br>\n"); never executed:  rich += QLatin1String("<br>\n"); | 0 | ||||||||||||||||||||||||||||||
| 80 | else { | - | ||||||||||||||||||||||||||||||
| 81 | rich += QLatin1String("</p>\n"); | - | ||||||||||||||||||||||||||||||
| 82 |                 while (--
 
  | 0 | ||||||||||||||||||||||||||||||
| 83 |                     rich += QLatin1String("<br>\n"); never executed:  rich += QLatin1String("<br>\n"); | 0 | ||||||||||||||||||||||||||||||
| 84 | rich += QLatin1String("<p>"); | - | ||||||||||||||||||||||||||||||
| 85 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 86 | col = 0; | - | ||||||||||||||||||||||||||||||
| 87 |         } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 88 |             if (mode == Qt::WhiteSpacePre
 
  | 0 | ||||||||||||||||||||||||||||||
| 89 | rich += QChar(0x00a0U); | - | ||||||||||||||||||||||||||||||
| 90 | ++col; | - | ||||||||||||||||||||||||||||||
| 91 |                 while (col % 8
  | 0 | ||||||||||||||||||||||||||||||
| 92 | rich += QChar(0x00a0U); | - | ||||||||||||||||||||||||||||||
| 93 | ++col; | - | ||||||||||||||||||||||||||||||
| 94 |                 } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 95 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 96 |             else if (mode == Qt::WhiteSpacePre
 
  | 0 | ||||||||||||||||||||||||||||||
| 97 |                 rich += QChar(0x00a0U); never executed:  rich += QChar(0x00a0U); | 0 | ||||||||||||||||||||||||||||||
| 98 |             else if (plain[i] == QLatin1Char('<')
  | 0 | ||||||||||||||||||||||||||||||
| 99 |                 rich += QLatin1String("<"); never executed:  rich += QLatin1String("<"); | 0 | ||||||||||||||||||||||||||||||
| 100 |             else if (plain[i] == QLatin1Char('>')
  | 0 | ||||||||||||||||||||||||||||||
| 101 |                 rich += QLatin1String(">"); never executed:  rich += QLatin1String(">"); | 0 | ||||||||||||||||||||||||||||||
| 102 |             else if (plain[i] == QLatin1Char('&')
  | 0 | ||||||||||||||||||||||||||||||
| 103 |                 rich += QLatin1String("&"); never executed:  rich += QLatin1String("&"); | 0 | ||||||||||||||||||||||||||||||
| 104 | else | - | ||||||||||||||||||||||||||||||
| 105 |                 rich += plain[i]; never executed:  rich += plain[i]; | 0 | ||||||||||||||||||||||||||||||
| 106 | ++col; | - | ||||||||||||||||||||||||||||||
| 107 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||||||||
| 109 |     if (col != 0
  | 0 | ||||||||||||||||||||||||||||||
| 110 |         rich += QLatin1String("</p>"); never executed:  rich += QLatin1String("</p>"); | 0 | ||||||||||||||||||||||||||||||
| 111 |     return never executed:   rich;return rich;never executed:  return rich; | 0 | ||||||||||||||||||||||||||||||
| 112 | } | - | ||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||||||||
| 120 | QTextCodec *Qt::codecForHtml(const QByteArray &ba) | - | ||||||||||||||||||||||||||||||
| 121 | { | - | ||||||||||||||||||||||||||||||
| 122 |     return never executed:   QTextCodec::codecForHtml(ba);return QTextCodec::codecForHtml(ba);never executed:  return QTextCodec::codecForHtml(ba); | 0 | ||||||||||||||||||||||||||||||
| 123 | } | - | ||||||||||||||||||||||||||||||
| 124 | QTextDocument::QTextDocument(QObject *parent) | - | ||||||||||||||||||||||||||||||
| 125 | : QObject(*new QTextDocumentPrivate, parent) | - | ||||||||||||||||||||||||||||||
| 126 | { | - | ||||||||||||||||||||||||||||||
| 127 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 128 | d->init(); | - | ||||||||||||||||||||||||||||||
| 129 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||
| 135 | QTextDocument::QTextDocument(const QString &text, QObject *parent) | - | ||||||||||||||||||||||||||||||
| 136 | : QObject(*new QTextDocumentPrivate, parent) | - | ||||||||||||||||||||||||||||||
| 137 | { | - | ||||||||||||||||||||||||||||||
| 138 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 139 | d->init(); | - | ||||||||||||||||||||||||||||||
| 140 | QTextCursor(this).insertText(text); | - | ||||||||||||||||||||||||||||||
| 141 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | QTextDocument::QTextDocument(QTextDocumentPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||||||||
| 147 | : QObject(dd, parent) | - | ||||||||||||||||||||||||||||||
| 148 | { | - | ||||||||||||||||||||||||||||||
| 149 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 150 | d->init(); | - | ||||||||||||||||||||||||||||||
| 151 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | QTextDocument::~QTextDocument() | - | ||||||||||||||||||||||||||||||
| 157 | { | - | ||||||||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | QTextDocument *QTextDocument::clone(QObject *parent) const | - | ||||||||||||||||||||||||||||||
| 166 | { | - | ||||||||||||||||||||||||||||||
| 167 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 168 | QTextDocument *doc = new QTextDocument(parent); | - | ||||||||||||||||||||||||||||||
| 169 | QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); | - | ||||||||||||||||||||||||||||||
| 170 | doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat()); | - | ||||||||||||||||||||||||||||||
| 171 | QTextDocumentPrivate *priv = doc->d_func(); | - | ||||||||||||||||||||||||||||||
| 172 | priv->title = d->title; | - | ||||||||||||||||||||||||||||||
| 173 | priv->url = d->url; | - | ||||||||||||||||||||||||||||||
| 174 | priv->pageSize = d->pageSize; | - | ||||||||||||||||||||||||||||||
| 175 | priv->indentWidth = d->indentWidth; | - | ||||||||||||||||||||||||||||||
| 176 | priv->defaultTextOption = d->defaultTextOption; | - | ||||||||||||||||||||||||||||||
| 177 | priv->setDefaultFont(d->defaultFont()); | - | ||||||||||||||||||||||||||||||
| 178 | priv->resources = d->resources; | - | ||||||||||||||||||||||||||||||
| 179 | priv->cachedResources.clear(); | - | ||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||
| 181 | priv->defaultStyleSheet = d->defaultStyleSheet; | - | ||||||||||||||||||||||||||||||
| 182 | priv->parsedDefaultStyleSheet = d->parsedDefaultStyleSheet; | - | ||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||
| 184 |     return never executed:   doc;return doc;never executed:  return doc; | 0 | ||||||||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||||||||
| 190 | bool QTextDocument::isEmpty() const | - | ||||||||||||||||||||||||||||||
| 191 | { | - | ||||||||||||||||||||||||||||||
| 192 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||
| 195 |     return never executed:   d->length() <= 1;return d->length() <= 1;never executed:  return d->length() <= 1; | 0 | ||||||||||||||||||||||||||||||
| 196 | } | - | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | void QTextDocument::clear() | - | ||||||||||||||||||||||||||||||
| 202 | { | - | ||||||||||||||||||||||||||||||
| 203 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 204 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 205 | d->resources.clear(); | - | ||||||||||||||||||||||||||||||
| 206 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 207 | void QTextDocument::undo(QTextCursor *cursor) | - | ||||||||||||||||||||||||||||||
| 208 | { | - | ||||||||||||||||||||||||||||||
| 209 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 210 | const int pos = d->undoRedo(true); | - | ||||||||||||||||||||||||||||||
| 211 |     if (cursor
 
  | 0 | ||||||||||||||||||||||||||||||
| 212 | *cursor = QTextCursor(this); | - | ||||||||||||||||||||||||||||||
| 213 | cursor->setPosition(pos); | - | ||||||||||||||||||||||||||||||
| 214 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 215 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 216 | void QTextDocument::redo(QTextCursor *cursor) | - | ||||||||||||||||||||||||||||||
| 217 | { | - | ||||||||||||||||||||||||||||||
| 218 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 219 | const int pos = d->undoRedo(false); | - | ||||||||||||||||||||||||||||||
| 220 |     if (cursor
 
  | 0 | ||||||||||||||||||||||||||||||
| 221 | *cursor = QTextCursor(this); | - | ||||||||||||||||||||||||||||||
| 222 | cursor->setPosition(pos); | - | ||||||||||||||||||||||||||||||
| 223 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 224 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 225 | void QTextDocument::clearUndoRedoStacks(Stacks stacksToClear) | - | ||||||||||||||||||||||||||||||
| 226 | { | - | ||||||||||||||||||||||||||||||
| 227 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 228 | d->clearUndoRedoStacks(stacksToClear, true); | - | ||||||||||||||||||||||||||||||
| 229 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | void QTextDocument::undo() | - | ||||||||||||||||||||||||||||||
| 236 | { | - | ||||||||||||||||||||||||||||||
| 237 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 238 | d->undoRedo(true); | - | ||||||||||||||||||||||||||||||
| 239 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||||||||
| 245 | void QTextDocument::redo() | - | ||||||||||||||||||||||||||||||
| 246 | { | - | ||||||||||||||||||||||||||||||
| 247 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 248 | d->undoRedo(false); | - | ||||||||||||||||||||||||||||||
| 249 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||
| 256 | void QTextDocument::appendUndoItem(QAbstractUndoItem *item) | - | ||||||||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||||||||
| 258 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 259 | d->appendUndoItem(item); | - | ||||||||||||||||||||||||||||||
| 260 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 261 | void QTextDocument::setUndoRedoEnabled(bool enable) | - | ||||||||||||||||||||||||||||||
| 262 | { | - | ||||||||||||||||||||||||||||||
| 263 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 264 | d->enableUndoRedo(enable); | - | ||||||||||||||||||||||||||||||
| 265 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||||||||
| 267 | bool QTextDocument::isUndoRedoEnabled() const | - | ||||||||||||||||||||||||||||||
| 268 | { | - | ||||||||||||||||||||||||||||||
| 269 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 270 |     return never executed:   d->isUndoRedoEnabled();return d->isUndoRedoEnabled();never executed:  return d->isUndoRedoEnabled(); | 0 | ||||||||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||||||||
| 272 | int QTextDocument::maximumBlockCount() const | - | ||||||||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||||||||
| 274 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 275 |     return never executed:   d->maximumBlockCount;return d->maximumBlockCount;never executed:  return d->maximumBlockCount; | 0 | ||||||||||||||||||||||||||||||
| 276 | } | - | ||||||||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||||||||
| 278 | void QTextDocument::setMaximumBlockCount(int maximum) | - | ||||||||||||||||||||||||||||||
| 279 | { | - | ||||||||||||||||||||||||||||||
| 280 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 281 | d->maximumBlockCount = maximum; | - | ||||||||||||||||||||||||||||||
| 282 | d->ensureMaximumBlockCount(); | - | ||||||||||||||||||||||||||||||
| 283 | setUndoRedoEnabled(false); | - | ||||||||||||||||||||||||||||||
| 284 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 285 | QTextOption QTextDocument::defaultTextOption() const | - | ||||||||||||||||||||||||||||||
| 286 | { | - | ||||||||||||||||||||||||||||||
| 287 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 288 |     return never executed:   d->defaultTextOption;return d->defaultTextOption;never executed:  return d->defaultTextOption; | 0 | ||||||||||||||||||||||||||||||
| 289 | } | - | ||||||||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||||||||
| 296 | void QTextDocument::setDefaultTextOption(const QTextOption &option) | - | ||||||||||||||||||||||||||||||
| 297 | { | - | ||||||||||||||||||||||||||||||
| 298 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 299 | d->defaultTextOption = option; | - | ||||||||||||||||||||||||||||||
| 300 |     if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 301 |         d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 302 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 303 | QUrl QTextDocument::baseUrl() const | - | ||||||||||||||||||||||||||||||
| 304 | { | - | ||||||||||||||||||||||||||||||
| 305 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 306 |     return never executed:   d->baseUrl;return d->baseUrl;never executed:  return d->baseUrl; | 0 | ||||||||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||
| 309 | void QTextDocument::setBaseUrl(const QUrl &url) | - | ||||||||||||||||||||||||||||||
| 310 | { | - | ||||||||||||||||||||||||||||||
| 311 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 312 |     if (d->baseUrl != url
  | 0 | ||||||||||||||||||||||||||||||
| 313 | d->baseUrl = url; | - | ||||||||||||||||||||||||||||||
| 314 |         if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 315 |             d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 316 | baseUrlChanged(url); | - | ||||||||||||||||||||||||||||||
| 317 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 318 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||||||||
| 326 | Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const | - | ||||||||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||||||||
| 328 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 329 |     return never executed:   d->defaultCursorMoveStyle;return d->defaultCursorMoveStyle;never executed:  return d->defaultCursorMoveStyle; | 0 | ||||||||||||||||||||||||||||||
| 330 | } | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||
| 337 | void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style) | - | ||||||||||||||||||||||||||||||
| 338 | { | - | ||||||||||||||||||||||||||||||
| 339 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 340 | d->defaultCursorMoveStyle = style; | - | ||||||||||||||||||||||||||||||
| 341 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 342 | void QTextDocument::markContentsDirty(int from, int length) | - | ||||||||||||||||||||||||||||||
| 343 | { | - | ||||||||||||||||||||||||||||||
| 344 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 345 | d->documentChange(from, length); | - | ||||||||||||||||||||||||||||||
| 346 |     if (!d->inContentsChange
  | 0 | ||||||||||||||||||||||||||||||
| 347 |         if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 348 | d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength); | - | ||||||||||||||||||||||||||||||
| 349 | d->docChangeFrom = -1; | - | ||||||||||||||||||||||||||||||
| 350 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 351 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 352 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 353 | void QTextDocument::setUseDesignMetrics(bool b) | - | ||||||||||||||||||||||||||||||
| 354 | { | - | ||||||||||||||||||||||||||||||
| 355 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 356 |     if (b == d->defaultTextOption.useDesignMetrics()
  | 0 | ||||||||||||||||||||||||||||||
| 357 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 358 | d->defaultTextOption.setUseDesignMetrics(b); | - | ||||||||||||||||||||||||||||||
| 359 |     if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 360 |         d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 361 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||
| 363 | bool QTextDocument::useDesignMetrics() const | - | ||||||||||||||||||||||||||||||
| 364 | { | - | ||||||||||||||||||||||||||||||
| 365 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 366 |     return never executed:   d->defaultTextOption.useDesignMetrics();return d->defaultTextOption.useDesignMetrics();never executed:  return d->defaultTextOption.useDesignMetrics(); | 0 | ||||||||||||||||||||||||||||||
| 367 | } | - | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | void QTextDocument::drawContents(QPainter *p, const QRectF &rect) | - | ||||||||||||||||||||||||||||||
| 376 | { | - | ||||||||||||||||||||||||||||||
| 377 | p->save(); | - | ||||||||||||||||||||||||||||||
| 378 | QAbstractTextDocumentLayout::PaintContext ctx; | - | ||||||||||||||||||||||||||||||
| 379 |     if (rect.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 380 | p->setClipRect(rect); | - | ||||||||||||||||||||||||||||||
| 381 | ctx.clip = rect; | - | ||||||||||||||||||||||||||||||
| 382 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 383 | documentLayout()->draw(p, ctx); | - | ||||||||||||||||||||||||||||||
| 384 | p->restore(); | - | ||||||||||||||||||||||||||||||
| 385 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 386 | void QTextDocument::setTextWidth(qreal width) | - | ||||||||||||||||||||||||||||||
| 387 | { | - | ||||||||||||||||||||||||||||||
| 388 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 389 | QSizeF sz = d->pageSize; | - | ||||||||||||||||||||||||||||||
| 390 | sz.setWidth(width); | - | ||||||||||||||||||||||||||||||
| 391 | sz.setHeight(-1); | - | ||||||||||||||||||||||||||||||
| 392 | setPageSize(sz); | - | ||||||||||||||||||||||||||||||
| 393 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||||||||
| 395 | qreal QTextDocument::textWidth() const | - | ||||||||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||||||||
| 397 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 398 |     return never executed:   d->pageSize.width();return d->pageSize.width();never executed:  return d->pageSize.width(); | 0 | ||||||||||||||||||||||||||||||
| 399 | } | - | ||||||||||||||||||||||||||||||
| 400 | qreal QTextDocument::idealWidth() const | - | ||||||||||||||||||||||||||||||
| 401 | { | - | ||||||||||||||||||||||||||||||
| 402 |     if (QTextDocumentLayout *lout = qobject_cast<QTextDocumentLayout *>(documentLayout())
  | 0 | ||||||||||||||||||||||||||||||
| 403 |         return never executed:   lout->idealWidth();return lout->idealWidth();never executed:  return lout->idealWidth(); | 0 | ||||||||||||||||||||||||||||||
| 404 |     return never executed:   textWidth();return textWidth();never executed:  return textWidth(); | 0 | ||||||||||||||||||||||||||||||
| 405 | } | - | ||||||||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | qreal QTextDocument::documentMargin() const | - | ||||||||||||||||||||||||||||||
| 414 | { | - | ||||||||||||||||||||||||||||||
| 415 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 416 |     return never executed:   d->documentMargin;return d->documentMargin;never executed:  return d->documentMargin; | 0 | ||||||||||||||||||||||||||||||
| 417 | } | - | ||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||
| 419 | void QTextDocument::setDocumentMargin(qreal margin) | - | ||||||||||||||||||||||||||||||
| 420 | { | - | ||||||||||||||||||||||||||||||
| 421 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 422 |     if (d->documentMargin != margin
  | 0 | ||||||||||||||||||||||||||||||
| 423 | d->documentMargin = margin; | - | ||||||||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||||||||
| 425 | QTextFrame* root = rootFrame(); | - | ||||||||||||||||||||||||||||||
| 426 | QTextFrameFormat format = root->frameFormat(); | - | ||||||||||||||||||||||||||||||
| 427 | format.setMargin(margin); | - | ||||||||||||||||||||||||||||||
| 428 | root->setFrameFormat(format); | - | ||||||||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||||||||
| 430 |         if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 431 |             d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 432 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 433 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 434 | qreal QTextDocument::indentWidth() const | - | ||||||||||||||||||||||||||||||
| 435 | { | - | ||||||||||||||||||||||||||||||
| 436 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 437 |     return never executed:   d->indentWidth;return d->indentWidth;never executed:  return d->indentWidth; | 0 | ||||||||||||||||||||||||||||||
| 438 | } | - | ||||||||||||||||||||||||||||||
| 439 | void QTextDocument::setIndentWidth(qreal width) | - | ||||||||||||||||||||||||||||||
| 440 | { | - | ||||||||||||||||||||||||||||||
| 441 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 442 |     if (d->indentWidth != width
  | 0 | ||||||||||||||||||||||||||||||
| 443 | d->indentWidth = width; | - | ||||||||||||||||||||||||||||||
| 444 |         if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 445 |             d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 446 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 447 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 448 | void QTextDocument::adjustSize() | - | ||||||||||||||||||||||||||||||
| 449 | { | - | ||||||||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||||||||
| 451 | QFont f = defaultFont(); | - | ||||||||||||||||||||||||||||||
| 452 | QFontMetrics fm(f); | - | ||||||||||||||||||||||||||||||
| 453 | int mw = fm.width(QLatin1Char('x')) * 80; | - | ||||||||||||||||||||||||||||||
| 454 | int w = mw; | - | ||||||||||||||||||||||||||||||
| 455 | setTextWidth(w); | - | ||||||||||||||||||||||||||||||
| 456 | QSizeF size = documentLayout()->documentSize(); | - | ||||||||||||||||||||||||||||||
| 457 |     if (size.width() != 0
  | 0 | ||||||||||||||||||||||||||||||
| 458 | w = qt_int_sqrt((uint)(5 * size.height() * size.width() / 3)); | - | ||||||||||||||||||||||||||||||
| 459 | setTextWidth(qMin(w, mw)); | - | ||||||||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||||||||
| 461 | size = documentLayout()->documentSize(); | - | ||||||||||||||||||||||||||||||
| 462 |         if (w*3 < 5*size.height()
  | 0 | ||||||||||||||||||||||||||||||
| 463 | w = qt_int_sqrt((uint)(2 * size.height() * size.width())); | - | ||||||||||||||||||||||||||||||
| 464 | setTextWidth(qMin(w, mw)); | - | ||||||||||||||||||||||||||||||
| 465 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 466 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 467 | setTextWidth(idealWidth()); | - | ||||||||||||||||||||||||||||||
| 468 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 469 | QSizeF QTextDocument::size() const | - | ||||||||||||||||||||||||||||||
| 470 | { | - | ||||||||||||||||||||||||||||||
| 471 |     return never executed:   documentLayout()->documentSize();return documentLayout()->documentSize();never executed:  return documentLayout()->documentSize(); | 0 | ||||||||||||||||||||||||||||||
| 472 | } | - | ||||||||||||||||||||||||||||||
| 473 | int QTextDocument::blockCount() const | - | ||||||||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||||||||
| 475 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 476 |     return never executed:   d->blockMap().numNodes();return d->blockMap().numNodes();never executed:  return d->blockMap().numNodes(); | 0 | ||||||||||||||||||||||||||||||
| 477 | } | - | ||||||||||||||||||||||||||||||
| 478 | int QTextDocument::lineCount() const | - | ||||||||||||||||||||||||||||||
| 479 | { | - | ||||||||||||||||||||||||||||||
| 480 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 481 |     return never executed:   d->blockMap().length(2);return d->blockMap().length(2);never executed:  return d->blockMap().length(2); | 0 | ||||||||||||||||||||||||||||||
| 482 | } | - | ||||||||||||||||||||||||||||||
| 483 | int QTextDocument::characterCount() const | - | ||||||||||||||||||||||||||||||
| 484 | { | - | ||||||||||||||||||||||||||||||
| 485 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 486 |     return never executed:   d->length();return d->length();never executed:  return d->length(); | 0 | ||||||||||||||||||||||||||||||
| 487 | } | - | ||||||||||||||||||||||||||||||
| 488 | QChar QTextDocument::characterAt(int pos) const | - | ||||||||||||||||||||||||||||||
| 489 | { | - | ||||||||||||||||||||||||||||||
| 490 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 491 |     if (pos < 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 492 |         return never executed:   QChar();return QChar();never executed:  return QChar(); | 0 | ||||||||||||||||||||||||||||||
| 493 | QTextDocumentPrivate::FragmentIterator fragIt = d->find(pos); | - | ||||||||||||||||||||||||||||||
| 494 | const QTextFragmentData * const frag = fragIt.value(); | - | ||||||||||||||||||||||||||||||
| 495 | const int offsetInFragment = qMax(0, pos - fragIt.position()); | - | ||||||||||||||||||||||||||||||
| 496 |     return never executed:   d->text.at(frag->stringPosition + offsetInFragment);return d->text.at(frag->stringPosition + offsetInFragment);never executed:  return d->text.at(frag->stringPosition + offsetInFragment); | 0 | ||||||||||||||||||||||||||||||
| 497 | } | - | ||||||||||||||||||||||||||||||
| 498 | void QTextDocument::setDefaultStyleSheet(const QString &sheet) | - | ||||||||||||||||||||||||||||||
| 499 | { | - | ||||||||||||||||||||||||||||||
| 500 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 501 | d->defaultStyleSheet = sheet; | - | ||||||||||||||||||||||||||||||
| 502 | QCss::Parser parser(sheet); | - | ||||||||||||||||||||||||||||||
| 503 | d->parsedDefaultStyleSheet = QCss::StyleSheet(); | - | ||||||||||||||||||||||||||||||
| 504 | d->parsedDefaultStyleSheet.origin = QCss::StyleSheetOrigin_UserAgent; | - | ||||||||||||||||||||||||||||||
| 505 | parser.parse(&d->parsedDefaultStyleSheet); | - | ||||||||||||||||||||||||||||||
| 506 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||||||||
| 508 | QString QTextDocument::defaultStyleSheet() const | - | ||||||||||||||||||||||||||||||
| 509 | { | - | ||||||||||||||||||||||||||||||
| 510 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 511 |     return never executed:   d->defaultStyleSheet;return d->defaultStyleSheet;never executed:  return d->defaultStyleSheet; | 0 | ||||||||||||||||||||||||||||||
| 512 | } | - | ||||||||||||||||||||||||||||||
| 513 | bool QTextDocument::isUndoAvailable() const | - | ||||||||||||||||||||||||||||||
| 514 | { | - | ||||||||||||||||||||||||||||||
| 515 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 516 |     return never executed:   d->isUndoAvailable();return d->isUndoAvailable();never executed:  return d->isUndoAvailable(); | 0 | ||||||||||||||||||||||||||||||
| 517 | } | - | ||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||
| 524 | bool QTextDocument::isRedoAvailable() const | - | ||||||||||||||||||||||||||||||
| 525 | { | - | ||||||||||||||||||||||||||||||
| 526 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 527 |     return never executed:   d->isRedoAvailable();return d->isRedoAvailable();never executed:  return d->isRedoAvailable(); | 0 | ||||||||||||||||||||||||||||||
| 528 | } | - | ||||||||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||
| 536 | int QTextDocument::availableUndoSteps() const | - | ||||||||||||||||||||||||||||||
| 537 | { | - | ||||||||||||||||||||||||||||||
| 538 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 539 |     return never executed:   d->availableUndoSteps();return d->availableUndoSteps();never executed:  return d->availableUndoSteps(); | 0 | ||||||||||||||||||||||||||||||
| 540 | } | - | ||||||||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | int QTextDocument::availableRedoSteps() const | - | ||||||||||||||||||||||||||||||
| 549 | { | - | ||||||||||||||||||||||||||||||
| 550 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 551 |     return never executed:   d->availableRedoSteps();return d->availableRedoSteps();never executed:  return d->availableRedoSteps(); | 0 | ||||||||||||||||||||||||||||||
| 552 | } | - | ||||||||||||||||||||||||||||||
| 553 | int QTextDocument::revision() const | - | ||||||||||||||||||||||||||||||
| 554 | { | - | ||||||||||||||||||||||||||||||
| 555 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 556 |     return never executed:   d->revision;return d->revision;never executed:  return d->revision; | 0 | ||||||||||||||||||||||||||||||
| 557 | } | - | ||||||||||||||||||||||||||||||
| 558 | void QTextDocument::setDocumentLayout(QAbstractTextDocumentLayout *layout) | - | ||||||||||||||||||||||||||||||
| 559 | { | - | ||||||||||||||||||||||||||||||
| 560 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 561 | d->setLayout(layout); | - | ||||||||||||||||||||||||||||||
| 562 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||||||||
| 567 | QAbstractTextDocumentLayout *QTextDocument::documentLayout() const | - | ||||||||||||||||||||||||||||||
| 568 | { | - | ||||||||||||||||||||||||||||||
| 569 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 570 |     if (!d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 571 | QTextDocument *that = const_cast<QTextDocument *>(this); | - | ||||||||||||||||||||||||||||||
| 572 | that->d_func()->setLayout(new QTextDocumentLayout(that)); | - | ||||||||||||||||||||||||||||||
| 573 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 574 |     return never executed:   d->lout;return d->lout;never executed:  return d->lout; | 0 | ||||||||||||||||||||||||||||||
| 575 | } | - | ||||||||||||||||||||||||||||||
| 576 | QString QTextDocument::metaInformation(MetaInformation info) const | - | ||||||||||||||||||||||||||||||
| 577 | { | - | ||||||||||||||||||||||||||||||
| 578 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 579 | switch (info) { | - | ||||||||||||||||||||||||||||||
| 580 |     case never executed:   DocumentTitle:case DocumentTitle:never executed:  case DocumentTitle: | 0 | ||||||||||||||||||||||||||||||
| 581 |         return never executed:   d->title;return d->title;never executed:  return d->title; | 0 | ||||||||||||||||||||||||||||||
| 582 |     case never executed:   DocumentUrl:case DocumentUrl:never executed:  case DocumentUrl: | 0 | ||||||||||||||||||||||||||||||
| 583 |         return never executed:   d->url;return d->url;never executed:  return d->url; | 0 | ||||||||||||||||||||||||||||||
| 584 | } | - | ||||||||||||||||||||||||||||||
| 585 |     return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||||||||||||||
| 586 | } | - | ||||||||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||||||||
| 594 | void QTextDocument::setMetaInformation(MetaInformation info, const QString &string) | - | ||||||||||||||||||||||||||||||
| 595 | { | - | ||||||||||||||||||||||||||||||
| 596 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 597 | switch (info) { | - | ||||||||||||||||||||||||||||||
| 598 |     case never executed:   DocumentTitle:case DocumentTitle:never executed:  case DocumentTitle: | 0 | ||||||||||||||||||||||||||||||
| 599 | d->title = string; | - | ||||||||||||||||||||||||||||||
| 600 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 601 |     case never executed:   DocumentUrl:case DocumentUrl:never executed:  case DocumentUrl: | 0 | ||||||||||||||||||||||||||||||
| 602 | d->url = string; | - | ||||||||||||||||||||||||||||||
| 603 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 604 | } | - | ||||||||||||||||||||||||||||||
| 605 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 606 | QString QTextDocument::toPlainText() const | - | ||||||||||||||||||||||||||||||
| 607 | { | - | ||||||||||||||||||||||||||||||
| 608 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 609 | QString txt = d->plainText(); | - | ||||||||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||||||||
| 611 | QChar *uc = txt.data(); | - | ||||||||||||||||||||||||||||||
| 612 | QChar *e = uc + txt.size(); | - | ||||||||||||||||||||||||||||||
| 613 | - | |||||||||||||||||||||||||||||||
| 614 |     for (; uc != e
  | 0 | ||||||||||||||||||||||||||||||
| 615 | switch (uc->unicode()) { | - | ||||||||||||||||||||||||||||||
| 616 |         case never executed:   0xfdd0:case 0xfdd0:never executed:  case 0xfdd0: | 0 | ||||||||||||||||||||||||||||||
| 617 |         case never executed:   0xfdd1:case 0xfdd1:never executed:  case 0xfdd1: | 0 | ||||||||||||||||||||||||||||||
| 618 |         case never executed:   QChar::ParagraphSeparator:case QChar::ParagraphSeparator:never executed:  case QChar::ParagraphSeparator: | 0 | ||||||||||||||||||||||||||||||
| 619 |         case never executed:   QChar::LineSeparator:case QChar::LineSeparator:never executed:  case QChar::LineSeparator: | 0 | ||||||||||||||||||||||||||||||
| 620 | *uc = QLatin1Char('\n'); | - | ||||||||||||||||||||||||||||||
| 621 |             break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 622 |         case never executed:   QChar::Nbsp:case QChar::Nbsp:never executed:  case QChar::Nbsp: | 0 | ||||||||||||||||||||||||||||||
| 623 | *uc = QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 624 |             break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 625 |         default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||||||||||||||
| 626 | ; | - | ||||||||||||||||||||||||||||||
| 627 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 628 | } | - | ||||||||||||||||||||||||||||||
| 629 |     return never executed:   txt;return txt;never executed:  return txt; | 0 | ||||||||||||||||||||||||||||||
| 630 | } | - | ||||||||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||||||||
| 638 | void QTextDocument::setPlainText(const QString &text) | - | ||||||||||||||||||||||||||||||
| 639 | { | - | ||||||||||||||||||||||||||||||
| 640 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 641 | bool previousState = d->isUndoRedoEnabled(); | - | ||||||||||||||||||||||||||||||
| 642 | d->enableUndoRedo(false); | - | ||||||||||||||||||||||||||||||
| 643 | d->beginEditBlock(); | - | ||||||||||||||||||||||||||||||
| 644 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 645 | QTextCursor(this).insertText(text); | - | ||||||||||||||||||||||||||||||
| 646 | d->endEditBlock(); | - | ||||||||||||||||||||||||||||||
| 647 | d->enableUndoRedo(previousState); | - | ||||||||||||||||||||||||||||||
| 648 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 649 | void QTextDocument::setHtml(const QString &html) | - | ||||||||||||||||||||||||||||||
| 650 | { | - | ||||||||||||||||||||||||||||||
| 651 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 652 | bool previousState = d->isUndoRedoEnabled(); | - | ||||||||||||||||||||||||||||||
| 653 | d->enableUndoRedo(false); | - | ||||||||||||||||||||||||||||||
| 654 | d->beginEditBlock(); | - | ||||||||||||||||||||||||||||||
| 655 | d->clear(); | - | ||||||||||||||||||||||||||||||
| 656 | QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import(); | - | ||||||||||||||||||||||||||||||
| 657 | d->endEditBlock(); | - | ||||||||||||||||||||||||||||||
| 658 | d->enableUndoRedo(previousState); | - | ||||||||||||||||||||||||||||||
| 659 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 660 | static bool findInBlock(const QTextBlock &block, const QString &expression, int offset, | - | ||||||||||||||||||||||||||||||
| 661 | QTextDocument::FindFlags options, QTextCursor *cursor) | - | ||||||||||||||||||||||||||||||
| 662 | { | - | ||||||||||||||||||||||||||||||
| 663 | QString text = block.text(); | - | ||||||||||||||||||||||||||||||
| 664 | text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | ||||||||||||||||||||||||||||||
| 665 |     Qt::CaseSensitivity sensitivity = options & QTextDocument::FindCaseSensitively
  | 0 | ||||||||||||||||||||||||||||||
| 666 | int idx = -1; | - | ||||||||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||||||||
| 668 |     while (offset >= 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 669 |         idx = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 670 | text.lastIndexOf(expression, offset, sensitivity) : text.indexOf(expression, offset, sensitivity); | - | ||||||||||||||||||||||||||||||
| 671 |         if (idx == -1
  | 0 | ||||||||||||||||||||||||||||||
| 672 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||||||||
| 674 |         if (options & QTextDocument::FindWholeWords
  | 0 | ||||||||||||||||||||||||||||||
| 675 | const int start = idx; | - | ||||||||||||||||||||||||||||||
| 676 | const int end = start + expression.length(); | - | ||||||||||||||||||||||||||||||
| 677 |             if ((start != 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 678 |                 || (end != text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||||||||
| 680 |                 offset = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 681 | idx = -1; | - | ||||||||||||||||||||||||||||||
| 682 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||||||||||||||
| 683 | } | - | ||||||||||||||||||||||||||||||
| 684 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||||||||
| 686 | *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | ||||||||||||||||||||||||||||||
| 687 | cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||||||||
| 688 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 689 | } | - | ||||||||||||||||||||||||||||||
| 690 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 691 | } | - | ||||||||||||||||||||||||||||||
| 692 | QTextCursor QTextDocument::find(const QString &subString, int from, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 693 | { | - | ||||||||||||||||||||||||||||||
| 694 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||||||||
| 696 |     if (subString.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 697 |         return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||||||||
| 699 | int pos = from; | - | ||||||||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||||||||
| 702 |     if (options & FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 703 | --pos ; | - | ||||||||||||||||||||||||||||||
| 704 |         if (pos < 0
  | 0 | ||||||||||||||||||||||||||||||
| 705 |             return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 706 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||||||||
| 708 | QTextCursor cursor; | - | ||||||||||||||||||||||||||||||
| 709 | QTextBlock block = d->blocksFind(pos); | - | ||||||||||||||||||||||||||||||
| 710 | int blockOffset = pos - block.position(); | - | ||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 |     if (!(options & FindBackward)
  | 0 | ||||||||||||||||||||||||||||||
| 713 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 714 |             if (findInBlock(block, subString, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 715 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 716 | block = block.next(); | - | ||||||||||||||||||||||||||||||
| 717 | blockOffset = 0; | - | ||||||||||||||||||||||||||||||
| 718 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 719 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 720 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 721 |             if (findInBlock(block, subString, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 722 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 723 | block = block.previous(); | - | ||||||||||||||||||||||||||||||
| 724 | blockOffset = block.length() - 2; | - | ||||||||||||||||||||||||||||||
| 725 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 726 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||||||||
| 728 |     return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 729 | } | - | ||||||||||||||||||||||||||||||
| 730 | QTextCursor QTextDocument::find(const QString &subString, const QTextCursor &cursor, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 731 | { | - | ||||||||||||||||||||||||||||||
| 732 | int pos = 0; | - | ||||||||||||||||||||||||||||||
| 733 |     if (!cursor.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 734 |         if (options & QTextDocument::FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 735 |             pos = cursor.selectionStart(); never executed:  pos = cursor.selectionStart(); | 0 | ||||||||||||||||||||||||||||||
| 736 | else | - | ||||||||||||||||||||||||||||||
| 737 |             pos = cursor.selectionEnd(); never executed:  pos = cursor.selectionEnd(); | 0 | ||||||||||||||||||||||||||||||
| 738 | } | - | ||||||||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||||||||
| 740 |     return never executed:   find(subString, pos, options);return find(subString, pos, options);never executed:  return find(subString, pos, options); | 0 | ||||||||||||||||||||||||||||||
| 741 | } | - | ||||||||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||||||||
| 745 | static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int offset, | - | ||||||||||||||||||||||||||||||
| 746 | QTextDocument::FindFlags options, QTextCursor *cursor) | - | ||||||||||||||||||||||||||||||
| 747 | { | - | ||||||||||||||||||||||||||||||
| 748 | QRegExp expr(expression); | - | ||||||||||||||||||||||||||||||
| 749 | QString text = block.text(); | - | ||||||||||||||||||||||||||||||
| 750 | text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | ||||||||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||||||||
| 752 | int idx = -1; | - | ||||||||||||||||||||||||||||||
| 753 |     while (offset >=0
 
  | 0 | ||||||||||||||||||||||||||||||
| 754 |         idx = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 755 | expr.lastIndexIn(text, offset) : expr.indexIn(text, offset); | - | ||||||||||||||||||||||||||||||
| 756 |         if (idx == -1
  | 0 | ||||||||||||||||||||||||||||||
| 757 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||||||||
| 759 |         if (options & QTextDocument::FindWholeWords
  | 0 | ||||||||||||||||||||||||||||||
| 760 | const int start = idx; | - | ||||||||||||||||||||||||||||||
| 761 | const int end = start + expr.matchedLength(); | - | ||||||||||||||||||||||||||||||
| 762 |             if ((start != 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 763 |                 || (end != text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||||||||
| 765 |                 offset = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 766 | idx = -1; | - | ||||||||||||||||||||||||||||||
| 767 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||||||||||||||
| 768 | } | - | ||||||||||||||||||||||||||||||
| 769 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||||||||
| 771 | *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | ||||||||||||||||||||||||||||||
| 772 | cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||||||||
| 773 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 774 | } | - | ||||||||||||||||||||||||||||||
| 775 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||||||||
| 777 | QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 778 | { | - | ||||||||||||||||||||||||||||||
| 779 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||||||||
| 781 |     if (expr.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 782 |         return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||||||||
| 784 | int pos = from; | - | ||||||||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||||||||
| 787 |     if (options & FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 788 | --pos ; | - | ||||||||||||||||||||||||||||||
| 789 |         if(pos < 0
  | 0 | ||||||||||||||||||||||||||||||
| 790 |             return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 791 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||||||||
| 793 | QTextCursor cursor; | - | ||||||||||||||||||||||||||||||
| 794 | QTextBlock block = d->blocksFind(pos); | - | ||||||||||||||||||||||||||||||
| 795 | int blockOffset = pos - block.position(); | - | ||||||||||||||||||||||||||||||
| 796 |     if (!(options & FindBackward)
  | 0 | ||||||||||||||||||||||||||||||
| 797 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 798 |             if (findInBlock(block, expr, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 799 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 800 | block = block.next(); | - | ||||||||||||||||||||||||||||||
| 801 | blockOffset = 0; | - | ||||||||||||||||||||||||||||||
| 802 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 803 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 804 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 805 |             if (findInBlock(block, expr, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 806 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 807 | block = block.previous(); | - | ||||||||||||||||||||||||||||||
| 808 | blockOffset = block.length() - 1; | - | ||||||||||||||||||||||||||||||
| 809 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 810 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||||||||
| 812 |     return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 813 | } | - | ||||||||||||||||||||||||||||||
| 814 | QTextCursor QTextDocument::find(const QRegExp &expr, const QTextCursor &cursor, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 815 | { | - | ||||||||||||||||||||||||||||||
| 816 | int pos = 0; | - | ||||||||||||||||||||||||||||||
| 817 |     if (!cursor.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 818 |         if (options & QTextDocument::FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 819 |             pos = cursor.selectionStart(); never executed:  pos = cursor.selectionStart(); | 0 | ||||||||||||||||||||||||||||||
| 820 | else | - | ||||||||||||||||||||||||||||||
| 821 |             pos = cursor.selectionEnd(); never executed:  pos = cursor.selectionEnd(); | 0 | ||||||||||||||||||||||||||||||
| 822 | } | - | ||||||||||||||||||||||||||||||
| 823 |     return never executed:   find(expr, pos, options);return find(expr, pos, options);never executed:  return find(expr, pos, options); | 0 | ||||||||||||||||||||||||||||||
| 824 | } | - | ||||||||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||||||||
| 828 | static bool findInBlock(const QTextBlock &block, const QRegularExpression &expression, int offset, | - | ||||||||||||||||||||||||||||||
| 829 | QTextDocument::FindFlags options, QTextCursor *cursor) | - | ||||||||||||||||||||||||||||||
| 830 | { | - | ||||||||||||||||||||||||||||||
| 831 | QRegularExpression expr(expression); | - | ||||||||||||||||||||||||||||||
| 832 |     if (!(options & QTextDocument::FindCaseSensitively)
  | 0 | ||||||||||||||||||||||||||||||
| 833 |         expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption); never executed:  expr.setPatternOptions(expr.patternOptions() | QRegularExpression::CaseInsensitiveOption); | 0 | ||||||||||||||||||||||||||||||
| 834 | else | - | ||||||||||||||||||||||||||||||
| 835 |         expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption); never executed:  expr.setPatternOptions(expr.patternOptions() & ~QRegularExpression::CaseInsensitiveOption); | 0 | ||||||||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||||||||
| 837 | QString text = block.text(); | - | ||||||||||||||||||||||||||||||
| 838 | text.replace(QChar::Nbsp, QLatin1Char(' ')); | - | ||||||||||||||||||||||||||||||
| 839 | QRegularExpressionMatch match; | - | ||||||||||||||||||||||||||||||
| 840 | int idx = -1; | - | ||||||||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||||||||
| 842 |     while (offset >= 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 843 |         idx = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 844 | text.lastIndexOf(expr, offset, &match) : text.indexOf(expr, offset, &match); | - | ||||||||||||||||||||||||||||||
| 845 |         if (idx == -1
  | 0 | ||||||||||||||||||||||||||||||
| 846 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||||||||
| 848 |         if (options & QTextDocument::FindWholeWords
  | 0 | ||||||||||||||||||||||||||||||
| 849 | const int start = idx; | - | ||||||||||||||||||||||||||||||
| 850 | const int end = start + match.capturedLength(); | - | ||||||||||||||||||||||||||||||
| 851 |             if ((start != 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 852 |                 || (end != text.length()
 
  | 0 | ||||||||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||||||||
| 854 |                 offset = (
 
  | 0 | ||||||||||||||||||||||||||||||
| 855 | idx = -1; | - | ||||||||||||||||||||||||||||||
| 856 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||||||||||||||
| 857 | } | - | ||||||||||||||||||||||||||||||
| 858 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||||||||
| 860 | *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); | - | ||||||||||||||||||||||||||||||
| 861 | cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||||||||
| 862 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||||||||||||||
| 863 | } | - | ||||||||||||||||||||||||||||||
| 864 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||||||||||||||
| 865 | } | - | ||||||||||||||||||||||||||||||
| 866 | QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 867 | { | - | ||||||||||||||||||||||||||||||
| 868 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||||||||
| 870 |     if (!expr.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 871 |         return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||||||||
| 873 | int pos = from; | - | ||||||||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||||||||
| 876 |     if (options & FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 877 | --pos ; | - | ||||||||||||||||||||||||||||||
| 878 |         if (pos < 0
  | 0 | ||||||||||||||||||||||||||||||
| 879 |             return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 880 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||||||||
| 882 | QTextCursor cursor; | - | ||||||||||||||||||||||||||||||
| 883 | QTextBlock block = d->blocksFind(pos); | - | ||||||||||||||||||||||||||||||
| 884 | int blockOffset = pos - block.position(); | - | ||||||||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||||||||
| 886 |     if (!(options & FindBackward)
  | 0 | ||||||||||||||||||||||||||||||
| 887 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 888 |             if (findInBlock(block, expr, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 889 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 890 | block = block.next(); | - | ||||||||||||||||||||||||||||||
| 891 | blockOffset = 0; | - | ||||||||||||||||||||||||||||||
| 892 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 893 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 894 |         while (block.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 895 |             if (findInBlock(block, expr, blockOffset, options, &cursor)
  | 0 | ||||||||||||||||||||||||||||||
| 896 |                 return never executed:   cursor;return cursor;never executed:  return cursor; | 0 | ||||||||||||||||||||||||||||||
| 897 | block = block.previous(); | - | ||||||||||||||||||||||||||||||
| 898 | blockOffset = block.length() - 1; | - | ||||||||||||||||||||||||||||||
| 899 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 900 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||||||||
| 902 |     return never executed:   QTextCursor();return QTextCursor();never executed:  return QTextCursor(); | 0 | ||||||||||||||||||||||||||||||
| 903 | } | - | ||||||||||||||||||||||||||||||
| 904 | QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCursor &cursor, FindFlags options) const | - | ||||||||||||||||||||||||||||||
| 905 | { | - | ||||||||||||||||||||||||||||||
| 906 | int pos = 0; | - | ||||||||||||||||||||||||||||||
| 907 |     if (!cursor.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 908 |         if (options & QTextDocument::FindBackward
  | 0 | ||||||||||||||||||||||||||||||
| 909 |             pos = cursor.selectionStart(); never executed:  pos = cursor.selectionStart(); | 0 | ||||||||||||||||||||||||||||||
| 910 | else | - | ||||||||||||||||||||||||||||||
| 911 |             pos = cursor.selectionEnd(); never executed:  pos = cursor.selectionEnd(); | 0 | ||||||||||||||||||||||||||||||
| 912 | } | - | ||||||||||||||||||||||||||||||
| 913 |     return never executed:   find(expr, pos, options);return find(expr, pos, options);never executed:  return find(expr, pos, options); | 0 | ||||||||||||||||||||||||||||||
| 914 | } | - | ||||||||||||||||||||||||||||||
| 915 | QTextObject *QTextDocument::createObject(const QTextFormat &f) | - | ||||||||||||||||||||||||||||||
| 916 | { | - | ||||||||||||||||||||||||||||||
| 917 | QTextObject *obj = 0; | - | ||||||||||||||||||||||||||||||
| 918 |     if (f.isListFormat()
  | 0 | ||||||||||||||||||||||||||||||
| 919 |         obj = new QTextList(this); never executed:  obj = new QTextList(this); | 0 | ||||||||||||||||||||||||||||||
| 920 |     else if (f.isTableFormat()
  | 0 | ||||||||||||||||||||||||||||||
| 921 |         obj = new QTextTable(this); never executed:  obj = new QTextTable(this); | 0 | ||||||||||||||||||||||||||||||
| 922 |     else if (f.isFrameFormat()
  | 0 | ||||||||||||||||||||||||||||||
| 923 |         obj = new QTextFrame(this); never executed:  obj = new QTextFrame(this); | 0 | ||||||||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||||||||
| 925 |     return never executed:   obj;return obj;never executed:  return obj; | 0 | ||||||||||||||||||||||||||||||
| 926 | } | - | ||||||||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||||||||
| 928 | - | |||||||||||||||||||||||||||||||
| 929 | - | |||||||||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||||||||
| 932 | - | |||||||||||||||||||||||||||||||
| 933 | QTextFrame *QTextDocument::frameAt(int pos) const | - | ||||||||||||||||||||||||||||||
| 934 | { | - | ||||||||||||||||||||||||||||||
| 935 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 936 |     return never executed:   d->frameAt(pos);return d->frameAt(pos);never executed:  return d->frameAt(pos); | 0 | ||||||||||||||||||||||||||||||
| 937 | } | - | ||||||||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||||||||
| 942 | QTextFrame *QTextDocument::rootFrame() const | - | ||||||||||||||||||||||||||||||
| 943 | { | - | ||||||||||||||||||||||||||||||
| 944 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 945 |     return never executed:   d->rootFrame();return d->rootFrame();never executed:  return d->rootFrame(); | 0 | ||||||||||||||||||||||||||||||
| 946 | } | - | ||||||||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||||||||
| 951 | QTextObject *QTextDocument::object(int objectIndex) const | - | ||||||||||||||||||||||||||||||
| 952 | { | - | ||||||||||||||||||||||||||||||
| 953 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 954 |     return never executed:   d->objectForIndex(objectIndex);return d->objectForIndex(objectIndex);never executed:  return d->objectForIndex(objectIndex); | 0 | ||||||||||||||||||||||||||||||
| 955 | } | - | ||||||||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||||||||
| 958 | - | |||||||||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||||||||
| 960 | QTextObject *QTextDocument::objectForFormat(const QTextFormat &f) const | - | ||||||||||||||||||||||||||||||
| 961 | { | - | ||||||||||||||||||||||||||||||
| 962 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 963 |     return never executed:   d->objectForFormat(f);return d->objectForFormat(f);never executed:  return d->objectForFormat(f); | 0 | ||||||||||||||||||||||||||||||
| 964 | } | - | ||||||||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||||||||
| 966 | - | |||||||||||||||||||||||||||||||
| 967 | - | |||||||||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||||||||
| 969 | - | |||||||||||||||||||||||||||||||
| 970 | QTextBlock QTextDocument::findBlock(int pos) const | - | ||||||||||||||||||||||||||||||
| 971 | { | - | ||||||||||||||||||||||||||||||
| 972 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 973 |     return never executed:   QTextBlock(docHandle(), d->blockMap().findNode(pos));return QTextBlock(docHandle(), d->blockMap().findNode(pos));never executed:  return QTextBlock(docHandle(), d->blockMap().findNode(pos)); | 0 | ||||||||||||||||||||||||||||||
| 974 | } | - | ||||||||||||||||||||||||||||||
| 975 | - | |||||||||||||||||||||||||||||||
| 976 | - | |||||||||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||||||||
| 978 | - | |||||||||||||||||||||||||||||||
| 979 | - | |||||||||||||||||||||||||||||||
| 980 | - | |||||||||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||||||||
| 982 | QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const | - | ||||||||||||||||||||||||||||||
| 983 | { | - | ||||||||||||||||||||||||||||||
| 984 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 985 |     return never executed:   QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1));never executed:  return QTextBlock(docHandle(), d->blockMap().findNode(blockNumber, 1)); | 0 | ||||||||||||||||||||||||||||||
| 986 | } | - | ||||||||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||||||||
| 989 | - | |||||||||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||||||||
| 991 | - | |||||||||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||||||||
| 993 | - | |||||||||||||||||||||||||||||||
| 994 | QTextBlock QTextDocument::findBlockByLineNumber(int lineNumber) const | - | ||||||||||||||||||||||||||||||
| 995 | { | - | ||||||||||||||||||||||||||||||
| 996 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 997 |     return never executed:   QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2));never executed:  return QTextBlock(docHandle(), d->blockMap().findNode(lineNumber, 2)); | 0 | ||||||||||||||||||||||||||||||
| 998 | } | - | ||||||||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||||||||
| 1000 | - | |||||||||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||||||||
| 1003 | - | |||||||||||||||||||||||||||||||
| 1004 | - | |||||||||||||||||||||||||||||||
| 1005 | QTextBlock QTextDocument::begin() const | - | ||||||||||||||||||||||||||||||
| 1006 | { | - | ||||||||||||||||||||||||||||||
| 1007 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1008 |     return never executed:   QTextBlock(docHandle(), d->blockMap().begin().n);return QTextBlock(docHandle(), d->blockMap().begin().n);never executed:  return QTextBlock(docHandle(), d->blockMap().begin().n); | 0 | ||||||||||||||||||||||||||||||
| 1009 | } | - | ||||||||||||||||||||||||||||||
| 1010 | QTextBlock QTextDocument::end() const | - | ||||||||||||||||||||||||||||||
| 1011 | { | - | ||||||||||||||||||||||||||||||
| 1012 |     return never executed:   QTextBlock(docHandle(), 0);return QTextBlock(docHandle(), 0);never executed:  return QTextBlock(docHandle(), 0); | 0 | ||||||||||||||||||||||||||||||
| 1013 | } | - | ||||||||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||||||||
| 1019 | QTextBlock QTextDocument::firstBlock() const | - | ||||||||||||||||||||||||||||||
| 1020 | { | - | ||||||||||||||||||||||||||||||
| 1021 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1022 |     return never executed:   QTextBlock(docHandle(), d->blockMap().begin().n);return QTextBlock(docHandle(), d->blockMap().begin().n);never executed:  return QTextBlock(docHandle(), d->blockMap().begin().n); | 0 | ||||||||||||||||||||||||||||||
| 1023 | } | - | ||||||||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||||||||
| 1027 | - | |||||||||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||||||||
| 1029 | QTextBlock QTextDocument::lastBlock() const | - | ||||||||||||||||||||||||||||||
| 1030 | { | - | ||||||||||||||||||||||||||||||
| 1031 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1032 |     return never executed:   QTextBlock(docHandle(), d->blockMap().last().n);return QTextBlock(docHandle(), d->blockMap().last().n);never executed:  return QTextBlock(docHandle(), d->blockMap().last().n); | 0 | ||||||||||||||||||||||||||||||
| 1033 | } | - | ||||||||||||||||||||||||||||||
| 1034 | void QTextDocument::setPageSize(const QSizeF &size) | - | ||||||||||||||||||||||||||||||
| 1035 | { | - | ||||||||||||||||||||||||||||||
| 1036 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1037 | d->pageSize = size; | - | ||||||||||||||||||||||||||||||
| 1038 |     if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 1039 |         d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 1040 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||||||||
| 1042 | QSizeF QTextDocument::pageSize() const | - | ||||||||||||||||||||||||||||||
| 1043 | { | - | ||||||||||||||||||||||||||||||
| 1044 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1045 |     return never executed:   d->pageSize;return d->pageSize;never executed:  return d->pageSize; | 0 | ||||||||||||||||||||||||||||||
| 1046 | } | - | ||||||||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||||||||
| 1051 | int QTextDocument::pageCount() const | - | ||||||||||||||||||||||||||||||
| 1052 | { | - | ||||||||||||||||||||||||||||||
| 1053 |     return never executed:   documentLayout()->pageCount();return documentLayout()->pageCount();never executed:  return documentLayout()->pageCount(); | 0 | ||||||||||||||||||||||||||||||
| 1054 | } | - | ||||||||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||||||||
| 1058 | - | |||||||||||||||||||||||||||||||
| 1059 | void QTextDocument::setDefaultFont(const QFont &font) | - | ||||||||||||||||||||||||||||||
| 1060 | { | - | ||||||||||||||||||||||||||||||
| 1061 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1062 | d->setDefaultFont(font); | - | ||||||||||||||||||||||||||||||
| 1063 |     if (d->lout
  | 0 | ||||||||||||||||||||||||||||||
| 1064 |         d->lout->documentChanged(0, 0, d->length()); never executed:  d->lout->documentChanged(0, 0, d->length()); | 0 | ||||||||||||||||||||||||||||||
| 1065 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||||||||
| 1069 | - | |||||||||||||||||||||||||||||||
| 1070 | QFont QTextDocument::defaultFont() const | - | ||||||||||||||||||||||||||||||
| 1071 | { | - | ||||||||||||||||||||||||||||||
| 1072 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1073 |     return never executed:   d->defaultFont();return d->defaultFont();never executed:  return d->defaultFont(); | 0 | ||||||||||||||||||||||||||||||
| 1074 | } | - | ||||||||||||||||||||||||||||||
| 1075 | bool QTextDocument::isModified() const | - | ||||||||||||||||||||||||||||||
| 1076 | { | - | ||||||||||||||||||||||||||||||
| 1077 |     return never executed:   docHandle()->isModified();return docHandle()->isModified();never executed:  return docHandle()->isModified(); | 0 | ||||||||||||||||||||||||||||||
| 1078 | } | - | ||||||||||||||||||||||||||||||
| 1079 | - | |||||||||||||||||||||||||||||||
| 1080 | void QTextDocument::setModified(bool m) | - | ||||||||||||||||||||||||||||||
| 1081 | { | - | ||||||||||||||||||||||||||||||
| 1082 | docHandle()->setModified(m); | - | ||||||||||||||||||||||||||||||
| 1083 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||||||||
| 1086 | static void printPage(int index, QPainter *painter, const QTextDocument *doc, const QRectF &body, const QPointF &pageNumberPos) | - | ||||||||||||||||||||||||||||||
| 1087 | { | - | ||||||||||||||||||||||||||||||
| 1088 | painter->save(); | - | ||||||||||||||||||||||||||||||
| 1089 | painter->translate(body.left(), body.top() - (index - 1) * body.height()); | - | ||||||||||||||||||||||||||||||
| 1090 | QRectF view(0, (index - 1) * body.height(), body.width(), body.height()); | - | ||||||||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||||||||
| 1092 | QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - | ||||||||||||||||||||||||||||||
| 1093 | QAbstractTextDocumentLayout::PaintContext ctx; | - | ||||||||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||||||||
| 1095 | painter->setClipRect(view); | - | ||||||||||||||||||||||||||||||
| 1096 | ctx.clip = view; | - | ||||||||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||||||||
| 1101 | ctx.palette.setColor(QPalette::Text, Qt::black); | - | ||||||||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||||||||
| 1103 | layout->draw(painter, ctx); | - | ||||||||||||||||||||||||||||||
| 1104 | - | |||||||||||||||||||||||||||||||
| 1105 |     if (!pageNumberPos.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 1106 | painter->setClipping(false); | - | ||||||||||||||||||||||||||||||
| 1107 | painter->setFont(QFont(doc->defaultFont())); | - | ||||||||||||||||||||||||||||||
| 1108 | const QString pageString = QString::number(index); | - | ||||||||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||||||||
| 1110 | painter->drawText(qRound(pageNumberPos.x() - painter->fontMetrics().width(pageString)), | - | ||||||||||||||||||||||||||||||
| 1111 | qRound(pageNumberPos.y() + view.top()), | - | ||||||||||||||||||||||||||||||
| 1112 | pageString); | - | ||||||||||||||||||||||||||||||
| 1113 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||||||||
| 1115 | painter->restore(); | - | ||||||||||||||||||||||||||||||
| 1116 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1117 | void QTextDocument::print(QPagedPaintDevice *printer) const | - | ||||||||||||||||||||||||||||||
| 1118 | { | - | ||||||||||||||||||||||||||||||
| 1119 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||||||||
| 1121 |     if (!printer
  | 0 | ||||||||||||||||||||||||||||||
| 1122 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||||||||
| 1124 |     bool documentPaginated = d->pageSize.isValid()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1125 |                              && d->pageSize.height() != 2147483647
  | 0 | ||||||||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||||||||
| 1127 | QPagedPaintDevicePrivate *pd = QPagedPaintDevicePrivate::get(printer); | - | ||||||||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||||||||
| 1130 | QPagedPaintDevice::Margins m = printer->margins(); | - | ||||||||||||||||||||||||||||||
| 1131 |     if (!documentPaginated
 
 
 
 
  | 0 | ||||||||||||||||||||||||||||||
| 1132 | m.left = m.right = m.top = m.bottom = 2.; | - | ||||||||||||||||||||||||||||||
| 1133 | printer->setMargins(m); | - | ||||||||||||||||||||||||||||||
| 1134 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||||||||
| 1137 | QPainter p(printer); | - | ||||||||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||||||||
| 1140 |     if (!p.isActive()
  | 0 | ||||||||||||||||||||||||||||||
| 1141 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1142 | - | |||||||||||||||||||||||||||||||
| 1143 | const QTextDocument *doc = this; | - | ||||||||||||||||||||||||||||||
| 1144 | QScopedPointer<QTextDocument> clonedDoc; | - | ||||||||||||||||||||||||||||||
| 1145 | (void)doc->documentLayout(); | - | ||||||||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||||||||
| 1147 | QRectF body = QRectF(QPointF(0, 0), d->pageSize); | - | ||||||||||||||||||||||||||||||
| 1148 | QPointF pageNumberPos; | - | ||||||||||||||||||||||||||||||
| 1149 | - | |||||||||||||||||||||||||||||||
| 1150 |     if (documentPaginated
  | 0 | ||||||||||||||||||||||||||||||
| 1151 | qreal sourceDpiX = qt_defaultDpi(); | - | ||||||||||||||||||||||||||||||
| 1152 | qreal sourceDpiY = sourceDpiX; | - | ||||||||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||||||||
| 1154 | QPaintDevice *dev = doc->documentLayout()->paintDevice(); | - | ||||||||||||||||||||||||||||||
| 1155 |         if (dev
  | 0 | ||||||||||||||||||||||||||||||
| 1156 | sourceDpiX = dev->logicalDpiX(); | - | ||||||||||||||||||||||||||||||
| 1157 | sourceDpiY = dev->logicalDpiY(); | - | ||||||||||||||||||||||||||||||
| 1158 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1159 | - | |||||||||||||||||||||||||||||||
| 1160 | const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX; | - | ||||||||||||||||||||||||||||||
| 1161 | const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY; | - | ||||||||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||||||||
| 1164 | p.scale(dpiScaleX, dpiScaleY); | - | ||||||||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||||||||
| 1166 | QSizeF scaledPageSize = d->pageSize; | - | ||||||||||||||||||||||||||||||
| 1167 | scaledPageSize.rwidth() *= dpiScaleX; | - | ||||||||||||||||||||||||||||||
| 1168 | scaledPageSize.rheight() *= dpiScaleY; | - | ||||||||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||||||||
| 1170 | const QSizeF printerPageSize(printer->width(), printer->height()); | - | ||||||||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||||||||
| 1173 | p.scale(printerPageSize.width() / scaledPageSize.width(), | - | ||||||||||||||||||||||||||||||
| 1174 | printerPageSize.height() / scaledPageSize.height()); | - | ||||||||||||||||||||||||||||||
| 1175 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1176 | doc = clone(const_cast<QTextDocument *>(this)); | - | ||||||||||||||||||||||||||||||
| 1177 | clonedDoc.reset(const_cast<QTextDocument *>(doc)); | - | ||||||||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||||||||
| 1179 | for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); | - | ||||||||||||||||||||||||||||||
| 1180 |              srcBlock.isValid()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1181 | srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { | - | ||||||||||||||||||||||||||||||
| 1182 | dstBlock.layout()->setFormats(srcBlock.layout()->formats()); | - | ||||||||||||||||||||||||||||||
| 1183 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1184 | - | |||||||||||||||||||||||||||||||
| 1185 | QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - | ||||||||||||||||||||||||||||||
| 1186 | layout->setPaintDevice(p.device()); | - | ||||||||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||||||||
| 1189 | layout->d_func()->handlers = documentLayout()->d_func()->handlers; | - | ||||||||||||||||||||||||||||||
| 1190 | - | |||||||||||||||||||||||||||||||
| 1191 | int dpiy = p.device()->logicalDpiY(); | - | ||||||||||||||||||||||||||||||
| 1192 | int margin = (int) ((2/2.54)*dpiy); | - | ||||||||||||||||||||||||||||||
| 1193 | QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); | - | ||||||||||||||||||||||||||||||
| 1194 | fmt.setMargin(margin); | - | ||||||||||||||||||||||||||||||
| 1195 | doc->rootFrame()->setFrameFormat(fmt); | - | ||||||||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||||||||
| 1197 | body = QRectF(0, 0, printer->width(), printer->height()); | - | ||||||||||||||||||||||||||||||
| 1198 | pageNumberPos = QPointF(body.width() - margin, | - | ||||||||||||||||||||||||||||||
| 1199 | body.height() - margin | - | ||||||||||||||||||||||||||||||
| 1200 | + QFontMetrics(doc->defaultFont(), p.device()).ascent() | - | ||||||||||||||||||||||||||||||
| 1201 | + 5 * dpiy / 72.0); | - | ||||||||||||||||||||||||||||||
| 1202 | clonedDoc->setPageSize(body.size()); | - | ||||||||||||||||||||||||||||||
| 1203 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||||||||
| 1205 | int fromPage = pd->fromPage; | - | ||||||||||||||||||||||||||||||
| 1206 | int toPage = pd->toPage; | - | ||||||||||||||||||||||||||||||
| 1207 | bool ascending = true; | - | ||||||||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||||||||
| 1209 |     if (fromPage == 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 1210 | fromPage = 1; | - | ||||||||||||||||||||||||||||||
| 1211 | toPage = doc->pageCount(); | - | ||||||||||||||||||||||||||||||
| 1212 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||||||||
| 1214 | fromPage = qMax(1, fromPage); | - | ||||||||||||||||||||||||||||||
| 1215 | toPage = qMin(doc->pageCount(), toPage); | - | ||||||||||||||||||||||||||||||
| 1216 | - | |||||||||||||||||||||||||||||||
| 1217 |     if (toPage < fromPage
  | 0 | ||||||||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||||||||
| 1220 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1221 | } | - | ||||||||||||||||||||||||||||||
| 1222 | int page = fromPage; | - | ||||||||||||||||||||||||||||||
| 1223 | while (true) { | - | ||||||||||||||||||||||||||||||
| 1224 | printPage(page, &p, doc, body, pageNumberPos); | - | ||||||||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||||||||
| 1226 |         if (page == toPage
  | 0 | ||||||||||||||||||||||||||||||
| 1227 |             break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||||||||
| 1229 |         if (ascending
  | 0 | ||||||||||||||||||||||||||||||
| 1230 |             ++ never executed:  page;++page;never executed:  ++page; | 0 | ||||||||||||||||||||||||||||||
| 1231 | else | - | ||||||||||||||||||||||||||||||
| 1232 |             -- never executed:  page;--page;never executed:  --page; | 0 | ||||||||||||||||||||||||||||||
| 1233 | - | |||||||||||||||||||||||||||||||
| 1234 |         if (!printer->newPage()
  | 0 | ||||||||||||||||||||||||||||||
| 1235 |             return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1236 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1237 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1238 | QVariant QTextDocument::resource(int type, const QUrl &name) const | - | ||||||||||||||||||||||||||||||
| 1239 | { | - | ||||||||||||||||||||||||||||||
| 1240 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1241 | const QUrl url = d->baseUrl.resolved(name); | - | ||||||||||||||||||||||||||||||
| 1242 | QVariant r = d->resources.value(url); | - | ||||||||||||||||||||||||||||||
| 1243 |     if (!r.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 1244 | r = d->cachedResources.value(url); | - | ||||||||||||||||||||||||||||||
| 1245 |         if (!r.isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 1246 |             r = const_cast<QTextDocument *>(this)->loadResource(type, url); never executed:  r = const_cast<QTextDocument *>(this)->loadResource(type, url); | 0 | ||||||||||||||||||||||||||||||
| 1247 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1248 |     return never executed:   r;return r;never executed:  return r; | 0 | ||||||||||||||||||||||||||||||
| 1249 | } | - | ||||||||||||||||||||||||||||||
| 1250 | void QTextDocument::addResource(int type, const QUrl &name, const QVariant &resource) | - | ||||||||||||||||||||||||||||||
| 1251 | { | - | ||||||||||||||||||||||||||||||
| 1252 | (void)type;; | - | ||||||||||||||||||||||||||||||
| 1253 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1254 | d->resources.insert(name, resource); | - | ||||||||||||||||||||||||||||||
| 1255 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1256 | QVariant QTextDocument::loadResource(int type, const QUrl &name) | - | ||||||||||||||||||||||||||||||
| 1257 | { | - | ||||||||||||||||||||||||||||||
| 1258 | QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1259 | QVariant r; | - | ||||||||||||||||||||||||||||||
| 1260 | - | |||||||||||||||||||||||||||||||
| 1261 | QObject *p = parent(); | - | ||||||||||||||||||||||||||||||
| 1262 |     if (p
  | 0 | ||||||||||||||||||||||||||||||
| 1263 | const QMetaObject *me = p->metaObject(); | - | ||||||||||||||||||||||||||||||
| 1264 | int index = me->indexOfMethod("loadResource(int,QUrl)"); | - | ||||||||||||||||||||||||||||||
| 1265 |         if (index >= 0
  | 0 | ||||||||||||||||||||||||||||||
| 1266 | QMetaMethod loader = me->method(index); | - | ||||||||||||||||||||||||||||||
| 1267 | loader.invoke(p, QReturnArgument<QVariant >("QVariant", r), QArgument<int >("int", type), QArgument<QUrl >("QUrl", name)); | - | ||||||||||||||||||||||||||||||
| 1268 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1269 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||||||||
| 1272 |     if (r.isNull()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1273 | QString mimetype; | - | ||||||||||||||||||||||||||||||
| 1274 | QByteArray payload; | - | ||||||||||||||||||||||||||||||
| 1275 |         if (qDecodeDataUrl(name, mimetype, payload)
  | 0 | ||||||||||||||||||||||||||||||
| 1276 |             r = payload; never executed:  r = payload; | 0 | ||||||||||||||||||||||||||||||
| 1277 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||||||||
| 1280 |     if (!qobject_cast<QTextDocument *>(p)
 
  | 0 | ||||||||||||||||||||||||||||||
| 1281 | QUrl resourceUrl = name; | - | ||||||||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||||||||
| 1283 |         if (name.isRelative()
  | 0 | ||||||||||||||||||||||||||||||
| 1284 | QUrl currentURL = d->url; | - | ||||||||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||||||||
| 1286 | - | |||||||||||||||||||||||||||||||
| 1287 |             if (!(currentURL.isRelative()
  | 0 | ||||||||||||||||||||||||||||||
| 1288 |                   || (currentURL.scheme() == QLatin1String("file")
  | 0 | ||||||||||||||||||||||||||||||
| 1289 |                       && !QFileInfo(currentURL.toLocalFile()).isAbsolute()
  | 0 | ||||||||||||||||||||||||||||||
| 1290 |                 || (name.hasFragment()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1291 | resourceUrl = currentURL.resolved(name); | - | ||||||||||||||||||||||||||||||
| 1292 |             } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1293 | - | |||||||||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||||||||
| 1296 | QFileInfo fi(currentURL.toLocalFile()); | - | ||||||||||||||||||||||||||||||
| 1297 |                 if (fi.exists()
  | 0 | ||||||||||||||||||||||||||||||
| 1298 | resourceUrl = | - | ||||||||||||||||||||||||||||||
| 1299 | QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name); | - | ||||||||||||||||||||||||||||||
| 1300 |                 } never executed:   else if (currentURL.isEmpty()end of block
  | 0 | ||||||||||||||||||||||||||||||
| 1301 | resourceUrl.setScheme(QLatin1String("file")); | - | ||||||||||||||||||||||||||||||
| 1302 |                 } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1303 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1304 | } | - | ||||||||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||||||||
| 1306 | QString s = resourceUrl.toLocalFile(); | - | ||||||||||||||||||||||||||||||
| 1307 | QFile f(s); | - | ||||||||||||||||||||||||||||||
| 1308 |         if (!s.isEmpty()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1309 | r = f.readAll(); | - | ||||||||||||||||||||||||||||||
| 1310 | f.close(); | - | ||||||||||||||||||||||||||||||
| 1311 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1312 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||||||||
| 1314 |     if (!r.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 1315 |         if (type == ImageResource
 
  | 0 | ||||||||||||||||||||||||||||||
| 1316 |             if (QCoreApplication::instance()->thread() != QThread::currentThread()
  | 0 | ||||||||||||||||||||||||||||||
| 1317 | - | |||||||||||||||||||||||||||||||
| 1318 | QImage image; | - | ||||||||||||||||||||||||||||||
| 1319 | image.loadFromData(r.toByteArray()); | - | ||||||||||||||||||||||||||||||
| 1320 |                 if (!image.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 1321 |                     r = image; never executed:  r = image; | 0 | ||||||||||||||||||||||||||||||
| 1322 |             } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1323 | QPixmap pm; | - | ||||||||||||||||||||||||||||||
| 1324 | pm.loadFromData(r.toByteArray()); | - | ||||||||||||||||||||||||||||||
| 1325 |                 if (!pm.isNull()
  | 0 | ||||||||||||||||||||||||||||||
| 1326 |                     r = pm; never executed:  r = pm; | 0 | ||||||||||||||||||||||||||||||
| 1327 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1328 | } | - | ||||||||||||||||||||||||||||||
| 1329 | d->cachedResources.insert(name, r); | - | ||||||||||||||||||||||||||||||
| 1330 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1331 |     return never executed:   r;return r;never executed:  return r; | 0 | ||||||||||||||||||||||||||||||
| 1332 | } | - | ||||||||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||||||||
| 1334 | static QTextFormat formatDifference(const QTextFormat &from, const QTextFormat &to) | - | ||||||||||||||||||||||||||||||
| 1335 | { | - | ||||||||||||||||||||||||||||||
| 1336 | QTextFormat diff = to; | - | ||||||||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||||||||
| 1338 | const QMap<int, QVariant> props = to.properties(); | - | ||||||||||||||||||||||||||||||
| 1339 | for (QMap<int, QVariant>::ConstIterator it = props.begin(), end = props.end(); | - | ||||||||||||||||||||||||||||||
| 1340 |          it != end
  | 0 | ||||||||||||||||||||||||||||||
| 1341 |         if (it.value() == from.property(it.key())
  | 0 | ||||||||||||||||||||||||||||||
| 1342 |             diff.clearProperty(it.key()); never executed:  diff.clearProperty(it.key()); | 0 | ||||||||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||||||||
| 1344 |     return never executed:   diff;return diff;never executed:  return diff; | 0 | ||||||||||||||||||||||||||||||
| 1345 | } | - | ||||||||||||||||||||||||||||||
| 1346 | - | |||||||||||||||||||||||||||||||
| 1347 | static QString colorValue(QColor color) | - | ||||||||||||||||||||||||||||||
| 1348 | { | - | ||||||||||||||||||||||||||||||
| 1349 | QString result; | - | ||||||||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||||||||
| 1351 |     if (color.alpha() == 255
  | 0 | ||||||||||||||||||||||||||||||
| 1352 | result = color.name(); | - | ||||||||||||||||||||||||||||||
| 1353 |     } never executed:   else if (color.alpha()end of block
  | 0 | ||||||||||||||||||||||||||||||
| 1354 | QString alphaValue = QString::number(color.alphaF(), 'f', 6).remove(QRegExp(QLatin1String("\\.?0*$"))); | - | ||||||||||||||||||||||||||||||
| 1355 | result = QString::fromLatin1("rgba(%1,%2,%3,%4)").arg(color.red()) | - | ||||||||||||||||||||||||||||||
| 1356 | .arg(color.green()) | - | ||||||||||||||||||||||||||||||
| 1357 | .arg(color.blue()) | - | ||||||||||||||||||||||||||||||
| 1358 | .arg(alphaValue); | - | ||||||||||||||||||||||||||||||
| 1359 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1360 | result = QLatin1String("transparent"); | - | ||||||||||||||||||||||||||||||
| 1361 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||||||||
| 1363 |     return never executed:   result;return result;never executed:  return result; | 0 | ||||||||||||||||||||||||||||||
| 1364 | } | - | ||||||||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||||||||
| 1366 | QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc) | - | ||||||||||||||||||||||||||||||
| 1367 | : doc(_doc), fragmentMarkers(false) | - | ||||||||||||||||||||||||||||||
| 1368 | { | - | ||||||||||||||||||||||||||||||
| 1369 | const QFont defaultFont = doc->defaultFont(); | - | ||||||||||||||||||||||||||||||
| 1370 | defaultCharFormat.setFont(defaultFont); | - | ||||||||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||||||||
| 1372 | defaultCharFormat.clearProperty(QTextFormat::FontUnderline); | - | ||||||||||||||||||||||||||||||
| 1373 | defaultCharFormat.clearProperty(QTextFormat::FontOverline); | - | ||||||||||||||||||||||||||||||
| 1374 | defaultCharFormat.clearProperty(QTextFormat::FontStrikeOut); | - | ||||||||||||||||||||||||||||||
| 1375 | defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle); | - | ||||||||||||||||||||||||||||||
| 1376 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||||||||
| 1378 | - | |||||||||||||||||||||||||||||||
| 1379 | - | |||||||||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||||||||
| 1382 | - | |||||||||||||||||||||||||||||||
| 1383 | QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) | - | ||||||||||||||||||||||||||||||
| 1384 | { | - | ||||||||||||||||||||||||||||||
| 1385 | html = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" " | - | ||||||||||||||||||||||||||||||
| 1386 | "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" | - | ||||||||||||||||||||||||||||||
| 1387 | "<html><head><meta name=\"qrichtext\" content=\"1\" />"); | - | ||||||||||||||||||||||||||||||
| 1388 | html.reserve(doc->docHandle()->length()); | - | ||||||||||||||||||||||||||||||
| 1389 | - | |||||||||||||||||||||||||||||||
| 1390 | fragmentMarkers = (mode == ExportFragment); | - | ||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 |     if (!encoding.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 1393 |         html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding)); never executed:  html += QString::fromLatin1("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%1\" />").arg(QString::fromLatin1(encoding)); | 0 | ||||||||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||||||||
| 1395 | QString title = doc->metaInformation(QTextDocument::DocumentTitle); | - | ||||||||||||||||||||||||||||||
| 1396 |     if (!title.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 1397 |         html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>"); never executed:  html += QString::fromLatin1("<title>") + title + QString::fromLatin1("</title>"); | 0 | ||||||||||||||||||||||||||||||
| 1398 | html += QLatin1String("<style type=\"text/css\">\n"); | - | ||||||||||||||||||||||||||||||
| 1399 | html += QLatin1String("p, li { white-space: pre-wrap; }\n"); | - | ||||||||||||||||||||||||||||||
| 1400 | html += QLatin1String("</style>"); | - | ||||||||||||||||||||||||||||||
| 1401 | html += QLatin1String("</head><body"); | - | ||||||||||||||||||||||||||||||
| 1402 | - | |||||||||||||||||||||||||||||||
| 1403 |     if (mode == ExportEntireDocument
  | 0 | ||||||||||||||||||||||||||||||
| 1404 | html += QLatin1String(" style=\""); | - | ||||||||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||||||||
| 1406 | emitFontFamily(defaultCharFormat.fontFamily()); | - | ||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 |         if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)
  | 0 | ||||||||||||||||||||||||||||||
| 1409 | html += QLatin1String(" font-size:"); | - | ||||||||||||||||||||||||||||||
| 1410 | html += QString::number(defaultCharFormat.fontPointSize()); | - | ||||||||||||||||||||||||||||||
| 1411 | html += QLatin1String("pt;"); | - | ||||||||||||||||||||||||||||||
| 1412 |         } never executed:   else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)end of block
  | 0 | ||||||||||||||||||||||||||||||
| 1413 | html += QLatin1String(" font-size:"); | - | ||||||||||||||||||||||||||||||
| 1414 | html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize)); | - | ||||||||||||||||||||||||||||||
| 1415 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1416 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1417 | - | |||||||||||||||||||||||||||||||
| 1418 | html += QLatin1String(" font-weight:"); | - | ||||||||||||||||||||||||||||||
| 1419 | html += QString::number(defaultCharFormat.fontWeight() * 8); | - | ||||||||||||||||||||||||||||||
| 1420 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||||||||
| 1422 | html += QLatin1String(" font-style:"); | - | ||||||||||||||||||||||||||||||
| 1423 |         html += (defaultCharFormat.fontItalic()
  | 0 | ||||||||||||||||||||||||||||||
| 1424 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||||||||
| 1427 | - | |||||||||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||||||||
| 1429 | html += QLatin1Char('\"'); | - | ||||||||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||||||||
| 1431 | const QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); | - | ||||||||||||||||||||||||||||||
| 1432 | emitBackgroundAttribute(fmt); | - | ||||||||||||||||||||||||||||||
| 1433 | - | |||||||||||||||||||||||||||||||
| 1434 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1435 | defaultCharFormat = QTextCharFormat(); | - | ||||||||||||||||||||||||||||||
| 1436 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1437 | html += QLatin1Char('>'); | - | ||||||||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||||||||
| 1439 | QTextFrameFormat rootFmt = doc->rootFrame()->frameFormat(); | - | ||||||||||||||||||||||||||||||
| 1440 | rootFmt.clearProperty(QTextFormat::BackgroundBrush); | - | ||||||||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||||||||
| 1442 | QTextFrameFormat defaultFmt; | - | ||||||||||||||||||||||||||||||
| 1443 | defaultFmt.setMargin(doc->documentMargin()); | - | ||||||||||||||||||||||||||||||
| 1444 | - | |||||||||||||||||||||||||||||||
| 1445 |     if (rootFmt == defaultFmt
  | 0 | ||||||||||||||||||||||||||||||
| 1446 |         emitFrame(doc->rootFrame()->begin()); never executed:  emitFrame(doc->rootFrame()->begin()); | 0 | ||||||||||||||||||||||||||||||
| 1447 | else | - | ||||||||||||||||||||||||||||||
| 1448 |         emitTextFrame(doc->rootFrame()); never executed:  emitTextFrame(doc->rootFrame()); | 0 | ||||||||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||||||||
| 1450 | html += QLatin1String("</body></html>"); | - | ||||||||||||||||||||||||||||||
| 1451 |     return never executed:   html;return html;never executed:  return html; | 0 | ||||||||||||||||||||||||||||||
| 1452 | } | - | ||||||||||||||||||||||||||||||
| 1453 | - | |||||||||||||||||||||||||||||||
| 1454 | void QTextHtmlExporter::emitAttribute(const char *attribute, const QString &value) | - | ||||||||||||||||||||||||||||||
| 1455 | { | - | ||||||||||||||||||||||||||||||
| 1456 | html += QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 1457 | html += QLatin1String(attribute); | - | ||||||||||||||||||||||||||||||
| 1458 | html += QLatin1String("=\""); | - | ||||||||||||||||||||||||||||||
| 1459 | html += value.toHtmlEscaped(); | - | ||||||||||||||||||||||||||||||
| 1460 | html += QLatin1Char('"'); | - | ||||||||||||||||||||||||||||||
| 1461 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1462 | - | |||||||||||||||||||||||||||||||
| 1463 | bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) | - | ||||||||||||||||||||||||||||||
| 1464 | { | - | ||||||||||||||||||||||||||||||
| 1465 | bool attributesEmitted = false; | - | ||||||||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||||||||
| 1467 | { | - | ||||||||||||||||||||||||||||||
| 1468 | const QString family = format.fontFamily(); | - | ||||||||||||||||||||||||||||||
| 1469 |         if (!family.isEmpty()
 
  | 0 | ||||||||||||||||||||||||||||||
| 1470 | emitFontFamily(family); | - | ||||||||||||||||||||||||||||||
| 1471 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1472 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1473 | } | - | ||||||||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||||||||
| 1475 |     if (format.hasProperty(QTextFormat::FontPointSize)
  | 0 | ||||||||||||||||||||||||||||||
| 1476 |         && format.fontPointSize() != defaultCharFormat.fontPointSize()
  | 0 | ||||||||||||||||||||||||||||||
| 1477 | html += QLatin1String(" font-size:"); | - | ||||||||||||||||||||||||||||||
| 1478 | html += QString::number(format.fontPointSize()); | - | ||||||||||||||||||||||||||||||
| 1479 | html += QLatin1String("pt;"); | - | ||||||||||||||||||||||||||||||
| 1480 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1481 |     } never executed:   else if (format.hasProperty(QTextFormat::FontSizeAdjustment)end of block
  | 0 | ||||||||||||||||||||||||||||||
| 1482 | static const char sizeNameData[] = | - | ||||||||||||||||||||||||||||||
| 1483 | "small" "\0" | - | ||||||||||||||||||||||||||||||
| 1484 | "medium" "\0" | - | ||||||||||||||||||||||||||||||
| 1485 | "xx-large" ; | - | ||||||||||||||||||||||||||||||
| 1486 | static const quint8 sizeNameOffsets[] = { | - | ||||||||||||||||||||||||||||||
| 1487 | 0, | - | ||||||||||||||||||||||||||||||
| 1488 | sizeof("small"), | - | ||||||||||||||||||||||||||||||
| 1489 | sizeof("small") + sizeof("medium") + 3, | - | ||||||||||||||||||||||||||||||
| 1490 | sizeof("small") + sizeof("medium") + 1, | - | ||||||||||||||||||||||||||||||
| 1491 | sizeof("small") + sizeof("medium"), | - | ||||||||||||||||||||||||||||||
| 1492 | }; | - | ||||||||||||||||||||||||||||||
| 1493 | const char *name = 0; | - | ||||||||||||||||||||||||||||||
| 1494 | const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1; | - | ||||||||||||||||||||||||||||||
| 1495 |         if (idx >= 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 1496 | name = sizeNameData + sizeNameOffsets[idx]; | - | ||||||||||||||||||||||||||||||
| 1497 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1498 |         if (name
  | 0 | ||||||||||||||||||||||||||||||
| 1499 | html += QLatin1String(" font-size:"); | - | ||||||||||||||||||||||||||||||
| 1500 | html += QLatin1String(name); | - | ||||||||||||||||||||||||||||||
| 1501 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1502 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1503 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1504 |     } never executed:   else if (format.hasProperty(QTextFormat::FontPixelSize)end of block
  | 0 | ||||||||||||||||||||||||||||||
| 1505 | html += QLatin1String(" font-size:"); | - | ||||||||||||||||||||||||||||||
| 1506 | html += QString::number(format.intProperty(QTextFormat::FontPixelSize)); | - | ||||||||||||||||||||||||||||||
| 1507 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1508 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1509 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1510 | - | |||||||||||||||||||||||||||||||
| 1511 |     if (format.hasProperty(QTextFormat::FontWeight)
  | 0 | ||||||||||||||||||||||||||||||
| 1512 |         && format.fontWeight() != defaultCharFormat.fontWeight()
  | 0 | ||||||||||||||||||||||||||||||
| 1513 | html += QLatin1String(" font-weight:"); | - | ||||||||||||||||||||||||||||||
| 1514 | html += QString::number(format.fontWeight() * 8); | - | ||||||||||||||||||||||||||||||
| 1515 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1516 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1517 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1518 | - | |||||||||||||||||||||||||||||||
| 1519 |     if (format.hasProperty(QTextFormat::FontItalic)
  | 0 | ||||||||||||||||||||||||||||||
| 1520 |         && format.fontItalic() != defaultCharFormat.fontItalic()
  | 0 | ||||||||||||||||||||||||||||||
| 1521 | html += QLatin1String(" font-style:"); | - | ||||||||||||||||||||||||||||||
| 1522 |         html += (format.fontItalic()
  | 0 | ||||||||||||||||||||||||||||||
| 1523 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1524 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1525 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1526 | - | |||||||||||||||||||||||||||||||
| 1527 | QLatin1String decorationTag(" text-decoration:"); | - | ||||||||||||||||||||||||||||||
| 1528 | html += decorationTag; | - | ||||||||||||||||||||||||||||||
| 1529 | bool hasDecoration = false; | - | ||||||||||||||||||||||||||||||
| 1530 | bool atLeastOneDecorationSet = false; | - | ||||||||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||||||||
| 1532 |     if ((format.hasProperty(QTextFormat::FontUnderline)
 
  | 0 | ||||||||||||||||||||||||||||||
| 1533 |         && format.fontUnderline() != defaultCharFormat.fontUnderline()
  | 0 | ||||||||||||||||||||||||||||||
| 1534 | hasDecoration = true; | - | ||||||||||||||||||||||||||||||
| 1535 |         if (format.fontUnderline()
  | 0 | ||||||||||||||||||||||||||||||
| 1536 | html += QLatin1String(" underline"); | - | ||||||||||||||||||||||||||||||
| 1537 | atLeastOneDecorationSet = true; | - | ||||||||||||||||||||||||||||||
| 1538 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1539 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||||||||
| 1541 |     if (format.hasProperty(QTextFormat::FontOverline)
  | 0 | ||||||||||||||||||||||||||||||
| 1542 |         && format.fontOverline() != defaultCharFormat.fontOverline()
  | 0 | ||||||||||||||||||||||||||||||
| 1543 | hasDecoration = true; | - | ||||||||||||||||||||||||||||||
| 1544 |         if (format.fontOverline()
  | 0 | ||||||||||||||||||||||||||||||
| 1545 | html += QLatin1String(" overline"); | - | ||||||||||||||||||||||||||||||
| 1546 | atLeastOneDecorationSet = true; | - | ||||||||||||||||||||||||||||||
| 1547 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1548 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||||||||
| 1550 |     if (format.hasProperty(QTextFormat::FontStrikeOut)
  | 0 | ||||||||||||||||||||||||||||||
| 1551 |         && format.fontStrikeOut() != defaultCharFormat.fontStrikeOut()
  | 0 | ||||||||||||||||||||||||||||||
| 1552 | hasDecoration = true; | - | ||||||||||||||||||||||||||||||
| 1553 |         if (format.fontStrikeOut()
  | 0 | ||||||||||||||||||||||||||||||
| 1554 | html += QLatin1String(" line-through"); | - | ||||||||||||||||||||||||||||||
| 1555 | atLeastOneDecorationSet = true; | - | ||||||||||||||||||||||||||||||
| 1556 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1557 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||||||||
| 1559 |     if (hasDecoration
  | 0 | ||||||||||||||||||||||||||||||
| 1560 |         if (!atLeastOneDecorationSet
  | 0 | ||||||||||||||||||||||||||||||
| 1561 |             html += QLatin1String("none"); never executed:  html += QLatin1String("none"); | 0 | ||||||||||||||||||||||||||||||
| 1562 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1563 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1564 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1565 | html.chop(qstrlen(decorationTag.latin1())); | - | ||||||||||||||||||||||||||||||
| 1566 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1567 | - | |||||||||||||||||||||||||||||||
| 1568 |     if (format.foreground() != defaultCharFormat.foreground()
  | 0 | ||||||||||||||||||||||||||||||
| 1569 |         && format.foreground().style() != Qt::NoBrush
  | 0 | ||||||||||||||||||||||||||||||
| 1570 | html += QLatin1String(" color:"); | - | ||||||||||||||||||||||||||||||
| 1571 | html += colorValue(format.foreground().color()); | - | ||||||||||||||||||||||||||||||
| 1572 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1573 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1574 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1575 | - | |||||||||||||||||||||||||||||||
| 1576 |     if (format.background() != defaultCharFormat.background()
  | 0 | ||||||||||||||||||||||||||||||
| 1577 |         && format.background().style() == Qt::SolidPattern
  | 0 | ||||||||||||||||||||||||||||||
| 1578 | html += QLatin1String(" background-color:"); | - | ||||||||||||||||||||||||||||||
| 1579 | html += colorValue(format.background().color()); | - | ||||||||||||||||||||||||||||||
| 1580 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1581 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1582 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||||||||
| 1584 |     if (format.verticalAlignment() != defaultCharFormat.verticalAlignment()
  | 0 | ||||||||||||||||||||||||||||||
| 1585 |         && format.verticalAlignment() != QTextCharFormat::AlignNormal
  | 0 | ||||||||||||||||||||||||||||||
| 1586 | { | - | ||||||||||||||||||||||||||||||
| 1587 | html += QLatin1String(" vertical-align:"); | - | ||||||||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||||||||
| 1589 | QTextCharFormat::VerticalAlignment valign = format.verticalAlignment(); | - | ||||||||||||||||||||||||||||||
| 1590 |         if (valign == QTextCharFormat::AlignSubScript
  | 0 | ||||||||||||||||||||||||||||||
| 1591 |             html += QLatin1String("sub"); never executed:  html += QLatin1String("sub"); | 0 | ||||||||||||||||||||||||||||||
| 1592 |         else if (valign == QTextCharFormat::AlignSuperScript
  | 0 | ||||||||||||||||||||||||||||||
| 1593 |             html += QLatin1String("super"); never executed:  html += QLatin1String("super"); | 0 | ||||||||||||||||||||||||||||||
| 1594 |         else if (valign == QTextCharFormat::AlignMiddle
  | 0 | ||||||||||||||||||||||||||||||
| 1595 |             html += QLatin1String("middle"); never executed:  html += QLatin1String("middle"); | 0 | ||||||||||||||||||||||||||||||
| 1596 |         else if (valign == QTextCharFormat::AlignTop
  | 0 | ||||||||||||||||||||||||||||||
| 1597 |             html += QLatin1String("top"); never executed:  html += QLatin1String("top"); | 0 | ||||||||||||||||||||||||||||||
| 1598 |         else if (valign == QTextCharFormat::AlignBottom
  | 0 | ||||||||||||||||||||||||||||||
| 1599 |             html += QLatin1String("bottom"); never executed:  html += QLatin1String("bottom"); | 0 | ||||||||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||||||||
| 1601 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1602 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1603 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1604 | - | |||||||||||||||||||||||||||||||
| 1605 |     if (format.fontCapitalization() != QFont::MixedCase
  | 0 | ||||||||||||||||||||||||||||||
| 1606 | const QFont::Capitalization caps = format.fontCapitalization(); | - | ||||||||||||||||||||||||||||||
| 1607 |         if (caps == QFont::AllUppercase
  | 0 | ||||||||||||||||||||||||||||||
| 1608 |             html += QLatin1String(" text-transform:uppercase;"); never executed:  html += QLatin1String(" text-transform:uppercase;"); | 0 | ||||||||||||||||||||||||||||||
| 1609 |         else if (caps == QFont::AllLowercase
  | 0 | ||||||||||||||||||||||||||||||
| 1610 |             html += QLatin1String(" text-transform:lowercase;"); never executed:  html += QLatin1String(" text-transform:lowercase;"); | 0 | ||||||||||||||||||||||||||||||
| 1611 |         else if (caps == QFont::SmallCaps
  | 0 | ||||||||||||||||||||||||||||||
| 1612 |             html += QLatin1String(" font-variant:small-caps;"); never executed:  html += QLatin1String(" font-variant:small-caps;"); | 0 | ||||||||||||||||||||||||||||||
| 1613 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1614 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||||||||
| 1616 |     if (format.fontWordSpacing() != 0.0
  | 0 | ||||||||||||||||||||||||||||||
| 1617 | html += QLatin1String(" word-spacing:"); | - | ||||||||||||||||||||||||||||||
| 1618 | html += QString::number(format.fontWordSpacing()); | - | ||||||||||||||||||||||||||||||
| 1619 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1620 | attributesEmitted = true; | - | ||||||||||||||||||||||||||||||
| 1621 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1622 | - | |||||||||||||||||||||||||||||||
| 1623 |     return never executed:   attributesEmitted;return attributesEmitted;never executed:  return attributesEmitted; | 0 | ||||||||||||||||||||||||||||||
| 1624 | } | - | ||||||||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||||||||
| 1626 | void QTextHtmlExporter::emitTextLength(const char *attribute, const QTextLength &length) | - | ||||||||||||||||||||||||||||||
| 1627 | { | - | ||||||||||||||||||||||||||||||
| 1628 |     if (length.type() == QTextLength::VariableLength
  | 0 | ||||||||||||||||||||||||||||||
| 1629 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1630 | - | |||||||||||||||||||||||||||||||
| 1631 | html += QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 1632 | html += QLatin1String(attribute); | - | ||||||||||||||||||||||||||||||
| 1633 | html += QLatin1String("=\""); | - | ||||||||||||||||||||||||||||||
| 1634 | html += QString::number(length.rawValue()); | - | ||||||||||||||||||||||||||||||
| 1635 | - | |||||||||||||||||||||||||||||||
| 1636 |     if (length.type() == QTextLength::PercentageLength
  | 0 | ||||||||||||||||||||||||||||||
| 1637 |         html += QLatin1String("%\""); never executed:  html += QLatin1String("%\""); | 0 | ||||||||||||||||||||||||||||||
| 1638 | else | - | ||||||||||||||||||||||||||||||
| 1639 |         html += QLatin1Char('\"'); never executed:  html += QLatin1Char('\"'); | 0 | ||||||||||||||||||||||||||||||
| 1640 | } | - | ||||||||||||||||||||||||||||||
| 1641 | - | |||||||||||||||||||||||||||||||
| 1642 | void QTextHtmlExporter::emitAlignment(Qt::Alignment align) | - | ||||||||||||||||||||||||||||||
| 1643 | { | - | ||||||||||||||||||||||||||||||
| 1644 |     if (align & Qt::AlignLeft
  | 0 | ||||||||||||||||||||||||||||||
| 1645 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1646 |     else if (align & Qt::AlignRight
  | 0 | ||||||||||||||||||||||||||||||
| 1647 |         html += QLatin1String(" align=\"right\""); never executed:  html += QLatin1String(" align=\"right\""); | 0 | ||||||||||||||||||||||||||||||
| 1648 |     else if (align & Qt::AlignHCenter
  | 0 | ||||||||||||||||||||||||||||||
| 1649 |         html += QLatin1String(" align=\"center\""); never executed:  html += QLatin1String(" align=\"center\""); | 0 | ||||||||||||||||||||||||||||||
| 1650 |     else if (align & Qt::AlignJustify
  | 0 | ||||||||||||||||||||||||||||||
| 1651 |         html += QLatin1String(" align=\"justify\""); never executed:  html += QLatin1String(" align=\"justify\""); | 0 | ||||||||||||||||||||||||||||||
| 1652 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1653 | - | |||||||||||||||||||||||||||||||
| 1654 | void QTextHtmlExporter::emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode) | - | ||||||||||||||||||||||||||||||
| 1655 | { | - | ||||||||||||||||||||||||||||||
| 1656 |     if (pos == QTextFrameFormat::InFlow
  | 0 | ||||||||||||||||||||||||||||||
| 1657 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||||||||
| 1659 |     if (mode == EmitStyleTag
  | 0 | ||||||||||||||||||||||||||||||
| 1660 |         html += QLatin1String(" style=\"float:"); never executed:  html += QLatin1String(" style=\"float:"); | 0 | ||||||||||||||||||||||||||||||
| 1661 | else | - | ||||||||||||||||||||||||||||||
| 1662 |         html += QLatin1String(" float:"); never executed:  html += QLatin1String(" float:"); | 0 | ||||||||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||||||||
| 1664 |     if (pos == QTextFrameFormat::FloatLeft
  | 0 | ||||||||||||||||||||||||||||||
| 1665 |         html += QLatin1String(" left;"); never executed:  html += QLatin1String(" left;"); | 0 | ||||||||||||||||||||||||||||||
| 1666 |     else if (pos == QTextFrameFormat::FloatRight
  | 0 | ||||||||||||||||||||||||||||||
| 1667 |         html += QLatin1String(" right;"); never executed:  html += QLatin1String(" right;"); | 0 | ||||||||||||||||||||||||||||||
| 1668 | else | - | ||||||||||||||||||||||||||||||
| 1669 |         (( never executed:  !(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2535) : qt_noop());((!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2535) : qt_noop());never executed:  ((!(0)) ? qt_assert_x("QTextHtmlExporter::emitFloatStyle()", "pos should be a valid enum type",__FILE__,2535) : qt_noop()); | 0 | ||||||||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||||||||
| 1671 |     if (mode == EmitStyleTag
  | 0 | ||||||||||||||||||||||||||||||
| 1672 |         html += QLatin1Char('\"'); never executed:  html += QLatin1Char('\"'); | 0 | ||||||||||||||||||||||||||||||
| 1673 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1674 | - | |||||||||||||||||||||||||||||||
| 1675 | void QTextHtmlExporter::emitBorderStyle(QTextFrameFormat::BorderStyle style) | - | ||||||||||||||||||||||||||||||
| 1676 | { | - | ||||||||||||||||||||||||||||||
| 1677 | ((!(style <= QTextFrameFormat::BorderStyle_Outset)) ? qt_assert("style <= QTextFrameFormat::BorderStyle_Outset",__FILE__,2543) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1678 | - | |||||||||||||||||||||||||||||||
| 1679 | html += QLatin1String(" border-style:"); | - | ||||||||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||||||||
| 1681 | switch (style) { | - | ||||||||||||||||||||||||||||||
| 1682 |     case never executed:   QTextFrameFormat::BorderStyle_None:case QTextFrameFormat::BorderStyle_None:never executed:  case QTextFrameFormat::BorderStyle_None: | 0 | ||||||||||||||||||||||||||||||
| 1683 | html += QLatin1String("none"); | - | ||||||||||||||||||||||||||||||
| 1684 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1685 |     case never executed:   QTextFrameFormat::BorderStyle_Dotted:case QTextFrameFormat::BorderStyle_Dotted:never executed:  case QTextFrameFormat::BorderStyle_Dotted: | 0 | ||||||||||||||||||||||||||||||
| 1686 | html += QLatin1String("dotted"); | - | ||||||||||||||||||||||||||||||
| 1687 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1688 |     case never executed:   QTextFrameFormat::BorderStyle_Dashed:case QTextFrameFormat::BorderStyle_Dashed:never executed:  case QTextFrameFormat::BorderStyle_Dashed: | 0 | ||||||||||||||||||||||||||||||
| 1689 | html += QLatin1String("dashed"); | - | ||||||||||||||||||||||||||||||
| 1690 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1691 |     case never executed:   QTextFrameFormat::BorderStyle_Solid:case QTextFrameFormat::BorderStyle_Solid:never executed:  case QTextFrameFormat::BorderStyle_Solid: | 0 | ||||||||||||||||||||||||||||||
| 1692 | html += QLatin1String("solid"); | - | ||||||||||||||||||||||||||||||
| 1693 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1694 |     case never executed:   QTextFrameFormat::BorderStyle_Double:case QTextFrameFormat::BorderStyle_Double:never executed:  case QTextFrameFormat::BorderStyle_Double: | 0 | ||||||||||||||||||||||||||||||
| 1695 | html += QLatin1String("double"); | - | ||||||||||||||||||||||||||||||
| 1696 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1697 |     case never executed:   QTextFrameFormat::BorderStyle_DotDash:case QTextFrameFormat::BorderStyle_DotDash:never executed:  case QTextFrameFormat::BorderStyle_DotDash: | 0 | ||||||||||||||||||||||||||||||
| 1698 | html += QLatin1String("dot-dash"); | - | ||||||||||||||||||||||||||||||
| 1699 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1700 |     case never executed:   QTextFrameFormat::BorderStyle_DotDotDash:case QTextFrameFormat::BorderStyle_DotDotDash:never executed:  case QTextFrameFormat::BorderStyle_DotDotDash: | 0 | ||||||||||||||||||||||||||||||
| 1701 | html += QLatin1String("dot-dot-dash"); | - | ||||||||||||||||||||||||||||||
| 1702 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1703 |     case never executed:   QTextFrameFormat::BorderStyle_Groove:case QTextFrameFormat::BorderStyle_Groove:never executed:  case QTextFrameFormat::BorderStyle_Groove: | 0 | ||||||||||||||||||||||||||||||
| 1704 | html += QLatin1String("groove"); | - | ||||||||||||||||||||||||||||||
| 1705 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1706 |     case never executed:   QTextFrameFormat::BorderStyle_Ridge:case QTextFrameFormat::BorderStyle_Ridge:never executed:  case QTextFrameFormat::BorderStyle_Ridge: | 0 | ||||||||||||||||||||||||||||||
| 1707 | html += QLatin1String("ridge"); | - | ||||||||||||||||||||||||||||||
| 1708 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1709 |     case never executed:   QTextFrameFormat::BorderStyle_Inset:case QTextFrameFormat::BorderStyle_Inset:never executed:  case QTextFrameFormat::BorderStyle_Inset: | 0 | ||||||||||||||||||||||||||||||
| 1710 | html += QLatin1String("inset"); | - | ||||||||||||||||||||||||||||||
| 1711 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1712 |     case never executed:   QTextFrameFormat::BorderStyle_Outset:case QTextFrameFormat::BorderStyle_Outset:never executed:  case QTextFrameFormat::BorderStyle_Outset: | 0 | ||||||||||||||||||||||||||||||
| 1713 | html += QLatin1String("outset"); | - | ||||||||||||||||||||||||||||||
| 1714 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1715 |     default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||||||||||||||
| 1716 | ((!(false)) ? qt_assert("false",__FILE__,2582) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1717 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1718 | }; | - | ||||||||||||||||||||||||||||||
| 1719 | - | |||||||||||||||||||||||||||||||
| 1720 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1721 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1722 | - | |||||||||||||||||||||||||||||||
| 1723 | void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy) | - | ||||||||||||||||||||||||||||||
| 1724 | { | - | ||||||||||||||||||||||||||||||
| 1725 |     if (policy & QTextFormat::PageBreak_AlwaysBefore
  | 0 | ||||||||||||||||||||||||||||||
| 1726 |         html += QLatin1String(" page-break-before:always;"); never executed:  html += QLatin1String(" page-break-before:always;"); | 0 | ||||||||||||||||||||||||||||||
| 1727 | - | |||||||||||||||||||||||||||||||
| 1728 |     if (policy & QTextFormat::PageBreak_AlwaysAfter
  | 0 | ||||||||||||||||||||||||||||||
| 1729 |         html += QLatin1String(" page-break-after:always;"); never executed:  html += QLatin1String(" page-break-after:always;"); | 0 | ||||||||||||||||||||||||||||||
| 1730 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1731 | - | |||||||||||||||||||||||||||||||
| 1732 | void QTextHtmlExporter::emitFontFamily(const QString &family) | - | ||||||||||||||||||||||||||||||
| 1733 | { | - | ||||||||||||||||||||||||||||||
| 1734 | html += QLatin1String(" font-family:"); | - | ||||||||||||||||||||||||||||||
| 1735 | - | |||||||||||||||||||||||||||||||
| 1736 | QLatin1String quote("\'"); | - | ||||||||||||||||||||||||||||||
| 1737 |     if (family.contains(QLatin1Char('\''))
  | 0 | ||||||||||||||||||||||||||||||
| 1738 |         quote = QLatin1String("""); never executed:  quote = QLatin1String("""); | 0 | ||||||||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||||||||
| 1740 | html += quote; | - | ||||||||||||||||||||||||||||||
| 1741 | html += family.toHtmlEscaped(); | - | ||||||||||||||||||||||||||||||
| 1742 | html += quote; | - | ||||||||||||||||||||||||||||||
| 1743 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1744 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1745 | - | |||||||||||||||||||||||||||||||
| 1746 | void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right) | - | ||||||||||||||||||||||||||||||
| 1747 | { | - | ||||||||||||||||||||||||||||||
| 1748 | html += QLatin1String(" margin-top:"); | - | ||||||||||||||||||||||||||||||
| 1749 | html += top; | - | ||||||||||||||||||||||||||||||
| 1750 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||||||||
| 1752 | html += QLatin1String(" margin-bottom:"); | - | ||||||||||||||||||||||||||||||
| 1753 | html += bottom; | - | ||||||||||||||||||||||||||||||
| 1754 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1755 | - | |||||||||||||||||||||||||||||||
| 1756 | html += QLatin1String(" margin-left:"); | - | ||||||||||||||||||||||||||||||
| 1757 | html += left; | - | ||||||||||||||||||||||||||||||
| 1758 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1759 | - | |||||||||||||||||||||||||||||||
| 1760 | html += QLatin1String(" margin-right:"); | - | ||||||||||||||||||||||||||||||
| 1761 | html += right; | - | ||||||||||||||||||||||||||||||
| 1762 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1763 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1764 | - | |||||||||||||||||||||||||||||||
| 1765 | void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) | - | ||||||||||||||||||||||||||||||
| 1766 | { | - | ||||||||||||||||||||||||||||||
| 1767 | const QTextCharFormat format = fragment.charFormat(); | - | ||||||||||||||||||||||||||||||
| 1768 | - | |||||||||||||||||||||||||||||||
| 1769 | bool closeAnchor = false; | - | ||||||||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||||||||
| 1771 |     if (format.isAnchor()
  | 0 | ||||||||||||||||||||||||||||||
| 1772 | const QString name = format.anchorName(); | - | ||||||||||||||||||||||||||||||
| 1773 |         if (!name.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 1774 | html += QLatin1String("<a name=\""); | - | ||||||||||||||||||||||||||||||
| 1775 | html += name.toHtmlEscaped(); | - | ||||||||||||||||||||||||||||||
| 1776 | html += QLatin1String("\"></a>"); | - | ||||||||||||||||||||||||||||||
| 1777 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1778 | const QString href = format.anchorHref(); | - | ||||||||||||||||||||||||||||||
| 1779 |         if (!href.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 1780 | html += QLatin1String("<a href=\""); | - | ||||||||||||||||||||||||||||||
| 1781 | html += href.toHtmlEscaped(); | - | ||||||||||||||||||||||||||||||
| 1782 | html += QLatin1String("\">"); | - | ||||||||||||||||||||||||||||||
| 1783 | closeAnchor = true; | - | ||||||||||||||||||||||||||||||
| 1784 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1785 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||||||||
| 1787 | QString txt = fragment.text(); | - | ||||||||||||||||||||||||||||||
| 1788 | const bool isObject = txt.contains(QChar::ObjectReplacementCharacter); | - | ||||||||||||||||||||||||||||||
| 1789 |     const bool isImage = isObject
 
  | 0 | ||||||||||||||||||||||||||||||
| 1790 | - | |||||||||||||||||||||||||||||||
| 1791 | QLatin1String styleTag("<span style=\""); | - | ||||||||||||||||||||||||||||||
| 1792 | html += styleTag; | - | ||||||||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||||||||
| 1794 | bool attributesEmitted = false; | - | ||||||||||||||||||||||||||||||
| 1795 |     if (!isImage
  | 0 | ||||||||||||||||||||||||||||||
| 1796 |         attributesEmitted = emitCharFormatStyle(format); never executed:  attributesEmitted = emitCharFormatStyle(format); | 0 | ||||||||||||||||||||||||||||||
| 1797 |     if (attributesEmitted
  | 0 | ||||||||||||||||||||||||||||||
| 1798 |         html += QLatin1String("\">"); never executed:  html += QLatin1String("\">"); | 0 | ||||||||||||||||||||||||||||||
| 1799 | else | - | ||||||||||||||||||||||||||||||
| 1800 |         html.chop(qstrlen(styleTag.latin1())); never executed:  html.chop(qstrlen(styleTag.latin1())); | 0 | ||||||||||||||||||||||||||||||
| 1801 | - | |||||||||||||||||||||||||||||||
| 1802 |     if (isObject
  | 0 | ||||||||||||||||||||||||||||||
| 1803 |         for (int i = 0; isImage
 
  | 0 | ||||||||||||||||||||||||||||||
| 1804 | QTextImageFormat imgFmt = format.toImageFormat(); | - | ||||||||||||||||||||||||||||||
| 1805 | - | |||||||||||||||||||||||||||||||
| 1806 | html += QLatin1String("<img"); | - | ||||||||||||||||||||||||||||||
| 1807 | - | |||||||||||||||||||||||||||||||
| 1808 |             if (imgFmt.hasProperty(QTextFormat::ImageName)
  | 0 | ||||||||||||||||||||||||||||||
| 1809 |                 emitAttribute("src", imgFmt.name()); never executed:  emitAttribute("src", imgFmt.name()); | 0 | ||||||||||||||||||||||||||||||
| 1810 | - | |||||||||||||||||||||||||||||||
| 1811 |             if (imgFmt.hasProperty(QTextFormat::ImageWidth)
  | 0 | ||||||||||||||||||||||||||||||
| 1812 |                 emitAttribute("width", QString::number(imgFmt.width())); never executed:  emitAttribute("width", QString::number(imgFmt.width())); | 0 | ||||||||||||||||||||||||||||||
| 1813 | - | |||||||||||||||||||||||||||||||
| 1814 |             if (imgFmt.hasProperty(QTextFormat::ImageHeight)
  | 0 | ||||||||||||||||||||||||||||||
| 1815 |                 emitAttribute("height", QString::number(imgFmt.height())); never executed:  emitAttribute("height", QString::number(imgFmt.height())); | 0 | ||||||||||||||||||||||||||||||
| 1816 | - | |||||||||||||||||||||||||||||||
| 1817 |             if (imgFmt.verticalAlignment() == QTextCharFormat::AlignMiddle
  | 0 | ||||||||||||||||||||||||||||||
| 1818 |                 html += QLatin1String(" style=\"vertical-align: middle;\""); never executed:  html += QLatin1String(" style=\"vertical-align: middle;\""); | 0 | ||||||||||||||||||||||||||||||
| 1819 |             else if (imgFmt.verticalAlignment() == QTextCharFormat::AlignTop
  | 0 | ||||||||||||||||||||||||||||||
| 1820 |                 html += QLatin1String(" style=\"vertical-align: top;\""); never executed:  html += QLatin1String(" style=\"vertical-align: top;\""); | 0 | ||||||||||||||||||||||||||||||
| 1821 | - | |||||||||||||||||||||||||||||||
| 1822 |             if (QTextFrame *imageFrame = qobject_cast<QTextFrame *>(doc->objectForFormat(imgFmt))
  | 0 | ||||||||||||||||||||||||||||||
| 1823 |                 emitFloatStyle(imageFrame->frameFormat().position()); never executed:  emitFloatStyle(imageFrame->frameFormat().position()); | 0 | ||||||||||||||||||||||||||||||
| 1824 | - | |||||||||||||||||||||||||||||||
| 1825 | html += QLatin1String(" />"); | - | ||||||||||||||||||||||||||||||
| 1826 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1827 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1828 | ((!(!txt.contains(QChar::ObjectReplacementCharacter))) ? qt_assert("!txt.contains(QChar::ObjectReplacementCharacter)",__FILE__,2694) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1829 | - | |||||||||||||||||||||||||||||||
| 1830 | txt = txt.toHtmlEscaped(); | - | ||||||||||||||||||||||||||||||
| 1831 | - | |||||||||||||||||||||||||||||||
| 1832 | - | |||||||||||||||||||||||||||||||
| 1833 | QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]"); | - | ||||||||||||||||||||||||||||||
| 1834 | forcedLineBreakRegExp[3] = QChar::LineSeparator; | - | ||||||||||||||||||||||||||||||
| 1835 | - | |||||||||||||||||||||||||||||||
| 1836 | const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp)); | - | ||||||||||||||||||||||||||||||
| 1837 |         for (int i = 0; i < lines.count()
  | 0 | ||||||||||||||||||||||||||||||
| 1838 |             if (i > 0
  | 0 | ||||||||||||||||||||||||||||||
| 1839 |                 html += QLatin1String("<br />"); never executed:  html += QLatin1String("<br />"); | 0 | ||||||||||||||||||||||||||||||
| 1840 | html += lines.at(i); | - | ||||||||||||||||||||||||||||||
| 1841 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1842 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1843 | - | |||||||||||||||||||||||||||||||
| 1844 |     if (attributesEmitted
  | 0 | ||||||||||||||||||||||||||||||
| 1845 |         html += QLatin1String("</span>"); never executed:  html += QLatin1String("</span>"); | 0 | ||||||||||||||||||||||||||||||
| 1846 | - | |||||||||||||||||||||||||||||||
| 1847 |     if (closeAnchor
  | 0 | ||||||||||||||||||||||||||||||
| 1848 |         html += QLatin1String("</a>"); never executed:  html += QLatin1String("</a>"); | 0 | ||||||||||||||||||||||||||||||
| 1849 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||||||||
| 1851 | static bool isOrderedList(int style) | - | ||||||||||||||||||||||||||||||
| 1852 | { | - | ||||||||||||||||||||||||||||||
| 1853 |     return never executed:   style == QTextListFormat::ListDecimalreturn style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ;
 
 never executed:  return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ; | 0 | ||||||||||||||||||||||||||||||
| 1854 |            || style == QTextListFormat::ListUpperAlpha
 never executed:  return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ; | 0 | ||||||||||||||||||||||||||||||
| 1855 |            || style == QTextListFormat::ListUpperRoman
 never executed:  return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ; | 0 | ||||||||||||||||||||||||||||||
| 1856 |            || style == QTextListFormat::ListLowerRoman
 never executed:  return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ; | 0 | ||||||||||||||||||||||||||||||
| 1857 |            ; never executed:  return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman ; | 0 | ||||||||||||||||||||||||||||||
| 1858 | } | - | ||||||||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||||||||
| 1860 | void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block) | - | ||||||||||||||||||||||||||||||
| 1861 | { | - | ||||||||||||||||||||||||||||||
| 1862 | QTextBlockFormat format = block.blockFormat(); | - | ||||||||||||||||||||||||||||||
| 1863 | emitAlignment(format.alignment()); | - | ||||||||||||||||||||||||||||||
| 1864 | - | |||||||||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||||||||
| 1866 | - | |||||||||||||||||||||||||||||||
| 1867 |     if (block.textDirection() == Qt::RightToLeft
  | 0 | ||||||||||||||||||||||||||||||
| 1868 |         html += QLatin1String(" dir='rtl'"); never executed:  html += QLatin1String(" dir='rtl'"); | 0 | ||||||||||||||||||||||||||||||
| 1869 | - | |||||||||||||||||||||||||||||||
| 1870 | QLatin1String style(" style=\""); | - | ||||||||||||||||||||||||||||||
| 1871 | html += style; | - | ||||||||||||||||||||||||||||||
| 1872 | - | |||||||||||||||||||||||||||||||
| 1873 | const bool emptyBlock = block.begin().atEnd(); | - | ||||||||||||||||||||||||||||||
| 1874 |     if (emptyBlock
  | 0 | ||||||||||||||||||||||||||||||
| 1875 | html += QLatin1String("-qt-paragraph-type:empty;"); | - | ||||||||||||||||||||||||||||||
| 1876 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||||||||
| 1878 | emitMargins(QString::number(format.topMargin()), | - | ||||||||||||||||||||||||||||||
| 1879 | QString::number(format.bottomMargin()), | - | ||||||||||||||||||||||||||||||
| 1880 | QString::number(format.leftMargin()), | - | ||||||||||||||||||||||||||||||
| 1881 | QString::number(format.rightMargin())); | - | ||||||||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||||||||
| 1883 | html += QLatin1String(" -qt-block-indent:"); | - | ||||||||||||||||||||||||||||||
| 1884 | html += QString::number(format.indent()); | - | ||||||||||||||||||||||||||||||
| 1885 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1886 | - | |||||||||||||||||||||||||||||||
| 1887 | html += QLatin1String(" text-indent:"); | - | ||||||||||||||||||||||||||||||
| 1888 | html += QString::number(format.textIndent()); | - | ||||||||||||||||||||||||||||||
| 1889 | html += QLatin1String("px;"); | - | ||||||||||||||||||||||||||||||
| 1890 | - | |||||||||||||||||||||||||||||||
| 1891 |     if (block.userState() != -1
  | 0 | ||||||||||||||||||||||||||||||
| 1892 | html += QLatin1String(" -qt-user-state:"); | - | ||||||||||||||||||||||||||||||
| 1893 | html += QString::number(block.userState()); | - | ||||||||||||||||||||||||||||||
| 1894 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1895 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||||||||
| 1897 |     if (format.lineHeightType() != QTextBlockFormat::SingleHeight
  | 0 | ||||||||||||||||||||||||||||||
| 1898 | switch (format.lineHeightType()) { | - | ||||||||||||||||||||||||||||||
| 1899 |             case never executed:   QTextBlockFormat::ProportionalHeight:case QTextBlockFormat::ProportionalHeight:never executed:  case QTextBlockFormat::ProportionalHeight: | 0 | ||||||||||||||||||||||||||||||
| 1900 |             case never executed:   QTextBlockFormat::FixedHeight:case QTextBlockFormat::FixedHeight:never executed:  case QTextBlockFormat::FixedHeight: | 0 | ||||||||||||||||||||||||||||||
| 1901 | html += QLatin1String(" line-height:"); | - | ||||||||||||||||||||||||||||||
| 1902 |                 break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1903 |             case never executed:   QTextBlockFormat::MinimumHeight:case QTextBlockFormat::MinimumHeight:never executed:  case QTextBlockFormat::MinimumHeight: | 0 | ||||||||||||||||||||||||||||||
| 1904 | html += QLatin1String(" min-height:"); | - | ||||||||||||||||||||||||||||||
| 1905 |                 break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1906 |             case never executed:   QTextBlockFormat::LineDistanceHeight:case QTextBlockFormat::LineDistanceHeight:never executed:  case QTextBlockFormat::LineDistanceHeight: | 0 | ||||||||||||||||||||||||||||||
| 1907 | html += QLatin1String(" line-spacing:"); | - | ||||||||||||||||||||||||||||||
| 1908 |                 break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1909 |             case never executed:   QTextBlockFormat::SingleHeight:case QTextBlockFormat::SingleHeight:never executed:  case QTextBlockFormat::SingleHeight: | 0 | ||||||||||||||||||||||||||||||
| 1910 |             default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||||||||||||||
| 1911 |                 break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1912 | } | - | ||||||||||||||||||||||||||||||
| 1913 | html += QString::number(format.lineHeight()); | - | ||||||||||||||||||||||||||||||
| 1914 |         if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight
  | 0 | ||||||||||||||||||||||||||||||
| 1915 |             html += QLatin1String("%;"); never executed:  html += QLatin1String("%;"); | 0 | ||||||||||||||||||||||||||||||
| 1916 | else | - | ||||||||||||||||||||||||||||||
| 1917 |             html += QLatin1String("px;"); never executed:  html += QLatin1String("px;"); | 0 | ||||||||||||||||||||||||||||||
| 1918 | } | - | ||||||||||||||||||||||||||||||
| 1919 | - | |||||||||||||||||||||||||||||||
| 1920 | emitPageBreakPolicy(format.pageBreakPolicy()); | - | ||||||||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||||||||
| 1922 | QTextCharFormat diff; | - | ||||||||||||||||||||||||||||||
| 1923 |     if (emptyBlock
  | 0 | ||||||||||||||||||||||||||||||
| 1924 | const QTextCharFormat blockCharFmt = block.charFormat(); | - | ||||||||||||||||||||||||||||||
| 1925 | diff = formatDifference(defaultCharFormat, blockCharFmt).toCharFormat(); | - | ||||||||||||||||||||||||||||||
| 1926 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1927 | - | |||||||||||||||||||||||||||||||
| 1928 | diff.clearProperty(QTextFormat::BackgroundBrush); | - | ||||||||||||||||||||||||||||||
| 1929 |     if (format.hasProperty(QTextFormat::BackgroundBrush)
  | 0 | ||||||||||||||||||||||||||||||
| 1930 | QBrush bg = format.background(); | - | ||||||||||||||||||||||||||||||
| 1931 |         if (bg.style() != Qt::NoBrush
  | 0 | ||||||||||||||||||||||||||||||
| 1932 |             diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush)); never executed:  diff.setProperty(QTextFormat::BackgroundBrush, format.property(QTextFormat::BackgroundBrush)); | 0 | ||||||||||||||||||||||||||||||
| 1933 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1934 | - | |||||||||||||||||||||||||||||||
| 1935 |     if (!diff.properties().isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 1936 |         emitCharFormatStyle(diff); never executed:  emitCharFormatStyle(diff); | 0 | ||||||||||||||||||||||||||||||
| 1937 | - | |||||||||||||||||||||||||||||||
| 1938 | html += QLatin1Char('"'); | - | ||||||||||||||||||||||||||||||
| 1939 | - | |||||||||||||||||||||||||||||||
| 1940 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1941 | - | |||||||||||||||||||||||||||||||
| 1942 | void QTextHtmlExporter::emitBlock(const QTextBlock &block) | - | ||||||||||||||||||||||||||||||
| 1943 | { | - | ||||||||||||||||||||||||||||||
| 1944 |     if (block.begin().atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 1945 | - | |||||||||||||||||||||||||||||||
| 1946 | int p = block.position(); | - | ||||||||||||||||||||||||||||||
| 1947 |         if (p > 0
  | 0 | ||||||||||||||||||||||||||||||
| 1948 |             -- never executed:  p;--p;never executed:  --p; | 0 | ||||||||||||||||||||||||||||||
| 1949 | QTextDocumentPrivate::FragmentIterator frag = doc->docHandle()->find(p); | - | ||||||||||||||||||||||||||||||
| 1950 | QChar ch = doc->docHandle()->buffer().at(frag->stringPosition); | - | ||||||||||||||||||||||||||||||
| 1951 |         if (ch == QChar(0xfdd0)
  | 0 | ||||||||||||||||||||||||||||||
| 1952 |             || ch == QChar(0xfdd1)
  | 0 | ||||||||||||||||||||||||||||||
| 1953 |             return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 1954 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||||||||
| 1956 | html += QLatin1Char('\n'); | - | ||||||||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||||||||
| 1958 | - | |||||||||||||||||||||||||||||||
| 1959 | - | |||||||||||||||||||||||||||||||
| 1960 | QTextCharFormat oldDefaultCharFormat = defaultCharFormat; | - | ||||||||||||||||||||||||||||||
| 1961 | - | |||||||||||||||||||||||||||||||
| 1962 | QTextList *list = block.textList(); | - | ||||||||||||||||||||||||||||||
| 1963 |     if (list
  | 0 | ||||||||||||||||||||||||||||||
| 1964 |         if (list->itemNumber(block) == 0
  | 0 | ||||||||||||||||||||||||||||||
| 1965 | const QTextListFormat format = list->format(); | - | ||||||||||||||||||||||||||||||
| 1966 | const int style = format.style(); | - | ||||||||||||||||||||||||||||||
| 1967 | switch (style) { | - | ||||||||||||||||||||||||||||||
| 1968 |                 case never executed:   QTextListFormat::ListDecimal:case QTextListFormat::ListDecimal:never executed:   html += QLatin1String("<ol"); break;case QTextListFormat::ListDecimal:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1969 |                 case never executed:   QTextListFormat::ListDisc:case QTextListFormat::ListDisc:never executed:   html += QLatin1String("<ul"); break;case QTextListFormat::ListDisc:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1970 |                 case never executed:   QTextListFormat::ListCircle:case QTextListFormat::ListCircle:never executed:   html += QLatin1String("<ul type=\"circle\""); break;case QTextListFormat::ListCircle:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1971 |                 case never executed:   QTextListFormat::ListSquare:case QTextListFormat::ListSquare:never executed:   html += QLatin1String("<ul type=\"square\""); break;case QTextListFormat::ListSquare:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1972 |                 case never executed:   QTextListFormat::ListLowerAlpha:case QTextListFormat::ListLowerAlpha:never executed:   html += QLatin1String("<ol type=\"a\""); break;case QTextListFormat::ListLowerAlpha:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1973 |                 case never executed:   QTextListFormat::ListUpperAlpha:case QTextListFormat::ListUpperAlpha:never executed:   html += QLatin1String("<ol type=\"A\""); break;case QTextListFormat::ListUpperAlpha:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1974 |                 case never executed:   QTextListFormat::ListLowerRoman:case QTextListFormat::ListLowerRoman:never executed:   html += QLatin1String("<ol type=\"i\""); break;case QTextListFormat::ListLowerRoman:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1975 |                 case never executed:   QTextListFormat::ListUpperRoman:case QTextListFormat::ListUpperRoman:never executed:   html += QLatin1String("<ol type=\"I\""); break;case QTextListFormat::ListUpperRoman:never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 1976 |                 default never executed:  :default:never executed:   html += QLatin1String("<ul");default: | 0 | ||||||||||||||||||||||||||||||
| 1977 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1978 | - | |||||||||||||||||||||||||||||||
| 1979 | QString styleString = QString::fromLatin1("margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;"); | - | ||||||||||||||||||||||||||||||
| 1980 | - | |||||||||||||||||||||||||||||||
| 1981 |             if (format.hasProperty(QTextFormat::ListIndent)
  | 0 | ||||||||||||||||||||||||||||||
| 1982 | styleString += QLatin1String(" -qt-list-indent: "); | - | ||||||||||||||||||||||||||||||
| 1983 | styleString += QString::number(format.indent()); | - | ||||||||||||||||||||||||||||||
| 1984 | styleString += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1985 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1986 | - | |||||||||||||||||||||||||||||||
| 1987 |             if (format.hasProperty(QTextFormat::ListNumberPrefix)
  | 0 | ||||||||||||||||||||||||||||||
| 1988 | QString numberPrefix = format.numberPrefix(); | - | ||||||||||||||||||||||||||||||
| 1989 | numberPrefix.replace(QLatin1Char('"'), QLatin1String("\\22")); | - | ||||||||||||||||||||||||||||||
| 1990 | numberPrefix.replace(QLatin1Char('\''), QLatin1String("\\27")); | - | ||||||||||||||||||||||||||||||
| 1991 | styleString += QLatin1String(" -qt-list-number-prefix: "); | - | ||||||||||||||||||||||||||||||
| 1992 | styleString += QLatin1Char('\''); | - | ||||||||||||||||||||||||||||||
| 1993 | styleString += numberPrefix; | - | ||||||||||||||||||||||||||||||
| 1994 | styleString += QLatin1Char('\''); | - | ||||||||||||||||||||||||||||||
| 1995 | styleString += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 1996 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 1997 | - | |||||||||||||||||||||||||||||||
| 1998 |             if (format.hasProperty(QTextFormat::ListNumberSuffix)
  | 0 | ||||||||||||||||||||||||||||||
| 1999 |                 if (format.numberSuffix() != QLatin1String(".")
  | 0 | ||||||||||||||||||||||||||||||
| 2000 | QString numberSuffix = format.numberSuffix(); | - | ||||||||||||||||||||||||||||||
| 2001 | numberSuffix.replace(QLatin1Char('"'), QLatin1String("\\22")); | - | ||||||||||||||||||||||||||||||
| 2002 | numberSuffix.replace(QLatin1Char('\''), QLatin1String("\\27")); | - | ||||||||||||||||||||||||||||||
| 2003 | styleString += QLatin1String(" -qt-list-number-suffix: "); | - | ||||||||||||||||||||||||||||||
| 2004 | styleString += QLatin1Char('\''); | - | ||||||||||||||||||||||||||||||
| 2005 | styleString += numberSuffix; | - | ||||||||||||||||||||||||||||||
| 2006 | styleString += QLatin1Char('\''); | - | ||||||||||||||||||||||||||||||
| 2007 | styleString += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 2008 |                 } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2009 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2010 | - | |||||||||||||||||||||||||||||||
| 2011 | html += QLatin1String(" style=\""); | - | ||||||||||||||||||||||||||||||
| 2012 | html += styleString; | - | ||||||||||||||||||||||||||||||
| 2013 | html += QLatin1String("\">"); | - | ||||||||||||||||||||||||||||||
| 2014 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2015 | - | |||||||||||||||||||||||||||||||
| 2016 | html += QLatin1String("<li"); | - | ||||||||||||||||||||||||||||||
| 2017 | - | |||||||||||||||||||||||||||||||
| 2018 | const QTextCharFormat blockFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat(); | - | ||||||||||||||||||||||||||||||
| 2019 |         if (!blockFmt.properties().isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 2020 | html += QLatin1String(" style=\""); | - | ||||||||||||||||||||||||||||||
| 2021 | emitCharFormatStyle(blockFmt); | - | ||||||||||||||||||||||||||||||
| 2022 | html += QLatin1Char('\"'); | - | ||||||||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||||||||
| 2024 | defaultCharFormat.merge(block.charFormat()); | - | ||||||||||||||||||||||||||||||
| 2025 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2026 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2027 | - | |||||||||||||||||||||||||||||||
| 2028 | const QTextBlockFormat blockFormat = block.blockFormat(); | - | ||||||||||||||||||||||||||||||
| 2029 |     if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)
  | 0 | ||||||||||||||||||||||||||||||
| 2030 | html += QLatin1String("<hr"); | - | ||||||||||||||||||||||||||||||
| 2031 | - | |||||||||||||||||||||||||||||||
| 2032 | QTextLength width = blockFormat.lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth); | - | ||||||||||||||||||||||||||||||
| 2033 |         if (width.type() != QTextLength::VariableLength
  | 0 | ||||||||||||||||||||||||||||||
| 2034 |             emitTextLength("width", width); never executed:  emitTextLength("width", width); | 0 | ||||||||||||||||||||||||||||||
| 2035 | else | - | ||||||||||||||||||||||||||||||
| 2036 |             html += QLatin1Char(' '); never executed:  html += QLatin1Char(' '); | 0 | ||||||||||||||||||||||||||||||
| 2037 | - | |||||||||||||||||||||||||||||||
| 2038 | html += QLatin1String("/>"); | - | ||||||||||||||||||||||||||||||
| 2039 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 2040 | } | - | ||||||||||||||||||||||||||||||
| 2041 | - | |||||||||||||||||||||||||||||||
| 2042 | const bool pre = blockFormat.nonBreakableLines(); | - | ||||||||||||||||||||||||||||||
| 2043 |     if (pre
  | 0 | ||||||||||||||||||||||||||||||
| 2044 |         if (list
  | 0 | ||||||||||||||||||||||||||||||
| 2045 |             html += QLatin1Char('>'); never executed:  html += QLatin1Char('>'); | 0 | ||||||||||||||||||||||||||||||
| 2046 | html += QLatin1String("<pre"); | - | ||||||||||||||||||||||||||||||
| 2047 |     } never executed:   else if (!listend of block
  | 0 | ||||||||||||||||||||||||||||||
| 2048 | html += QLatin1String("<p"); | - | ||||||||||||||||||||||||||||||
| 2049 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2050 | - | |||||||||||||||||||||||||||||||
| 2051 | emitBlockAttributes(block); | - | ||||||||||||||||||||||||||||||
| 2052 | - | |||||||||||||||||||||||||||||||
| 2053 | html += QLatin1Char('>'); | - | ||||||||||||||||||||||||||||||
| 2054 |     if (block.begin().atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2055 |         html += QLatin1String("<br />"); never executed:  html += QLatin1String("<br />"); | 0 | ||||||||||||||||||||||||||||||
| 2056 | - | |||||||||||||||||||||||||||||||
| 2057 | QTextBlock::Iterator it = block.begin(); | - | ||||||||||||||||||||||||||||||
| 2058 |     if (fragmentMarkers
 
 
  | 0 | ||||||||||||||||||||||||||||||
| 2059 |         html += QLatin1String("<!--StartFragment-->"); never executed:  html += QLatin1String("<!--StartFragment-->"); | 0 | ||||||||||||||||||||||||||||||
| 2060 | - | |||||||||||||||||||||||||||||||
| 2061 |     for (; !it.atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2062 |         emitFragment(it.fragment()); never executed:  emitFragment(it.fragment()); | 0 | ||||||||||||||||||||||||||||||
| 2063 | - | |||||||||||||||||||||||||||||||
| 2064 |     if (fragmentMarkers
 
  | 0 | ||||||||||||||||||||||||||||||
| 2065 |         html += QLatin1String("<!--EndFragment-->"); never executed:  html += QLatin1String("<!--EndFragment-->"); | 0 | ||||||||||||||||||||||||||||||
| 2066 | - | |||||||||||||||||||||||||||||||
| 2067 |     if (pre
  | 0 | ||||||||||||||||||||||||||||||
| 2068 |         html += QLatin1String("</pre>"); never executed:  html += QLatin1String("</pre>"); | 0 | ||||||||||||||||||||||||||||||
| 2069 |     else if (list
  | 0 | ||||||||||||||||||||||||||||||
| 2070 |         html += QLatin1String("</li>"); never executed:  html += QLatin1String("</li>"); | 0 | ||||||||||||||||||||||||||||||
| 2071 | else | - | ||||||||||||||||||||||||||||||
| 2072 |         html += QLatin1String("</p>"); never executed:  html += QLatin1String("</p>"); | 0 | ||||||||||||||||||||||||||||||
| 2073 | - | |||||||||||||||||||||||||||||||
| 2074 |     if (list
  | 0 | ||||||||||||||||||||||||||||||
| 2075 |         if (list->itemNumber(block) == list->count() - 1
  | 0 | ||||||||||||||||||||||||||||||
| 2076 |             if (isOrderedList(list->format().style())
  | 0 | ||||||||||||||||||||||||||||||
| 2077 |                 html += QLatin1String("</ol>"); never executed:  html += QLatin1String("</ol>"); | 0 | ||||||||||||||||||||||||||||||
| 2078 | else | - | ||||||||||||||||||||||||||||||
| 2079 |                 html += QLatin1String("</ul>"); never executed:  html += QLatin1String("</ul>"); | 0 | ||||||||||||||||||||||||||||||
| 2080 | } | - | ||||||||||||||||||||||||||||||
| 2081 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2082 | - | |||||||||||||||||||||||||||||||
| 2083 | defaultCharFormat = oldDefaultCharFormat; | - | ||||||||||||||||||||||||||||||
| 2084 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2085 | - | |||||||||||||||||||||||||||||||
| 2086 | extern bool qHasPixmapTexture(const QBrush& brush); | - | ||||||||||||||||||||||||||||||
| 2087 | - | |||||||||||||||||||||||||||||||
| 2088 | QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap) | - | ||||||||||||||||||||||||||||||
| 2089 | { | - | ||||||||||||||||||||||||||||||
| 2090 | QString url; | - | ||||||||||||||||||||||||||||||
| 2091 |     if (!doc
  | 0 | ||||||||||||||||||||||||||||||
| 2092 |         return never executed:   url;return url;never executed:  return url; | 0 | ||||||||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||||||||
| 2094 |     if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent())
  | 0 | ||||||||||||||||||||||||||||||
| 2095 |         return never executed:   findUrlForImage(parent, cacheKey, isPixmap);return findUrlForImage(parent, cacheKey, isPixmap);never executed:  return findUrlForImage(parent, cacheKey, isPixmap); | 0 | ||||||||||||||||||||||||||||||
| 2096 | - | |||||||||||||||||||||||||||||||
| 2097 |     if (doc
 
  | 0 | ||||||||||||||||||||||||||||||
| 2098 | QTextDocumentPrivate *priv = doc->docHandle(); | - | ||||||||||||||||||||||||||||||
| 2099 | QMap<QUrl, QVariant>::const_iterator it = priv->cachedResources.constBegin(); | - | ||||||||||||||||||||||||||||||
| 2100 |         for (; it != priv->cachedResources.constEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||||||||
| 2102 | const QVariant &v = it.value(); | - | ||||||||||||||||||||||||||||||
| 2103 |             if (v.type() == QVariant::Image
 
  | 0 | ||||||||||||||||||||||||||||||
| 2104 |                 if (qvariant_cast<QImage>(v).cacheKey() == cacheKey
  | 0 | ||||||||||||||||||||||||||||||
| 2105 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2106 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||||||||
| 2108 |             if (v.type() == QVariant::Pixmap
 
  | 0 | ||||||||||||||||||||||||||||||
| 2109 |                 if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey
  | 0 | ||||||||||||||||||||||||||||||
| 2110 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2111 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2112 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2113 | - | |||||||||||||||||||||||||||||||
| 2114 |         if (it != priv->cachedResources.constEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2115 |             url = it.key().toString(); never executed:  url = it.key().toString(); | 0 | ||||||||||||||||||||||||||||||
| 2116 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2117 | - | |||||||||||||||||||||||||||||||
| 2118 |     return never executed:   url;return url;never executed:  return url; | 0 | ||||||||||||||||||||||||||||||
| 2119 | } | - | ||||||||||||||||||||||||||||||
| 2120 | - | |||||||||||||||||||||||||||||||
| 2121 | void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv) | - | ||||||||||||||||||||||||||||||
| 2122 | { | - | ||||||||||||||||||||||||||||||
| 2123 |     if (!priv
  | 0 | ||||||||||||||||||||||||||||||
| 2124 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 2125 | - | |||||||||||||||||||||||||||||||
| 2126 | cachedResources.unite(priv->cachedResources); | - | ||||||||||||||||||||||||||||||
| 2127 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||||||||
| 2129 | void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format) | - | ||||||||||||||||||||||||||||||
| 2130 | { | - | ||||||||||||||||||||||||||||||
| 2131 |     if (format.hasProperty(QTextFormat::BackgroundImageUrl)
  | 0 | ||||||||||||||||||||||||||||||
| 2132 | QString url = format.property(QTextFormat::BackgroundImageUrl).toString(); | - | ||||||||||||||||||||||||||||||
| 2133 | emitAttribute("background", url); | - | ||||||||||||||||||||||||||||||
| 2134 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2135 | const QBrush &brush = format.background(); | - | ||||||||||||||||||||||||||||||
| 2136 |         if (brush.style() == Qt::SolidPattern
  | 0 | ||||||||||||||||||||||||||||||
| 2137 | emitAttribute("bgcolor", colorValue(brush.color())); | - | ||||||||||||||||||||||||||||||
| 2138 |         } never executed:   else if (brush.style() == Qt::TexturePatternend of block
  | 0 | ||||||||||||||||||||||||||||||
| 2139 | const bool isPixmap = qHasPixmapTexture(brush); | - | ||||||||||||||||||||||||||||||
| 2140 |             const qint64 cacheKey = isPixmap
  | 0 | ||||||||||||||||||||||||||||||
| 2141 | - | |||||||||||||||||||||||||||||||
| 2142 | const QString url = findUrlForImage(doc, cacheKey, isPixmap); | - | ||||||||||||||||||||||||||||||
| 2143 | - | |||||||||||||||||||||||||||||||
| 2144 |             if (!url.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 2145 |                 emitAttribute("background", url); never executed:  emitAttribute("background", url); | 0 | ||||||||||||||||||||||||||||||
| 2146 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2147 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2148 | } | - | ||||||||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||||||||
| 2150 | void QTextHtmlExporter::emitTable(const QTextTable *table) | - | ||||||||||||||||||||||||||||||
| 2151 | { | - | ||||||||||||||||||||||||||||||
| 2152 | QTextTableFormat format = table->format(); | - | ||||||||||||||||||||||||||||||
| 2153 | - | |||||||||||||||||||||||||||||||
| 2154 | html += QLatin1String("\n<table"); | - | ||||||||||||||||||||||||||||||
| 2155 | - | |||||||||||||||||||||||||||||||
| 2156 |     if (format.hasProperty(QTextFormat::FrameBorder)
  | 0 | ||||||||||||||||||||||||||||||
| 2157 |         emitAttribute("border", QString::number(format.border())); never executed:  emitAttribute("border", QString::number(format.border())); | 0 | ||||||||||||||||||||||||||||||
| 2158 | - | |||||||||||||||||||||||||||||||
| 2159 | emitFrameStyle(format, TableFrame); | - | ||||||||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||||||||
| 2161 | emitAlignment(format.alignment()); | - | ||||||||||||||||||||||||||||||
| 2162 | emitTextLength("width", format.width()); | - | ||||||||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||||||||
| 2164 |     if (format.hasProperty(QTextFormat::TableCellSpacing)
  | 0 | ||||||||||||||||||||||||||||||
| 2165 |         emitAttribute("cellspacing", QString::number(format.cellSpacing())); never executed:  emitAttribute("cellspacing", QString::number(format.cellSpacing())); | 0 | ||||||||||||||||||||||||||||||
| 2166 |     if (format.hasProperty(QTextFormat::TableCellPadding)
  | 0 | ||||||||||||||||||||||||||||||
| 2167 |         emitAttribute("cellpadding", QString::number(format.cellPadding())); never executed:  emitAttribute("cellpadding", QString::number(format.cellPadding())); | 0 | ||||||||||||||||||||||||||||||
| 2168 | - | |||||||||||||||||||||||||||||||
| 2169 | emitBackgroundAttribute(format); | - | ||||||||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||||||||
| 2171 | html += QLatin1Char('>'); | - | ||||||||||||||||||||||||||||||
| 2172 | - | |||||||||||||||||||||||||||||||
| 2173 | const int rows = table->rows(); | - | ||||||||||||||||||||||||||||||
| 2174 | const int columns = table->columns(); | - | ||||||||||||||||||||||||||||||
| 2175 | - | |||||||||||||||||||||||||||||||
| 2176 | QVector<QTextLength> columnWidths = format.columnWidthConstraints(); | - | ||||||||||||||||||||||||||||||
| 2177 |     if (columnWidths.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 2178 | columnWidths.resize(columns); | - | ||||||||||||||||||||||||||||||
| 2179 | columnWidths.fill(QTextLength()); | - | ||||||||||||||||||||||||||||||
| 2180 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2181 | ((!(columnWidths.count() == columns)) ? qt_assert("columnWidths.count() == columns",__FILE__,3047) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 2182 | - | |||||||||||||||||||||||||||||||
| 2183 | QVarLengthArray<bool> widthEmittedForColumn(columns); | - | ||||||||||||||||||||||||||||||
| 2184 |     for (int i = 0; i < columns
  | 0 | ||||||||||||||||||||||||||||||
| 2185 |         widthEmittedForColumn[i] = false; never executed:  widthEmittedForColumn[i] = false; | 0 | ||||||||||||||||||||||||||||||
| 2186 | - | |||||||||||||||||||||||||||||||
| 2187 | const int headerRowCount = qMin(format.headerRowCount(), rows); | - | ||||||||||||||||||||||||||||||
| 2188 |     if (headerRowCount > 0
  | 0 | ||||||||||||||||||||||||||||||
| 2189 |         html += QLatin1String("<thead>"); never executed:  html += QLatin1String("<thead>"); | 0 | ||||||||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||||||||
| 2191 |     for (int row = 0; row < rows
  | 0 | ||||||||||||||||||||||||||||||
| 2192 | html += QLatin1String("\n<tr>"); | - | ||||||||||||||||||||||||||||||
| 2193 | - | |||||||||||||||||||||||||||||||
| 2194 |         for (int col = 0; col < columns
  | 0 | ||||||||||||||||||||||||||||||
| 2195 | const QTextTableCell cell = table->cellAt(row, col); | - | ||||||||||||||||||||||||||||||
| 2196 | - | |||||||||||||||||||||||||||||||
| 2197 | - | |||||||||||||||||||||||||||||||
| 2198 |             if (cell.row() != row
  | 0 | ||||||||||||||||||||||||||||||
| 2199 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||||||||
| 2201 |             if (cell.column() != col
  | 0 | ||||||||||||||||||||||||||||||
| 2202 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||||||||
| 2204 | html += QLatin1String("\n<td"); | - | ||||||||||||||||||||||||||||||
| 2205 | - | |||||||||||||||||||||||||||||||
| 2206 |             if (!widthEmittedForColumn[col]
 
  | 0 | ||||||||||||||||||||||||||||||
| 2207 | emitTextLength("width", columnWidths.at(col)); | - | ||||||||||||||||||||||||||||||
| 2208 | widthEmittedForColumn[col] = true; | - | ||||||||||||||||||||||||||||||
| 2209 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2210 | - | |||||||||||||||||||||||||||||||
| 2211 |             if (cell.columnSpan() > 1
  | 0 | ||||||||||||||||||||||||||||||
| 2212 |                 emitAttribute("colspan", QString::number(cell.columnSpan())); never executed:  emitAttribute("colspan", QString::number(cell.columnSpan())); | 0 | ||||||||||||||||||||||||||||||
| 2213 | - | |||||||||||||||||||||||||||||||
| 2214 |             if (cell.rowSpan() > 1
  | 0 | ||||||||||||||||||||||||||||||
| 2215 |                 emitAttribute("rowspan", QString::number(cell.rowSpan())); never executed:  emitAttribute("rowspan", QString::number(cell.rowSpan())); | 0 | ||||||||||||||||||||||||||||||
| 2216 | - | |||||||||||||||||||||||||||||||
| 2217 | const QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); | - | ||||||||||||||||||||||||||||||
| 2218 | emitBackgroundAttribute(cellFormat); | - | ||||||||||||||||||||||||||||||
| 2219 | - | |||||||||||||||||||||||||||||||
| 2220 | QTextCharFormat oldDefaultCharFormat = defaultCharFormat; | - | ||||||||||||||||||||||||||||||
| 2221 | - | |||||||||||||||||||||||||||||||
| 2222 | QTextCharFormat::VerticalAlignment valign = cellFormat.verticalAlignment(); | - | ||||||||||||||||||||||||||||||
| 2223 | - | |||||||||||||||||||||||||||||||
| 2224 | QString styleString; | - | ||||||||||||||||||||||||||||||
| 2225 |             if (valign >= QTextCharFormat::AlignMiddle
 
  | 0 | ||||||||||||||||||||||||||||||
| 2226 | styleString += QLatin1String(" vertical-align:"); | - | ||||||||||||||||||||||||||||||
| 2227 | switch (valign) { | - | ||||||||||||||||||||||||||||||
| 2228 |                 case never executed:   QTextCharFormat::AlignMiddle:case QTextCharFormat::AlignMiddle:never executed:  case QTextCharFormat::AlignMiddle: | 0 | ||||||||||||||||||||||||||||||
| 2229 | styleString += QLatin1String("middle"); | - | ||||||||||||||||||||||||||||||
| 2230 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2231 |                 case never executed:   QTextCharFormat::AlignTop:case QTextCharFormat::AlignTop:never executed:  case QTextCharFormat::AlignTop: | 0 | ||||||||||||||||||||||||||||||
| 2232 | styleString += QLatin1String("top"); | - | ||||||||||||||||||||||||||||||
| 2233 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2234 |                 case never executed:   QTextCharFormat::AlignBottom:case QTextCharFormat::AlignBottom:never executed:  case QTextCharFormat::AlignBottom: | 0 | ||||||||||||||||||||||||||||||
| 2235 | styleString += QLatin1String("bottom"); | - | ||||||||||||||||||||||||||||||
| 2236 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2237 |                 default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||||||||||||||
| 2238 |                     break; never executed:  break; | 0 | ||||||||||||||||||||||||||||||
| 2239 | } | - | ||||||||||||||||||||||||||||||
| 2240 | styleString += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 2241 | - | |||||||||||||||||||||||||||||||
| 2242 | QTextCharFormat temp; | - | ||||||||||||||||||||||||||||||
| 2243 | temp.setVerticalAlignment(valign); | - | ||||||||||||||||||||||||||||||
| 2244 | defaultCharFormat.merge(temp); | - | ||||||||||||||||||||||||||||||
| 2245 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2246 | - | |||||||||||||||||||||||||||||||
| 2247 |             if (cellFormat.hasProperty(QTextFormat::TableCellLeftPadding)
  | 0 | ||||||||||||||||||||||||||||||
| 2248 |                 styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';'); never executed:  styleString += QLatin1String(" padding-left:") + QString::number(cellFormat.leftPadding()) + QLatin1Char(';'); | 0 | ||||||||||||||||||||||||||||||
| 2249 |             if (cellFormat.hasProperty(QTextFormat::TableCellRightPadding)
  | 0 | ||||||||||||||||||||||||||||||
| 2250 |                 styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';'); never executed:  styleString += QLatin1String(" padding-right:") + QString::number(cellFormat.rightPadding()) + QLatin1Char(';'); | 0 | ||||||||||||||||||||||||||||||
| 2251 |             if (cellFormat.hasProperty(QTextFormat::TableCellTopPadding)
  | 0 | ||||||||||||||||||||||||||||||
| 2252 |                 styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';'); never executed:  styleString += QLatin1String(" padding-top:") + QString::number(cellFormat.topPadding()) + QLatin1Char(';'); | 0 | ||||||||||||||||||||||||||||||
| 2253 |             if (cellFormat.hasProperty(QTextFormat::TableCellBottomPadding)
  | 0 | ||||||||||||||||||||||||||||||
| 2254 |                 styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';'); never executed:  styleString += QLatin1String(" padding-bottom:") + QString::number(cellFormat.bottomPadding()) + QLatin1Char(';'); | 0 | ||||||||||||||||||||||||||||||
| 2255 | - | |||||||||||||||||||||||||||||||
| 2256 |             if (!styleString.isEmpty()
  | 0 | ||||||||||||||||||||||||||||||
| 2257 |                 html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"'); never executed:  html += QLatin1String(" style=\"") + styleString + QLatin1Char('\"'); | 0 | ||||||||||||||||||||||||||||||
| 2258 | - | |||||||||||||||||||||||||||||||
| 2259 | html += QLatin1Char('>'); | - | ||||||||||||||||||||||||||||||
| 2260 | - | |||||||||||||||||||||||||||||||
| 2261 | emitFrame(cell.begin()); | - | ||||||||||||||||||||||||||||||
| 2262 | - | |||||||||||||||||||||||||||||||
| 2263 | html += QLatin1String("</td>"); | - | ||||||||||||||||||||||||||||||
| 2264 | - | |||||||||||||||||||||||||||||||
| 2265 | defaultCharFormat = oldDefaultCharFormat; | - | ||||||||||||||||||||||||||||||
| 2266 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2267 | - | |||||||||||||||||||||||||||||||
| 2268 | html += QLatin1String("</tr>"); | - | ||||||||||||||||||||||||||||||
| 2269 |         if (headerRowCount > 0
 
  | 0 | ||||||||||||||||||||||||||||||
| 2270 |             html += QLatin1String("</thead>"); never executed:  html += QLatin1String("</thead>"); | 0 | ||||||||||||||||||||||||||||||
| 2271 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2272 | - | |||||||||||||||||||||||||||||||
| 2273 | html += QLatin1String("</table>"); | - | ||||||||||||||||||||||||||||||
| 2274 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2275 | - | |||||||||||||||||||||||||||||||
| 2276 | void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt) | - | ||||||||||||||||||||||||||||||
| 2277 | { | - | ||||||||||||||||||||||||||||||
| 2278 |     if (!frameIt.atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2279 | QTextFrame::Iterator next = frameIt; | - | ||||||||||||||||||||||||||||||
| 2280 | ++next; | - | ||||||||||||||||||||||||||||||
| 2281 |         if (next.atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2282 |             && frameIt.currentFrame() == 0
  | 0 | ||||||||||||||||||||||||||||||
| 2283 |             && frameIt.parentFrame() != doc->rootFrame()
  | 0 | ||||||||||||||||||||||||||||||
| 2284 |             && frameIt.currentBlock().begin().atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2285 |             return; never executed:  return; | 0 | ||||||||||||||||||||||||||||||
| 2286 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2287 | - | |||||||||||||||||||||||||||||||
| 2288 | for (QTextFrame::Iterator it = frameIt; | - | ||||||||||||||||||||||||||||||
| 2289 |          !it.atEnd()
  | 0 | ||||||||||||||||||||||||||||||
| 2290 |         if (QTextFrame *f = it.currentFrame()
  | 0 | ||||||||||||||||||||||||||||||
| 2291 |             if (QTextTable *table = qobject_cast<QTextTable *>(f)
  | 0 | ||||||||||||||||||||||||||||||
| 2292 | emitTable(table); | - | ||||||||||||||||||||||||||||||
| 2293 |             } never executed:   else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2294 | emitTextFrame(f); | - | ||||||||||||||||||||||||||||||
| 2295 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2296 |         } else if (it.currentBlock().isValid()
  | 0 | ||||||||||||||||||||||||||||||
| 2297 | emitBlock(it.currentBlock()); | - | ||||||||||||||||||||||||||||||
| 2298 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2299 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2300 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2301 | - | |||||||||||||||||||||||||||||||
| 2302 | void QTextHtmlExporter::emitTextFrame(const QTextFrame *f) | - | ||||||||||||||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||||||||||||||
| 2304 |     FrameType frameType = f->parentFrame()
  | 0 | ||||||||||||||||||||||||||||||
| 2305 | - | |||||||||||||||||||||||||||||||
| 2306 | html += QLatin1String("\n<table"); | - | ||||||||||||||||||||||||||||||
| 2307 | QTextFrameFormat format = f->frameFormat(); | - | ||||||||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||||||||
| 2309 |     if (format.hasProperty(QTextFormat::FrameBorder)
  | 0 | ||||||||||||||||||||||||||||||
| 2310 |         emitAttribute("border", QString::number(format.border())); never executed:  emitAttribute("border", QString::number(format.border())); | 0 | ||||||||||||||||||||||||||||||
| 2311 | - | |||||||||||||||||||||||||||||||
| 2312 | emitFrameStyle(format, frameType); | - | ||||||||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||||||||
| 2314 | emitTextLength("width", format.width()); | - | ||||||||||||||||||||||||||||||
| 2315 | emitTextLength("height", format.height()); | - | ||||||||||||||||||||||||||||||
| 2316 | - | |||||||||||||||||||||||||||||||
| 2317 | - | |||||||||||||||||||||||||||||||
| 2318 |     if (frameType != RootFrame
  | 0 | ||||||||||||||||||||||||||||||
| 2319 |         emitBackgroundAttribute(format); never executed:  emitBackgroundAttribute(format); | 0 | ||||||||||||||||||||||||||||||
| 2320 | - | |||||||||||||||||||||||||||||||
| 2321 | html += QLatin1Char('>'); | - | ||||||||||||||||||||||||||||||
| 2322 | html += QLatin1String("\n<tr>\n<td style=\"border: none;\">"); | - | ||||||||||||||||||||||||||||||
| 2323 | emitFrame(f->begin()); | - | ||||||||||||||||||||||||||||||
| 2324 | html += QLatin1String("</td></tr></table>"); | - | ||||||||||||||||||||||||||||||
| 2325 | } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||||||||
| 2327 | void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType frameType) | - | ||||||||||||||||||||||||||||||
| 2328 | { | - | ||||||||||||||||||||||||||||||
| 2329 | QLatin1String styleAttribute(" style=\""); | - | ||||||||||||||||||||||||||||||
| 2330 | html += styleAttribute; | - | ||||||||||||||||||||||||||||||
| 2331 | const int originalHtmlLength = html.length(); | - | ||||||||||||||||||||||||||||||
| 2332 | - | |||||||||||||||||||||||||||||||
| 2333 |     if (frameType == TextFrame
  | 0 | ||||||||||||||||||||||||||||||
| 2334 |         html += QLatin1String("-qt-table-type: frame;"); never executed:  html += QLatin1String("-qt-table-type: frame;"); | 0 | ||||||||||||||||||||||||||||||
| 2335 |     else if (frameType == RootFrame
  | 0 | ||||||||||||||||||||||||||||||
| 2336 |         html += QLatin1String("-qt-table-type: root;"); never executed:  html += QLatin1String("-qt-table-type: root;"); | 0 | ||||||||||||||||||||||||||||||
| 2337 | - | |||||||||||||||||||||||||||||||
| 2338 | const QTextFrameFormat defaultFormat; | - | ||||||||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||||||||
| 2340 | emitFloatStyle(format.position(), OmitStyleTag); | - | ||||||||||||||||||||||||||||||
| 2341 | emitPageBreakPolicy(format.pageBreakPolicy()); | - | ||||||||||||||||||||||||||||||
| 2342 | - | |||||||||||||||||||||||||||||||
| 2343 |     if (format.borderBrush() != defaultFormat.borderBrush()
  | 0 | ||||||||||||||||||||||||||||||
| 2344 | html += QLatin1String(" border-color:"); | - | ||||||||||||||||||||||||||||||
| 2345 | html += colorValue(format.borderBrush().color()); | - | ||||||||||||||||||||||||||||||
| 2346 | html += QLatin1Char(';'); | - | ||||||||||||||||||||||||||||||
| 2347 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||||||||
| 2348 | - | |||||||||||||||||||||||||||||||
| 2349 |     if (format.borderStyle() != defaultFormat.borderStyle()
  | 0 | ||||||||||||||||||||||||||||||
| 2350 |         emitBorderStyle(format.borderStyle()); never executed:  emitBorderStyle(format.borderStyle()); | 0 | ||||||||||||||||||||||||||||||
| 2351 | - | |||||||||||||||||||||||||||||||
| 2352 |     if (format.hasProperty(QTextFormat::FrameMargin)
  | 0 | ||||||||||||||||||||||||||||||
| 2353 |         || format.hasProperty(QTextFormat::FrameLeftMargin)
  | 0 | ||||||||||||||||||||||||||||||
| 2354 |         || format.hasProperty(QTextFormat::FrameRightMargin)
  | 0 | ||||||||||||||||||||||||||||||
| 2355 |         || format.hasProperty(QTextFormat::FrameTopMargin)
  | 0 | ||||||||||||||||||||||||||||||
| 2356 |         || format.hasProperty(QTextFormat::FrameBottomMargin)
  | 0 | ||||||||||||||||||||||||||||||
| 2357 |         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 | ||||||||||||||||||||||||||||||
| 2358 |                     QString::number(format.bottomMargin()), never executed:  emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin())); | 0 | ||||||||||||||||||||||||||||||
| 2359 |                     QString::number(format.leftMargin()), never executed:  emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin())); | 0 | ||||||||||||||||||||||||||||||
| 2360 |                     QString::number(format.rightMargin())); never executed:  emitMargins(QString::number(format.topMargin()), QString::number(format.bottomMargin()), QString::number(format.leftMargin()), QString::number(format.rightMargin())); | 0 | ||||||||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||||||||
| 2362 |     if (html.length() == originalHtmlLength
  | 0 | ||||||||||||||||||||||||||||||
| 2363 |         html.chop(qstrlen(styleAttribute.latin1())); never executed:  html.chop(qstrlen(styleAttribute.latin1())); | 0 | ||||||||||||||||||||||||||||||
| 2364 | else | - | ||||||||||||||||||||||||||||||
| 2365 |         html += QLatin1Char('\"'); never executed:  html += QLatin1Char('\"'); | 0 | ||||||||||||||||||||||||||||||
| 2366 | } | - | ||||||||||||||||||||||||||||||
| 2367 | QString QTextDocument::toHtml(const QByteArray &encoding) const | - | ||||||||||||||||||||||||||||||
| 2368 | { | - | ||||||||||||||||||||||||||||||
| 2369 |     return never executed:   QTextHtmlExporter(this).toHtml(encoding);return QTextHtmlExporter(this).toHtml(encoding);never executed:  return QTextHtmlExporter(this).toHtml(encoding); | 0 | ||||||||||||||||||||||||||||||
| 2370 | } | - | ||||||||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||||||||
| 2372 | - | |||||||||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||||||||
| 2376 | QVector<QTextFormat> QTextDocument::allFormats() const | - | ||||||||||||||||||||||||||||||
| 2377 | { | - | ||||||||||||||||||||||||||||||
| 2378 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2379 |     return never executed:   d->formatCollection()->formats;return d->formatCollection()->formats;never executed:  return d->formatCollection()->formats; | 0 | ||||||||||||||||||||||||||||||
| 2380 | } | - | ||||||||||||||||||||||||||||||
| 2381 | - | |||||||||||||||||||||||||||||||
| 2382 | - | |||||||||||||||||||||||||||||||
| 2383 | - | |||||||||||||||||||||||||||||||
| 2384 | - | |||||||||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||||||||
| 2386 | - | |||||||||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||||||||
| 2388 | QTextDocumentPrivate *QTextDocument::docHandle() const | - | ||||||||||||||||||||||||||||||
| 2389 | { | - | ||||||||||||||||||||||||||||||
| 2390 | const QTextDocumentPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2391 |     return never executed:   const_cast<QTextDocumentPrivate *>(d);return const_cast<QTextDocumentPrivate *>(d);never executed:  return const_cast<QTextDocumentPrivate *>(d); | 0 | ||||||||||||||||||||||||||||||
| 2392 | } | - | ||||||||||||||||||||||||||||||
| 2393 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |