New cleaner xpdf IO code.
use make bonobo-image-x-pdf in xpdf to compile.
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4a from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PTHREAD_LIB = @PTHREAD_LIB@
RANLIB = @RANLIB@
STRIP = @STRIP@
+USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
XPM_LIBS = @XPM_LIBS@
YACC = @YACC@
ZVT_LIBS = @ZVT_LIBS@
cflags_set = @cflags_set@
cxxflags_set = @cxxflags_set@
-t1_CFLAGS = @t1_CFLAGS@
-t1_LIBS = @t1_LIBS@
-t1x_CFLAGS = @t1x_CFLAGS@
-t1x_LIBS = @t1x_LIBS@
lib_LIBRARIES = libgoo.a
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/GString.P .deps/gfile.P .deps/gmem.P .deps/gmempp.P \
.deps/parseargs.P
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
all-am: Makefile $(LIBRARIES)
all-redirect: all-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir)
+1999-08-15 Michael Meeks <michael@imaginator.com>
+
+ * Now bonobo-image-x-pdf works, but everything else
+ is broken: use
+
+ make bonobo-image-xpdf to compile...
+
1999-08-11 Michael Meeks <michael@imaginator.com>
* bonobo-image-x-pdf.cc: Fixed innumerable bugs,
bin_PROGRAMS = pdftops pdftotext pdfinfo pdftopbm pdfimages $(gui) bonobo-image-x-pdf
-common_sources = \
+common_sources = \
Array.cc \
+ BaseFile.h \
Catalog.cc \
Dict.cc \
Error.cc \
bonobo_image_x_pdf_SOURCES = \
$(common_sources) \
+ BonoboFile.h \
+ BonoboFile.cc \
GOutputDev.cc \
bonobo-image-x-pdf.cc
+bonobo_image_x_pdf_CFLAGS = \
+ -DBONOBO_IO
+
bonobo_image_x_pdf_LDADD = \
../goo/libgoo.a \
$(GTK_LIBS) \
bin_PROGRAMS = pdftops pdftotext pdfinfo pdftopbm pdfimages $(gui) bonobo-image-x-pdf
-common_sources = Array.cc Catalog.cc Dict.cc Error.cc FontEncoding.cc FontEncoding.h FontFile.cc FontFile.h FontInfo.h Gfx.cc GfxFont.cc GfxState.cc Lexer.cc Link.cc Object.cc OutputDev.cc Page.cc Params.cc Parser.cc PDFDoc.cc Stream.cc TextOutputDev.cc XRef.cc
+common_sources = Array.cc BaseFile.h Catalog.cc Dict.cc Error.cc FontEncoding.cc FontEncoding.h FontFile.cc FontFile.h FontInfo.h Gfx.cc GfxFont.cc GfxState.cc Lexer.cc Link.cc Object.cc OutputDev.cc Page.cc Params.cc Parser.cc PDFDoc.cc Stream.cc TextOutputDev.cc XRef.cc
gpdf_CFLAGS =
gpdf_LDADD = $(EXTRA_GNOME_LIBS) ../goo/libgoo.a
-bonobo_image_x_pdf_SOURCES = $(common_sources) GOutputDev.cc bonobo-image-x-pdf.cc
+bonobo_image_x_pdf_SOURCES = $(common_sources) BonoboFile.h BonoboFile.cc GOutputDev.cc bonobo-image-x-pdf.cc
+
+
+bonobo_image_x_pdf_CFLAGS = -DBONOBO_IO
bonobo_image_x_pdf_LDADD = ../goo/libgoo.a $(GTK_LIBS) $(GNOME_LIBDIR) -lbonobo $(GNOMEGNORBA_LIBS) $(INTLLIBS)
bonobo_image_x_pdf_OBJECTS = Array.o Catalog.o Dict.o Error.o \
FontEncoding.o FontFile.o Gfx.o GfxFont.o GfxState.o Lexer.o Link.o \
Object.o OutputDev.o Page.o Params.o Parser.o PDFDoc.o Stream.o \
-TextOutputDev.o XRef.o GOutputDev.o bonobo-image-x-pdf.o
+TextOutputDev.o XRef.o BonoboFile.o GOutputDev.o bonobo-image-x-pdf.o
bonobo_image_x_pdf_DEPENDENCIES = ../goo/libgoo.a
bonobo_image_x_pdf_LDFLAGS =
CXXFLAGS = @CXXFLAGS@
TAR = gtar
GZIP_ENV = --best
-DEP_FILES = .deps/Array.P .deps/Catalog.P .deps/Dict.P .deps/Error.P \
-.deps/FontEncoding.P .deps/FontFile.P .deps/GOutputDev.P .deps/Gfx.P \
-.deps/GfxFont.P .deps/GfxState.P .deps/ImageOutputDev.P \
-.deps/LTKOutputDev.P .deps/Lexer.P .deps/Link.P .deps/Object.P \
-.deps/OutputDev.P .deps/PBMOutputDev.P .deps/PDFDoc.P \
+DEP_FILES = .deps/Array.P .deps/BonoboFile.P .deps/Catalog.P \
+.deps/Dict.P .deps/Error.P .deps/FontEncoding.P .deps/FontFile.P \
+.deps/GOutputDev.P .deps/Gfx.P .deps/GfxFont.P .deps/GfxState.P \
+.deps/ImageOutputDev.P .deps/LTKOutputDev.P .deps/Lexer.P .deps/Link.P \
+.deps/Object.P .deps/OutputDev.P .deps/PBMOutputDev.P .deps/PDFDoc.P \
.deps/PSOutputDev.P .deps/Page.P .deps/Params.P .deps/Parser.P \
.deps/Stream.P .deps/TextOutputDev.P .deps/XOutputDev.P .deps/XRef.P \
.deps/bonobo-image-x-pdf.P .deps/gpdf.P .deps/pdfimages.P \
#include "gtypes.h"
#include "gmem.h"
#include "GString.h"
+#include "BaseFile.h"
class Array;
class Dict;
char *streamGetLine(char *buf, int size);
int streamGetPos();
void streamSetPos(int pos);
- FILE *streamGetFile();
+ BaseFile streamGetFile();
Dict *streamGetDict();
// Output.
inline void Object::streamSetPos(int pos)
{ stream->setPos(pos); }
-inline FILE *Object::streamGetFile()
+inline BaseFile Object::streamGetFile()
{ return stream->getFile(); }
inline Dict *Object::streamGetDict()
// PDFDoc
//------------------------------------------------------------------------
-PDFDoc::PDFDoc(GString *fileName1) {
+PDFDoc::PDFDoc(BaseFile file1, GString *fileName1) {
FileStream *str;
Object catObj;
Object obj;
- GString *fileName2;
// setup
ok = gFalse;
file = NULL;
links = NULL;
- // try to open file
fileName = fileName1;
- fileName2 = NULL;
-#ifdef VMS
- if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) {
- error(-1, "Couldn't open file '%s'", fileName->getCString());
+ file = file1;
+ if (!file)
return;
- }
-#else
- if (!(file = fopen(fileName->getCString(), "rb"))) {
- fileName2 = fileName->copy();
- fileName2->lowerCase();
- if (!(file = fopen(fileName2->getCString(), "rb"))) {
- fileName2->upperCase();
- if (!(file = fopen(fileName2->getCString(), "rb"))) {
- error(-1, "Couldn't open file '%s'", fileName->getCString());
- delete fileName2;
- return;
- }
- }
- delete fileName2;
- }
-#endif
// create stream
obj.initNull();
- str = new FileStream(file, 0, -1, &obj);
+ str = new FileStream(file, 0, -1, &obj);
// check header
str->checkHeader();
if (xref)
delete xref;
if (file)
- fclose(file);
+ bfclose(file);
if (fileName)
delete fileName;
if (links)
error(-1, "Couldn't open file '%s'", name->getCString());
return gFalse;
}
- rewind(file);
- while ((n = fread(buf, 1, sizeof(buf), file)) > 0)
+ brewind(file);
+ while ((n = bfread(buf, 1, sizeof(buf), file)) > 0)
fwrite(buf, 1, n, f);
fclose(f);
return gTrue;
#include <stdio.h>
#include "Link.h"
+#include "BaseFile.h"
class GString;
class XRef;
class PDFDoc {
public:
- PDFDoc(GString *fileName1);
+ PDFDoc(BaseFile file, GString *fileName1);
~PDFDoc();
// Was PDF document successfully opened?
void getLinks(int page);
GString *fileName;
- FILE *file;
+ BaseFile file;
XRef *xref;
Catalog *catalog;
Links *links;
// FileStream
//------------------------------------------------------------------------
-FileStream::FileStream(FILE *f1, int start1, int length1, Object *dict1) {
+FileStream::FileStream(BaseFile f1, int start1, int length1, Object *dict1) {
f = f1;
start = start1;
length = length1;
FileStream::~FileStream() {
if (savePos >= 0)
- fseek(f, savePos, SEEK_SET);
+ bfseek(f, savePos, SEEK_SET);
dict.free();
}
void FileStream::reset() {
- savePos = (int)ftell(f);
- fseek(f, start, SEEK_SET);
+ savePos = (int)bftell(f);
+ bfseek(f, start, SEEK_SET);
bufPtr = bufEnd = buf;
bufPos = start;
}
n = start + length - bufPos;
else
n = 256;
- n = fread(buf, 1, n, f);
+ n = bfread(buf, 1, n, f);
bufEnd = buf + n;
if (bufPtr >= bufEnd)
return gFalse;
long size;
if (pos1 >= 0) {
- fseek(f, pos1, SEEK_SET);
+ bfseek(f, pos1, SEEK_SET);
bufPos = pos1;
} else {
- fseek(f, 0, SEEK_END);
- size = ftell(f);
+ bfseek(f, 0, SEEK_END);
+ size = bftell(f);
if (pos1 < -size)
pos1 = (int)(-size);
- fseek(f, pos1, SEEK_END);
- bufPos = (int)ftell(f);
+ bfseek(f, pos1, SEEK_END);
+ bufPos = (int)bftell(f);
}
bufPtr = bufEnd = buf;
}
#include <stdio.h>
#include "gtypes.h"
#include "Object.h"
+#include "BaseFile.h"
//------------------------------------------------------------------------
virtual Stream *getBaseStream() = 0;
// Get the base file of this stream.
- virtual FILE *getFile() = 0;
+ virtual BaseFile getFile() = 0;
// Get the dictionary associated with this stream.
virtual Dict *getDict() = 0;
class FileStream: public Stream {
public:
- FileStream(FILE *f1, int start1, int length1, Object *dict1);
+ FileStream(BaseFile f1, int start1, int length1, Object *dict1);
virtual ~FileStream();
virtual StreamKind getKind() { return strFile; }
virtual void reset();
virtual void setPos(int pos1);
virtual GBool isBinary(GBool last = gTrue) { return last; }
virtual Stream *getBaseStream() { return this; }
- virtual FILE *getFile() { return f; }
+ virtual BaseFile getFile() { return f; }
virtual Dict *getDict() { return dict.getDict(); }
// Check for a PDF header on this stream. Skip past some garbage
GBool fillBuf();
- FILE *f;
+ BaseFile f;
int start;
int length;
char buf[256];
virtual int getPos() { return str->getPos(); }
virtual GBool isBinary(GBool last = gTrue) { return last; }
virtual Stream *getBaseStream() { return this; }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return dict.getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
Stream *getRawStream() { return str; }
virtual GString *getPSFilter(char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
private:
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
virtual GString *getPSFilter(char *indent) { return NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual Stream *getBaseStream() { return str->getBaseStream(); }
- virtual FILE *getFile() { return str->getFile(); }
+ virtual BaseFile getFile() { return str->getFile(); }
virtual Dict *getDict() { return str->getDict(); }
virtual GBool isEncoder() { return gTrue; }
#include <stdio.h>
#include "gtypes.h"
#include "Object.h"
+#include "BaseFile.h"
class Dict;
class FileStream;
private:
- FILE *file; // input file
+ BaseFile file; // input file
int start; // offset in file (to allow for garbage
// at beginning of file)
XRefEntry *entries; // xref entries
typedef struct {
GnomeEmbeddable *bonobo_object;
- PDFDoc *pdf;
+ PDFDoc *pdf;
+ GNOME_Stream stream; /* To free it later */
GList *views;
} bonobo_object_data_t;
load_image_from_stream (GnomePersistStream *ps, GNOME_Stream stream, void *data)
{
bonobo_object_data_t *bonobo_object_data = (bonobo_object_data_t *)data;
- CORBA_Environment ev;
CORBA_long length;
GNOME_Stream_iobuf *buffer;
guint lp;
FILE *hack;
char *name;
- buffer = GNOME_Stream_iobuf__alloc ();
+ if (bonobo_object_data->pdf ||
+ bonobo_object_data->stream) {
+ g_warning ("Won't overwrite pre-existing stream: you wierdo");
+ return 0;
+ }
+
+ /* We need this for later */
+ CORBA_Object_duplicate (stream, &ev);
+ g_return_val_if_fail (ev._major == CORBA_NO_EXCEPTION, 0);
+
+/* buffer = GNOME_Stream_iobuf__alloc ();
length = GNOME_Stream_length (stream, &ev);
name = tempnam (NULL, "xpdf-hack");
fclose (hack);
- CORBA_free (buffer);
+ CORBA_free (buffer);*/
- bonobo_object_data->pdf = new PDFDoc (new GString (name));
+ printf ("Loading PDF from persiststream\n");
+ bonobo_object_data->stream = stream;
+ bonobo_object_data->pdf = new PDFDoc (stream, new GString ("Bonobo.pdf"));
+ printf ("Done load\n");
if (!(bonobo_object_data->pdf->isOk())) {
g_warning ("Duff pdf data\n");
delete bonobo_object_data->pdf;
getPDF (GString *fname)
{
PDFDoc *pdf;
- pdf = new PDFDoc(fname);
+ BaseFile *file;
+
+ pdf = new PDFDoc(bxpdfopen(fname), fname);
if (!pdf->isOk()) {
delete pdf;
return NULL;
// open PDF fihe
xref = NULL;
- doc = new PDFDoc(fileName);
+ doc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!doc->isOk()) {
goto err1;
}
// open PDF file
xref = NULL;
- doc = new PDFDoc(fileName);
+ doc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!doc->isOk())
exit(1);
// open PDF file
xref = NULL;
- doc = new PDFDoc(fileName);
+ doc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!doc->isOk())
exit(1);
// open PDF file
xref = NULL;
- doc = new PDFDoc(fileName);
+ doc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!doc->isOk()) {
goto err1;
}
// open PDF file
xref = NULL;
- doc = new PDFDoc(fileName);
+ doc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!doc->isOk()) {
goto err1;
}
win->setBusyCursor(gTrue);
// open PDF file
- newDoc = new PDFDoc(fileName);
+ newDoc = new PDFDoc(bxpdfopen(fileName), fileName);
if (!newDoc->isOk()) {
delete newDoc;
if (win)