523
523
QString KRichTextEdit::toCleanHtml() const
525
// Does nothing anymore, as Qt seems to be fixed now.
526
// See the unit test which confirms this.
525
QString result = toHtml();
527
static const QString EMPTYLINEFROMQT = QLatin1String(
528
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
529
"margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "
530
"-qt-user-state:0;\"></p>" );
532
static const QString EMPTYLINEHTML = QLatin1String(
533
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; "
534
"margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; "
535
"-qt-user-state:0;\"><br /></p>" );
537
static const QString OLLISTPATTERNQT = QLatin1String(
538
"<ol style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;" );
540
static const QString ULLISTPATTERNQT = QLatin1String(
541
"<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;" );
543
static const QString ORDEREDLISTHTML = QLatin1String(
544
"<ol style=\"margin-top: 0px; margin-bottom: 0px;" );
546
static const QString UNORDEREDLISTHTML = QLatin1String(
547
"<ul style=\"margin-top: 0px; margin-bottom: 0px;" );
549
// fix 1 - empty lines should show as empty lines - MS Outlook treats margin-top:0px; as
550
// a non-existing line.
551
// Although we can simply remove the margin-top style property, we still get unwanted results
552
// if you have three or more empty lines. It's best to replace empty <p> elements with <p><br /></p>.
553
// As per http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict, <br> elements are still proper
555
result.replace(EMPTYLINEFROMQT, EMPTYLINEHTML);
557
// fix 2a - ordered lists - MS Outlook treats margin-left:0px; as
558
// a non-existing number; e.g: "1. First item" turns into "First Item"
559
result.replace(OLLISTPATTERNQT, ORDEREDLISTHTML);
561
// fix 2b - unordered lists - MS Outlook treats margin-left:0px; as
562
// a non-existing bullet; e.g: "* First bullet" turns into "First Bullet"
563
result.replace(ULLISTPATTERNQT, UNORDEREDLISTHTML);
530
568
#include "krichtextedit.moc"