Export the block's line-height settings to html
Task-number: QTBUG-28404 Change-Id: I87e03ecd981c302a5aefdadf7bcfd9729e37bd13 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
257e98917c
commit
3fe242781e
@ -2531,6 +2531,29 @@ void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block)
|
|||||||
html += QLatin1Char(';');
|
html += QLatin1Char(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format.lineHeightType() != QTextBlockFormat::SingleHeight) {
|
||||||
|
switch (format.lineHeightType()) {
|
||||||
|
case QTextBlockFormat::ProportionalHeight:
|
||||||
|
case QTextBlockFormat::FixedHeight:
|
||||||
|
html += QLatin1String(" line-height:");
|
||||||
|
break;
|
||||||
|
case QTextBlockFormat::MinimumHeight:
|
||||||
|
html += QLatin1String(" min-height:");
|
||||||
|
break;
|
||||||
|
case QTextBlockFormat::LineDistanceHeight:
|
||||||
|
html += QLatin1String(" line-spacing:");
|
||||||
|
break;
|
||||||
|
case QTextBlockFormat::SingleHeight:
|
||||||
|
default:
|
||||||
|
break; // Should never reach here
|
||||||
|
}
|
||||||
|
html += QString::number(format.lineHeight());
|
||||||
|
if (format.lineHeightType() == QTextBlockFormat::ProportionalHeight)
|
||||||
|
html += QLatin1String("%;");
|
||||||
|
else
|
||||||
|
html += QLatin1String("px;");
|
||||||
|
}
|
||||||
|
|
||||||
emitPageBreakPolicy(format.pageBreakPolicy());
|
emitPageBreakPolicy(format.pageBreakPolicy());
|
||||||
|
|
||||||
QTextCharFormat diff;
|
QTextCharFormat diff;
|
||||||
|
@ -113,6 +113,7 @@ private slots:
|
|||||||
void toHtmlBodyBgColorRgba();
|
void toHtmlBodyBgColorRgba();
|
||||||
void toHtmlBodyBgColorTransparent();
|
void toHtmlBodyBgColorTransparent();
|
||||||
void toHtmlRootFrameProperties();
|
void toHtmlRootFrameProperties();
|
||||||
|
void toHtmlLineHeightProperties();
|
||||||
void capitalizationHtmlInExport();
|
void capitalizationHtmlInExport();
|
||||||
void wordspacingHtmlExport();
|
void wordspacingHtmlExport();
|
||||||
|
|
||||||
@ -1856,6 +1857,25 @@ void tst_QTextDocument::toHtmlRootFrameProperties()
|
|||||||
QCOMPARE(doc.toHtml(), expectedOutput);
|
QCOMPARE(doc.toHtml(), expectedOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTextDocument::toHtmlLineHeightProperties()
|
||||||
|
{
|
||||||
|
CREATE_DOC_AND_CURSOR();
|
||||||
|
|
||||||
|
QTextBlock block = doc.firstBlock();
|
||||||
|
QTextBlockFormat blockFormat = block.blockFormat();
|
||||||
|
blockFormat.setLineHeight(200, QTextBlockFormat::ProportionalHeight);
|
||||||
|
cursor.setBlockFormat(blockFormat);
|
||||||
|
|
||||||
|
cursor.insertText("Blah");
|
||||||
|
QString expectedOutput("<p DEFAULTBLOCKSTYLE line-height:200%;\">Blah</p>");
|
||||||
|
|
||||||
|
expectedOutput.prepend(htmlHead);
|
||||||
|
expectedOutput.replace("DEFAULTBLOCKSTYLE", "style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;");
|
||||||
|
expectedOutput.append(htmlTail);
|
||||||
|
|
||||||
|
QCOMPARE(doc.toHtml(), expectedOutput);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTextDocument::capitalizationHtmlInExport()
|
void tst_QTextDocument::capitalizationHtmlInExport()
|
||||||
{
|
{
|
||||||
doc->setPlainText("Test");
|
doc->setPlainText("Test");
|
||||||
|
Loading…
Reference in New Issue
Block a user