Export text-decoration
It used to be ignored because we couldn't disable it, but that works fine now. So re-enable it. Fixes: QTBUG-91171 Change-Id: I4cf966211bb200b73326e90fc7e4c4d3d4090511 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>bb10
parent
358df462a0
commit
720defd2ca
|
|
@ -2331,11 +2331,6 @@ QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc)
|
|||
{
|
||||
const QFont defaultFont = doc->defaultFont();
|
||||
defaultCharFormat.setFont(defaultFont);
|
||||
// don't export those for the default font since we cannot turn them off with CSS
|
||||
defaultCharFormat.clearProperty(QTextFormat::FontUnderline);
|
||||
defaultCharFormat.clearProperty(QTextFormat::FontOverline);
|
||||
defaultCharFormat.clearProperty(QTextFormat::FontStrikeOut);
|
||||
defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle);
|
||||
}
|
||||
|
||||
static QStringList resolvedFontFamilies(const QTextCharFormat &format)
|
||||
|
|
@ -2408,8 +2403,28 @@ QString QTextHtmlExporter::toHtml(ExportMode mode)
|
|||
html += QLatin1String("px;");
|
||||
}
|
||||
|
||||
// do not set text-decoration on the default font since those values are /always/ propagated
|
||||
// and cannot be turned off with CSS
|
||||
QString decorationTag(QLatin1String(" text-decoration:"));
|
||||
bool atLeastOneDecorationSet = false;
|
||||
if (defaultCharFormat.hasProperty(QTextFormat::FontUnderline) || defaultCharFormat.hasProperty(QTextFormat::TextUnderlineStyle)) {
|
||||
if (defaultCharFormat.fontUnderline()) {
|
||||
decorationTag += QLatin1String(" underline");
|
||||
atLeastOneDecorationSet = true;
|
||||
}
|
||||
}
|
||||
if (defaultCharFormat.hasProperty(QTextFormat::FontOverline)) {
|
||||
if (defaultCharFormat.fontOverline()) {
|
||||
decorationTag += QLatin1String(" overline");
|
||||
atLeastOneDecorationSet = true;
|
||||
}
|
||||
}
|
||||
if (defaultCharFormat.hasProperty(QTextFormat::FontStrikeOut)) {
|
||||
if (defaultCharFormat.fontStrikeOut()) {
|
||||
decorationTag += QLatin1String(" line-through");
|
||||
atLeastOneDecorationSet = true;
|
||||
}
|
||||
}
|
||||
if (atLeastOneDecorationSet)
|
||||
html += decorationTag + QLatin1Char(';');
|
||||
|
||||
html += QLatin1Char('\"');
|
||||
|
||||
|
|
|
|||
|
|
@ -2426,12 +2426,12 @@ void tst_QTextDocumentFragment::defaultFont()
|
|||
f.setFamily("Courier New");
|
||||
f.setBold(true);
|
||||
f.setItalic(true);
|
||||
f.setStrikeOut(true); // set here but deliberately ignored for the html export
|
||||
f.setStrikeOut(true);
|
||||
f.setPointSize(100);
|
||||
doc->setDefaultFont(f);
|
||||
doc->setPlainText("Hello World");
|
||||
const QString html = doc->toHtml();
|
||||
QLatin1String str("<body style=\" font-family:'Courier New'; font-size:100pt; font-weight:700; font-style:italic;\">");
|
||||
QLatin1String str("<body style=\" font-family:'Courier New'; font-size:100pt; font-weight:700; font-style:italic; text-decoration: line-through;\">");
|
||||
QVERIFY(html.contains(str));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue