Commit f2424ef6 authored by Albert Astals Cid's avatar Albert Astals Cid

* qt4/src/poppler-document.cc:

        * qt4/src/poppler-private.h:
        * qt4/src/poppler-qt4.h: Add the possibility of setting the paper
        color

One step more to make oKular fully use the qt4 bindings
parent 4147400e
2006-05-01 Albert Astals Cid <aacid@kde.org>
* qt4/src/poppler-document.cc:
* qt4/src/poppler-private.h:
* qt4/src/poppler-qt4.h: Add the possibility of setting the paper
color
2006-04-29 Albert Astals Cid <aacid@kde.org>
* poppler/JBIG2Stream.cc: fix memory leak. Bug 6765, reported by
......
......@@ -58,50 +58,7 @@ static int fromRoman(const char *buffer) {
return value;
}
static void toRoman(int number, GooString *str, GBool uppercase) {
static const char uppercaseNumerals[] = "IVXLCDM";
static const char lowercaseNumerals[] = "ivxlcdm";
int divisor;
int i, j, k;
const char *wh;
if (uppercase)
wh = uppercaseNumerals;
else
wh = lowercaseNumerals;
divisor = 1000;
for (k = 3; k >= 0; k--) {
i = number / divisor;
number = number % divisor;
switch (i) {
case 0:
break;
case 5:
str->append(wh[2 * k + 1]);
break;
case 9:
str->append(wh[2 * k + 0]);
str->append(wh[ 2 * k + 2]);
break;
case 4:
str->append(wh[2 * k + 0]);
str->append(wh[2 * k + 1]);
break;
default:
if (i > 5) {
str->append(wh[2 * k + 1]);
i -= 5;
}
for (j = 0; j < i; j++) {
str->append(wh[2 * k + 0]);
}
}
divisor = divisor / 10;
}
}
static int fromLatin(const char *buffer)
{
......
......@@ -37,3 +37,47 @@ private:
GooList intervals;
};
static void toRoman(int number, GooString *str, GBool uppercase) {
static const char uppercaseNumerals[] = "IVXLCDM";
static const char lowercaseNumerals[] = "ivxlcdm";
int divisor;
int i, j, k;
const char *wh;
if (uppercase)
wh = uppercaseNumerals;
else
wh = lowercaseNumerals;
divisor = 1000;
for (k = 3; k >= 0; k--) {
i = number / divisor;
number = number % divisor;
switch (i) {
case 0:
break;
case 5:
str->append(wh[2 * k + 1]);
break;
case 9:
str->append(wh[2 * k + 0]);
str->append(wh[ 2 * k + 2]);
break;
case 4:
str->append(wh[2 * k + 0]);
str->append(wh[2 * k + 1]);
break;
default:
if (i > 5) {
str->append(wh[2 * k + 1]);
i -= 5;
}
for (j = 0; j < i; j++) {
str->append(wh[2 * k + 0]);
}
}
divisor = divisor / 10;
}
}
\ No newline at end of file
......@@ -420,6 +420,16 @@ namespace Poppler {
return false;
}
}
void Document::setPaperColor(const QColor &color)
{
m_doc->setPaperColor(color);
}
QColor Document::paperColor() const
{
return m_doc->paperColor;
}
QDateTime convertDate( char *dateString )
{
......
......@@ -66,6 +66,7 @@ namespace Poppler {
DocumentData(GooString *filePath, GooString *ownerPassword, GooString *userPassword) :
doc(filePath, ownerPassword, userPassword), m_splashOutputDev(0)
{
paperColor = Qt::white;
// It might be more appropriate to delete these in PDFDoc
delete ownerPassword;
delete userPassword;
......@@ -82,11 +83,11 @@ namespace Poppler {
{
if (!m_splashOutputDev)
{
SplashColor white;
white[0] = 255;
white[1] = 255;
white[2] = 255;
m_splashOutputDev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
SplashColor bgColor;
bgColor[0] = paperColor.red();
bgColor[1] = paperColor.green();
bgColor[2] = paperColor.blue();
m_splashOutputDev = new SplashOutputDev(splashModeRGB8, 4, gFalse, bgColor);
m_splashOutputDev->startDoc(doc.getXRef());
}
return m_splashOutputDev;
......@@ -146,12 +147,23 @@ namespace Poppler {
addTocChildren( docSyn, &item, children );
}
}
void setPaperColor(const QColor &color)
{
if (color != paperColor)
{
paperColor = color;
delete m_splashOutputDev;
m_splashOutputDev = NULL;
}
}
class PDFDoc doc;
bool locked;
FontInfoScanner *m_fontInfoScanner;
SplashOutputDev *m_splashOutputDev;
QList<EmbeddedFile*> m_embeddedFiles;
QColor paperColor;
};
class FontInfoData
......
......@@ -685,6 +685,12 @@ delete pixmap;
LinkDestination *linkDestination( const QString &name );
bool print(const QString &fileName, const QList<int> pageList, double hDPI, double vDPI, int rotate);
/**
Sets the paper color, if not set it is white by default.
*/
void setPaperColor(const QColor &color);
QColor paperColor() const;
~Document();
......
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