source: trunk/poppler/mypoppler/poppler/XRef.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 3.9 KB
Line 
1//========================================================================
2//
3// XRef.h
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef XREF_H
10#define XREF_H
11
12#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16#include "goo/gtypes.h"
17#include "Object.h"
18
19class Dict;
20class Stream;
21class Parser;
22class ObjectStream;
23
24//------------------------------------------------------------------------
25// XRef
26//------------------------------------------------------------------------
27
28enum XRefEntryType {
29  xrefEntryFree,
30  xrefEntryUncompressed,
31  xrefEntryCompressed
32};
33
34struct XRefEntry {
35  Guint offset;
36  int gen;
37  XRefEntryType type;
38};
39
40class XRef {
41public:
42
43  // Constructor.  Read xref table from stream.
44  XRef(BaseStream *strA);
45
46  // Destructor.
47  ~XRef();
48
49  // Is xref table valid?
50  GBool isOk() { return ok; }
51
52  // Get the error code (if isOk() returns false).
53  int getErrorCode() { return errCode; }
54
55  // Set the encryption parameters.
56  void setEncryption(int permFlagsA, GBool ownerPasswordOkA,
57                     Guchar *fileKeyA, int keyLengthA,
58                     int encVersionA, int encRevisionA);
59
60  // Is the file encrypted?
61  GBool isEncrypted() { return encrypted; }
62
63  // Check various permissions.
64  GBool okToPrint(GBool ignoreOwnerPW = gFalse);
65  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse);
66  GBool okToChange(GBool ignoreOwnerPW = gFalse);
67  GBool okToCopy(GBool ignoreOwnerPW = gFalse);
68  GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);
69  GBool okToFillForm(GBool ignoreOwnerPW = gFalse);
70  GBool okToAccessibility(GBool ignoreOwnerPW = gFalse);
71  GBool okToAssemble(GBool ignoreOwnerPW = gFalse);
72
73  // Get catalog object.
74  Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
75
76  // Fetch an indirect reference.
77  Object *fetch(int num, int gen, Object *obj);
78
79  // Return the document's Info dictionary (if any).
80  Object *getDocInfo(Object *obj);
81  Object *getDocInfoNF(Object *obj);
82
83  // Return the number of objects in the xref table.
84  int getNumObjects() { return size; }
85
86  // Return the offset of the last xref table.
87  Guint getLastXRefPos() { return lastXRefPos; }
88
89  // Return the catalog object reference.
90  int getRootNum() { return rootNum; }
91  int getRootGen() { return rootGen; }
92
93  // Get end position for a stream in a damaged file.
94  // Returns false if unknown or file is not damaged.
95  GBool getStreamEnd(Guint streamStart, Guint *streamEnd);
96
97  // Retuns the entry that belongs to the offset
98  int getNumEntry(int offset) const;
99
100  // Direct access.
101  int getSize() { return size; }
102  XRefEntry *getEntry(int i) { return &entries[i]; }
103  Object *getTrailerDict() { return &trailerDict; }
104
105private:
106
107  BaseStream *str;              // input stream
108  Guint start;                  // offset in file (to allow for garbage
109                                //   at beginning of file)
110  XRefEntry *entries;           // xref entries
111  int size;                     // size of <entries> array
112  int rootNum, rootGen;         // catalog dict
113  GBool ok;                     // true if xref table is valid
114  int errCode;                  // error code (if <ok> is false)
115  Object trailerDict;           // trailer dictionary
116  Guint lastXRefPos;            // offset of last xref table
117  Guint *streamEnds;            // 'endstream' positions - only used in
118                                //   damaged files
119  int streamEndsLen;            // number of valid entries in streamEnds
120  ObjectStream *objStr;         // cached object stream
121  GBool encrypted;              // true if file is encrypted
122  int encRevision;             
123  int encVersion;               // encryption algorithm
124  int keyLength;                // length of key, in bytes
125  int permFlags;                // permission bits
126  Guchar fileKey[16];           // file decryption key
127  GBool ownerPasswordOk;        // true if owner password is correct
128
129  Guint getStartXref();
130  GBool readXRef(Guint *pos);
131  GBool readXRefTable(Parser *parser, Guint *pos);
132  GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
133  GBool readXRefStream(Stream *xrefStr, Guint *pos);
134  GBool constructXRef();
135  Guint strToUnsigned(char *s);
136};
137
138#endif
Note: See TracBrowser for help on using the repository browser.