diff options
author | Martin Kretzschmar <mkretzschmar@src.gnome.org> | 2003-03-31 21:08:43 (GMT) |
---|---|---|
committer | Martin Kretzschmar <mkretzschmar@src.gnome.org> | 2003-03-31 21:08:43 (GMT) |
commit | 64676031423465996e83c4a685290f0c3d97a249 (patch) | |
tree | cef578bc8c300722abb3fe1693181e68895a94a7 /pdf/xpdf/Link.cc | |
parent | 28c37dbcf87665a4ccec58bef9ef8ff0697022dd (diff) |
kill traces of ltk, incorporate new sources
* xpdf/Makefile.am: kill traces of ltk, incorporate new sources
* Makefile.am, configure.in: don't build the ltk subdir
* ANNOUNCE, CHANGES, ChangeLog, README, aconf-dj.h, aconf-win32.h,
dj_make.bat, ms_make.bat, vms_make.com: update
* xpdf/LTKOutputDev.cc, xpdf/LTKOutputDev.h, xpdf/postscript.xbm,
xpdf/xpdf-flip.ltk, xpdf/xpdf-ltk.h, xpdf/xpdf-top.ltk,
xpdf/xpdf.ltk: remove.
* xpdf/Annot.cc, xpdf/Annot.h, xpdf/Array.cc, xpdf/Array.h,
xpdf/BuiltinFont.cc, xpdf/BuiltinFont.h,
xpdf/BuiltinFontTables.cc, xpdf/CMap.cc, xpdf/CMap.h,
xpdf/Catalog.cc, xpdf/Catalog.h, xpdf/CharCodeToUnicode.cc,
xpdf/CharCodeToUnicode.h, xpdf/Decrypt.cc, xpdf/Decrypt.h,
xpdf/Dict.cc, xpdf/Dict.h, xpdf/Error.cc, xpdf/Error.h,
xpdf/FTFont.cc, xpdf/FTFont.h, xpdf/FontFile.cc, xpdf/FontFile.h,
xpdf/Function.cc, xpdf/Function.h, xpdf/Gfx.cc, xpdf/Gfx.h,
xpdf/GfxFont.cc, xpdf/GfxFont.h, xpdf/GfxState.cc,
xpdf/GfxState.h, xpdf/GlobalParams.cc, xpdf/GlobalParams.h,
xpdf/ImageOutputDev.cc, xpdf/ImageOutputDev.h, xpdf/Lexer.cc,
xpdf/Lexer.h, xpdf/Link.cc, xpdf/Link.h, xpdf/NameToCharCode.cc,
xpdf/NameToCharCode.h, xpdf/NameToUnicodeTable.h, xpdf/Object.cc,
xpdf/Object.h, xpdf/OutputDev.cc, xpdf/OutputDev.h,
xpdf/PBMOutputDev.cc, xpdf/PBMOutputDev.h, xpdf/PDFDoc.cc,
xpdf/PDFDoc.h, xpdf/PSOutputDev.cc, xpdf/PSOutputDev.h,
xpdf/PSTokenizer.cc, xpdf/PSTokenizer.h, xpdf/Page.cc,
xpdf/Page.h, xpdf/Parser.cc, xpdf/Parser.h, xpdf/SFont.cc,
xpdf/SFont.h, xpdf/Stream.cc, xpdf/Stream.h, xpdf/T1Font.cc,
xpdf/T1Font.h, xpdf/TTFont.cc, xpdf/TTFont.h,
xpdf/TextOutputDev.cc, xpdf/TextOutputDev.h, xpdf/UnicodeMap.cc,
xpdf/UnicodeMap.h, xpdf/XOutputDev.cc, xpdf/XOutputDev.h,
xpdf/XRef.cc, xpdf/XRef.h, xpdf/config.h, xpdf/pdffonts.cc,
xpdf/pdfimages.cc, xpdf/pdfinfo.cc, xpdf/pdftopbm.cc,
xpdf/pdftops.cc, xpdf/pdftotext.cc, xpdf/vms_make.com,
xpdf/xpdf.cc: update.
* goo/GHash.cc, goo/GHash.h, goo/GList.cc, goo/GList.h,
goo/GString.cc, goo/GString.h: mostly Mac OS X gcc fixage.
* doc/pdffonts.1, doc/pdffonts.cat, doc/pdffonts.hlp,
doc/pdfimages.1, doc/pdfimages.cat, doc/pdfimages.hlp,
doc/pdfinfo.1, doc/pdfinfo.cat, doc/pdfinfo.hlp, doc/pdftopbm.1,
doc/pdftopbm.cat, doc/pdftopbm.hlp, doc/pdftops.1,
doc/pdftops.cat, doc/pdftops.hlp, doc/pdftotext.1,
doc/pdftotext.cat, doc/pdftotext.hlp, doc/xpdf.1, doc/xpdf.cat,
doc/xpdf.hlp, doc/xpdfrc.5, doc/xpdfrc.cat, doc/xpdfrc.hlp:
update docs.
Diffstat (limited to 'pdf/xpdf/Link.cc')
-rw-r--r-- | pdf/xpdf/Link.cc | 279 |
1 files changed, 192 insertions, 87 deletions
diff --git a/pdf/xpdf/Link.cc b/pdf/xpdf/Link.cc index eb9d033..b16563a 100644 --- a/pdf/xpdf/Link.cc +++ b/pdf/xpdf/Link.cc @@ -6,11 +6,12 @@ // //======================================================================== -#ifdef __GNUC__ +#include <aconf.h> + +#ifdef USE_GCC_PRAGMAS #pragma implementation #endif -#include <aconf.h> #include <stddef.h> #include <string.h> #include "gmem.h" @@ -22,8 +23,117 @@ #include "Link.h" //------------------------------------------------------------------------ +// LinkAction +//------------------------------------------------------------------------ + +LinkAction *LinkAction::parseDest(Object *obj) { + LinkAction *action; + + action = new LinkGoTo(obj); + if (!action->isOk()) { + delete action; + return NULL; + } + return action; +} + +LinkAction *LinkAction::parseAction(Object *obj, GString *baseURI) { + LinkAction *action; + Object obj2, obj3, obj4; + + if (!obj->isDict()) { + error(-1, "Bad annotation action"); + return NULL; + } + + obj->dictLookup("S", &obj2); + + // GoTo action + if (obj2.isName("GoTo")) { + obj->dictLookup("D", &obj3); + action = new LinkGoTo(&obj3); + obj3.free(); + + // GoToR action + } else if (obj2.isName("GoToR")) { + obj->dictLookup("F", &obj3); + obj->dictLookup("D", &obj4); + action = new LinkGoToR(&obj3, &obj4); + obj3.free(); + obj4.free(); + + // Launch action + } else if (obj2.isName("Launch")) { + action = new LinkLaunch(obj); + + // URI action + } else if (obj2.isName("URI")) { + obj->dictLookup("URI", &obj3); + action = new LinkURI(&obj3, baseURI); + obj3.free(); + + // Named action + } else if (obj2.isName("Named")) { + obj->dictLookup("N", &obj3); + action = new LinkNamed(&obj3); + obj3.free(); + + // Movie action + } else if (obj2.isName("Movie")) { + obj->dictLookupNF("Annot", &obj3); + obj->dictLookup("T", &obj4); + action = new LinkMovie(&obj3, &obj4); + obj3.free(); + obj4.free(); + + // unknown action + } else if (obj2.isName()) { + action = new LinkUnknown(obj2.getName()); + + // action is missing or wrong type + } else { + error(-1, "Bad annotation action"); + action = NULL; + } -static GString *getFileSpecName(Object *fileSpecObj); + obj2.free(); + + if (action && !action->isOk()) { + delete action; + return NULL; + } + return action; +} + +GString *LinkAction::getFileSpecName(Object *fileSpecObj) { + GString *name; + Object obj1; + + name = NULL; + + // string + if (fileSpecObj->isString()) { + name = fileSpecObj->getString()->copy(); + + // dictionary + } else if (fileSpecObj->isDict()) { + if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) { + obj1.free(); + fileSpecObj->dictLookup("F", &obj1); + } + if (obj1.isString()) + name = obj1.getString()->copy(); + else + error(-1, "Illegal file spec in link"); + obj1.free(); + + // error + } else { + error(-1, "Illegal file spec in link"); + } + + return name; +} //------------------------------------------------------------------------ // LinkDest @@ -37,6 +147,10 @@ LinkDest::LinkDest(Array *a) { ok = gFalse; // get page + if (a->getLength() < 2) { + error(-1, "Annotation destination array has wrong length"); + return; + } a->getNF(0, &obj1); if (obj1.isInt()) { pageNum = obj1.getInt() + 1; @@ -56,6 +170,10 @@ LinkDest::LinkDest(Array *a) { // XYZ link if (obj1.isName("XYZ")) { + if (a->getLength() != 5) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destXYZ; a->get(2, &obj2); if (obj2.isNull()) { @@ -93,10 +211,18 @@ LinkDest::LinkDest(Array *a) { // Fit link } else if (obj1.isName("Fit")) { + if (a->getLength() != 2) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFit; // FitH link } else if (obj1.isName("FitH")) { + if (a->getLength() != 3) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitH; if (!a->get(2, &obj2)->isNum()) { error(-1, "Bad annotation destination position"); @@ -107,6 +233,10 @@ LinkDest::LinkDest(Array *a) { // FitV link } else if (obj1.isName("FitV")) { + if (a->getLength() != 3) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitV; if (!a->get(2, &obj2)->isNum()) { error(-1, "Bad annotation destination position"); @@ -117,6 +247,10 @@ LinkDest::LinkDest(Array *a) { // FitR link } else if (obj1.isName("FitR")) { + if (a->getLength() != 6) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitR; if (!a->get(2, &obj2)->isNum()) { error(-1, "Bad annotation destination position"); @@ -145,10 +279,18 @@ LinkDest::LinkDest(Array *a) { // FitB link } else if (obj1.isName("FitB")) { + if (a->getLength() != 2) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitB; // FitBH link } else if (obj1.isName("FitBH")) { + if (a->getLength() != 3) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitBH; if (!a->get(2, &obj2)->isNum()) { error(-1, "Bad annotation destination position"); @@ -159,6 +301,10 @@ LinkDest::LinkDest(Array *a) { // FitBV link } else if (obj1.isName("FitBV")) { + if (a->getLength() != 3) { + error(-1, "Annotation destination array has wrong length"); + goto err2; + } kind = destFitBV; if (!a->get(2, &obj2)->isNum()) { error(-1, "Bad annotation destination position"); @@ -292,18 +438,33 @@ LinkLaunch::LinkLaunch(Object *actionObj) { fileName = getFileSpecName(&obj1); } else { obj1.free(); +#ifdef WIN32 + if (actionObj->dictLookup("Win", &obj1)->isDict()) { + obj1.dictLookup("F", &obj2); + fileName = getFileSpecName(&obj2); + obj2.free(); + if (obj1.dictLookup("P", &obj2)->isString()) { + params = obj2.getString()->copy(); + } + obj2.free(); + } else { + error(-1, "Bad launch-type link action"); + } +#else //~ This hasn't been defined by Adobe yet, so assume it looks //~ just like the Win dictionary until they say otherwise. if (actionObj->dictLookup("Unix", &obj1)->isDict()) { obj1.dictLookup("F", &obj2); fileName = getFileSpecName(&obj2); obj2.free(); - if (obj1.dictLookup("P", &obj2)->isString()) + if (obj1.dictLookup("P", &obj2)->isString()) { params = obj2.getString()->copy(); + } obj2.free(); } else { error(-1, "Bad launch-type link action"); } +#endif } obj1.free(); } @@ -378,6 +539,28 @@ LinkNamed::~LinkNamed() { } //------------------------------------------------------------------------ +// LinkMovie +//------------------------------------------------------------------------ + +LinkMovie::LinkMovie(Object *annotObj, Object *titleObj) { + annotRef.num = -1; + title = NULL; + if (annotObj->isRef()) { + annotRef = annotObj->getRef(); + } else if (titleObj->isString()) { + title = titleObj->getString()->copy(); + } else { + error(-1, "Movie action is missing both the Annot and T keys"); + } +} + +LinkMovie::~LinkMovie() { + if (title) { + delete title; + } +} + +//------------------------------------------------------------------------ // LinkUnknown //------------------------------------------------------------------------ @@ -394,7 +577,7 @@ LinkUnknown::~LinkUnknown() { //------------------------------------------------------------------------ Link::Link(Dict *dict, GString *baseURI) { - Object obj1, obj2, obj3, obj4; + Object obj1, obj2; double t; action = NULL; @@ -457,66 +640,21 @@ Link::Link(Dict *dict, GString *baseURI) { // look for destination if (!dict->lookup("Dest", &obj1)->isNull()) { - action = new LinkGoTo(&obj1); + action = LinkAction::parseDest(&obj1); // look for action } else { obj1.free(); if (dict->lookup("A", &obj1)->isDict()) { - obj1.dictLookup("S", &obj2); - - // GoTo action - if (obj2.isName("GoTo")) { - obj1.dictLookup("D", &obj3); - action = new LinkGoTo(&obj3); - obj3.free(); - - // GoToR action - } else if (obj2.isName("GoToR")) { - obj1.dictLookup("F", &obj3); - obj1.dictLookup("D", &obj4); - action = new LinkGoToR(&obj3, &obj4); - obj3.free(); - obj4.free(); - - // Launch action - } else if (obj2.isName("Launch")) { - action = new LinkLaunch(&obj1); - - // URI action - } else if (obj2.isName("URI")) { - obj1.dictLookup("URI", &obj3); - action = new LinkURI(&obj3, baseURI); - obj3.free(); - - // Named action - } else if (obj2.isName("Named")) { - obj1.dictLookup("N", &obj3); - action = new LinkNamed(&obj3); - obj3.free(); - - // unknown action - } else if (obj2.isName()) { - action = new LinkUnknown(obj2.getName()); - - // action is missing or wrong type - } else { - error(-1, "Bad annotation action"); - action = NULL; - } - - obj2.free(); - - } else { - error(-1, "Missing annotation destination/action"); - action = NULL; + action = LinkAction::parseAction(&obj1, baseURI); } } obj1.free(); // check for bad action - if (action && action->isOk()) + if (action) { ok = gTrue; + } return; @@ -595,36 +733,3 @@ GBool Links::onLink(double x, double y) const { } return gFalse; } - -//------------------------------------------------------------------------ - -// Extract a file name from a file specification (string or dictionary). -static GString *getFileSpecName(Object *fileSpecObj) { - GString *name; - Object obj1; - - name = NULL; - - // string - if (fileSpecObj->isString()) { - name = fileSpecObj->getString()->copy(); - - // dictionary - } else if (fileSpecObj->isDict()) { - if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) { - obj1.free(); - fileSpecObj->dictLookup("F", &obj1); - } - if (obj1.isString()) - name = obj1.getString()->copy(); - else - error(-1, "Illegal file spec in link"); - obj1.free(); - - // error - } else { - error(-1, "Illegal file spec in link"); - } - - return name; -} |