]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/XRef.h
8e947e421b527d93bef1bd56329fcdc17e6787be
[evince.git] / pdf / xpdf / XRef.h
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 *str);
37
38   // Destructor.
39   ~XRef();
40
41   // Is xref table valid?
42   GBool isOk() { return ok; }
43
44   // Is the file encrypted?
45   GBool isEncrypted() { return gFalse; }
46
47   // Are printing and copying allowed?  If not, print an error message.
48   GBool okToPrint();
49   GBool okToCopy();
50
51   // Get catalog object.
52   Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
53
54   // Fetch an indirect reference.
55   Object *fetch(int num, int gen, Object *obj);
56
57   // Return the document's Info dictionary (if any).
58   Object *getDocInfo(Object *obj);
59
60 private:
61
62   BaseStream *str;              // input stream
63   int start;                    // offset in file (to allow for garbage
64                                 //   at beginning of file)
65   XRefEntry *entries;           // xref entries
66   int size;                     // size of <entries> array
67   int rootNum, rootGen;         // catalog dict
68   GBool ok;                     // true if xref table is valid
69   Object trailerDict;           // trailer dictionary
70
71   int readTrailer();
72   GBool readXRef(int *pos);
73   GBool constructXRef();
74   GBool checkEncrypted();
75 };
76
77 //------------------------------------------------------------------------
78 // The global xref table
79 //------------------------------------------------------------------------
80
81 extern XRef *xref;
82
83 #endif