Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Link.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/Link.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/Link.cc b/noncore/unsupported/qpdf/xpdf/Link.cc index 79a5f6e..c25ec43 100644 --- a/noncore/unsupported/qpdf/xpdf/Link.cc +++ b/noncore/unsupported/qpdf/xpdf/Link.cc | |||
@@ -1,11 +1,11 @@ | |||
1 | //======================================================================== | 1 | //======================================================================== |
2 | // | 2 | // |
3 | // Link.cc | 3 | // Link.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 |
@@ -26,37 +26,33 @@ | |||
26 | static GString *getFileSpecName(Object *fileSpecObj); | 26 | static GString *getFileSpecName(Object *fileSpecObj); |
27 | 27 | ||
28 | //------------------------------------------------------------------------ | 28 | //------------------------------------------------------------------------ |
29 | // LinkDest | 29 | // LinkDest |
30 | //------------------------------------------------------------------------ | 30 | //------------------------------------------------------------------------ |
31 | 31 | ||
32 | LinkDest::LinkDest(Array *a, GBool pageIsRefA) { | 32 | LinkDest::LinkDest(Array *a) { |
33 | Object obj1, obj2; | 33 | Object obj1, obj2; |
34 | 34 | ||
35 | // initialize fields | 35 | // initialize fields |
36 | pageIsRef = pageIsRefA; | ||
37 | left = bottom = right = top = zoom = 0; | 36 | left = bottom = right = top = zoom = 0; |
38 | ok = gFalse; | 37 | ok = gFalse; |
39 | 38 | ||
40 | // get page | 39 | // get page |
41 | if (pageIsRef) { | 40 | a->getNF(0, &obj1); |
42 | if (!a->getNF(0, &obj1)->isRef()) { | 41 | if (obj1.isInt()) { |
43 | error(-1, "Bad annotation destination"); | 42 | pageNum = obj1.getInt() + 1; |
44 | goto err2; | 43 | pageIsRef = gFalse; |
45 | } | 44 | } else if (obj1.isRef()) { |
46 | pageRef.num = obj1.getRefNum(); | 45 | pageRef.num = obj1.getRefNum(); |
47 | pageRef.gen = obj1.getRefGen(); | 46 | pageRef.gen = obj1.getRefGen(); |
48 | obj1.free(); | 47 | pageIsRef = gTrue; |
49 | } else { | 48 | } else { |
50 | if (!a->get(0, &obj1)->isInt()) { | 49 | error(-1, "Bad annotation destination"); |
51 | error(-1, "Bad annotation destination"); | 50 | goto err2; |
52 | goto err2; | ||
53 | } | ||
54 | pageNum = obj1.getInt() + 1; | ||
55 | obj1.free(); | ||
56 | } | 51 | } |
52 | obj1.free(); | ||
57 | 53 | ||
58 | // get destination type | 54 | // get destination type |
59 | a->get(1, &obj1); | 55 | a->get(1, &obj1); |
60 | 56 | ||
61 | // XYZ link | 57 | // XYZ link |
62 | if (obj1.isName("XYZ")) { | 58 | if (obj1.isName("XYZ")) { |
@@ -218,13 +214,13 @@ LinkGoTo::LinkGoTo(Object *destObj) { | |||
218 | namedDest = new GString(destObj->getName()); | 214 | namedDest = new GString(destObj->getName()); |
219 | } else if (destObj->isString()) { | 215 | } else if (destObj->isString()) { |
220 | namedDest = destObj->getString()->copy(); | 216 | namedDest = destObj->getString()->copy(); |
221 | 217 | ||
222 | // destination dictionary | 218 | // destination dictionary |
223 | } else if (destObj->isArray()) { | 219 | } else if (destObj->isArray()) { |
224 | dest = new LinkDest(destObj->getArray(), gTrue); | 220 | dest = new LinkDest(destObj->getArray()); |
225 | if (!dest->isOk()) { | 221 | if (!dest->isOk()) { |
226 | delete dest; | 222 | delete dest; |
227 | dest = NULL; | 223 | dest = NULL; |
228 | } | 224 | } |
229 | 225 | ||
230 | // error | 226 | // error |
@@ -256,13 +252,13 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) { | |||
256 | namedDest = new GString(destObj->getName()); | 252 | namedDest = new GString(destObj->getName()); |
257 | } else if (destObj->isString()) { | 253 | } else if (destObj->isString()) { |
258 | namedDest = destObj->getString()->copy(); | 254 | namedDest = destObj->getString()->copy(); |
259 | 255 | ||
260 | // destination dictionary | 256 | // destination dictionary |
261 | } else if (destObj->isArray()) { | 257 | } else if (destObj->isArray()) { |
262 | dest = new LinkDest(destObj->getArray(), gFalse); | 258 | dest = new LinkDest(destObj->getArray()); |
263 | if (!dest->isOk()) { | 259 | if (!dest->isOk()) { |
264 | delete dest; | 260 | delete dest; |
265 | dest = NULL; | 261 | dest = NULL; |
266 | } | 262 | } |
267 | 263 | ||
268 | // error | 264 | // error |
@@ -443,13 +439,13 @@ Link::Link(Dict *dict, GString *baseURI) { | |||
443 | t = y1; | 439 | t = y1; |
444 | y1 = y2; | 440 | y1 = y2; |
445 | y2 = t; | 441 | y2 = t; |
446 | } | 442 | } |
447 | 443 | ||
448 | // get border | 444 | // get border |
449 | borderW = 0; | 445 | borderW = 1; |
450 | if (!dict->lookup("Border", &obj1)->isNull()) { | 446 | if (!dict->lookup("Border", &obj1)->isNull()) { |
451 | if (obj1.isArray() && obj1.arrayGetLength() >= 3) { | 447 | if (obj1.isArray() && obj1.arrayGetLength() >= 3) { |
452 | if (obj1.arrayGet(2, &obj2)->isNum()) { | 448 | if (obj1.arrayGet(2, &obj2)->isNum()) { |
453 | borderW = obj2.getNum(); | 449 | borderW = obj2.getNum(); |
454 | } else { | 450 | } else { |
455 | error(-1, "Bad annotation border"); | 451 | error(-1, "Bad annotation border"); |
@@ -579,13 +575,13 @@ Links::~Links() { | |||
579 | gfree(links); | 575 | gfree(links); |
580 | } | 576 | } |
581 | 577 | ||
582 | LinkAction *Links::find(fouble x, fouble y) { | 578 | LinkAction *Links::find(fouble x, fouble y) { |
583 | int i; | 579 | int i; |
584 | 580 | ||
585 | for (i = 0; i < numLinks; ++i) { | 581 | for (i = numLinks - 1; i >= 0; --i) { |
586 | if (links[i]->inRect(x, y)) { | 582 | if (links[i]->inRect(x, y)) { |
587 | return links[i]->getAction(); | 583 | return links[i]->getAction(); |
588 | } | 584 | } |
589 | } | 585 | } |
590 | return NULL; | 586 | return NULL; |
591 | } | 587 | } |