⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 link.cc

📁 将pdf文档转换为高质量的html文档
💻 CC
📖 第 1 页 / 共 2 页
字号:
  fileName = getFileSpecName(fileSpecObj);  // named destination  if (destObj->isName()) {    namedDest = new GString(destObj->getName());  } else if (destObj->isString()) {    namedDest = destObj->getString()->copy();  // destination dictionary  } else if (destObj->isArray()) {    dest = new LinkDest(destObj->getArray());    if (!dest->isOk()) {      delete dest;      dest = NULL;    }  // error  } else {    error(-1, "Illegal annotation destination");  }}LinkGoToR::~LinkGoToR() {  if (fileName)    delete fileName;  if (dest)    delete dest;  if (namedDest)    delete namedDest;}//------------------------------------------------------------------------// LinkLaunch//------------------------------------------------------------------------LinkLaunch::LinkLaunch(Object *actionObj) {  Object obj1, obj2;  fileName = NULL;  params = NULL;  if (actionObj->isDict()) {    if (!actionObj->dictLookup("F", &obj1)->isNull()) {      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()) {	  params = obj2.getString()->copy();	}	obj2.free();      } else {	error(-1, "Bad launch-type link action");      }#endif    }    obj1.free();  }}LinkLaunch::~LinkLaunch() {  if (fileName)    delete fileName;  if (params)    delete params;}//------------------------------------------------------------------------// LinkURI//------------------------------------------------------------------------LinkURI::LinkURI(Object *uriObj, GString *baseURI) {  GString *uri2;  int n;  char c;  uri = NULL;  if (uriObj->isString()) {    uri2 = uriObj->getString()->copy();    if (baseURI && baseURI->getLength() > 0) {      n = strcspn(uri2->getCString(), "/:");      if (n == uri2->getLength() || uri2->getChar(n) == '/') {	uri = baseURI->copy();	c = uri->getChar(uri->getLength() - 1);	if (c == '/' || c == '?') {	  if (uri2->getChar(0) == '/') {	    uri2->del(0);	  }	} else {	  if (uri2->getChar(0) != '/') {	    uri->append('/');	  }	}	uri->append(uri2);	delete uri2;      } else {	uri = uri2;      }    } else {      uri = uri2;    }  } else {    error(-1, "Illegal URI-type link");  }}LinkURI::~LinkURI() {  if (uri)    delete uri;}//------------------------------------------------------------------------// LinkNamed//------------------------------------------------------------------------LinkNamed::LinkNamed(Object *nameObj) {  name = NULL;  if (nameObj->isName()) {    name = new GString(nameObj->getName());  }}LinkNamed::~LinkNamed() {  if (name) {    delete name;  }}//------------------------------------------------------------------------// 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//------------------------------------------------------------------------LinkUnknown::LinkUnknown(char *actionA) {  action = new GString(actionA);}LinkUnknown::~LinkUnknown() {  delete action;}//------------------------------------------------------------------------// LinkBorderStyle//------------------------------------------------------------------------LinkBorderStyle::LinkBorderStyle(LinkBorderType typeA, double widthA,				 double *dashA, int dashLengthA,				 double rA, double gA, double bA) {  type = typeA;  width = widthA;  dash = dashA;  dashLength = dashLengthA;  r = rA;  g = gA;  b = bA;}LinkBorderStyle::~LinkBorderStyle() {  if (dash) {    gfree(dash);  }}//------------------------------------------------------------------------// Link//------------------------------------------------------------------------Link::Link(Dict *dict, GString *baseURI) {  Object obj1, obj2, obj3;  LinkBorderType borderType;  double borderWidth;  double *borderDash;  int borderDashLength;  double borderR, borderG, borderB;  double t;  int i;  borderStyle = NULL;  action = NULL;  ok = gFalse;  // get rectangle  if (!dict->lookup("Rect", &obj1)->isArray()) {    error(-1, "Annotation rectangle is wrong type");    goto err2;  }  if (!obj1.arrayGet(0, &obj2)->isNum()) {    error(-1, "Bad annotation rectangle");    goto err1;  }  x1 = obj2.getNum();  obj2.free();  if (!obj1.arrayGet(1, &obj2)->isNum()) {    error(-1, "Bad annotation rectangle");    goto err1;  }  y1 = obj2.getNum();  obj2.free();  if (!obj1.arrayGet(2, &obj2)->isNum()) {    error(-1, "Bad annotation rectangle");    goto err1;  }  x2 = obj2.getNum();  obj2.free();  if (!obj1.arrayGet(3, &obj2)->isNum()) {    error(-1, "Bad annotation rectangle");    goto err1;  }  y2 = obj2.getNum();  obj2.free();  obj1.free();  if (x1 > x2) {    t = x1;    x1 = x2;    x2 = t;  }  if (y1 > y2) {    t = y1;    y1 = y2;    y2 = t;  }  // get the border style info  borderType = linkBorderSolid;  borderWidth = 1;  borderDash = NULL;  borderDashLength = 0;  borderR = 0;  borderG = 0;  borderB = 1;  if (dict->lookup("BS", &obj1)->isDict()) {    if (obj1.dictLookup("S", &obj2)->isName()) {      if (obj2.isName("S")) {	borderType = linkBorderSolid;      } else if (obj2.isName("D")) {	borderType = linkBorderDashed;      } else if (obj2.isName("B")) {	borderType = linkBorderEmbossed;      } else if (obj2.isName("I")) {	borderType = linkBorderEngraved;      } else if (obj2.isName("U")) {	borderType = linkBorderUnderlined;      }    }    obj2.free();    if (obj1.dictLookup("W", &obj2)->isNum()) {      borderWidth = obj2.getNum();    }    obj2.free();    if (obj1.dictLookup("D", &obj2)->isArray()) {      borderDashLength = obj2.arrayGetLength();      borderDash = (double *)gmallocn(borderDashLength, sizeof(double));      for (i = 0; i < borderDashLength; ++i) {	if (obj2.arrayGet(i, &obj3)->isNum()) {	  borderDash[i] = obj3.getNum();	} else {	  borderDash[i] = 1;	}	obj3.free();      }    }    obj2.free();  } else {    obj1.free();    if (dict->lookup("Border", &obj1)->isArray()) {      if (obj1.arrayGetLength() >= 3) {	if (obj1.arrayGet(2, &obj2)->isNum()) {	  borderWidth = obj2.getNum();	}	obj2.free();	if (obj1.arrayGetLength() >= 4) {	  if (obj1.arrayGet(3, &obj2)->isArray()) {	    borderType = linkBorderDashed;	    borderDashLength = obj2.arrayGetLength();	    borderDash = (double *)gmallocn(borderDashLength, sizeof(double));	    for (i = 0; i < borderDashLength; ++i) {	      if (obj2.arrayGet(i, &obj3)->isNum()) {		borderDash[i] = obj3.getNum();	      } else {		borderDash[i] = 1;	      }	      obj3.free();	    }	  } else {	    // Adobe draws no border at all if the last element is of	    // the wrong type.	    borderWidth = 0;	  }	  obj2.free();	}      }    }  }  obj1.free();  if (dict->lookup("C", &obj1)->isArray() && obj1.arrayGetLength() == 3) {    if (obj1.arrayGet(0, &obj2)->isNum()) {      borderR = obj2.getNum();    }    obj1.free();    if (obj1.arrayGet(1, &obj2)->isNum()) {      borderG = obj2.getNum();    }    obj1.free();    if (obj1.arrayGet(2, &obj2)->isNum()) {      borderB = obj2.getNum();    }    obj1.free();  }  obj1.free();  /*  borderStyle = new LinkBorderStyle(borderType, borderWidth,				    borderDash, borderDashLength,				    borderR, borderG, borderB);*/  // look for destination  if (!dict->lookup("Dest", &obj1)->isNull()) {    action = LinkAction::parseDest(&obj1);  // look for action  } else {    obj1.free();    if (dict->lookup("A", &obj1)->isDict()) {      action = LinkAction::parseAction(&obj1, baseURI);    }  }  obj1.free();  // check for bad action  if (action) {    ok = gTrue;  }  return; err1:  obj2.free(); err2:  obj1.free();}Link::~Link() {  if (borderStyle) {    delete borderStyle;  }  if (action) {    delete action;  }}//------------------------------------------------------------------------// Links//------------------------------------------------------------------------Links::Links(Object *annots, GString *baseURI) {  Link *link;  Object obj1, obj2;  int size;  int i;  links = NULL;  size = 0;  numLinks = 0;  if (annots->isArray()) {    for (i = 0; i < annots->arrayGetLength(); ++i) {      if (annots->arrayGet(i, &obj1)->isDict()) {	if (obj1.dictLookup("Subtype", &obj2)->isName("Link")) {	  link = new Link(obj1.getDict(), baseURI);	  if (link->isOk()) {	    if (numLinks >= size) {	      size += 16;	      links = (Link **)greallocn(links, size, sizeof(Link *));	    }	    links[numLinks++] = link;	  } else {	    delete link;	  }	}	obj2.free();      }      obj1.free();    }  }}Links::~Links() {  int i;  for (i = 0; i < numLinks; ++i)    delete links[i];  gfree(links);}LinkAction *Links::find(double x, double y) {  int i;  for (i = numLinks - 1; i >= 0; --i) {    if (links[i]->inRect(x, y)) {      return links[i]->getAction();    }  }  return NULL;}GBool Links::onLink(double x, double y) {  int i;  for (i = 0; i < numLinks; ++i) {    if (links[i]->inRect(x, y))      return gTrue;  }  return gFalse;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -