]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/XRef.h
Totaly re-hash stream architecture ... again :-)
[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 <stdio.h>
17 #include "gtypes.h"
18 #include "Object.h"
19
20 class Dict;
21 class FileStream;
22
23 //------------------------------------------------------------------------
24 // XRef
25 //------------------------------------------------------------------------
26
27 struct XRefEntry {
28   int offset;
29   int gen;
30   GBool used;
31 };
32
33 class XRef {
34 public:
35
36   // Constructor.  Read xref table from stream.
37   XRef(Stream *str);
38
39   // Destructor.
40   ~XRef();
41
42   // Is xref table valid?
43   GBool isOk() { return ok; }
44
45   // Is the file encrypted?
46   GBool isEncrypted() { return gFalse; }
47
48   // Are printing and copying allowed?  If not, print an error message.
49   GBool okToPrint();
50   GBool okToCopy();
51
52   // Get catalog object.
53   Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
54
55   // Fetch an indirect reference.
56   Object *fetch(int num, int gen, Object *obj);
57
58   // Return the document's Info dictionary (if any).
59   Object *getDocInfo(Object *obj);
60
61 private:
62
63   Stream *str;                  // input file
64   int start;                    // offset in file (to allow for garbage
65                                 //   at beginning of file)
66   XRefEntry *entries;           // xref entries
67   int size;                     // size of <entries> array
68   int rootNum, rootGen;         // catalog dict
69   GBool ok;                     // true if xref table is valid
70   Object trailerDict;           // trailer dictionary
71
72   int readTrailer(Stream *str);
73   GBool readXRef(Stream *str, int *pos);
74   GBool constructXRef(Stream *str);
75   GBool checkEncrypted();
76 };
77
78 //------------------------------------------------------------------------
79 // The global xref table
80 //------------------------------------------------------------------------
81
82 extern XRef *xref;
83
84 #endif