Commit a3cee0e7 authored by Adrian Johnson's avatar Adrian Johnson

Large file support

Create a Goffset type and use this type for all file offsets and file
sizes.

Bug 44085
parent 6eebbb9c
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
using namespace poppler; using namespace poppler;
void detail::error_function(void * /*data*/, ErrorCategory /*category*/, int pos, char *msg) void detail::error_function(void * /*data*/, ErrorCategory /*category*/, Goffset pos, char *msg)
{ {
std::ostringstream oss; std::ostringstream oss;
if (pos >= 0) { if (pos >= 0) {
......
...@@ -38,7 +38,7 @@ namespace poppler ...@@ -38,7 +38,7 @@ namespace poppler
namespace detail namespace detail
{ {
void error_function(void *data, ErrorCategory category, int pos, char *msg); void error_function(void *data, ErrorCategory category, Goffset pos, char *msg);
rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect); rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "poppler-input-stream.h" #include "poppler-input-stream.h"
PopplerInputStream::PopplerInputStream(GInputStream *inputStreamA, GCancellable *cancellableA, PopplerInputStream::PopplerInputStream(GInputStream *inputStreamA, GCancellable *cancellableA,
Guint startA, GBool limitedA, Guint lengthA, Object *dictA) Goffset startA, GBool limitedA, Goffset lengthA, Object *dictA)
: BaseStream(dictA, lengthA) : BaseStream(dictA, lengthA)
{ {
inputStream = (GInputStream *)g_object_ref(inputStreamA); inputStream = (GInputStream *)g_object_ref(inputStreamA);
...@@ -45,8 +45,8 @@ BaseStream *PopplerInputStream::copy() { ...@@ -45,8 +45,8 @@ BaseStream *PopplerInputStream::copy() {
return new PopplerInputStream(inputStream, cancellable, start, limited, length, &dict); return new PopplerInputStream(inputStream, cancellable, start, limited, length, &dict);
} }
Stream *PopplerInputStream::makeSubStream(Guint startA, GBool limitedA, Stream *PopplerInputStream::makeSubStream(Goffset startA, GBool limitedA,
Guint lengthA, Object *dictA) Goffset lengthA, Object *dictA)
{ {
return new PopplerInputStream(inputStream, cancellable, startA, limitedA, lengthA, dictA); return new PopplerInputStream(inputStream, cancellable, startA, limitedA, lengthA, dictA);
} }
...@@ -70,7 +70,7 @@ void PopplerInputStream::close() ...@@ -70,7 +70,7 @@ void PopplerInputStream::close()
saved = gFalse; saved = gFalse;
} }
void PopplerInputStream::setPos(Guint pos, int dir) void PopplerInputStream::setPos(Goffset pos, int dir)
{ {
Guint size; Guint size;
GSeekable *seekable = G_SEEKABLE(inputStream); GSeekable *seekable = G_SEEKABLE(inputStream);
...@@ -90,7 +90,7 @@ void PopplerInputStream::setPos(Guint pos, int dir) ...@@ -90,7 +90,7 @@ void PopplerInputStream::setPos(Guint pos, int dir)
bufPtr = bufEnd = buf; bufPtr = bufEnd = buf;
} }
void PopplerInputStream::moveStart(int delta) void PopplerInputStream::moveStart(Goffset delta)
{ {
start += delta; start += delta;
bufPtr = bufEnd = buf; bufPtr = bufEnd = buf;
......
...@@ -31,11 +31,11 @@ class PopplerInputStream: public BaseStream { ...@@ -31,11 +31,11 @@ class PopplerInputStream: public BaseStream {
public: public:
PopplerInputStream(GInputStream *inputStream, GCancellable *cancellableA, PopplerInputStream(GInputStream *inputStream, GCancellable *cancellableA,
Guint startA, GBool limitedA, Guint lengthA, Object *dictA); Goffset startA, GBool limitedA, Goffset lengthA, Object *dictA);
virtual ~PopplerInputStream(); virtual ~PopplerInputStream();
virtual BaseStream *copy(); virtual BaseStream *copy();
virtual Stream *makeSubStream(Guint start, GBool limited, virtual Stream *makeSubStream(Goffset start, GBool limited,
Guint lengthA, Object *dictA); Goffset lengthA, Object *dictA);
virtual StreamKind getKind() { return strWeird; } virtual StreamKind getKind() { return strWeird; }
virtual void reset(); virtual void reset();
virtual void close(); virtual void close();
...@@ -43,10 +43,10 @@ public: ...@@ -43,10 +43,10 @@ public:
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar() virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
virtual int getPos() { return bufPos + (bufPtr - buf); } virtual Goffset getPos() { return bufPos + (bufPtr - buf); }
virtual void setPos(Guint pos, int dir = 0); virtual void setPos(Goffset pos, int dir = 0);
virtual Guint getStart() { return start; } virtual Goffset getStart() { return start; }
virtual void moveStart(int delta); virtual void moveStart(Goffset delta);
virtual int getUnfilteredChar() { return getChar(); } virtual int getUnfilteredChar() { return getChar(); }
virtual void unfilteredReset() { reset(); } virtual void unfilteredReset() { reset(); }
...@@ -60,7 +60,7 @@ private: ...@@ -60,7 +60,7 @@ private:
GInputStream *inputStream; GInputStream *inputStream;
GCancellable *cancellable; GCancellable *cancellable;
Guint start; Goffset start;
GBool limited; GBool limited;
char buf[inputStreamBufSize]; char buf[inputStreamBufSize];
char *bufPtr; char *bufPtr;
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#ifndef GTYPES_H #ifndef GTYPES_H
#define GTYPES_H #define GTYPES_H
#include "poppler-config.h"
#include <stdio.h> // for off_t
/* /*
* These have stupid names to avoid conflicts with some (but not all) * These have stupid names to avoid conflicts with some (but not all)
* C++ compilers which define them. * C++ compilers which define them.
...@@ -45,4 +48,16 @@ typedef unsigned short Gushort; ...@@ -45,4 +48,16 @@ typedef unsigned short Gushort;
typedef unsigned int Guint; typedef unsigned int Guint;
typedef unsigned long Gulong; typedef unsigned long Gulong;
/* Define Goffset to be the offset type used by the version of
* fseek we are using.
*/
#if HAVE_FSEEKO
typedef off_t Goffset;
#elif HAVE_FSEEK64
typedef off64_t Goffset;
#else
typedef long Goffset;
#endif
#endif #endif
...@@ -341,7 +341,7 @@ void BaseCryptStream::reset() { ...@@ -341,7 +341,7 @@ void BaseCryptStream::reset() {
str->reset(); str->reset();
} }
int BaseCryptStream::getPos() { Goffset BaseCryptStream::getPos() {
return charactersRead; return charactersRead;
} }
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
virtual void reset(); virtual void reset();
virtual int getChar(); virtual int getChar();
virtual int lookChar() = 0; virtual int lookChar() = 0;
virtual int getPos(); virtual Goffset getPos();
virtual GBool isBinary(GBool last); virtual GBool isBinary(GBool last);
virtual Stream *getUndecodedStream() { return this; } virtual Stream *getUndecodedStream() { return this; }
void setAutoDelete(GBool val); void setAutoDelete(GBool val);
......
...@@ -48,17 +48,17 @@ static const char *errorCategoryNames[] = { ...@@ -48,17 +48,17 @@ static const char *errorCategoryNames[] = {
}; };
static void (*errorCbk)(void *data, ErrorCategory category, static void (*errorCbk)(void *data, ErrorCategory category,
int pos, char *msg) = NULL; Goffset pos, char *msg) = NULL;
static void *errorCbkData = NULL; static void *errorCbkData = NULL;
void setErrorCallback(void (*cbk)(void *data, ErrorCategory category, void setErrorCallback(void (*cbk)(void *data, ErrorCategory category,
int pos, char *msg), Goffset pos, char *msg),
void *data) { void *data) {
errorCbk = cbk; errorCbk = cbk;
errorCbkData = data; errorCbkData = data;
} }
void CDECL error(ErrorCategory category, int pos, const char *msg, ...) { void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...) {
va_list args; va_list args;
GooString *s, *sanitized; GooString *s, *sanitized;
...@@ -84,8 +84,8 @@ void CDECL error(ErrorCategory category, int pos, const char *msg, ...) { ...@@ -84,8 +84,8 @@ void CDECL error(ErrorCategory category, int pos, const char *msg, ...) {
(*errorCbk)(errorCbkData, category, pos, sanitized->getCString()); (*errorCbk)(errorCbkData, category, pos, sanitized->getCString());
} else { } else {
if (pos >= 0) { if (pos >= 0) {
fprintf(stderr, "%s (%d): %s\n", fprintf(stderr, "%s (%lld): %s\n",
errorCategoryNames[category], pos, sanitized->getCString()); errorCategoryNames[category], (long long)pos, sanitized->getCString());
} else { } else {
fprintf(stderr, "%s: %s\n", fprintf(stderr, "%s: %s\n",
errorCategoryNames[category], sanitized->getCString()); errorCategoryNames[category], sanitized->getCString());
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "poppler-config.h" #include "poppler-config.h"
#include "goo/gtypes.h"
enum ErrorCategory { enum ErrorCategory {
errSyntaxWarning, // PDF syntax error which can be worked around; errSyntaxWarning, // PDF syntax error which can be worked around;
...@@ -48,9 +49,9 @@ enum ErrorCategory { ...@@ -48,9 +49,9 @@ enum ErrorCategory {
}; };
extern void setErrorCallback(void (*cbk)(void *data, ErrorCategory category, extern void setErrorCallback(void (*cbk)(void *data, ErrorCategory category,
int pos, char *msg), Goffset pos, char *msg),
void *data); void *data);
extern void CDECL error(ErrorCategory category, int pos, const char *msg, ...); extern void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...);
#endif #endif
...@@ -51,7 +51,7 @@ Hints::Hints(BaseStream *str, Linearization *linearization, XRef *xref, Security ...@@ -51,7 +51,7 @@ Hints::Hints(BaseStream *str, Linearization *linearization, XRef *xref, Security
pageObjectNum = (int *) gmallocn_checkoverflow(nPages, sizeof(int)); pageObjectNum = (int *) gmallocn_checkoverflow(nPages, sizeof(int));
xRefOffset = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint)); xRefOffset = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
pageLength = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint)); pageLength = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
pageOffset = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint)); pageOffset = (Goffset *) gmallocn_checkoverflow(nPages, sizeof(Goffset));
numSharedObject = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint)); numSharedObject = (Guint *) gmallocn_checkoverflow(nPages, sizeof(Guint));
sharedObjectId = (Guint **) gmallocn_checkoverflow(nPages, sizeof(Guint*)); sharedObjectId = (Guint **) gmallocn_checkoverflow(nPages, sizeof(Guint*));
if (!nObjects || !pageObjectNum || !xRefOffset || !pageLength || !pageOffset || if (!nObjects || !pageObjectNum || !xRefOffset || !pageLength || !pageOffset ||
...@@ -344,7 +344,7 @@ void Hints::readSharedObjectsTable(Stream *str) ...@@ -344,7 +344,7 @@ void Hints::readSharedObjectsTable(Stream *str)
} }
} }
Guint Hints::getPageOffset(int page) Goffset Hints::getPageOffset(int page)
{ {
if ((page < 1) || (page > nPages)) return 0; if ((page < 1) || (page > nPages)) return 0;
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
~Hints(); ~Hints();
int getPageObjectNum(int page); int getPageObjectNum(int page);
Guint getPageOffset(int page); Goffset getPageOffset(int page);
std::vector<ByteRange>* getPageRanges(int page); std::vector<ByteRange>* getPageRanges(int page);
private: private:
...@@ -54,7 +54,7 @@ private: ...@@ -54,7 +54,7 @@ private:
int nPages; int nPages;
int pageFirst; int pageFirst;
int pageObjectFirst; int pageObjectFirst;
Guint pageOffsetFirst; Goffset pageOffsetFirst;
Guint pageEndFirst; Guint pageEndFirst;
int objectNumberFirst; int objectNumberFirst;
...@@ -76,7 +76,7 @@ private: ...@@ -76,7 +76,7 @@ private:
int *pageObjectNum; int *pageObjectNum;
Guint *xRefOffset; Guint *xRefOffset;
Guint *pageLength; Guint *pageLength;
Guint *pageOffset; Goffset *pageOffset;
Guint *numSharedObject; Guint *numSharedObject;
Guint **sharedObjectId; Guint **sharedObjectId;
......
...@@ -1284,7 +1284,7 @@ int JBIG2Stream::lookChar() { ...@@ -1284,7 +1284,7 @@ int JBIG2Stream::lookChar() {
return EOF; return EOF;
} }
int JBIG2Stream::getPos() { Goffset JBIG2Stream::getPos() {
if (pageBitmap == NULL) { if (pageBitmap == NULL) {
return 0; return 0;
} }
...@@ -1320,7 +1320,7 @@ void JBIG2Stream::readSegments() { ...@@ -1320,7 +1320,7 @@ void JBIG2Stream::readSegments() {
Guint segNum, segFlags, segType, page, segLength; Guint segNum, segFlags, segType, page, segLength;
Guint refFlags, nRefSegs; Guint refFlags, nRefSegs;
Guint *refSegs; Guint *refSegs;
int segDataPos; Goffset segDataPos;
int c1, c2, c3; int c1, c2, c3;
Guint i; Guint i;
...@@ -1483,7 +1483,7 @@ void JBIG2Stream::readSegments() { ...@@ -1483,7 +1483,7 @@ void JBIG2Stream::readSegments() {
if (segLength != 0xffffffff) { if (segLength != 0xffffffff) {
int segExtraBytes = segDataPos + segLength - curStr->getPos(); Goffset segExtraBytes = segDataPos + segLength - curStr->getPos();
if (segExtraBytes > 0) { if (segExtraBytes > 0) {
// If we didn't read all of the bytes in the segment data, // If we didn't read all of the bytes in the segment data,
...@@ -1501,7 +1501,7 @@ void JBIG2Stream::readSegments() { ...@@ -1501,7 +1501,7 @@ void JBIG2Stream::readSegments() {
// hopefully we're not doing this much // hopefully we're not doing this much
int trash; int trash;
for (int i = segExtraBytes; i > 0; i--) { for (Goffset i = segExtraBytes; i > 0; i--) {
readByte(&trash); readByte(&trash);
} }
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
virtual StreamKind getKind() { return strJBIG2; } virtual StreamKind getKind() { return strJBIG2; }
virtual void reset(); virtual void reset();
virtual void close(); virtual void close();
virtual int getPos(); virtual Goffset getPos();
virtual int getChar(); virtual int getChar();
virtual int lookChar(); virtual int lookChar();
virtual GooString *getPSFilter(int psLevel, const char *indent); virtual GooString *getPSFilter(int psLevel, const char *indent);
......
...@@ -46,7 +46,7 @@ void JPXStream::close() { ...@@ -46,7 +46,7 @@ void JPXStream::close() {
} }
} }
int JPXStream::getPos() { Goffset JPXStream::getPos() {
return counter * ncomps + ccounter; return counter * ncomps + ccounter;
} }
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
virtual StreamKind getKind() { return strJPX; } virtual StreamKind getKind() { return strJPX; }
virtual void reset(); virtual void reset();
virtual void close(); virtual void close();
virtual int getPos(); virtual Goffset getPos();
virtual int getChar(); virtual int getChar();
virtual int lookChar(); virtual int lookChar();
virtual GooString *getPSFilter(int psLevel, const char *indent); virtual GooString *getPSFilter(int psLevel, const char *indent);
......
...@@ -67,12 +67,12 @@ public: ...@@ -67,12 +67,12 @@ public:
{ return curStr.isStream() ? curStr.getStream() : (Stream *)NULL; } { return curStr.isStream() ? curStr.getStream() : (Stream *)NULL; }
// Get current position in file. This is only used for error // Get current position in file. This is only used for error
// messages, so it returns an int instead of a Guint. // messages.
int getPos() Goffset getPos()
{ return curStr.isStream() ? (int)curStr.streamGetPos() : -1; } { return curStr.isStream() ? curStr.streamGetPos() : -1; }
// Set position in file. // Set position in file.
void setPos(Guint pos, int dir = 0) void setPos(Goffset pos, int dir = 0)
{ if (curStr.isStream()) curStr.streamSetPos(pos, dir); } { if (curStr.isStream()) curStr.streamSetPos(pos, dir); }
// Returns true if <c> is a whitespace character. // Returns true if <c> is a whitespace character.
......
...@@ -234,8 +234,8 @@ public: ...@@ -234,8 +234,8 @@ public:
int streamGetChars(int nChars, Guchar *buffer); int streamGetChars(int nChars, Guchar *buffer);
int streamLookChar(); int streamLookChar();
char *streamGetLine(char *buf, int size); char *streamGetLine(char *buf, int size);
Guint streamGetPos(); Goffset streamGetPos();
void streamSetPos(Guint pos, int dir = 0); void streamSetPos(Goffset pos, int dir = 0);
Dict *streamGetDict(); Dict *streamGetDict();
// Output. // Output.
...@@ -355,10 +355,10 @@ inline int Object::streamLookChar() ...@@ -355,10 +355,10 @@ inline int Object::streamLookChar()
inline char *Object::streamGetLine(char *buf, int size) inline char *Object::streamGetLine(char *buf, int size)
{ OBJECT_TYPE_CHECK(objStream); return stream->getLine(buf, size); } { OBJECT_TYPE_CHECK(objStream); return stream->getLine(buf, size); }
inline Guint Object::streamGetPos() inline Goffset Object::streamGetPos()
{ OBJECT_TYPE_CHECK(objStream); return stream->getPos(); } { OBJECT_TYPE_CHECK(objStream); return stream->getPos(); }
inline void Object::streamSetPos(Guint pos, int dir) inline void Object::streamSetPos(Goffset pos, int dir)
{ OBJECT_TYPE_CHECK(objStream); stream->setPos(pos, dir); } { OBJECT_TYPE_CHECK(objStream); stream->setPos(pos, dir); }
inline Dict *Object::streamGetDict() inline Dict *Object::streamGetDict()
......
...@@ -117,7 +117,7 @@ void PDFDoc::init() ...@@ -117,7 +117,7 @@ void PDFDoc::init()
#ifndef DISABLE_OUTLINE #ifndef DISABLE_OUTLINE
outline = NULL; outline = NULL;
#endif #endif
startXRefPos = ~(Guint)0; startXRefPos = -1;
secHdlr = NULL; secHdlr = NULL;
pageCache = NULL; pageCache = NULL;
} }
...@@ -130,7 +130,7 @@ PDFDoc::PDFDoc() ...@@ -130,7 +130,7 @@ PDFDoc::PDFDoc()
PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword,
GooString *userPassword, void *guiDataA) { GooString *userPassword, void *guiDataA) {
Object obj; Object obj;
int size = 0; Goffset size = 0;
#ifdef _WIN32 #ifdef _WIN32
int n, i; int n, i;
#endif #endif
...@@ -369,7 +369,7 @@ PDFDoc::~PDFDoc() { ...@@ -369,7 +369,7 @@ PDFDoc::~PDFDoc() {
GBool PDFDoc::checkFooter() { GBool PDFDoc::checkFooter() {
// we look in the last 1024 chars because Adobe does the same // we look in the last 1024 chars because Adobe does the same
char *eof = new char[1025]; char *eof = new char[1025];
int pos = str->getPos(); Goffset pos = str->getPos();
str->setPos(1024, -1); str->setPos(1024, -1);
int i, ch; int i, ch;
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
...@@ -767,7 +767,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) ...@@ -767,7 +767,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo)
objectsCount++; objectsCount++;
page.free(); page.free();
Guint uxrefOffset = outStr->getPos(); Goffset uxrefOffset = outStr->getPos();
Ref ref; Ref ref;
ref.num = rootNum; ref.num = rootNum;
ref.gen = 0; ref.gen = 0;
...@@ -906,7 +906,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) ...@@ -906,7 +906,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
return; return;
} }
Guint uxrefOffset = outStr->getPos(); Goffset uxrefOffset = outStr->getPos();
int numobjects = xref->getNumObjects(); int numobjects = xref->getNumObjects();
const char *fileNameA = fileName ? fileName->getCString() : NULL; const char *fileNameA = fileName ? fileName->getCString() : NULL;
Ref rootRef, uxrefStreamRef; Ref rootRef, uxrefStreamRef;
...@@ -991,7 +991,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) ...@@ -991,7 +991,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr)
} }
} }
xref->unlock(); xref->unlock();
Guint uxrefOffset = outStr->getPos(); Goffset uxrefOffset = outStr->getPos();
writeXRefTableTrailer(uxrefOffset, uxref, gTrue /* write all entries */, writeXRefTableTrailer(uxrefOffset, uxref, gTrue /* write all entries */,
uxref->getNumObjects(), outStr, gFalse /* complete rewrite */); uxref->getNumObjects(), outStr, gFalse /* complete rewrite */);
delete uxref; delete uxref;
...@@ -1027,17 +1027,21 @@ void PDFDoc::writeRawStream (Stream* str, OutStream* outStr) ...@@ -1027,17 +1027,21 @@ void PDFDoc::writeRawStream (Stream* str, OutStream* outStr)
{ {
Object obj1; Object obj1;
str->getDict()->lookup("Length", &obj1); str->getDict()->lookup("Length", &obj1);
if (!obj1.isInt()) { if (!obj1.isInt() && !obj1.isInt64()) {
error (errSyntaxError, -1, "PDFDoc::writeRawStream, no Length in stream dict"); error (errSyntaxError, -1, "PDFDoc::writeRawStream, no Length in stream dict");
return; return;
} }
const int length = obj1.getInt(); Goffset length;
if (obj1.isInt())
length = obj1.getInt();
else
length = obj1.getInt64();
obj1.free(); obj1.free();
outStr->printf("stream\r\n"); outStr->printf("stream\r\n");
str->unfilteredReset(); str->unfilteredReset();
for (int i=0; i<length; i++) { for (Goffset i = 0; i < length; i++) {
int c = str->getUnfilteredChar(); int c = str->getUnfilteredChar();
outStr->printf("%c", c); outStr->printf("%c", c);
} }
...@@ -1103,7 +1107,7 @@ void PDFDoc::writeString (GooString* s, OutStream* outStr, Guchar *fileKey, ...@@ -1103,7 +1107,7 @@ void PDFDoc::writeString (GooString* s, OutStream* outStr, Guchar *fileKey,
Guint PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr) Guint PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr)
{ {
Guint offset = outStr->getPos(); Goffset offset = outStr->getPos();
outStr->printf("%i %i obj ", ref->num, ref->gen); outStr->printf("%i %i obj ", ref->num, ref->gen);
return offset; return offset;
} }
...@@ -1113,7 +1117,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO ...@@ -1113,7 +1117,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
{ {
Array *array; Array *array;
Object obj1; Object obj1;
int tmp; Goffset tmp;
switch (obj->getType()) { switch (obj->getType()) {
case objBool: case objBool:
...@@ -1180,7 +1184,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO ...@@ -1180,7 +1184,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
for (int c=stream->getChar(); c!=EOF; c=stream->getChar()) { for (int c=stream->getChar(); c!=EOF; c=stream->getChar()) {
tmp++; tmp++;
} }
obj1.initInt(tmp); obj1.initInt64(tmp);
stream->getDict()->set("Length", &obj1); stream->getDict()->set("Length", &obj1);
//Remove Stream encoding //Remove Stream encoding
...@@ -1197,10 +1201,10 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO ...@@ -1197,10 +1201,10 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
if (fs) { if (fs) {
BaseStream *bs = fs->getBaseStream(); BaseStream *bs = fs->getBaseStream();
if (bs) { if (bs) {
Guint streamEnd; Goffset streamEnd;
if (xRef->getStreamEnd(bs->getStart(), &streamEnd)) { if (xRef->getStreamEnd(bs->getStart(), &streamEnd)) {
Object val; Object val;
val.initInt(streamEnd - bs->getStart()); val.initInt64(streamEnd - bs->getStart());
stream->getDict()->set("Length", &val); stream->getDict()->set("Length", &val);
} }
} }
...@@ -1237,7 +1241,7 @@ void PDFDoc::writeObjectFooter (OutStream* outStr) ...@@ -1237,7 +1241,7 @@ void PDFDoc::writeObjectFooter (OutStream* outStr)
} }
Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef, Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef,
Ref *root, XRef *xRef, const char *fileName, Guint fileSize) Ref *root, XRef *xRef, const char *fileName, Goffset fileSize)
{ {
Dict *trailerDict = new Dict(xRef); Dict *trailerDict = new Dict(xRef);
Object obj1; Object obj1;
...@@ -1258,7 +1262,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef ...@@ -1258,7 +1262,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef
if (fileName) if (fileName)
message.append(fileName); message.append(fileName);
sprintf(buffer, "%i", fileSize); sprintf(buffer, "%lli", (long long)fileSize);
message.append(buffer); message.append(buffer);
//info dict -- only use text string //info dict -- only use text string
...@@ -1336,7 +1340,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef ...@@ -1336,7 +1340,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Guint startxRef
return trailerDict; return trailerDict;
} }
void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAllEntries, Guint uxrefOffset, OutStream* outStr, XRef *xRef) void<