1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
16 #include "goo/gtypes.h"
24 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
30 xrefEntryUncompressed
,
43 // Constructor. Read xref table from stream.
44 XRef(BaseStream
*strA
);
49 // Is xref table valid?
50 GBool
isOk() { return ok
; }
52 // Get the error code (if isOk() returns false).
53 int getErrorCode() { return errCode
; }
55 // Set the encryption parameters.
56 void setEncryption(int permFlagsA
, GBool ownerPasswordOkA
,
57 Guchar
*fileKeyA
, int keyLengthA
,
58 int encVersionA
, int encRevisionA
);
60 // Is the file encrypted?
61 GBool
isEncrypted() { return encrypted
; }
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
);
73 // Get catalog object.
74 Object
*getCatalog(Object
*obj
) { return fetch(rootNum
, rootGen
, obj
); }
76 // Fetch an indirect reference.
77 Object
*fetch(int num
, int gen
, Object
*obj
);
79 // Return the document's Info dictionary (if any).
80 Object
*getDocInfo(Object
*obj
);
81 Object
*getDocInfoNF(Object
*obj
);
83 // Return the number of objects in the xref table.
84 int getNumObjects() { return size
; }
86 // Return the offset of the last xref table.
87 Guint
getLastXRefPos() { return lastXRefPos
; }
89 // Return the catalog object reference.
90 int getRootNum() { return rootNum
; }
91 int getRootGen() { return rootGen
; }
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
);
97 // Retuns the entry that belongs to the offset
98 int getNumEntry(int offset
) const;
101 int getSize() { return size
; }
102 XRefEntry
*getEntry(int i
) { return &entries
[i
]; }
103 Object
*getTrailerDict() { return &trailerDict
; }
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
119 int streamEndsLen
; // number of valid entries in streamEnds
120 ObjectStream
*objStr
; // cached object stream
121 GBool encrypted
; // true if file is encrypted
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
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
);