diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-05-06 08:19:56 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-05-06 08:19:56 +0000 |
commit | 72351c3e68ec7574a578bd41f7a0b17578d857af (patch) | |
tree | 84f9dfe9627578aee454107602231168c950cc83 /Build/source/texk/web2c/pdftexdir | |
parent | f4c2f03b11aecc0d90f836edfd44da8bd24e1bd8 (diff) |
support libpoppler as 'system-xpdf'
git-svn-id: svn://tug.org/texlive/trunk@12943 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/pdftexdir')
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/pdftoepdf.cc | 12 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/pdftosrc.cc | 212 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/utils.c | 11 |
4 files changed, 238 insertions, 3 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index b60cc4965a3..07175b9784b 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,9 @@ +2009-05-05 Peter Breitenlohner <peb@mppmu.mpg.de> + + * pdftoepdf.cc, pdftosrc.cc, utils.c: adapt for poppler. + + patches from Norbert Preinig <preining@logic.at> + 2009-02-18 Peter Breitenlohner <peb@mppmu.mpg.de> * pdftoepdf.cc: Uninclude <config.h>, included later by "epdf.h". diff --git a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc index 87684a39dc2..25f42ccbf58 100644 --- a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc +++ b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc @@ -18,17 +18,27 @@ with pdfTeX; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <aconf.h> #include <stdlib.h> #include <math.h> #include <stddef.h> #include <stdio.h> #include <string.h> #include <ctype.h> + +#ifdef POPPLER_VERSION +#include <dirent.h> +#include <poppler-config.h> +#include <goo/GooString.h> +#include <goo/gmem.h> +#include <goo/gfile.h> +#define GString GooString +#else +#include <aconf.h> #include <GString.h> #include <gmem.h> #include <gfile.h> #include <assert.h> +#endif #include "Object.h" #include "Stream.h" #include "Array.h" diff --git a/Build/source/texk/web2c/pdftexdir/pdftosrc.cc b/Build/source/texk/web2c/pdftexdir/pdftosrc.cc index 014c4da7a64..c1334bed373 100644 --- a/Build/source/texk/web2c/pdftexdir/pdftosrc.cc +++ b/Build/source/texk/web2c/pdftexdir/pdftosrc.cc @@ -23,16 +23,228 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include <stdio.h> #include <string.h> #include <ctype.h> + +#ifdef POPPLER_VERSION +#define GString GooString +#define xpdfVersion POPPLER_VERSION +#include <dirent.h> +#include <goo/GooString.h> +#include <goo/gmem.h> +#include <goo/gfile.h> +#else #include <aconf.h> #include <assert.h> #include <GString.h> #include <gmem.h> #include <gfile.h> +#endif + #include "Object.h" #include "Stream.h" #include "Array.h" #include "Dict.h" +#ifdef POPPLER_VERSION +// here we include a fixed version of XRef.h + +//======================================================================== +// +// XRef.h +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> +// Copyright (C) 2006, 2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org> +// Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef XREF_H +#define XREF_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "goo/gtypes.h" +#include "Object.h" + +class Dict; +class Stream; +class Parser; + +class ObjectStream { +public: + + // Create an object stream, using object number <objStrNum>, + // generation 0. + ObjectStream(XRef *xref, int objStrNumA); + + ~ObjectStream(); + + // Return the object number of this object stream. + int getObjStrNum() { return objStrNum; } + + // Get the <objIdx>th object from this stream, which should be + // object number <objNum>, generation 0. + Object *getObject(int objIdx, int objNum, Object *obj); + + int *getOffsets() { return offsets; } + Guint getFirstOffset() { return firstOffset; } + +private: + + int objStrNum; // object number of the object stream + int nObjects; // number of objects in the stream + Object *objs; // the objects (length = nObjects) + int *objNums; // the object numbers (length = nObjects) + int *offsets; // the object offsets (length = nObjects) + Guint firstOffset; +}; + +//------------------------------------------------------------------------ +// XRef +//------------------------------------------------------------------------ + +enum XRefEntryType { + xrefEntryFree, + xrefEntryUncompressed, + xrefEntryCompressed +}; + +struct XRefEntry { + Guint offset; + int gen; + XRefEntryType type; + bool updated; + Object obj; //if this entry was updated, obj will contains the updated object +}; + +class XRef { +public: + + // Constructor, create an empty XRef, used for PDF writing + XRef(); + // Constructor. Read xref table from stream. + XRef(BaseStream *strA); + + // Destructor. + ~XRef(); + + // Is xref table valid? + GBool isOk() { return ok; } + + // Get the error code (if isOk() returns false). + int getErrorCode() { return errCode; } + + // Set the encryption parameters. + void setEncryption(int permFlagsA, GBool ownerPasswordOkA, + Guchar *fileKeyA, int keyLengthA, + int encVersionA, int encRevisionA, + CryptAlgorithm encAlgorithmA); + + // Is the file encrypted? + GBool isEncrypted() { return encrypted; } + + // Check various permissions. + GBool okToPrint(GBool ignoreOwnerPW = gFalse); + GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse); + GBool okToChange(GBool ignoreOwnerPW = gFalse); + GBool okToCopy(GBool ignoreOwnerPW = gFalse); + GBool okToAddNotes(GBool ignoreOwnerPW = gFalse); + GBool okToFillForm(GBool ignoreOwnerPW = gFalse); + GBool okToAccessibility(GBool ignoreOwnerPW = gFalse); + GBool okToAssemble(GBool ignoreOwnerPW = gFalse); + + // Get catalog object. + Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); } + + // Fetch an indirect reference. + Object *fetch(int num, int gen, Object *obj); + + // Return the document's Info dictionary (if any). + Object *getDocInfo(Object *obj); + Object *getDocInfoNF(Object *obj); + + // Return the number of objects in the xref table. + int getNumObjects() { return size; } + + // Return the offset of the last xref table. + Guint getLastXRefPos() { return lastXRefPos; } + + // Return the catalog object reference. + int getRootNum() { return rootNum; } + int getRootGen() { return rootGen; } + + // Get end position for a stream in a damaged file. + // Returns false if unknown or file is not damaged. + GBool getStreamEnd(Guint streamStart, Guint *streamEnd); + + // Retuns the entry that belongs to the offset + int getNumEntry(Guint offset) const; + + // Direct access. + int getSize() { return size; } + XRefEntry *getEntry(int i) { return &entries[i]; } + Object *getTrailerDict() { return &trailerDict; } + ObjectStream *getObjStr() { return objStr; } + + // Write access + void setModifiedObject(Object* o, Ref r); + Ref addIndirectObject (Object* o); + void add(int num, int gen, Guint offs, GBool used); + void writeToFile(OutStream* outStr, GBool writeAllEntries); + +private: + + BaseStream *str; // input stream + Guint start; // offset in file (to allow for garbage + // at beginning of file) + XRefEntry *entries; // xref entries + int size; // size of <entries> array + int rootNum, rootGen; // catalog dict + GBool ok; // true if xref table is valid + int errCode; // error code (if <ok> is false) + Object trailerDict; // trailer dictionary + Guint lastXRefPos; // offset of last xref table + Guint *streamEnds; // 'endstream' positions - only used in + // damaged files + int streamEndsLen; // number of valid entries in streamEnds + ObjectStream *objStr; // cached object stream + GBool encrypted; // true if file is encrypted + int encRevision; + int encVersion; // encryption algorithm + CryptAlgorithm encAlgorithm; // encryption algorithm + int keyLength; // length of key, in bytes + int permFlags; // permission bits + Guchar fileKey[16]; // file decryption key + GBool ownerPasswordOk; // true if owner password is correct + + Guint getStartXref(); + GBool readXRef(Guint *pos); + GBool readXRefTable(Parser *parser, Guint *pos); + GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n); + GBool readXRefStream(Stream *xrefStr, Guint *pos); + GBool constructXRef(); + Guint strToUnsigned(char *s); +}; + +#endif +#else #include "XRef.h" +#endif #include "Catalog.h" #include "Page.h" #include "GfxFont.h" diff --git a/Build/source/texk/web2c/pdftexdir/utils.c b/Build/source/texk/web2c/pdftexdir/utils.c index 919b9436c69..ecdeb6b8aa9 100644 --- a/Build/source/texk/web2c/pdftexdir/utils.c +++ b/Build/source/texk/web2c/pdftexdir/utils.c @@ -43,7 +43,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "zlib.h" #include "ptexlib.h" #include "png.h" +#ifdef POPPLER_VERSION +#include "poppler-config.h" +#define xpdfVersion POPPLER_VERSION +#define xpdfString "poppler" +#else #include "xpdf/config.h" /* just to get the xpdf version */ +#define xpdfString "xpdf" +#endif #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ @@ -1272,9 +1279,9 @@ void initversionstring(char **versions) (void) asprintf(versions, "Compiled with libpng %s; using libpng %s\n" "Compiled with zlib %s; using zlib %s\n" - "Compiled with xpdf version %s\n", + "Compiled with %s version %s\n", PNG_LIBPNG_VER_STRING, png_libpng_ver, - ZLIB_VERSION, zlib_version, xpdfVersion); + ZLIB_VERSION, zlib_version, xpdfString, xpdfVersion); } |