[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/widgets
From: Thomas McGuire <mcguire () kde ! org>
Date: 2011-01-04 19:15:21
Message-ID: 20110104191521.F023DAC8AE () svn ! kde ! org
[Download RAW message or body]
SVN commit 1211736 by tmcguire:
Fix the HTML output in cleanHTML() again.
This fixes MS Outlook not displaying mails from KMail
correctly.
Thanks to "Frank Vanderham" <twelve dot eighty at gmail dot com>
for the patch!
BUG: 207779
M +41 -3 krichtextedit.cpp
--- trunk/KDE/kdelibs/kdeui/widgets/krichtextedit.cpp #1211735:1211736
@@ -522,9 +522,47 @@
QString KRichTextEdit::toCleanHtml() const
{
- // Does nothing anymore, as Qt seems to be fixed now.
- // See the unit test which confirms this.
- return toHtml();
+ QString result = toHtml();
+
+ static const QString EMPTYLINEFROMQT = QLatin1String(
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
+ "margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "
+ "-qt-user-state:0;\"></p>" );
+
+ static const QString EMPTYLINEHTML = QLatin1String(
+ "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
+ "margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "
+ "-qt-user-state:0;\"><br /></p>" );
+
+ static const QString OLLISTPATTERNQT = QLatin1String(
+ "<ol style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;" );
+
+ static const QString ULLISTPATTERNQT = QLatin1String(
+ "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;" );
+
+ static const QString ORDEREDLISTHTML = QLatin1String(
+ "<ol style=\"margin-top: 0px; margin-bottom: 0px;" );
+
+ static const QString UNORDEREDLISTHTML = QLatin1String(
+ "<ul style=\"margin-top: 0px; margin-bottom: 0px;" );
+
+ // fix 1 - empty lines should show as empty lines - MS Outlook treats margin-top:0px; as
+ // a non-existing line.
+ // Although we can simply remove the margin-top style property, we still get unwanted results
+ // if you have three or more empty lines. It's best to replace empty <p> elements with <p><br /></p>.
+ // As per http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict, <br> elements are still proper
+ // HTML.
+ result.replace(EMPTYLINEFROMQT, EMPTYLINEHTML);
+
+ // fix 2a - ordered lists - MS Outlook treats margin-left:0px; as
+ // a non-existing number; e.g: "1. First item" turns into "First Item"
+ result.replace(OLLISTPATTERNQT, ORDEREDLISTHTML);
+
+ // fix 2b - unordered lists - MS Outlook treats margin-left:0px; as
+ // a non-existing bullet; e.g: "* First bullet" turns into "First Bullet"
+ result.replace(ULLISTPATTERNQT, UNORDEREDLISTHTML);
+
+ return result;
}
#include "krichtextedit.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic