Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/PDFDoc.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/PDFDoc.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/PDFDoc.cc b/noncore/unsupported/qpdf/xpdf/PDFDoc.cc index 4bbe9b7..97dfa55 100644 --- a/noncore/unsupported/qpdf/xpdf/PDFDoc.cc +++ b/noncore/unsupported/qpdf/xpdf/PDFDoc.cc | |||
@@ -1,11 +1,11 @@ | |||
1 | //======================================================================== | 1 | //======================================================================== |
2 | // | 2 | // |
3 | // PDFDoc.cc | 3 | // PDFDoc.cc |
4 | // | 4 | // |
5 | // Copyright 1996 Derek B. Noonburg | 5 | // Copyright 1996-2002 Glyph & Cog, LLC |
6 | // | 6 | // |
7 | //======================================================================== | 7 | //======================================================================== |
8 | 8 | ||
9 | #ifdef __GNUC__ | 9 | #ifdef __GNUC__ |
10 | #pragma implementation | 10 | #pragma implementation |
11 | #endif | 11 | #endif |
@@ -21,12 +21,13 @@ | |||
21 | #include "Catalog.h" | 21 | #include "Catalog.h" |
22 | #include "Stream.h" | 22 | #include "Stream.h" |
23 | #include "XRef.h" | 23 | #include "XRef.h" |
24 | #include "Link.h" | 24 | #include "Link.h" |
25 | #include "OutputDev.h" | 25 | #include "OutputDev.h" |
26 | #include "Error.h" | 26 | #include "Error.h" |
27 | #include "ErrorCodes.h" | ||
27 | #include "Lexer.h" | 28 | #include "Lexer.h" |
28 | #include "Parser.h" | 29 | #include "Parser.h" |
29 | #include "PDFDoc.h" | 30 | #include "PDFDoc.h" |
30 | 31 | ||
31 | //------------------------------------------------------------------------ | 32 | //------------------------------------------------------------------------ |
32 | 33 | ||
@@ -40,12 +41,13 @@ | |||
40 | PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword, | 41 | PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword, |
41 | GString *userPassword, GBool printCommandsA) { | 42 | GString *userPassword, GBool printCommandsA) { |
42 | Object obj; | 43 | Object obj; |
43 | GString *fileName2; | 44 | GString *fileName2; |
44 | 45 | ||
45 | ok = gFalse; | 46 | ok = gFalse; |
47 | errCode = errNone; | ||
46 | 48 | ||
47 | file = NULL; | 49 | file = NULL; |
48 | str = NULL; | 50 | str = NULL; |
49 | xref = NULL; | 51 | xref = NULL; |
50 | catalog = NULL; | 52 | catalog = NULL; |
51 | links = NULL; | 53 | links = NULL; |
@@ -54,40 +56,43 @@ PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword, | |||
54 | // try to open file | 56 | // try to open file |
55 | fileName = fileNameA; | 57 | fileName = fileNameA; |
56 | fileName2 = NULL; | 58 | fileName2 = NULL; |
57 | #ifdef VMS | 59 | #ifdef VMS |
58 | if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) { | 60 | if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) { |
59 | error(-1, "Couldn't open file '%s'", fileName->getCString()); | 61 | error(-1, "Couldn't open file '%s'", fileName->getCString()); |
62 | errCode = errOpenFile; | ||
60 | return; | 63 | return; |
61 | } | 64 | } |
62 | #else | 65 | #else |
63 | if (!(file = fopen(fileName->getCString(), "rb"))) { | 66 | if (!(file = fopen(fileName->getCString(), "rb"))) { |
64 | fileName2 = fileName->copy(); | 67 | fileName2 = fileName->copy(); |
65 | fileName2->lowerCase(); | 68 | fileName2->lowerCase(); |
66 | if (!(file = fopen(fileName2->getCString(), "rb"))) { | 69 | if (!(file = fopen(fileName2->getCString(), "rb"))) { |
67 | fileName2->upperCase(); | 70 | fileName2->upperCase(); |
68 | if (!(file = fopen(fileName2->getCString(), "rb"))) { | 71 | if (!(file = fopen(fileName2->getCString(), "rb"))) { |
69 | error(-1, "Couldn't open file '%s'", fileName->getCString()); | 72 | error(-1, "Couldn't open file '%s'", fileName->getCString()); |
70 | delete fileName2; | 73 | delete fileName2; |
74 | errCode = errOpenFile; | ||
71 | return; | 75 | return; |
72 | } | 76 | } |
73 | } | 77 | } |
74 | delete fileName2; | 78 | delete fileName2; |
75 | } | 79 | } |
76 | #endif | 80 | #endif |
77 | 81 | ||
78 | // create stream | 82 | // create stream |
79 | obj.initNull(); | 83 | obj.initNull(); |
80 | str = new FileStream(file, 0, -1, &obj); | 84 | str = new FileStream(file, 0, gFalse, 0, &obj); |
81 | 85 | ||
82 | ok = setup(ownerPassword, userPassword); | 86 | ok = setup(ownerPassword, userPassword); |
83 | } | 87 | } |
84 | 88 | ||
85 | PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword, | 89 | PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword, |
86 | GString *userPassword, GBool printCommandsA) { | 90 | GString *userPassword, GBool printCommandsA) { |
87 | ok = gFalse; | 91 | ok = gFalse; |
92 | errCode = errNone; | ||
88 | fileName = NULL; | 93 | fileName = NULL; |
89 | file = NULL; | 94 | file = NULL; |
90 | str = strA; | 95 | str = strA; |
91 | xref = NULL; | 96 | xref = NULL; |
92 | catalog = NULL; | 97 | catalog = NULL; |
93 | links = NULL; | 98 | links = NULL; |
@@ -100,19 +105,21 @@ GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) { | |||
100 | checkHeader(); | 105 | checkHeader(); |
101 | 106 | ||
102 | // read xref table | 107 | // read xref table |
103 | xref = new XRef(str, ownerPassword, userPassword); | 108 | xref = new XRef(str, ownerPassword, userPassword); |
104 | if (!xref->isOk()) { | 109 | if (!xref->isOk()) { |
105 | error(-1, "Couldn't read xref table"); | 110 | error(-1, "Couldn't read xref table"); |
111 | errCode = xref->getErrorCode(); | ||
106 | return gFalse; | 112 | return gFalse; |
107 | } | 113 | } |
108 | 114 | ||
109 | // read catalog | 115 | // read catalog |
110 | catalog = new Catalog(xref, printCommands); | 116 | catalog = new Catalog(xref, printCommands); |
111 | if (!catalog->isOk()) { | 117 | if (!catalog->isOk()) { |
112 | error(-1, "Couldn't read page catalog"); | 118 | error(-1, "Couldn't read page catalog"); |
119 | errCode = errBadCatalog; | ||
113 | return gFalse; | 120 | return gFalse; |
114 | } | 121 | } |
115 | 122 | ||
116 | // done | 123 | // done |
117 | return gTrue; | 124 | return gTrue; |
118 | } | 125 | } |
@@ -201,14 +208,15 @@ GBool PDFDoc::isLinearized() { | |||
201 | Parser *parser; | 208 | Parser *parser; |
202 | Object obj1, obj2, obj3, obj4, obj5; | 209 | Object obj1, obj2, obj3, obj4, obj5; |
203 | GBool lin; | 210 | GBool lin; |
204 | 211 | ||
205 | lin = gFalse; | 212 | lin = gFalse; |
206 | obj1.initNull(); | 213 | obj1.initNull(); |
207 | parser = new Parser(xref, new Lexer(xref, str->makeSubStream(str->getStart(), | 214 | parser = new Parser(xref, |
208 | -1, &obj1))); | 215 | new Lexer(xref, |
216 | str->makeSubStream(str->getStart(), gFalse, 0, &obj1))); | ||
209 | parser->getObj(&obj1); | 217 | parser->getObj(&obj1); |
210 | parser->getObj(&obj2); | 218 | parser->getObj(&obj2); |
211 | parser->getObj(&obj3); | 219 | parser->getObj(&obj3); |
212 | parser->getObj(&obj4); | 220 | parser->getObj(&obj4); |
213 | if (obj1.isInt() && obj2.isInt() && obj3.isCmd("obj") && | 221 | if (obj1.isInt() && obj2.isInt() && obj3.isCmd("obj") && |
214 | obj4.isDict()) { | 222 | obj4.isDict()) { |