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