Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <mmeeks@src.gnome.org>1999-08-19 17:57:59 (GMT)
committer Michael Meeks <mmeeks@src.gnome.org>1999-08-19 17:57:59 (GMT)
commitbf3b381529f5388bd1bda8ed8fafb247a7b8a9fc (patch)
tree23e95c805c1d878ba0bf90c68765aba383848139
parent1a49446c08faaab930d3a36bc002b566eadb1ebc (diff)
Totaly re-hash stream architecture ... again :-)
Now we can compile but not run auxiliary utils.
-rw-r--r--pdf/xpdf/ChangeLog7
-rw-r--r--pdf/xpdf/Makefile.am7
-rw-r--r--pdf/xpdf/Object.h7
-rw-r--r--pdf/xpdf/PDFDoc.cc29
-rw-r--r--pdf/xpdf/PDFDoc.h5
-rw-r--r--pdf/xpdf/Parser.cc2
-rw-r--r--pdf/xpdf/Stream.cc117
-rw-r--r--pdf/xpdf/Stream.h75
-rw-r--r--pdf/xpdf/XRef.cc21
-rw-r--r--pdf/xpdf/XRef.h11
-rw-r--r--pdf/xpdf/bonobo-image-x-pdf.cc4
-rw-r--r--pdf/xpdf/pdfimages.cc2
-rw-r--r--pdf/xpdf/pdfinfo.cc2
-rw-r--r--pdf/xpdf/pdftopbm.cc2
-rw-r--r--pdf/xpdf/pdftops.cc3
-rw-r--r--pdf/xpdf/pdftotext.cc2
16 files changed, 180 insertions, 116 deletions
diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog
index b31f44d..bc9f82c 100644
--- a/pdf/xpdf/ChangeLog
+++ b/pdf/xpdf/ChangeLog
@@ -1,3 +1,10 @@
+1999-08-19 Michael Meeks <michael@imaginator.com>
+
+ * PDFDoc.cc: Altered to read / write lines.
+
+ * PDFDoc.cc: Move FileStream::checkHeader so its called
+ in FileStream constructor.
+
1999-08-18 Michael Meeks <michael@imaginator.com>
* gpdf.cc: cloned from test-container.
diff --git a/pdf/xpdf/Makefile.am b/pdf/xpdf/Makefile.am
index 606479c..3c95d80 100644
--- a/pdf/xpdf/Makefile.am
+++ b/pdf/xpdf/Makefile.am
@@ -11,8 +11,7 @@ else
gui = xpdf
endif
-#bin_PROGRAMS = pdftops pdftotext pdfinfo pdftopbm pdfimages $(gui) bonobo-image-x-pdf
-bin_PROGRAMS = bonobo-image-x-pdf gpdf
+bin_PROGRAMS = pdftops pdftotext pdfinfo pdftopbm pdfimages $(gui) bonobo-image-x-pdf
common_sources = \
Array.cc \
@@ -57,8 +56,8 @@ gpdf_LDADD = \
bonobo_image_x_pdf_SOURCES = \
$(common_sources) \
- BonoboFile.h \
- BonoboFile.cc \
+ BonoboStream.h \
+ BonoboStream.cc \
GOutputDev.cc \
bonobo-image-x-pdf.cc
diff --git a/pdf/xpdf/Object.h b/pdf/xpdf/Object.h
index 305d28a..cb7a418 100644
--- a/pdf/xpdf/Object.h
+++ b/pdf/xpdf/Object.h
@@ -18,7 +18,6 @@
#include "gtypes.h"
#include "gmem.h"
#include "GString.h"
-#include "BaseFile.h"
class Array;
class Dict;
@@ -178,7 +177,7 @@ public:
char *streamGetLine(char *buf, int size);
int streamGetPos();
void streamSetPos(int pos);
- BaseFile streamGetFile();
+/* BaseFile streamGetFile();*/
Dict *streamGetDict();
// Output.
@@ -291,8 +290,8 @@ inline int Object::streamGetPos()
inline void Object::streamSetPos(int pos)
{ stream->setPos(pos); }
-inline BaseFile Object::streamGetFile()
- { return stream->getFile(); }
+/*inline BaseFile Object::streamGetFile()
+ { return stream->getFile(); }*/
inline Dict *Object::streamGetDict()
{ return stream->getDict(); }
diff --git a/pdf/xpdf/PDFDoc.cc b/pdf/xpdf/PDFDoc.cc
index 599ceb1..e2dcd54 100644
--- a/pdf/xpdf/PDFDoc.cc
+++ b/pdf/xpdf/PDFDoc.cc
@@ -29,33 +29,30 @@
// PDFDoc
//------------------------------------------------------------------------
-PDFDoc::PDFDoc(BaseFile file1, GString *fileName1) {
- FileStream *str;
+PDFDoc::PDFDoc(Stream *str1, GString *fileName1) {
Object catObj;
- Object obj;
// setup
ok = gFalse;
catalog = NULL;
xref = NULL;
- file = NULL;
links = NULL;
fileName = fileName1;
- file = file1;
- if (!file)
+ if (!str1)
return;
// create stream
- obj.initNull();
- str = new FileStream(file, 0, -1, &obj);
+/* obj.initNull(); */
+/* str = new FileStream(file, 0, -1, &obj); */
+ str = str1;
// check header
- str->checkHeader();
+/* str->checkHeader(); FIXME */
// read xref table
xref = new XRef(str);
- delete str;
+/* delete str; */
if (!xref->isOk()) {
error(-1, "Couldn't read xref table");
return;
@@ -79,8 +76,10 @@ PDFDoc::~PDFDoc() {
delete catalog;
if (xref)
delete xref;
- if (file)
- bfclose(file);
+ if (str) {
+ delete (str);
+ str = NULL;
+ }
if (fileName)
delete fileName;
if (links)
@@ -133,9 +132,9 @@ GBool PDFDoc::saveAs(GString *name) {
error(-1, "Couldn't open file '%s'", name->getCString());
return gFalse;
}
- brewind(file);
- while ((n = bfread(buf, 1, sizeof(buf), file)) > 0)
- fwrite(buf, 1, n, f);
+ str->reset();
+ while (str->getLine (buf, 4096))
+ fputs (buf, f);
fclose(f);
return gTrue;
}
diff --git a/pdf/xpdf/PDFDoc.h b/pdf/xpdf/PDFDoc.h
index c5a2470..f76cfaf 100644
--- a/pdf/xpdf/PDFDoc.h
+++ b/pdf/xpdf/PDFDoc.h
@@ -15,7 +15,6 @@
#include <stdio.h>
#include "Link.h"
-#include "BaseFile.h"
class GString;
class XRef;
@@ -32,7 +31,7 @@ class LinkDest;
class PDFDoc {
public:
- PDFDoc(BaseFile file, GString *fileName1);
+ PDFDoc(Stream *str1, GString *fileName1);
~PDFDoc();
// Was PDF document successfully opened?
@@ -97,7 +96,7 @@ private:
void getLinks(int page);
GString *fileName;
- BaseFile file;
+ Stream *str;
XRef *xref;
Catalog *catalog;
Links *links;
diff --git a/pdf/xpdf/Parser.cc b/pdf/xpdf/Parser.cc
index 49968f3..0b61002 100644
--- a/pdf/xpdf/Parser.cc
+++ b/pdf/xpdf/Parser.cc
@@ -126,7 +126,7 @@ Stream *Parser::makeStream(Object *dict) {
}
// make base stream
- str = new FileStream(lexer->getStream()->getFile(), pos, length, dict);
+ str = lexer->getStream()->subStream (pos, length, dict);
// get filters
str = str->addFilters(dict);
diff --git a/pdf/xpdf/Stream.cc b/pdf/xpdf/Stream.cc
index 6e52d79..c15d517 100644
--- a/pdf/xpdf/Stream.cc
+++ b/pdf/xpdf/Stream.cc
@@ -511,8 +511,76 @@ GBool StreamPredictor::getNextLine() {
// FileStream
//------------------------------------------------------------------------
-FileStream::FileStream(BaseFile f1, int start1, int length1, Object *dict1) {
+GBool FileStream::checkHeader() {
+ char hdrBuf[headerSearchSize+1];
+ char *p;
+ double version;
+ int i;
+
+ for (i = 0; i < headerSearchSize; ++i)
+ hdrBuf[i] = getChar();
+ hdrBuf[headerSearchSize] = '\0';
+ for (i = 0; i < headerSearchSize - 5; ++i) {
+ if (!strncmp(&hdrBuf[i], "%PDF-", 5))
+ break;
+ }
+ if (i >= headerSearchSize - 5) {
+ error(-1, "May not be a PDF file (continuing anyway)");
+ return gFalse;
+ }
+ start += i;
+ p = strtok(&hdrBuf[i+5], " \t\n\r");
+ version = atof(p);
+ if (!(hdrBuf[i+5] >= '0' && hdrBuf[i+5] <= '9') ||
+ version > pdfVersionNum + 0.0001) {
+ error(getPos(), "PDF version %s -- xpdf supports version %s"
+ " (continuing anyway)", p, pdfVersion);
+ return gFalse;
+ }
+ return gTrue;
+}
+
+FILE *fileOpen (GString *fileName1) {
+ GString *fileName2;
+ // try to open file
+ fileName2 = NULL;
+ FILE *file;
+
+#ifdef VMS
+ if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) {
+ error(-1, "Couldn't open file '%s'", fileName->getCString());
+ return NULL;
+ }
+#else
+ if (!(file = fopen(fileName1->getCString(), "rb"))) {
+ fileName2 = fileName1->copy();
+ fileName2->lowerCase();
+ if (!(file = fopen(fileName2->getCString(), "rb"))) {
+ fileName2->upperCase();
+ if (!(file = fopen(fileName2->getCString(), "rb"))) {
+ error(-1, "Couldn't open file '%s'", fileName1->getCString());
+ delete fileName2;
+ return NULL;
+ }
+ }
+ delete fileName2;
+ }
+#endif
+ return file;
+}
+
+FileStream::FileStream(FILE *f1) {
f = f1;
+ start = 0;
+ length = -1;
+ bufPtr = bufEnd = buf;
+ bufPos = start;
+ savePos = -1;
+ dict.initNull();
+ checkHeader();
+}
+
+Stream *FileStream::subStream (int start1, int length1, Object *dict1) {
start = start1;
length = length1;
bufPtr = bufEnd = buf;
@@ -523,13 +591,13 @@ FileStream::FileStream(BaseFile f1, int start1, int length1, Object *dict1) {
FileStream::~FileStream() {
if (savePos >= 0)
- bfseek(f, savePos, SEEK_SET);
+ fseek(f, savePos, SEEK_SET);
dict.free();
}
void FileStream::reset() {
- savePos = (int)bftell(f);
- bfseek(f, start, SEEK_SET);
+ savePos = (int)ftell(f);
+ fseek(f, start, SEEK_SET);
bufPtr = bufEnd = buf;
bufPos = start;
}
@@ -545,7 +613,7 @@ GBool FileStream::fillBuf() {
n = start + length - bufPos;
else
n = 256;
- n = bfread(buf, 1, n, f);
+ n = fread(buf, 1, n, f);
bufEnd = buf + n;
if (bufPtr >= bufEnd)
return gFalse;
@@ -556,48 +624,19 @@ void FileStream::setPos(int pos1) {
long size;
if (pos1 >= 0) {
- bfseek(f, pos1, SEEK_SET);
+ fseek(f, pos1, SEEK_SET);
bufPos = pos1;
} else {
- bfseek(f, 0, SEEK_END);
- size = bftell(f);
+ fseek(f, 0, SEEK_END);
+ size = ftell(f);
if (pos1 < -size)
pos1 = (int)(-size);
- bfseek(f, pos1, SEEK_END);
- bufPos = (int)bftell(f);
+ fseek(f, pos1, SEEK_END);
+ bufPos = (int)ftell(f);
}
bufPtr = bufEnd = buf;
}
-GBool FileStream::checkHeader() {
- char hdrBuf[headerSearchSize+1];
- char *p;
- double version;
- int i;
-
- for (i = 0; i < headerSearchSize; ++i)
- hdrBuf[i] = getChar();
- hdrBuf[headerSearchSize] = '\0';
- for (i = 0; i < headerSearchSize - 5; ++i) {
- if (!strncmp(&hdrBuf[i], "%PDF-", 5))
- break;
- }
- if (i >= headerSearchSize - 5) {
- error(-1, "May not be a PDF file (continuing anyway)");
- return gFalse;
- }
- start += i;
- p = strtok(&hdrBuf[i+5], " \t\n\r");
- version = atof(p);
- if (!(hdrBuf[i+5] >= '0' && hdrBuf[i+5] <= '9') ||
- version > pdfVersionNum + 0.0001) {
- error(getPos(), "PDF version %s -- xpdf supports version %s"
- " (continuing anyway)", p, pdfVersion);
- return gFalse;
- }
- return gTrue;
-}
-
//------------------------------------------------------------------------
// SubStream
//------------------------------------------------------------------------
diff --git a/pdf/xpdf/Stream.h b/pdf/xpdf/Stream.h
index 14e68ea..06af0d7 100644
--- a/pdf/xpdf/Stream.h
+++ b/pdf/xpdf/Stream.h
@@ -16,7 +16,6 @@
#include <stdio.h>
#include "gtypes.h"
#include "Object.h"
-#include "BaseFile.h"
//------------------------------------------------------------------------
@@ -83,8 +82,11 @@ public:
// Get the base FileStream or SubStream of this stream.
virtual Stream *getBaseStream() = 0;
- // Get the base file of this stream.
- virtual BaseFile getFile() = 0;
+ // Get a substream of this stream.
+ virtual Stream *subStream (int start1, int length1, Object *dict1) = 0;
+
+ // Get start offset of a stream's data.
+ virtual int getStart () = 0;
// Get the dictionary associated with this stream.
virtual Dict *getDict() = 0;
@@ -175,10 +177,12 @@ private:
// FileStream
//------------------------------------------------------------------------
+// Portable pdf open helper function.
+extern FILE *fileOpen (GString *fileName1);
+
class FileStream: public Stream {
public:
-
- FileStream(BaseFile f1, int start1, int length1, Object *dict1);
+ FileStream(FILE *f1);
virtual ~FileStream();
virtual StreamKind getKind() { return strFile; }
virtual void reset();
@@ -190,21 +194,16 @@ public:
virtual void setPos(int pos1);
virtual GBool isBinary(GBool last = gTrue) { return last; }
virtual Stream *getBaseStream() { return this; }
- virtual BaseFile getFile() { return f; }
+ virtual Stream *subStream (int start1, int length1, Object *dict1);
+ virtual int getStart () { return start; }
virtual Dict *getDict() { return dict.getDict(); }
- // Check for a PDF header on this stream. Skip past some garbage
- // if necessary.
- GBool checkHeader();
-
- // Get position of first byte of stream within the file.
- int getStart() { return start; }
-
private:
GBool fillBuf();
+ GBool checkHeader();
- BaseFile f;
+ FILE *f;
int start;
int length;
char buf[256];
@@ -231,7 +230,9 @@ public:
virtual int getPos() { return str->getPos(); }
virtual GBool isBinary(GBool last = gTrue) { return last; }
virtual Stream *getBaseStream() { return this; }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return dict.getDict(); }
private:
@@ -258,7 +259,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -286,7 +289,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -317,7 +322,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -359,7 +366,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -395,7 +404,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -462,7 +473,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
Stream *getRawStream() { return str; }
@@ -553,7 +566,9 @@ public:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -607,7 +622,9 @@ public:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
private:
@@ -632,7 +649,9 @@ public:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
@@ -662,7 +681,9 @@ public:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
@@ -697,7 +718,9 @@ public:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual BaseFile getFile() { return str->getFile(); }
+ virtual Stream *subStream (int start1, int length1, Object *dict1)
+ { return str->subStream (start1, length1, dict1); }
+ virtual int getStart () { return str->getStart (); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
diff --git a/pdf/xpdf/XRef.cc b/pdf/xpdf/XRef.cc
index cc9bee8..c725a4a 100644
--- a/pdf/xpdf/XRef.cc
+++ b/pdf/xpdf/XRef.cc
@@ -38,7 +38,7 @@ XRef *xref = NULL;
// XRef
//------------------------------------------------------------------------
-XRef::XRef(FileStream *str) {
+XRef::XRef(Stream *str1) {
XRef *oldXref;
int pos;
int i;
@@ -53,7 +53,7 @@ XRef::XRef(FileStream *str) {
xref = NULL;
// read the trailer
- file = str->getFile();
+ str = str1;
start = str->getStart();
pos = readTrailer(str);
@@ -105,7 +105,7 @@ XRef::~XRef() {
// Read startxref position, xref table size, and root. Returns
// first xref position.
-int XRef::readTrailer(FileStream *str) {
+int XRef::readTrailer(Stream *str) {
Parser *parser;
Object obj;
char buf[xrefSearchSize+1];
@@ -166,7 +166,7 @@ int XRef::readTrailer(FileStream *str) {
// read trailer dict
obj.initNull();
- parser = new Parser(new Lexer(new FileStream(file, start + pos1, -1, &obj)));
+ parser = new Parser(new Lexer(str->subStream (start + pos1, -1, &obj)));
parser->getObj(&trailerDict);
if (trailerDict.isDict()) {
trailerDict.dictLookupNF("Size", &obj);
@@ -193,7 +193,7 @@ int XRef::readTrailer(FileStream *str) {
}
// Read an xref table and the prev pointer from the trailer.
-GBool XRef::readXRef(FileStream *str, int *pos) {
+GBool XRef::readXRef(Stream *str, int *pos) {
Parser *parser;
Object obj, obj2;
char s[20];
@@ -258,8 +258,7 @@ GBool XRef::readXRef(FileStream *str, int *pos) {
// read prev pointer from trailer dictionary
obj.initNull();
- parser = new Parser(new Lexer(
- new FileStream(file, str->getPos(), -1, &obj)));
+ parser = new Parser(new Lexer(str->subStream (str->getPos(), -1, &obj)));
parser->getObj(&obj);
if (!obj.isCmd("trailer"))
goto err1;
@@ -288,7 +287,7 @@ GBool XRef::readXRef(FileStream *str, int *pos) {
}
// Attempt to construct an xref table for a damaged file.
-GBool XRef::constructXRef(FileStream *str) {
+GBool XRef::constructXRef(Stream *str) {
Parser *parser;
Object obj;
char buf[256];
@@ -312,8 +311,7 @@ GBool XRef::constructXRef(FileStream *str) {
// got trailer dictionary
if (!strncmp(p, "trailer", 7)) {
obj.initNull();
- parser = new Parser(new Lexer(
- new FileStream(file, start + pos + 8, -1, &obj)));
+ parser = new Parser(new Lexer(str->subStream(start + pos + 8, -1, &obj)));
if (!trailerDict.isNone())
trailerDict.free();
parser->getObj(&trailerDict);
@@ -416,8 +414,7 @@ Object *XRef::fetch(int num, int gen, Object *obj) {
e = &entries[num];
if (e->gen == gen && e->offset >= 0) {
obj1.initNull();
- parser = new Parser(new Lexer(
- new FileStream(file, start + e->offset, -1, &obj1)));
+ parser = new Parser(new Lexer(str->subStream(start + e->offset, -1, &obj1)));
parser->getObj(&obj1);
parser->getObj(&obj2);
parser->getObj(&obj3);
diff --git a/pdf/xpdf/XRef.h b/pdf/xpdf/XRef.h
index e8874c7..7ef411d 100644
--- a/pdf/xpdf/XRef.h
+++ b/pdf/xpdf/XRef.h
@@ -16,7 +16,6 @@
#include <stdio.h>
#include "gtypes.h"
#include "Object.h"
-#include "BaseFile.h"
class Dict;
class FileStream;
@@ -35,7 +34,7 @@ class XRef {
public:
// Constructor. Read xref table from stream.
- XRef(FileStream *str);
+ XRef(Stream *str);
// Destructor.
~XRef();
@@ -61,7 +60,7 @@ public:
private:
- BaseFile file; // input file
+ Stream *str; // input file
int start; // offset in file (to allow for garbage
// at beginning of file)
XRefEntry *entries; // xref entries
@@ -70,9 +69,9 @@ private:
GBool ok; // true if xref table is valid
Object trailerDict; // trailer dictionary
- int readTrailer(FileStream *str);
- GBool readXRef(FileStream *str, int *pos);
- GBool constructXRef(FileStream *str);
+ int readTrailer(Stream *str);
+ GBool readXRef(Stream *str, int *pos);
+ GBool constructXRef(Stream *str);
GBool checkEncrypted();
};
diff --git a/pdf/xpdf/bonobo-image-x-pdf.cc b/pdf/xpdf/bonobo-image-x-pdf.cc
index 4cb8b1d..a7ac11a 100644
--- a/pdf/xpdf/bonobo-image-x-pdf.cc
+++ b/pdf/xpdf/bonobo-image-x-pdf.cc
@@ -37,6 +37,7 @@ extern "C" {
#include "Params.h"
#include "Error.h"
#include "config.h"
+#include "BonoboStream.h"
GBool printCommands = gFalse;
@@ -214,7 +215,8 @@ load_image_from_stream (GnomePersistStream *ps, GNOME_Stream stream, void *data)
printf ("Loading PDF from persiststream\n");
bonobo_object_data->stream = stream;
- bonobo_object_data->pdf = new PDFDoc (stream, new GString ("Bonobo.pdf"));
+ bonobo_object_data->pdf = new PDFDoc (new BonoboStream (stream),
+ new GString ("Bonobo.pdf"));
printf ("Done load\n");
if (!(bonobo_object_data->pdf->isOk())) {
g_warning ("Duff pdf data\n");
diff --git a/pdf/xpdf/pdfimages.cc b/pdf/xpdf/pdfimages.cc
index 9d7a484..3742249 100644
--- a/pdf/xpdf/pdfimages.cc
+++ b/pdf/xpdf/pdfimages.cc
@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
// open PDF fihe
xref = NULL;
- doc = new PDFDoc(bxpdfopen(fileName), fileName);
+ doc = new PDFDoc(new FileStream(fileOpen(fileName)), fileName);
if (!doc->isOk()) {
goto err1;
}
diff --git a/pdf/xpdf/pdfinfo.cc b/pdf/xpdf/pdfinfo.cc
index 78664aa..510e12e 100644
--- a/pdf/xpdf/pdfinfo.cc
+++ b/pdf/xpdf/pdfinfo.cc
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
// open PDF file
xref = NULL;
- doc = new PDFDoc(bxpdfopen(fileName), fileName);
+ doc = new PDFDoc(new FileStream(fileOpen(fileName)), fileName);
if (!doc->isOk())
exit(1);
diff --git a/pdf/xpdf/pdftopbm.cc b/pdf/xpdf/pdftopbm.cc
index 51adb49..c77130e 100644
--- a/pdf/xpdf/pdftopbm.cc
+++ b/pdf/xpdf/pdftopbm.cc
@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
// open PDF file
xref = NULL;
- doc = new PDFDoc(bxpdfopen(fileName), fileName);
+ doc = new PDFDoc(new FileStream (fileOpen (fileName)), fileName);
if (!doc->isOk())
exit(1);
diff --git a/pdf/xpdf/pdftops.cc b/pdf/xpdf/pdftops.cc
index d79681e..07dca22 100644
--- a/pdf/xpdf/pdftops.cc
+++ b/pdf/xpdf/pdftops.cc
@@ -61,6 +61,7 @@ int main(int argc, char *argv[]) {
PDFDoc *doc;
GString *fileName;
GString *psFileName;
+ FILE *file;
PSOutputDev *psOut;
GBool ok;
char *p;
@@ -87,7 +88,7 @@ int main(int argc, char *argv[]) {
// open PDF file
xref = NULL;
- doc = new PDFDoc(bxpdfopen(fileName), fileName);
+ doc = new PDFDoc(new FileStream (fileOpen (fileName)), fileName);
if (!doc->isOk()) {
goto err1;
}
diff --git a/pdf/xpdf/pdftotext.cc b/pdf/xpdf/pdftotext.cc
index f0b2b3a..95ae832 100644
--- a/pdf/xpdf/pdftotext.cc
+++ b/pdf/xpdf/pdftotext.cc
@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
// open PDF file
xref = NULL;
- doc = new PDFDoc(bxpdfopen(fileName), fileName);
+ doc = new PDFDoc(new FileStream (fileOpen(fileName)), fileName);
if (!doc->isOk()) {
goto err1;
}