fix build with recent changes/gcc 6.3.0
[AROS-Contrib.git] / arospdf / xpdf / XRef.h
blob98dbac54d9d987801ba8eab90b6ef7f771e97a10
1 //========================================================================
2 //
3 // XRef.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef XREF_H
10 #define XREF_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "gtypes.h"
19 #include "Object.h"
21 class Dict;
22 class Stream;
23 class Parser;
24 class ObjectStream;
26 //------------------------------------------------------------------------
27 // XRef
28 //------------------------------------------------------------------------
30 enum XRefEntryType {
31 xrefEntryFree,
32 xrefEntryUncompressed,
33 xrefEntryCompressed
36 struct XRefEntry {
37 Guint offset;
38 int gen;
39 XRefEntryType type;
42 class XRef {
43 public:
45 // Constructor. Read xref table from stream.
46 XRef(BaseStream *strA);
48 // Destructor.
49 ~XRef();
51 // Is xref table valid?
52 GBool isOk() { return ok; }
54 // Get the error code (if isOk() returns false).
55 int getErrorCode() { return errCode; }
57 // Set the encryption parameters.
58 void setEncryption(int permFlagsA, GBool ownerPasswordOkA,
59 Guchar *fileKeyA, int keyLengthA, int encVersionA,
60 CryptAlgorithm encAlgorithmA);
62 // Is the file encrypted?
63 GBool isEncrypted() { return encrypted; }
65 // Check various permissions.
66 GBool okToPrint(GBool ignoreOwnerPW = gFalse);
67 GBool okToChange(GBool ignoreOwnerPW = gFalse);
68 GBool okToCopy(GBool ignoreOwnerPW = gFalse);
69 GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);
71 // Get catalog xObject.
72 xObject *getCatalog(xObject *obj) { return fetch(rootNum, rootGen, obj); }
74 // Fetch an indirect reference.
75 xObject *fetch(int num, int gen, xObject *obj);
77 // Return the document's Info dictionary (if any).
78 xObject *getDocInfo(xObject *obj);
79 xObject *getDocInfoNF(xObject *obj);
81 // Return the number of xObjects in the xref table.
82 int getNumObjects() { return size; }
84 // Return the offset of the last xref table.
85 Guint getLastXRefPos() { return lastXRefPos; }
87 // Return the catalog xObject reference.
88 int getRootNum() { return rootNum; }
89 int getRootGen() { return rootGen; }
91 // Get end position for a stream in a damaged file.
92 // Returns false if unknown or file is not damaged.
93 GBool getStreamEnd(Guint streamStart, Guint *streamEnd);
95 // Direct access.
96 int getSize() { return size; }
97 XRefEntry *getEntry(int i) { return &entries[i]; }
98 xObject *getTrailerDict() { return &trailerDict; }
100 private:
102 BaseStream *str; // input stream
103 Guint start; // offset in file (to allow for garbage
104 // at beginning of file)
105 XRefEntry *entries; // xref entries
106 int size; // size of <entries> array
107 int rootNum, rootGen; // catalog dict
108 GBool ok; // true if xref table is valid
109 int errCode; // error code (if <ok> is false)
110 xObject trailerDict; // trailer dictionary
111 Guint lastXRefPos; // offset of last xref table
112 Guint *streamEnds; // 'endstream' positions - only used in
113 // damaged files
114 int streamEndsLen; // number of valid entries in streamEnds
115 ObjectStream *objStr; // cached xObject stream
116 GBool encrypted; // true if file is encrypted
117 int permFlags; // permission bits
118 GBool ownerPasswordOk; // true if owner password is correct
119 Guchar fileKey[16]; // file decryption key
120 int keyLength; // length of key, in bytes
121 int encVersion; // encryption version
122 CryptAlgorithm encAlgorithm; // encryption algorithm
124 Guint getStartXref();
125 GBool readXRef(Guint *pos);
126 GBool readXRefTable(Parser *parser, Guint *pos);
127 GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
128 GBool readXRefStream(Stream *xrefStr, Guint *pos);
129 GBool constructXRef();
130 Guint strToUnsigned(char *s);
133 #endif