w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Link.cc
Go to the documentation of this file.
1 //========================================================================
2 //
3 // Link.cc
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #include <aconf.h>
10 
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
13 #endif
14 
15 #include <stddef.h>
16 #include <string.h>
17 #include "gmem.h"
18 #include "gmempp.h"
19 #include "GString.h"
20 #include "Error.h"
21 #include "Object.h"
22 #include "Array.h"
23 #include "Dict.h"
24 #include "Link.h"
25 
26 //------------------------------------------------------------------------
27 // LinkAction
28 //------------------------------------------------------------------------
29 
32 
33  action = new LinkGoTo(obj);
34  if (!action->isOk()) {
35  delete action;
36  return NULL;
37  }
38  return action;
39 }
40 
43  Object obj2, obj3, obj4, obj5;
44 
45  if (!obj->isDict()) {
46  error(errSyntaxWarning, -1, "Bad annotation action");
47  return NULL;
48  }
49 
50  obj->dictLookup("S", &obj2);
51 
52  // GoTo action
53  if (obj2.isName("GoTo")) {
54  obj->dictLookup("D", &obj3);
55  action = new LinkGoTo(&obj3);
56  obj3.free();
57 
58  // GoToR action
59  } else if (obj2.isName("GoToR")) {
60  obj->dictLookup("F", &obj3);
61  obj->dictLookup("D", &obj4);
62  action = new LinkGoToR(&obj3, &obj4);
63  obj3.free();
64  obj4.free();
65 
66  // Launch action
67  } else if (obj2.isName("Launch")) {
68  action = new LinkLaunch(obj);
69 
70  // URI action
71  } else if (obj2.isName("URI")) {
72  obj->dictLookup("URI", &obj3);
73  action = new LinkURI(&obj3, baseURI);
74  obj3.free();
75 
76  // Named action
77  } else if (obj2.isName("Named")) {
78  obj->dictLookup("N", &obj3);
79  action = new LinkNamed(&obj3);
80  obj3.free();
81 
82  // Movie action
83  } else if (obj2.isName("Movie")) {
84  obj->dictLookupNF("Annot", &obj3);
85  obj->dictLookup("T", &obj4);
86  action = new LinkMovie(&obj3, &obj4);
87  obj3.free();
88  obj4.free();
89 
90  // JavaScript action
91  } else if (obj2.isName("JavaScript")) {
92  obj->dictLookup("JS", &obj3);
93  action = new LinkJavaScript(&obj3);
94  obj3.free();
95 
96  // SubmitForm action
97  } else if (obj2.isName("SubmitForm")) {
98  obj->dictLookup("F", &obj3);
99  obj->dictLookup("Fields", &obj4);
100  obj->dictLookup("Flags", &obj5);
101  action = new LinkSubmitForm(&obj3, &obj4, &obj5);
102  obj3.free();
103  obj4.free();
104  obj5.free();
105 
106  // Hide action
107  } else if (obj2.isName("Hide")) {
108  obj->dictLookupNF("T", &obj3);
109  obj->dictLookup("H", &obj4);
110  action = new LinkHide(&obj3, &obj4);
111  obj3.free();
112  obj4.free();
113 
114  // unknown action
115  } else if (obj2.isName()) {
116  action = new LinkUnknown(obj2.getName());
117 
118  // action is missing or wrong type
119  } else {
120  error(errSyntaxWarning, -1, "Bad annotation action");
121  action = NULL;
122  }
123 
124  obj2.free();
125 
126  if (action && !action->isOk()) {
127  delete action;
128  return NULL;
129  }
130  return action;
131 }
132 
134  GString *name;
135  Object obj1;
136 
137  name = NULL;
138 
139  // string
140  if (fileSpecObj->isString()) {
141  name = fileSpecObj->getString()->copy();
142 
143  // dictionary
144  } else if (fileSpecObj->isDict()) {
145 #ifdef _WIN32
146  if (!fileSpecObj->dictLookup("DOS", &obj1)->isString()) {
147 #else
148  if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) {
149 #endif
150  obj1.free();
151  fileSpecObj->dictLookup("F", &obj1);
152  }
153  if (obj1.isString()) {
154  name = obj1.getString()->copy();
155  } else {
156  error(errSyntaxWarning, -1, "Illegal file spec in link");
157  }
158  obj1.free();
159 
160  // error
161  } else {
162  error(errSyntaxWarning, -1, "Illegal file spec in link");
163  }
164 
165  // system-dependent path manipulation
166  if (name) {
167 #ifdef _WIN32
168  int i, j;
169 
170  // "//...." --> "\...."
171  // "/x/...." --> "x:\...."
172  // "/server/share/...." --> "\\server\share\...."
173  // convert escaped slashes to slashes and unescaped slashes to backslashes
174  i = 0;
175  if (name->getChar(0) == '/') {
176  if (name->getLength() >= 2 && name->getChar(1) == '/') {
177  name->del(0);
178  i = 0;
179  } else if (name->getLength() >= 2 &&
180  ((name->getChar(1) >= 'a' && name->getChar(1) <= 'z') ||
181  (name->getChar(1) >= 'A' && name->getChar(1) <= 'Z')) &&
182  (name->getLength() == 2 || name->getChar(2) == '/')) {
183  name->setChar(0, name->getChar(1));
184  name->setChar(1, ':');
185  i = 2;
186  } else {
187  for (j = 2; j < name->getLength(); ++j) {
188  if (name->getChar(j-1) != '\\' &&
189  name->getChar(j) == '/') {
190  break;
191  }
192  }
193  if (j < name->getLength()) {
194  name->setChar(0, '\\');
195  name->insert(0, '\\');
196  i = 2;
197  }
198  }
199  }
200  for (; i < name->getLength(); ++i) {
201  if (name->getChar(i) == '/') {
202  name->setChar(i, '\\');
203  } else if (name->getChar(i) == '\\' &&
204  i+1 < name->getLength() &&
205  name->getChar(i+1) == '/') {
206  name->del(i);
207  }
208  }
209 #else
210  // no manipulation needed for Unix
211 #endif
212  }
213 
214  return name;
215 }
216 
217 //------------------------------------------------------------------------
218 // LinkDest
219 //------------------------------------------------------------------------
220 
222  Object obj1, obj2;
223 
224  // initialize fields
225  left = bottom = right = top = zoom = 0;
226  ok = gFalse;
227 
228  // get page
229  if (a->getLength() < 2) {
230  error(errSyntaxWarning, -1, "Annotation destination array is too short");
231  return;
232  }
233  a->getNF(0, &obj1);
234  if (obj1.isInt()) {
235  pageNum = obj1.getInt() + 1;
236  pageIsRef = gFalse;
237  } else if (obj1.isRef()) {
238  pageRef.num = obj1.getRefNum();
239  pageRef.gen = obj1.getRefGen();
240  pageIsRef = gTrue;
241  } else {
242  error(errSyntaxWarning, -1, "Bad annotation destination");
243  goto err2;
244  }
245  obj1.free();
246 
247  // get destination type
248  a->get(1, &obj1);
249 
250  // XYZ link
251  if (obj1.isName("XYZ")) {
252  kind = destXYZ;
253  if (a->getLength() < 3) {
254  changeLeft = gFalse;
255  } else {
256  a->get(2, &obj2);
257  if (obj2.isNull()) {
258  changeLeft = gFalse;
259  } else if (obj2.isNum()) {
260  changeLeft = gTrue;
261  left = obj2.getNum();
262  } else {
263  error(errSyntaxWarning, -1, "Bad annotation destination position");
264  goto err1;
265  }
266  obj2.free();
267  }
268  if (a->getLength() < 4) {
269  changeTop = gFalse;
270  } else {
271  a->get(3, &obj2);
272  if (obj2.isNull()) {
273  changeTop = gFalse;
274  } else if (obj2.isNum()) {
275  changeTop = gTrue;
276  top = obj2.getNum();
277  } else {
278  error(errSyntaxWarning, -1, "Bad annotation destination position");
279  goto err1;
280  }
281  obj2.free();
282  }
283  if (a->getLength() < 5) {
284  changeZoom = gFalse;
285  } else {
286  a->get(4, &obj2);
287  if (obj2.isNull()) {
288  changeZoom = gFalse;
289  } else if (obj2.isNum()) {
290  changeZoom = gTrue;
291  zoom = obj2.getNum();
292  } else {
293  error(errSyntaxWarning, -1, "Bad annotation destination position");
294  goto err1;
295  }
296  obj2.free();
297  }
298 
299  // Fit link
300  } else if (obj1.isName("Fit")) {
301  if (a->getLength() < 2) {
302  error(errSyntaxWarning, -1, "Annotation destination array is too short");
303  goto err2;
304  }
305  kind = destFit;
306 
307  // FitH link
308  } else if (obj1.isName("FitH")) {
309  if (a->getLength() < 3) {
310  error(errSyntaxWarning, -1, "Annotation destination array is too short");
311  goto err2;
312  }
313  kind = destFitH;
314  if (a->get(2, &obj2)->isNum()) {
315  top = obj2.getNum();
316  changeTop = gTrue;
317  } else if (obj2.isNull()) {
318  changeTop = gFalse;
319  } else {
320  error(errSyntaxWarning, -1, "Bad annotation destination position");
321  kind = destFit;
322  }
323  obj2.free();
324 
325  // FitV link
326  } else if (obj1.isName("FitV")) {
327  if (a->getLength() < 3) {
328  error(errSyntaxWarning, -1, "Annotation destination array is too short");
329  goto err2;
330  }
331  kind = destFitV;
332  if (a->get(2, &obj2)->isNum()) {
333  left = obj2.getNum();
334  changeLeft = gTrue;
335  } else if (obj2.isNull()) {
336  changeLeft = gFalse;
337  } else {
338  error(errSyntaxWarning, -1, "Bad annotation destination position");
339  kind = destFit;
340  }
341  obj2.free();
342 
343  // FitR link
344  } else if (obj1.isName("FitR")) {
345  if (a->getLength() < 6) {
346  error(errSyntaxWarning, -1, "Annotation destination array is too short");
347  goto err2;
348  }
349  kind = destFitR;
350  if (a->get(2, &obj2)->isNum()) {
351  left = obj2.getNum();
352  } else {
353  error(errSyntaxWarning, -1, "Bad annotation destination position");
354  kind = destFit;
355  }
356  obj2.free();
357  if (!a->get(3, &obj2)->isNum()) {
358  error(errSyntaxWarning, -1, "Bad annotation destination position");
359  kind = destFit;
360  }
361  bottom = obj2.getNum();
362  obj2.free();
363  if (!a->get(4, &obj2)->isNum()) {
364  error(errSyntaxWarning, -1, "Bad annotation destination position");
365  kind = destFit;
366  }
367  right = obj2.getNum();
368  obj2.free();
369  if (!a->get(5, &obj2)->isNum()) {
370  error(errSyntaxWarning, -1, "Bad annotation destination position");
371  kind = destFit;
372  }
373  top = obj2.getNum();
374  obj2.free();
375 
376  // FitB link
377  } else if (obj1.isName("FitB")) {
378  if (a->getLength() < 2) {
379  error(errSyntaxWarning, -1, "Annotation destination array is too short");
380  goto err2;
381  }
382  kind = destFitB;
383 
384  // FitBH link
385  } else if (obj1.isName("FitBH")) {
386  if (a->getLength() < 3) {
387  error(errSyntaxWarning, -1, "Annotation destination array is too short");
388  goto err2;
389  }
390  kind = destFitBH;
391  if (a->get(2, &obj2)->isNum()) {
392  top = obj2.getNum();
393  changeTop = gTrue;
394  } else if (obj2.isNull()) {
395  changeTop = gFalse;
396  } else {
397  error(errSyntaxWarning, -1, "Bad annotation destination position");
398  kind = destFit;
399  }
400  obj2.free();
401 
402  // FitBV link
403  } else if (obj1.isName("FitBV")) {
404  if (a->getLength() < 3) {
405  error(errSyntaxWarning, -1, "Annotation destination array is too short");
406  goto err2;
407  }
408  kind = destFitBV;
409  if (a->get(2, &obj2)->isNum()) {
410  left = obj2.getNum();
411  changeLeft = gTrue;
412  } else if (obj2.isNull()) {
413  changeLeft = gFalse;
414  } else {
415  error(errSyntaxWarning, -1, "Bad annotation destination position");
416  kind = destFit;
417  }
418  obj2.free();
419 
420  // unknown link kind
421  } else {
422  error(errSyntaxWarning, -1, "Unknown annotation destination type");
423  goto err2;
424  }
425 
426  obj1.free();
427  ok = gTrue;
428  return;
429 
430  err1:
431  obj2.free();
432  err2:
433  obj1.free();
434 }
435 
437  kind = dest->kind;
438  pageIsRef = dest->pageIsRef;
439  if (pageIsRef)
440  pageRef = dest->pageRef;
441  else
442  pageNum = dest->pageNum;
443  left = dest->left;
444  bottom = dest->bottom;
445  right = dest->right;
446  top = dest->top;
447  zoom = dest->zoom;
448  changeLeft = dest->changeLeft;
449  changeTop = dest->changeTop;
450  changeZoom = dest->changeZoom;
451  ok = gTrue;
452 }
453 
454 //------------------------------------------------------------------------
455 // LinkGoTo
456 //------------------------------------------------------------------------
457 
459  dest = NULL;
460  namedDest = NULL;
461 
462  // named destination
463  if (destObj->isName()) {
464  namedDest = new GString(destObj->getName());
465  } else if (destObj->isString()) {
466  namedDest = destObj->getString()->copy();
467 
468  // destination dictionary
469  } else if (destObj->isArray()) {
470  dest = new LinkDest(destObj->getArray());
471  if (!dest->isOk()) {
472  delete dest;
473  dest = NULL;
474  }
475 
476  // error
477  } else {
478  error(errSyntaxWarning, -1, "Illegal annotation destination");
479  }
480 }
481 
483  if (dest)
484  delete dest;
485  if (namedDest)
486  delete namedDest;
487 }
488 
489 //------------------------------------------------------------------------
490 // LinkGoToR
491 //------------------------------------------------------------------------
492 
493 LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
494  dest = NULL;
495  namedDest = NULL;
496 
497  // get file name
498  fileName = getFileSpecName(fileSpecObj);
499 
500  // named destination
501  if (destObj->isName()) {
502  namedDest = new GString(destObj->getName());
503  } else if (destObj->isString()) {
504  namedDest = destObj->getString()->copy();
505 
506  // destination dictionary
507  } else if (destObj->isArray()) {
508  dest = new LinkDest(destObj->getArray());
509  if (!dest->isOk()) {
510  delete dest;
511  dest = NULL;
512  }
513 
514  // error
515  } else {
516  error(errSyntaxWarning, -1, "Illegal annotation destination");
517  }
518 }
519 
521  if (fileName)
522  delete fileName;
523  if (dest)
524  delete dest;
525  if (namedDest)
526  delete namedDest;
527 }
528 
529 
530 //------------------------------------------------------------------------
531 // LinkLaunch
532 //------------------------------------------------------------------------
533 
535  Object obj1, obj2;
536 
537  fileName = NULL;
538  params = NULL;
539 
540  if (actionObj->isDict()) {
541  if (!actionObj->dictLookup("F", &obj1)->isNull()) {
542  fileName = getFileSpecName(&obj1);
543  } else {
544  obj1.free();
545 #ifdef _WIN32
546  if (actionObj->dictLookup("Win", &obj1)->isDict()) {
547  obj1.dictLookup("F", &obj2);
548  fileName = getFileSpecName(&obj2);
549  obj2.free();
550  if (obj1.dictLookup("P", &obj2)->isString()) {
551  params = obj2.getString()->copy();
552  }
553  obj2.free();
554  } else {
555  error(errSyntaxWarning, -1, "Bad launch-type link action");
556  }
557 #else
558  //~ This hasn't been defined by Adobe yet, so assume it looks
559  //~ just like the Win dictionary until they say otherwise.
560  if (actionObj->dictLookup("Unix", &obj1)->isDict()) {
561  obj1.dictLookup("F", &obj2);
562  fileName = getFileSpecName(&obj2);
563  obj2.free();
564  if (obj1.dictLookup("P", &obj2)->isString()) {
565  params = obj2.getString()->copy();
566  }
567  obj2.free();
568  } else {
569  error(errSyntaxWarning, -1, "Bad launch-type link action");
570  }
571 #endif
572  }
573  obj1.free();
574  }
575 }
576 
578  if (fileName)
579  delete fileName;
580  if (params)
581  delete params;
582 }
583 
584 //------------------------------------------------------------------------
585 // LinkURI
586 //------------------------------------------------------------------------
587 
588 LinkURI::LinkURI(Object *uriObj, GString *baseURI) {
589  GString *uri2;
590  int n;
591  char c;
592 
593  uri = NULL;
594  if (uriObj->isString()) {
595  uri2 = uriObj->getString();
596  n = (int)strcspn(uri2->getCString(), "/:");
597  if (n < uri2->getLength() && uri2->getChar(n) == ':') {
598  // "http:..." etc.
599  uri = uri2->copy();
600  } else if (!uri2->cmpN("www.", 4)) {
601  // "www.[...]" without the leading "http://"
602  uri = new GString("http://");
603  uri->append(uri2);
604  } else {
605  // relative URI
606  if (baseURI) {
607  uri = baseURI->copy();
608  c = uri->getChar(uri->getLength() - 1);
609  if (c != '/' && c != '?') {
610  uri->append('/');
611  }
612  if (uri2->getChar(0) == '/') {
613  uri->append(uri2->getCString() + 1, uri2->getLength() - 1);
614  } else {
615  uri->append(uri2);
616  }
617  } else {
618  uri = uri2->copy();
619  }
620  }
621  } else {
622  error(errSyntaxWarning, -1, "Illegal URI-type link");
623  }
624 }
625 
627  if (uri)
628  delete uri;
629 }
630 
631 //------------------------------------------------------------------------
632 // LinkNamed
633 //------------------------------------------------------------------------
634 
636  name = NULL;
637  if (nameObj->isName()) {
638  name = new GString(nameObj->getName());
639  }
640 }
641 
643  if (name) {
644  delete name;
645  }
646 }
647 
648 //------------------------------------------------------------------------
649 // LinkMovie
650 //------------------------------------------------------------------------
651 
652 LinkMovie::LinkMovie(Object *annotObj, Object *titleObj) {
653  annotRef.num = -1;
654  title = NULL;
655  if (annotObj->isRef()) {
656  annotRef = annotObj->getRef();
657  } else if (titleObj->isString()) {
658  title = titleObj->getString()->copy();
659  } else {
660  error(errSyntaxError, -1,
661  "Movie action is missing both the Annot and T keys");
662  }
663 }
664 
666  if (title) {
667  delete title;
668  }
669 }
670 
671 //------------------------------------------------------------------------
672 // LinkJavaScript
673 //------------------------------------------------------------------------
674 
676  char buf[4096];
677  int n;
678 
679  if (jsObj->isString()) {
680  js = jsObj->getString()->copy();
681  } else if (jsObj->isStream()) {
682  js = new GString();
683  jsObj->streamReset();
684  while ((n = jsObj->getStream()->getBlock(buf, sizeof(buf))) > 0) {
685  js->append(buf, n);
686  }
687  jsObj->streamClose();
688  } else {
689  error(errSyntaxError, -1, "JavaScript action JS key is wrong type");
690  js = NULL;
691  }
692 }
693 
695  if (js) {
696  delete js;
697  }
698 }
699 
700 //------------------------------------------------------------------------
701 // LinkSubmitForm
702 //------------------------------------------------------------------------
703 
705  Object *flagsObj) {
706  if (urlObj->isString()) {
707  url = urlObj->getString()->copy();
708  } else {
709  error(errSyntaxError, -1, "SubmitForm action URL is wrong type");
710  url = NULL;
711  }
712 
713  if (fieldsObj->isArray()) {
714  fieldsObj->copy(&fields);
715  } else {
716  if (!fieldsObj->isNull()) {
717  error(errSyntaxError, -1, "SubmitForm action Fields value is wrong type");
718  }
719  fields.initNull();
720  }
721 
722  if (flagsObj->isInt()) {
723  flags = flagsObj->getInt();
724  } else {
725  if (!flagsObj->isNull()) {
726  error(errSyntaxError, -1, "SubmitForm action Flags value is wrong type");
727  }
728  flags = 0;
729  }
730 }
731 
733  if (url) {
734  delete url;
735  }
736  fields.free();
737 }
738 
739 //------------------------------------------------------------------------
740 // LinkHide
741 //------------------------------------------------------------------------
742 
743 LinkHide::LinkHide(Object *fieldsObj, Object *hideFlagObj) {
744  if (fieldsObj->isRef() || fieldsObj->isString() || fieldsObj->isArray()) {
745  fieldsObj->copy(&fields);
746  } else {
747  error(errSyntaxError, -1, "Hide action T value is wrong type");
748  fields.initNull();
749  }
750 
751  if (hideFlagObj->isBool()) {
752  hideFlag = hideFlagObj->getBool();
753  } else {
754  error(errSyntaxError, -1, "Hide action H value is wrong type");
755  hideFlag = gFalse;
756  }
757 }
758 
760  fields.free();
761 }
762 
763 //------------------------------------------------------------------------
764 // LinkUnknown
765 //------------------------------------------------------------------------
766 
767 LinkUnknown::LinkUnknown(char *actionA) {
768  action = new GString(actionA);
769 }
770 
772  delete action;
773 }
774 
775 //------------------------------------------------------------------------
776 // Link
777 //------------------------------------------------------------------------
778 
779 Link::Link(Dict *dict, GString *baseURI) {
780  Object obj1, obj2;
781  double t;
782 
783  action = NULL;
784  ok = gFalse;
785 
786  // get rectangle
787  if (!dict->lookup("Rect", &obj1)->isArray()) {
788  error(errSyntaxError, -1, "Annotation rectangle is wrong type");
789  goto err2;
790  }
791  if (!obj1.arrayGet(0, &obj2)->isNum()) {
792  error(errSyntaxError, -1, "Bad annotation rectangle");
793  goto err1;
794  }
795  x1 = obj2.getNum();
796  obj2.free();
797  if (!obj1.arrayGet(1, &obj2)->isNum()) {
798  error(errSyntaxError, -1, "Bad annotation rectangle");
799  goto err1;
800  }
801  y1 = obj2.getNum();
802  obj2.free();
803  if (!obj1.arrayGet(2, &obj2)->isNum()) {
804  error(errSyntaxError, -1, "Bad annotation rectangle");
805  goto err1;
806  }
807  x2 = obj2.getNum();
808  obj2.free();
809  if (!obj1.arrayGet(3, &obj2)->isNum()) {
810  error(errSyntaxError, -1, "Bad annotation rectangle");
811  goto err1;
812  }
813  y2 = obj2.getNum();
814  obj2.free();
815  obj1.free();
816  if (x1 > x2) {
817  t = x1;
818  x1 = x2;
819  x2 = t;
820  }
821  if (y1 > y2) {
822  t = y1;
823  y1 = y2;
824  y2 = t;
825  }
826 
827  // look for destination
828  if (!dict->lookup("Dest", &obj1)->isNull()) {
829  action = LinkAction::parseDest(&obj1);
830 
831  // look for action
832  } else {
833  obj1.free();
834  if (dict->lookup("A", &obj1)->isDict()) {
835  action = LinkAction::parseAction(&obj1, baseURI);
836  }
837  }
838  obj1.free();
839 
840  // check for bad action
841  if (action) {
842  ok = gTrue;
843  }
844 
845  return;
846 
847  err1:
848  obj2.free();
849  err2:
850  obj1.free();
851 }
852 
854  if (action) {
855  delete action;
856  }
857 }
858 
859 //------------------------------------------------------------------------
860 // Links
861 //------------------------------------------------------------------------
862 
863 Links::Links(Object *annots, GString *baseURI) {
864  Link *link;
865  Object obj1, obj2, obj3;
866  int size;
867  int i;
868 
869  links = NULL;
870  size = 0;
871  numLinks = 0;
872 
873  if (annots->isArray()) {
874  for (i = 0; i < annots->arrayGetLength(); ++i) {
875  if (annots->arrayGet(i, &obj1)->isDict()) {
876  obj1.dictLookup("Subtype", &obj2);
877  obj1.dictLookup("FT", &obj3);
878  if (obj2.isName("Link") ||
879  (obj2.isName("Widget") && (obj3.isName("Btn") || obj3.isNull()))) {
880  link = new Link(obj1.getDict(), baseURI);
881  if (link->isOk()) {
882  if (numLinks >= size) {
883  size += 16;
884  links = (Link **)greallocn(links, size, sizeof(Link *));
885  }
886  links[numLinks++] = link;
887  } else {
888  delete link;
889  }
890  }
891  obj3.free();
892  obj2.free();
893  }
894  obj1.free();
895  }
896  }
897 }
898 
900  int i;
901 
902  for (i = 0; i < numLinks; ++i)
903  delete links[i];
904  gfree(links);
905 }
906 
907 LinkAction *Links::find(double x, double y) {
908  int i;
909 
910  for (i = numLinks - 1; i >= 0; --i) {
911  if (links[i]->inRect(x, y)) {
912  return links[i]->getAction();
913  }
914  }
915  return NULL;
916 }
917 
918 GBool Links::onLink(double x, double y) {
919  int i;
920 
921  for (i = 0; i < numLinks; ++i) {
922  if (links[i]->inRect(x, y))
923  return gTrue;
924  }
925  return gFalse;
926 }
#define name
size_t __cdecl strcspn(char const *_Str, char const *_Control)
Definition: Array.h:29
Definition: Dict.h:29
Object * lookup(const char *key, Object *obj, int recursion=0)
Definition: Dict.cc:122
GString * copy()
Definition: GString.h:42
char getChar(int i)
Definition: GString.h:86
int cmpN(GString *str, int n)
Definition: GString.cc:792
char * getCString()
Definition: GString.h:83
int getLength()
Definition: GString.h:80
static GString * getFileSpecName(Object *fileSpecObj)
Definition: Link.cc:133
static LinkAction * parseAction(Object *obj, GString *baseURI=NULL)
Definition: Link.cc:41
static LinkAction * parseDest(Object *obj)
Definition: Link.cc:30
Definition: Link.h:79
LinkDest(Array *a)
Definition: Link.cc:221
LinkGoToR(Object *fileSpecObj, Object *destObj)
Definition: Link.cc:493
virtual ~LinkGoToR()
Definition: Link.cc:520
Definition: Link.h:129
virtual ~LinkGoTo()
Definition: Link.cc:482
LinkGoTo(Object *destObj)
Definition: Link.cc:458
Definition: Link.h:342
LinkHide(Object *fieldsObj, Object *hideFlagObj)
Definition: Link.cc:743
virtual ~LinkHide()
Definition: Link.cc:759
virtual ~LinkJavaScript()
Definition: Link.cc:694
LinkJavaScript(Object *jsObj)
Definition: Link.cc:675
LinkLaunch(Object *actionObj)
Definition: Link.cc:534
virtual ~LinkLaunch()
Definition: Link.cc:577
LinkMovie(Object *annotObj, Object *titleObj)
Definition: Link.cc:652
virtual ~LinkMovie()
Definition: Link.cc:665
LinkNamed(Object *nameObj)
Definition: Link.cc:635
virtual ~LinkNamed()
Definition: Link.cc:642
virtual ~LinkSubmitForm()
Definition: Link.cc:732
LinkSubmitForm(Object *urlObj, Object *fieldsObj, Object *flagsObj)
Definition: Link.cc:704
Definition: Link.h:217
virtual ~LinkURI()
Definition: Link.cc:626
LinkURI(Object *uriObj, GString *baseURI)
Definition: Link.cc:588
virtual ~LinkUnknown()
Definition: Link.cc:771
LinkUnknown(char *actionA)
Definition: Link.cc:767
Definition: Object.h:84
Ref getRef()
Definition: Object.h:163
GBool isDict()
Definition: Object.h:137
Object * dictLookup(const char *key, Object *obj, int recursion=0)
Definition: Object.h:266
Stream * getStream()
Definition: Object.h:162
GBool isNum()
Definition: Object.h:132
Array * getArray()
Definition: Object.h:160
void streamClose()
Definition: Object.h:296
double getNum()
Definition: Object.h:157
GBool isName()
Definition: Object.h:134
void free()
Definition: Object.cc:119
GBool isStream()
Definition: Object.h:138
GBool isRef()
Definition: Object.h:139
GBool getBool()
Definition: Object.h:154
int getRefGen()
Definition: Object.h:165
Object * copy(Object *obj)
Definition: Object.cc:80
char * getName()
Definition: Object.h:159
int getInt()
Definition: Object.h:155
GBool isInt()
Definition: Object.h:130
int arrayGetLength()
Definition: Object.h:236
GBool isArray()
Definition: Object.h:136
void streamReset()
Definition: Object.h:293
GBool isString()
Definition: Object.h:133
GString * getString()
Definition: Object.h:158
Dict * getDict()
Definition: Object.h:161
Object * dictLookupNF(const char *key, Object *obj)
Definition: Object.h:269
GBool isNull()
Definition: Object.h:135
int getRefNum()
Definition: Object.h:164
Object * arrayGet(int i, Object *obj, int recursion=0)
Definition: Object.h:242
GBool isBool()
Definition: Object.h:129
virtual int getBlock(char *blk, int size)
Definition: Stream.cc:72
#define n
Definition: t4ht.c:1290
int params
Definition: definitions.c:42
#define gfree(p)
Definition: dt2dv.c:326
#define error(a)
Definition: dviinfo.c:48
#define t
Definition: afcover.h:96
void * greallocn(void *p, int nObjs, int objSize)
Definition: gmem.cc:291
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
#define gFalse
Definition: gtypes.h:18
int GBool
Definition: gtypes.h:16
#define gTrue
Definition: gtypes.h:17
int kind
Definition: image.c:8980
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
kerning y
Definition: ttdriver.c:212
@ right
Definition: annotate.c:15
int int double double double char double char * top
Definition: gdfx.h:19
int int double double double char double char char * bottom
Definition: gdfx.h:20
@ errSyntaxError
Definition: Error.h:25
@ errSyntaxWarning
Definition: Error.h:23
static double zoom
Definition: pdftohtml.cc:32
#define buf
action
Definition: epdf.c:220
#define link
Definition: win32lib.h:82
#define dest
int getLength(char *s)
Definition: lengths.c:99
float x
Definition: cordic.py:15
static int size
Definition: ppmlabel.c:24
#define x1
#define y1
#define y2
#define x2
#define flags
Definition: dvips.h:235
int j
Definition: t4ht.c:1589
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
map< string, set< string > > links
Definition: tz2icu.cpp:904
const char * fileName
Definition: ugrep.cpp:52
@ title
Definition: preamble.c:50