Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/XRef.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/XRef.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/XRef.h b/noncore/unsupported/qpdf/xpdf/XRef.h new file mode 100644 index 0000000..a44c495 --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/XRef.h | |||
@@ -0,0 +1,111 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // XRef.h | ||
4 | // | ||
5 | // Copyright 1996 Derek B. Noonburg | ||
6 | // | ||
7 | //======================================================================== | ||
8 | |||
9 | #ifndef XREF_H | ||
10 | #define XREF_H | ||
11 | |||
12 | #ifdef __GNUC__ | ||
13 | #pragma interface | ||
14 | #endif | ||
15 | |||
16 | #include "gtypes.h" | ||
17 | #include "Object.h" | ||
18 | |||
19 | class Dict; | ||
20 | class Stream; | ||
21 | |||
22 | //------------------------------------------------------------------------ | ||
23 | // XRef | ||
24 | //------------------------------------------------------------------------ | ||
25 | |||
26 | struct XRefEntry { | ||
27 | int offset; | ||
28 | int gen; | ||
29 | GBool used; | ||
30 | }; | ||
31 | |||
32 | class XRef { | ||
33 | public: | ||
34 | |||
35 | // Constructor. Read xref table from stream. | ||
36 | XRef(BaseStream *strA, GString *ownerPassword, GString *userPassword); | ||
37 | |||
38 | // Destructor. | ||
39 | ~XRef(); | ||
40 | |||
41 | // Is xref table valid? | ||
42 | GBool isOk() { return ok; } | ||
43 | |||
44 | // Is the file encrypted? | ||
45 | #ifndef NO_DECRYPTION | ||
46 | GBool isEncrypted() { return encrypted; } | ||
47 | #else | ||
48 | GBool isEncrypted() { return gFalse; } | ||
49 | #endif | ||
50 | |||
51 | // Check various permissions. | ||
52 | GBool okToPrint(GBool ignoreOwnerPW = gFalse); | ||
53 | GBool okToChange(GBool ignoreOwnerPW = gFalse); | ||
54 | GBool okToCopy(GBool ignoreOwnerPW = gFalse); | ||
55 | GBool okToAddNotes(GBool ignoreOwnerPW = gFalse); | ||
56 | |||
57 | // Get catalog object. | ||
58 | Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); } | ||
59 | |||
60 | // Fetch an indirect reference. | ||
61 | Object *fetch(int num, int gen, Object *obj); | ||
62 | |||
63 | // Return the document's Info dictionary (if any). | ||
64 | Object *getDocInfo(Object *obj); | ||
65 | Object *getDocInfoNF(Object *obj); | ||
66 | |||
67 | // Return the number of objects in the xref table. | ||
68 | int getNumObjects() { return size; } | ||
69 | |||
70 | // Return the offset of the last xref table. | ||
71 | int getLastXRefPos() { return lastXRefPos; } | ||
72 | |||
73 | // Return the catalog object reference. | ||
74 | int getRootNum() { return rootNum; } | ||
75 | int getRootGen() { return rootGen; } | ||
76 | |||
77 | // Get end position for a stream in a damaged file. | ||
78 | // Returns -1 if unknown or file is not damaged. | ||
79 | int getStreamEnd(int streamStart); | ||
80 | |||
81 | private: | ||
82 | |||
83 | BaseStream *str; // input stream | ||
84 | int start; // offset in file (to allow for garbage | ||
85 | // at beginning of file) | ||
86 | XRefEntry *entries; // xref entries | ||
87 | int size; // size of <entries> array | ||
88 | int rootNum, rootGen; // catalog dict | ||
89 | GBool ok; // true if xref table is valid | ||
90 | Object trailerDict; // trailer dictionary | ||
91 | int lastXRefPos; // offset of last xref table | ||
92 | int *streamEnds; // 'endstream' positions - only used in | ||
93 | // damaged files | ||
94 | int streamEndsLen; // number of valid entries in streamEnds | ||
95 | #ifndef NO_DECRYPTION | ||
96 | GBool encrypted; // true if file is encrypted | ||
97 | int encVersion; // encryption algorithm | ||
98 | int encRevision; // security handler revision | ||
99 | int keyLength; // length of key, in bytes | ||
100 | int permFlags; // permission bits | ||
101 | Guchar fileKey[16]; // file decryption key | ||
102 | GBool ownerPasswordOk;// true if owner password is correct | ||
103 | #endif | ||
104 | |||
105 | int readTrailer(); | ||
106 | GBool readXRef(int *pos); | ||
107 | GBool constructXRef(); | ||
108 | GBool checkEncrypted(GString *ownerPassword, GString *userPassword); | ||
109 | }; | ||
110 | |||
111 | #endif | ||