X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FXRef.h;h=bec487a114756674f828afd31ff071b2b7f0fc16;hb=d97441740d457e1463083d561afdb719ca99e66b;hp=e8874c7ecf683d259ae1981a6b05417510700055;hpb=2610a3462d1ac3f20cba8f16dd07cba8a8c2fbef;p=evince.git diff --git a/pdf/xpdf/XRef.h b/pdf/xpdf/XRef.h index e8874c7e..bec487a1 100644 --- a/pdf/xpdf/XRef.h +++ b/pdf/xpdf/XRef.h @@ -2,40 +2,48 @@ // // XRef.h // -// Copyright 1996 Derek B. Noonburg +// Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== #ifndef XREF_H #define XREF_H -#ifdef __GNUC__ +#include + +#ifdef USE_GCC_PRAGMAS #pragma interface #endif -#include #include "gtypes.h" #include "Object.h" -#include "BaseFile.h" class Dict; -class FileStream; +class Stream; +class Parser; +class ObjectStream; //------------------------------------------------------------------------ // XRef //------------------------------------------------------------------------ +enum XRefEntryType { + xrefEntryFree, + xrefEntryUncompressed, + xrefEntryCompressed +}; + struct XRefEntry { - int offset; + Guint offset; int gen; - GBool used; + XRefEntryType type; }; class XRef { public: // Constructor. Read xref table from stream. - XRef(FileStream *str); + XRef(BaseStream *strA, GString *ownerPassword, GString *userPassword); // Destructor. ~XRef(); @@ -43,12 +51,21 @@ public: // Is xref table valid? GBool isOk() { return ok; } + // Get the error code (if isOk() returns false). + int getErrorCode() { return errCode; } + // Is the file encrypted? +#ifndef NO_DECRYPTION + GBool isEncrypted() { return encrypted; } +#else GBool isEncrypted() { return gFalse; } +#endif - // Are printing and copying allowed? If not, print an error message. - GBool okToPrint(); - GBool okToCopy(); + // Check various permissions. + GBool okToPrint(GBool ignoreOwnerPW = gFalse); + GBool okToChange(GBool ignoreOwnerPW = gFalse); + GBool okToCopy(GBool ignoreOwnerPW = gFalse); + GBool okToAddNotes(GBool ignoreOwnerPW = gFalse); // Get catalog object. Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); } @@ -58,28 +75,61 @@ public: // 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); + + // Direct access. + int getSize() { return size; } + XRefEntry *getEntry(int i) { return &entries[i]; } + Object *getTrailerDict() { return &trailerDict; } private: - BaseFile file; // input file - int start; // offset in file (to allow for garbage + 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 array int rootNum, rootGen; // catalog dict GBool ok; // true if xref table is valid + int errCode; // error code (if 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 +#ifndef NO_DECRYPTION + GBool encrypted; // true if file is encrypted + int encVersion; // encryption algorithm + int encRevision; // security handler revision + 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 +#endif - int readTrailer(FileStream *str); - GBool readXRef(FileStream *str, int *pos); - GBool constructXRef(FileStream *str); - GBool checkEncrypted(); + 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(); + GBool checkEncrypted(GString *ownerPassword, GString *userPassword); + Guint strToUnsigned(char *s); }; -//------------------------------------------------------------------------ -// The global xref table -//------------------------------------------------------------------------ - -extern XRef *xref; - #endif