Commit cb68d1a9 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Bring back printing to kpdf_experiments (last commit whitout log did that too, sorry :-()

Update xpdf/ with some changes from head

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=360216
parent da7b8eae
......@@ -12,6 +12,7 @@
#pragma implementation
#endif
#include <limits.h>
#include <stddef.h>
#include "gmem.h"
#include "Object.h"
......@@ -64,10 +65,9 @@ Catalog::Catalog(XRef *xrefA) {
}
pagesSize = numPages0 = (int)obj.getNum();
obj.free();
// The gcc doesnt optimize this away, so this check is ok,
// even if it looks like a pagesSize != pagesSize check
if (pagesSize*sizeof(Page *)/sizeof(Page *) != (unsigned int)pagesSize ||
pagesSize*sizeof(Ref)/sizeof(Ref) != (unsigned int)pagesSize) {
if (((unsigned) pagesSize >= INT_MAX / sizeof(Page *)) ||
((unsigned) pagesSize >= INT_MAX / sizeof(Ref)))
{
error(-1, "Invalid 'pagesSize'");
ok = gFalse;
return;
......@@ -200,8 +200,8 @@ int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start) {
}
if (start >= pagesSize) {
pagesSize += 32;
if (pagesSize*sizeof(Page *)/sizeof(Page *) != (unsigned int)pagesSize ||
pagesSize*sizeof(Ref)/sizeof(Ref) != (unsigned int)pagesSize) {
if ((unsigned) pagesSize >= INT_MAX / sizeof(Page*) ||
(unsigned) pagesSize >= INT_MAX / sizeof(Ref)) {
error(-1, "Invalid 'pagesSize' parameter.");
goto err3;
}
......
......@@ -1191,7 +1191,7 @@ int JBIG2Stream::lookChar() {
return EOF;
}
GString *JBIG2Stream::getPSFilter(int /*psLevel*/, char */*indent*/) {
GString *JBIG2Stream::getPSFilter(int /*psLevel*/, const char */*indent*/) {
return NULL;
}
......
......@@ -39,7 +39,7 @@ public:
virtual void reset();
virtual int getChar();
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......
......@@ -366,7 +366,7 @@ void JPXStream::fillReadBuf() {
} while (readBufLen < 8);
}
GString *JPXStream::getPSFilter(int /*psLevel*/, char */*indent*/) {
GString *JPXStream::getPSFilter(int /*psLevel*/, const char */*indent*/) {
return NULL;
}
......
......@@ -273,7 +273,7 @@ public:
virtual void reset();
virtual int getChar();
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......
......@@ -8,7 +8,7 @@ libxpdf_la_SOURCES = Annot.cc Array.cc BuiltinFont.cc BuiltinFontTables.cc \
GfxFont.cc GfxState.cc GlobalParams.cc JArithmeticDecoder.cc \
JBIG2Stream.cc Lexer.cc Link.cc NameToCharCode.cc Object.cc Outline.cc \
OutputDev.cc PDFDoc.cc PDFDocEncoding.cc PSTokenizer.cc \
Page.cc Parser.cc SplashOutputDev.cc Stream.cc JPXStream.cc \
Page.cc Parser.cc PSOutputDev.cc SplashOutputDev.cc Stream.cc JPXStream.cc \
TextOutputDev.cc UnicodeMap.cc UnicodeTypeTable.cc XRef.cc
noinst_LTLIBRARIES = libxpdf.la
......@@ -236,6 +236,19 @@ void PDFDoc::displayPages(OutputDev *out, int firstPage, int lastPage,
}
}
void PDFDoc::displayPages(OutputDev *out, list<int> &pages,
double hDPI, double vDPI, int rotate,
GBool crop, GBool doLinks,
GBool (*abortCheckCbk)(void *data),
void *abortCheckCbkData)
{
list<int>::const_iterator i;
for(i = pages.begin(); i != pages.end(); ++i)
displayPage(out, *i, hDPI, vDPI, rotate, crop, doLinks,
abortCheckCbk, abortCheckCbkData);
}
void PDFDoc::displayPageSlice(OutputDev *out, int page,
double hDPI, double vDPI,
int rotate, GBool crop,
......
......@@ -15,6 +15,7 @@
#pragma interface
#endif
#include <list>
#include <stdio.h>
#include "XRef.h"
#include "Link.h"
......@@ -29,6 +30,8 @@ class LinkAction;
class LinkDest;
class Outline;
using namespace std;
//------------------------------------------------------------------------
// PDFDoc
//------------------------------------------------------------------------
......@@ -91,6 +94,15 @@ public:
GBool (*abortCheckCbk)(void *data) = NULL,
void *abortCheckCbkData = NULL);
// Added by kpdf authors
// Display some pages
void displayPages(OutputDev *out, list<int> &pages,
double hDPI, double vDPI, int rotate,
GBool crop, GBool doLinks,
GBool (*abortCheckCbk)(void *data) = NULL,
void *abortCheckCbkData = NULL);
// Display part of a page.
void displayPageSlice(OutputDev *out, int page,
double hDPI, double vDPI,
......
......@@ -905,7 +905,7 @@ int ASCIIHexStream::lookChar() {
return buf;
}
GString *ASCIIHexStream::getPSFilter(int psLevel, char *indent) {
GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
......@@ -986,7 +986,7 @@ int ASCII85Stream::lookChar() {
return b[index];
}
GString *ASCII85Stream::getPSFilter(int psLevel, char *indent) {
GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
......@@ -1168,7 +1168,7 @@ int LZWStream::getCode() {
return code;
}
GString *LZWStream::getPSFilter(int psLevel, char *indent) {
GString *LZWStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2 || pred) {
......@@ -1205,7 +1205,7 @@ void RunLengthStream::reset() {
eof = gFalse;
}
GString *RunLengthStream::getPSFilter(int psLevel, char *indent) {
GString *RunLengthStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
......@@ -1745,7 +1745,7 @@ short CCITTFaxStream::lookBits(int n) {
return (inputBuf >> (inputBits - n)) & (0xffff >> (16 - n));
}
GString *CCITTFaxStream::getPSFilter(int psLevel, char *indent) {
GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
char s1[50];
......@@ -3160,7 +3160,7 @@ int DCTStream::read16() {
return (c1 << 8) + c2;
}
GString *DCTStream::getPSFilter(int psLevel, char *indent) {
GString *DCTStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
......@@ -3353,7 +3353,7 @@ int FlateStream::getRawChar() {
return c;
}
GString *FlateStream::getPSFilter(int psLevel, char *indent) {
GString *FlateStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 3 || pred) {
......
......@@ -379,7 +379,7 @@ public:
virtual int getChar()
{ int c = lookChar(); buf = EOF; return c; }
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -402,7 +402,7 @@ public:
virtual int getChar()
{ int ch = lookChar(); ++index; return ch; }
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -428,7 +428,7 @@ public:
virtual int getChar();
virtual int lookChar();
virtual int getRawChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -472,7 +472,7 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -503,7 +503,7 @@ public:
virtual int getChar()
{ int c = lookChar(); buf = EOF; return c; }
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -573,7 +573,7 @@ public:
virtual void reset();
virtual int getChar();
virtual int lookChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
Stream *getRawStream() { return str; }
......@@ -674,7 +674,7 @@ public:
virtual int getChar();
virtual int lookChar();
virtual int getRawChar();
virtual GString *getPSFilter(int psLevel, char *indent);
virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
......@@ -723,7 +723,7 @@ public:
virtual void reset() {}
virtual int getChar() { return EOF; }
virtual int lookChar() { return EOF; }
virtual GString *getPSFilter(int /*psLevel*/, char */*indent*/) { return NULL; }
virtual GString *getPSFilter(int /*psLevel*/, const char */*indent*/) { return NULL; }
virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; }
};
......@@ -740,7 +740,7 @@ public:
virtual void reset();
virtual int getChar();
virtual int lookChar();
virtual GString *getPSFilter(int /*psLevel*/, char */*indent*/) { return NULL; }
virtual GString *getPSFilter(int /*psLevel*/, const char */*indent*/) { return NULL; }
virtual GBool isBinary(GBool last = gTrue);
virtual GBool isEncoder() { return gTrue; }
......@@ -765,7 +765,7 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual GString *getPSFilter(int /*psLevel*/, char */*indent*/) { return NULL; }
virtual GString *getPSFilter(int /*psLevel*/, const char */*indent*/) { return NULL; }
virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; }
virtual GBool isEncoder() { return gTrue; }
......@@ -795,7 +795,7 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual GString *getPSFilter(int /*psLevel*/, char */*indent*/) { return NULL; }
virtual GString *getPSFilter(int /*psLevel*/, const char */*indent*/) { return NULL; }
virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; }
virtual GBool isEncoder() { return gTrue; }
......@@ -825,7 +825,7 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual GString *getPSFilter(int /*psLevel*/, char */*indent*/) { return NULL; }
virtual GString *getPSFilter(int /*psLevel*/, const char */*indent*/) { return NULL; }
virtual GBool isBinary(GBool /*last = gTrue*/) { return gTrue; }
virtual GBool isEncoder() { return gTrue; }
......
......@@ -12,6 +12,7 @@
#pragma implementation
#endif
#include <limits.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
......@@ -110,7 +111,7 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
goto err1;
}
if (nObjects*sizeof(int)/sizeof(int) != (uint)nObjects) {
if ((unsigned) nObjects >= INT_MAX / sizeof(int)) {
error(-1, "Invalid 'nObjects'");
goto err1;
}
......@@ -393,7 +394,7 @@ GBool XRef::readXRefTable(Parser *parser, Guint *pos) {
if (newSize < 0) {
goto err1;
}
if (newSize*sizeof(XRefEntry)/sizeof(XRefEntry) != (uint)newSize) {
if ((unsigned) newSize >= INT_MAX / sizeof(XRefEntry)) {
error(-1, "Invalid 'obj' parameters'");
goto err1;
}
......@@ -503,7 +504,7 @@ GBool XRef::readXRefStream(Stream *xrefStr, Guint *pos) {
goto err1;
}
if (newSize > size) {
if (newSize * sizeof(XRefEntry)/sizeof(XRefEntry) != (uint)newSize) {
if ((unsigned) newSize >= INT_MAX / sizeof(XRefEntry)) {
error(-1, "Invalid 'size' parameter.");
return gFalse;
}
......@@ -597,7 +598,7 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) {
if (newSize < 0) {
return gFalse;
}
if (newSize*sizeof(XRefEntry)/sizeof(XRefEntry) != (uint)newSize) {
if ((unsigned) newSize >= INT_MAX / sizeof(XRefEntry)) {
error(-1, "Invalid 'size' inside xref table.");
return gFalse;
}
......@@ -736,7 +737,7 @@ GBool XRef::constructXRef() {
error(-1, "Bad object number");
return gFalse;
}
if (newSize*sizeof(XRefEntry)/sizeof(XRefEntry) != (uint)newSize) {
if ((unsigned) newSize >= INT_MAX / sizeof(XRefEntry)) {
error(-1, "Invalid 'obj' parameters.");
return gFalse;
}
......@@ -763,7 +764,7 @@ GBool XRef::constructXRef() {
} else if (!strncmp(p, "endstream", 9)) {
if (streamEndsLen == streamEndsSize) {
streamEndsSize += 64;
if (streamEndsSize*sizeof(int)/sizeof(int) != (uint)streamEndsSize) {
if ((unsigned) streamEndsSize >= INT_MAX / sizeof(int)) {
error(-1, "Invalid 'endstream' parameter.");
return gFalse;
}
......
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