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

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

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