Commit 1c9788f0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix text color

parent e82a45cb
Pipeline #80591 passed with stage
in 4 minutes and 33 seconds
......@@ -970,7 +970,26 @@ void TextHTMLBuilderTest::testBug442416Bis()
auto regex = QRegularExpression(
QStringLiteral("^<p style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ffff00;\">Sss</span></p>\n<p "
"style=\"margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;\"><span style=\"background-color:#ff0000;\">sss</span></p>\n"));
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
delete doc;
}
void TextHTMLBuilderTest::testBugTextColor()
{
auto doc = new QTextDocument();
doc->setHtml(QStringLiteral("<p><span style=\"color:#ffff00;\">BBBB</span></p><p><span style=\"color:#ffff00;\">AAA</p>"));
auto hb = new KPIMTextEdit::TextHTMLBuilder();
auto md = new KPIMTextEdit::MarkupDirector(hb);
md->processDocument(doc);
auto result = hb->getResult();
// qDebug() << " result " << result;
auto regex = QRegularExpression(
QStringLiteral("^<p style=\"margin-top:12;margin-bottom:12;margin-left:0;margin-right:0;\"><span style=\"color:#ffff00;\">BBBB</span></p>\n<p "
"style=\"margin-top:12;margin-bottom:12;margin-left:0;margin-right:0;\"><span style=\"color:#ffff00;\">AAA</span></p>\n"));
QVERIFY(regex.match(result).hasMatch());
delete md;
delete hb;
......
......@@ -50,6 +50,7 @@ private Q_SLOTS:
void testBug436880();
void testBug442416();
void testBug442416Bis();
void testBugTextColor();
};
#endif // TEXTHTMLBUILDERTEST_H
......@@ -533,6 +533,8 @@ void MarkupDirector::processClosingElements(const QTextBlock::iterator &it)
break;
case SpanForeground:
m_builder->endForeground();
// Clear forground text color otherwise if we select 2 lines with same text color it will not applied. bug #442416
d->m_openForeground = {};
break;
case Anchor:
m_builder->endAnchor();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment