summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-03 15:27:08 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-05 16:28:54 +0200
commit720defd2caee5225527fa0b154fa68b738fb967b (patch)
tree951c013d6ed509174018815f06375b9cc46c63d4 /src/gui/text/qtextdocument.cpp
parent358df462a03f658277d6ce79d7846d3d53d8d05e (diff)
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>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index e302a1e170..bf8c10f0d9 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -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('\"');