Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
4.5.2
-
None
Description
The QTextHtmlParser has a problem with leading empty Paragraphs it creates an additional empty paragraph.
Here is some test code:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
/*
Given "s" without a leading emtpy paragraph works correctly. Here is the output:
*/
QString s = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"> "
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\"> "
"p, li
"
"</style></head><body style=\" font-family:'Arial'; font-size:56pt; font-weight:400; font-style:normal;\"> "
"<table border=\"0\" style=\"-qt-table-type: root; margin-top:50px; margin-bottom:50px; margin-left:50px; margin-right:50px;\"> "
"<tr> "
"<td style=\"border: none;\"> "
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Lucida Grande'; font-size:57pt; color:#000000;\">Working</span></p></td></tr></table></body></html>\" "
;
QTextDocument t;
qDebug() << "---- begin raw string output ---- ";
qDebug() << s;
t.setHtml(s);
qDebug() << "--- end raw string output ---";
qDebug() ;
qDebug() << t.toHtml();
qDebug() ;
/*
But, if my Text starts with an empty paragraph, another empty paragraph is inserted at the start.
*/
QString s2 = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\"> "
"p, li
"
"</style></head><body style=\" font-family:'Arial'; font-size:56pt; font-weight:400; font-style:normal;\"> "
"<table border=\"0\" style=\"-qt-table-type: root; margin-top:50px; margin-bottom:50px; margin-left:50px; margin-right:50px;\"> "
"<tr> "
"<td style=\"border: none;\"> "
"<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; font-family:'Lucida Grande'; font-size:57pt;\"></p> "
"<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; font-family:'Lucida Grande'; font-size:57pt; color:#000000;\"></p> "
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Lucida Grande'; font-size:57pt; color:#000000;\">Extra P tag inserted</span></p> "
"<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; font-family:'Lucida Grande'; font-size:57pt; color:#000000;\"></p></td></tr></table></body></html>\" "
;
QTextDocument t2;
qDebug() << "---- begin t2 raw string output ---- ";
qDebug() << s2;
t2.setHtml(s2);
qDebug() << "--- end raw t2 string output ---";
qDebug() ;
qDebug() << t2.toHtml();
qDebug() ;
return -1; //app.exec();
}