Commit 87e98d5c authored by Albert Astals Cid's avatar Albert Astals Cid

I have a few mobi files with

<font size="+2" face="AdobeGaramondPro" color="rgb(0,0,0)">
convert the color to something Qt understands

svn path=/trunk/KDE/kdegraphics/okular/; revision=1233920
parent 84cc400f
......@@ -9,6 +9,7 @@
#include "mobidocument.h"
#include "mobipocket.h"
#include "qfilestream.h"
#include <QtGui/QColor>
#include <QtCore/QFile>
#include <QtCore/QRegExp>
#include <kdebug.h>
......@@ -93,5 +94,12 @@ QString MobiDocument::fixMobiMarkup(const QString& data)
imgs.setMinimal(true);
ret.replace(imgs,"<img src=\"pdbrec:/\\1\">");
ret.replace("<mbp:pagebreak/>","<p style=\"page-break-after:always\"></p>");
static QRegExp rgb(" color=\"rgb\\((\\d+),(\\d+),(\\d+)\\)\"", Qt::CaseSensitive);
pos = 0;
while ((pos = rgb.indexIn(ret, pos)) != -1) {
const QString qtColor = QColor(rgb.cap(1).toInt(), rgb.cap(2).toInt(), rgb.cap(3).toInt()).name();
ret.replace(pos, rgb.matchedLength(), QString(" color=\"%1\"").arg(qtColor));
}
return ret;
}
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