int QPaintContext::height() const { if (myPixmap == NULL) { return 0; } return myPixmap->height() - bottomMargin() - topMargin(); }
QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() { switch (currentNode->id) { case Html_body: if (currentNode->charFormat.background().style() != Qt::NoBrush) { QTextFrameFormat fmt = doc->rootFrame()->frameFormat(); fmt.setBackground(currentNode->charFormat.background()); doc->rootFrame()->setFrameFormat(fmt); const_cast<QTextHtmlParserNode *>(currentNode)->charFormat.clearProperty(QTextFormat::BackgroundBrush); } compressNextWhitespace = RemoveWhiteSpace; break; case Html_ol: case Html_ul: { QTextListFormat::Style style = currentNode->listStyle; if (currentNode->id == Html_ul && !currentNode->hasOwnListStyle && currentNode->parent) { const QTextHtmlParserNode *n = &at(currentNode->parent); while (n) { if (n->id == Html_ul) { style = nextListStyle(currentNode->listStyle); } if (n->parent) n = &at(n->parent); else n = 0; } } QTextListFormat listFmt; listFmt.setStyle(style); ++indent; if (currentNode->hasCssListIndent) listFmt.setIndent(currentNode->cssListIndent); else listFmt.setIndent(indent); List l; l.format = listFmt; l.listNode = currentNodeIdx; lists.append(l); compressNextWhitespace = RemoveWhiteSpace; // broken html: <ul>Text here<li>Foo const QString simpl = currentNode->text.simplified(); if (simpl.isEmpty() || simpl.at(0).isSpace()) return ContinueWithNextNode; break; } case Html_table: { Table t = scanTable(currentNodeIdx); tables.append(t); hasBlock = false; compressNextWhitespace = RemoveWhiteSpace; return ContinueWithNextNode; } case Html_tr: return ContinueWithNextNode; case Html_img: { QTextImageFormat fmt; fmt.setName(currentNode->imageName); fmt.merge(currentNode->charFormat); if (currentNode->imageWidth != -1) fmt.setWidth(currentNode->imageWidth); if (currentNode->imageHeight != -1) fmt.setHeight(currentNode->imageHeight); cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat)); cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); cursor.mergeCharFormat(currentNode->charFormat); cursor.movePosition(QTextCursor::Right); compressNextWhitespace = CollapseWhiteSpace; hasBlock = false; return ContinueWithNextNode; } case Html_hr: { QTextBlockFormat blockFormat = currentNode->blockFormat; blockFormat.setTopMargin(topMargin(currentNodeIdx)); blockFormat.setBottomMargin(bottomMargin(currentNodeIdx)); blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, currentNode->width); if (hasBlock && importMode == ImportToDocument) cursor.mergeBlockFormat(blockFormat); else appendBlock(blockFormat); hasBlock = false; compressNextWhitespace = RemoveWhiteSpace; return ContinueWithNextNode; } default: break; } return ContinueWithCurrentNode; }