diff options
Diffstat (limited to 'src/gui/text/qtextdocumentfragment.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentfragment.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index ea37695f4e..f0eff2d4f3 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -420,7 +420,7 @@ static QTextListFormat::Style nextListStyle(QTextListFormat::Style style) } QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html, ImportMode mode, const QTextDocument *resourceProvider) - : indent(0), compressNextWhitespace(PreserveWhiteSpace), doc(_doc), importMode(mode) + : indent(0), headingLevel(0), compressNextWhitespace(PreserveWhiteSpace), doc(_doc), importMode(mode) { cursor = QTextCursor(doc); wsm = QTextHtmlParserNode::WhiteSpaceNormal; @@ -724,9 +724,9 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() cursor.insertImage(fmt, QTextFrameFormat::Position(currentNode->cssFloat)); - cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); + cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); cursor.mergeCharFormat(currentNode->charFormat); - cursor.movePosition(QTextCursor::Right); + cursor.movePosition(QTextCursor::NextCharacter); compressNextWhitespace = CollapseWhiteSpace; hasBlock = false; @@ -747,8 +747,28 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() return ContinueWithNextNode; } + case Html_h1: + headingLevel = 1; + break; + case Html_h2: + headingLevel = 2; + break; + case Html_h3: + headingLevel = 3; + break; + case Html_h4: + headingLevel = 4; + break; + case Html_h5: + headingLevel = 5; + break; + case Html_h6: + headingLevel = 6; + break; + default: break; } + return ContinueWithCurrentNode; } @@ -832,6 +852,15 @@ bool QTextHtmlImporter::closeTag() } } break; + case Html_h1: + case Html_h2: + case Html_h3: + case Html_h4: + case Html_h5: + case Html_h6: + headingLevel = 0; + blockTagClosed = true; + break; default: if (closedNode->isBlock()) blockTagClosed = true; @@ -1093,6 +1122,11 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() modifiedBlockFormat = true; } + if (headingLevel) { + block.setHeadingLevel(headingLevel); + modifiedBlockFormat = true; + } + if (currentNode->blockFormat.propertyCount() > 0) { modifiedBlockFormat = true; block.merge(currentNode->blockFormat); |