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

Last change on this file since 257 was 257, checked in by Eugene Romanenko, 13 years ago

PDF plugin: Poppler library updated to version 0.10.0

File size: 5.1 KB
Line 
1//========================================================================
2//
3// XRef.h
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2005 Brad Hards <bradh@frogmouth.net>
17// Copyright (C) 2006, 2008 Albert Astals Cid <aacid@kde.org>
18// Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org>
19// Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
20//
21// To see a description of the changes please see the Changelog file that
22// came with your tarball or type make ChangeLog if you are building from git
23//
24//========================================================================
25
26#ifndef XREF_H
27#define XREF_H
28
29#ifdef USE_GCC_PRAGMAS
30#pragma interface
31#endif
32
33#include "goo/gtypes.h"
34#include "Object.h"
35
36class Dict;
37class Stream;
38class Parser;
39class ObjectStream;
40
41//------------------------------------------------------------------------
42// XRef
43//------------------------------------------------------------------------
44
45enum XRefEntryType {
46  xrefEntryFree,
47  xrefEntryUncompressed,
48  xrefEntryCompressed
49};
50
51struct XRefEntry {
52  Guint offset;
53  int gen;
54  XRefEntryType type;
55  bool updated;
56  Object obj; //if this entry was updated, obj will contains the updated object
57};
58
59class XRef {
60public:
61
62  // Constructor, create an empty XRef, used for PDF writing
63  XRef();
64  // Constructor.  Read xref table from stream.
65  XRef(BaseStream *strA);
66
67  // Destructor.
68  ~XRef();
69
70  // Is xref table valid?
71  GBool isOk() { return ok; }
72
73  // Get the error code (if isOk() returns false).
74  int getErrorCode() { return errCode; }
75
76  // Set the encryption parameters.
77  void setEncryption(int permFlagsA, GBool ownerPasswordOkA,
78                     Guchar *fileKeyA, int keyLengthA,
79                     int encVersionA, int encRevisionA,
80                     CryptAlgorithm encAlgorithmA);
81
82  // Is the file encrypted?
83  GBool isEncrypted() { return encrypted; }
84
85  // Check various permissions.
86  GBool okToPrint(GBool ignoreOwnerPW = gFalse);
87  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse);
88  GBool okToChange(GBool ignoreOwnerPW = gFalse);
89  GBool okToCopy(GBool ignoreOwnerPW = gFalse);
90  GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);
91  GBool okToFillForm(GBool ignoreOwnerPW = gFalse);
92  GBool okToAccessibility(GBool ignoreOwnerPW = gFalse);
93  GBool okToAssemble(GBool ignoreOwnerPW = gFalse);
94
95  // Get catalog object.
96  Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
97
98  // Fetch an indirect reference.
99  Object *fetch(int num, int gen, Object *obj);
100
101  // Return the document's Info dictionary (if any).
102  Object *getDocInfo(Object *obj);
103  Object *getDocInfoNF(Object *obj);
104
105  // Return the number of objects in the xref table.
106  int getNumObjects() { return size; }
107
108  // Return the offset of the last xref table.
109  Guint getLastXRefPos() { return lastXRefPos; }
110
111  // Return the catalog object reference.
112  int getRootNum() { return rootNum; }
113  int getRootGen() { return rootGen; }
114
115  // Get end position for a stream in a damaged file.
116  // Returns false if unknown or file is not damaged.
117  GBool getStreamEnd(Guint streamStart, Guint *streamEnd);
118
119  // Retuns the entry that belongs to the offset
120  int getNumEntry(Guint offset) const;
121
122  // Direct access.
123  int getSize() { return size; }
124  XRefEntry *getEntry(int i) { return &entries[i]; }
125  Object *getTrailerDict() { return &trailerDict; }
126
127  // Write access
128  void setModifiedObject(Object* o, Ref r);
129  Ref addIndirectObject (Object* o);
130  void add(int num, int gen,  Guint offs, GBool used);
131  void writeToFile(OutStream* outStr, GBool writeAllEntries);
132
133private:
134
135  BaseStream *str;              // input stream
136  Guint start;                  // offset in file (to allow for garbage
137                                //   at beginning of file)
138  XRefEntry *entries;           // xref entries
139  int size;                     // size of <entries> array
140  int rootNum, rootGen;         // catalog dict
141  GBool ok;                     // true if xref table is valid
142  int errCode;                  // error code (if <ok> is false)
143  Object trailerDict;           // trailer dictionary
144  Guint lastXRefPos;            // offset of last xref table
145  Guint *streamEnds;            // 'endstream' positions - only used in
146                                //   damaged files
147  int streamEndsLen;            // number of valid entries in streamEnds
148  ObjectStream *objStr;         // cached object stream
149  GBool encrypted;              // true if file is encrypted
150  int encRevision;             
151  int encVersion;               // encryption algorithm
152  CryptAlgorithm encAlgorithm;  // encryption algorithm
153  int keyLength;                // length of key, in bytes
154  int permFlags;                // permission bits
155  Guchar fileKey[16];           // file decryption key
156  GBool ownerPasswordOk;        // true if owner password is correct
157
158  Guint getStartXref();
159  GBool readXRef(Guint *pos);
160  GBool readXRefTable(Parser *parser, Guint *pos);
161  GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
162  GBool readXRefStream(Stream *xrefStr, Guint *pos);
163  GBool constructXRef();
164  Guint strToUnsigned(char *s);
165};
166
167#endif
Note: See TracBrowser for help on using the repository browser.