filters
XRef.h00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef XREF_H
00010 #define XREF_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "gtypes.h"
00019 #include "Object.h"
00020
00021 class Dict;
00022 class Stream;
00023
00024
00025
00026
00027
00028 struct XRefEntry {
00029 Guint offset;
00030 int gen;
00031 GBool used;
00032 };
00033
00034 class XRef {
00035 public:
00036
00037
00038 XRef(BaseStream *strA, GString *ownerPassword, GString *userPassword);
00039
00040
00041 ~XRef();
00042
00043
00044 GBool isOk() { return ok; }
00045
00046
00047 int getErrorCode() { return errCode; }
00048
00049
00050 #ifndef NO_DECRYPTION
00051 GBool isEncrypted() { return encrypted; }
00052 #else
00053 GBool isEncrypted() { return gFalse; }
00054 #endif
00055
00056
00057 GBool okToPrint(GBool ignoreOwnerPW = gFalse);
00058 GBool okToChange(GBool ignoreOwnerPW = gFalse);
00059 GBool okToCopy(GBool ignoreOwnerPW = gFalse);
00060 GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);
00061
00062
00063 Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
00064
00065
00066 Object *fetch(int num, int gen, Object *obj);
00067
00068
00069 Object *getDocInfo(Object *obj);
00070 Object *getDocInfoNF(Object *obj);
00071
00072
00073 int getNumObjects() { return size; }
00074
00075
00076 Guint getLastXRefPos() { return lastXRefPos; }
00077
00078
00079 int getRootNum() { return rootNum; }
00080 int getRootGen() { return rootGen; }
00081
00082
00083
00084 GBool getStreamEnd(Guint streamStart, Guint *streamEnd);
00085
00086
00087 int getSize() { return size; }
00088 XRefEntry *getEntry(int i) { return &entries[i]; }
00089 Object *getTrailerDict() { return &trailerDict; }
00090
00091 private:
00092
00093 BaseStream *str;
00094 Guint start;
00095
00096 XRefEntry *entries;
00097 int size;
00098 int rootNum, rootGen;
00099 GBool ok;
00100 int errCode;
00101 Object trailerDict;
00102 Guint lastXRefPos;
00103 Guint *streamEnds;
00104
00105 int streamEndsLen;
00106 #ifndef NO_DECRYPTION
00107 GBool encrypted;
00108 int encVersion;
00109 int encRevision;
00110 int keyLength;
00111 int permFlags;
00112 Guchar fileKey[16];
00113 GBool ownerPasswordOk;
00114 #endif
00115
00116 Guint readTrailer();
00117 GBool readXRef(Guint *pos);
00118 GBool constructXRef();
00119 GBool checkEncrypted(GString *ownerPassword, GString *userPassword);
00120 Guint strToUnsigned(char *s);
00121 };
00122
00123 #endif
|