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

📄 globalparams.cc

📁 source code: Covert TXT to PDF
💻 CC
📖 第 1 页 / 共 3 页
字号:
				     int line) {  GString *collection, *name, *old;  if (tokens->getLength() != 3) {    error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  collection = (GString *)tokens->get(1);  name = (GString *)tokens->get(2);  if ((old = (GString *)cidToUnicodes->remove(collection))) {    delete old;  }  cidToUnicodes->add(collection->copy(), name->copy());}void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,				   int line) {  GString *encodingName, *name, *old;  if (tokens->getLength() != 3) {    error(-1, "Bad 'unicodeMap' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  encodingName = (GString *)tokens->get(1);  name = (GString *)tokens->get(2);  if ((old = (GString *)unicodeMaps->remove(encodingName))) {    delete old;  }  unicodeMaps->add(encodingName->copy(), name->copy());}void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {  GString *collection, *dir;  GList *list;  if (tokens->getLength() != 3) {    error(-1, "Bad 'cMapDir' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  collection = (GString *)tokens->get(1);  dir = (GString *)tokens->get(2);  if (!(list = (GList *)cMapDirs->lookup(collection))) {    list = new GList();    cMapDirs->add(collection->copy(), list);  }  list->append(dir->copy());}void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,				     int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());}void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,				    DisplayFontParamKind kind,				    GString *fileName, int line) {  DisplayFontParam *param, *old;  if (tokens->getLength() < 2) {    goto err1;  }  param = new DisplayFontParam(((GString *)tokens->get(1))->copy(), kind);    switch (kind) {  case displayFontX:    if (tokens->getLength() != 4) {      goto err2;    }    param->x.xlfd = ((GString *)tokens->get(2))->copy();    param->x.encoding = ((GString *)tokens->get(3))->copy();    break;  case displayFontT1:    if (tokens->getLength() != 3) {      goto err2;    }    param->t1.fileName = ((GString *)tokens->get(2))->copy();    break;  case displayFontTT:    if (tokens->getLength() != 3) {      goto err2;    }    param->tt.fileName = ((GString *)tokens->get(2))->copy();    break;  }  if ((old = (DisplayFontParam *)fontHash->remove(param->name))) {    delete old;  }  fontHash->add(param->name, param);  return; err2:  delete param; err1:  error(-1, "Bad 'display*Font*' config file command (%s:%d)",	fileName->getCString(), line);}void GlobalParams::parsePSPaperSize(GList *tokens, GString *fileName,				    int line) {  GString *tok;  if (tokens->getLength() == 2) {    tok = (GString *)tokens->get(1);    if (!setPSPaperSize(tok->getCString())) {      error(-1, "Bad 'psPaperSize' config file command (%s:%d)",	    fileName->getCString(), line);    }  } else if (tokens->getLength() == 3) {    tok = (GString *)tokens->get(1);    psPaperWidth = atoi(tok->getCString());    tok = (GString *)tokens->get(2);    psPaperHeight = atoi(tok->getCString());  } else {    error(-1, "Bad 'psPaperSize' config file command (%s:%d)",	  fileName->getCString(), line);  }}void GlobalParams::parsePSLevel(GList *tokens, GString *fileName, int line) {  GString *tok;  if (tokens->getLength() != 2) {    error(-1, "Bad 'psLevel' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  tok = (GString *)tokens->get(1);  if (!tok->cmp("level1")) {    psLevel = psLevel1;  } else if (!tok->cmp("level1sep")) {    psLevel = psLevel1Sep;  } else if (!tok->cmp("level2")) {    psLevel = psLevel2;  } else if (!tok->cmp("level2sep")) {    psLevel = psLevel2Sep;  } else if (!tok->cmp("level3")) {    psLevel = psLevel3;  } else if (!tok->cmp("level3Sep")) {    psLevel = psLevel3Sep;  } else {    error(-1, "Bad 'psLevel' config file command (%s:%d)",	  fileName->getCString(), line);  }}void GlobalParams::parsePSFile(GList *tokens, GString *fileName, int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad 'psFile' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  if (psFile) {    delete psFile;  }  psFile = ((GString *)tokens->get(1))->copy();}void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {  PSFontParam *param;  if (tokens->getLength() != 3) {    error(-1, "Bad 'psFont' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,			  ((GString *)tokens->get(2))->copy(), NULL);  psFonts->add(param->pdfFontName, param);}void GlobalParams::parsePSFont16(char *cmdName, GList *fontList,				 GList *tokens, GString *fileName, int line) {  PSFontParam *param;  int wMode;  GString *tok;  if (tokens->getLength() != 5) {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);    return;  }  tok = (GString *)tokens->get(2);  if (!tok->cmp("H")) {    wMode = 0;  } else if (!tok->cmp("V")) {    wMode = 1;  } else {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);    return;  }  param = new PSFontParam(((GString *)tokens->get(1))->copy(),			  wMode,			  ((GString *)tokens->get(3))->copy(),			  ((GString *)tokens->get(4))->copy());  fontList->append(param);}void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName,				     int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad 'textEncoding' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  delete textEncoding;  textEncoding = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) {  GString *tok;  if (tokens->getLength() != 2) {    error(-1, "Bad 'textEOL' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  tok = (GString *)tokens->get(1);  if (!tok->cmp("unix")) {    textEOL = eolUnix;  } else if (!tok->cmp("dos")) {    textEOL = eolDOS;  } else if (!tok->cmp("mac")) {    textEOL = eolMac;  } else {    error(-1, "Bad 'textEOL' config file command (%s:%d)",	  fileName->getCString(), line);  }}void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad 'fontDir' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  fontDirs->append(((GString *)tokens->get(1))->copy());}void GlobalParams::parseInitialZoom(GList *tokens,				    GString *fileName, int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad 'initialZoom' config file command (%s:%d)",	  fileName->getCString(), line);    return;  }  delete initialZoom;  initialZoom = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val,					GList *tokens, GString *fileName,					int line) {  GString *tok;  if (tokens->getLength() != 2) {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);    return;  }  tok = (GString *)tokens->get(1);  if (!setFontRastControl(val, tok->getCString())) {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);  }}void GlobalParams::parseCommand(char *cmdName, GString **val,				GList *tokens, GString *fileName, int line) {  if (tokens->getLength() != 2) {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);    return;  }  if (*val) {    delete *val;  }  *val = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseYesNo(char *cmdName, GBool *flag,			      GList *tokens, GString *fileName, int line) {  GString *tok;  if (tokens->getLength() != 2) {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);    return;  }  tok = (GString *)tokens->get(1);  if (!tok->cmp("yes")) {    *flag = gTrue;  } else if (!tok->cmp("no")) {    *flag = gFalse;  } else {    error(-1, "Bad '%s' config file command (%s:%d)",	  cmdName, fileName->getCString(), line);  }}GlobalParams::~GlobalParams() {  GHashIter *iter;  GString *key;  GList *list;  freeBuiltinFontTables();  delete macRomanReverseMap;  delete nameToUnicode;  deleteGHash(cidToUnicodes, GString);  deleteGHash(residentUnicodeMaps, UnicodeMap);  deleteGHash(unicodeMaps, GString);  deleteGList(toUnicodeDirs, GString);  deleteGHash(displayFonts, DisplayFontParam);  deleteGHash(displayCIDFonts, DisplayFontParam);  deleteGHash(displayNamedCIDFonts, DisplayFontParam);  if (psFile) {    delete psFile;  }  deleteGHash(psFonts, PSFontParam);  deleteGList(psNamedFonts16, PSFontParam);  deleteGList(psFonts16, PSFontParam);  delete textEncoding;  deleteGList(fontDirs, GString);  delete initialZoom;  if (urlCommand) {    delete urlCommand;  }  if (movieCommand) {    delete movieCommand;  }  cMapDirs->startIter(&iter);  while (cMapDirs->getNext(&iter, &key, (void **)&list)) {    deleteGList(list, GString);  }  delete cMapDirs;  delete cidToUnicodeCache;  delete unicodeMapCache;  delete cMapCache;#if MULTITHREADED  gDestroyMutex(&mutex);#endif}//------------------------------------------------------------------------// accessors//------------------------------------------------------------------------CharCode GlobalParams::getMacRomanCharCode(char *charName) {  return macRomanReverseMap->lookup(charName);}Unicode GlobalParams::mapNameToUnicode(char *charName) {  return nameToUnicode->lookup(charName);}FILE *GlobalParams::getCIDToUnicodeFile(GString *collection) {  GString *fileName;  if (!(fileName = (GString *)cidToUnicodes->lookup(collection))) {    return NULL;  }  return fopen(fileName->getCString(), "r");}UnicodeMap *GlobalParams::getResidentUnicodeMap(GString *encodingName) {  return (UnicodeMap *)residentUnicodeMaps->lookup(encodingName);}FILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {  GString *fileName;  if (!(fileName = (GString *)unicodeMaps->lookup(encodingName))) {    return NULL;  }  return fopen(fileName->getCString(), "r");}FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {  GList *list;  GString *dir;  GString *fileName;  FILE *f;  int i;  if (!(list = (GList *)cMapDirs->lookup(collection))) {    return NULL;  }  for (i = 0; i < list->getLength(); ++i) {    dir = (GString *)list->get(i);    fileName = appendToPath(dir->copy(), cMapName->getCString());    f = fopen(fileName->getCString(), "r");    delete fileName;    if (f) {      return f;    }  }  return NULL;}FILE *GlobalParams::findToUnicodeFile(GString *name) {  GString *dir, *fileName;  FILE *f;  int i;  for (i = 0; i < toUnicodeDirs->getLength(); ++i) {    dir = (GString *)toUnicodeDirs->get(i);    fileName = appendToPath(dir->copy(), name->getCString());    f = fopen(fileName->getCString(), "r");    delete fileName;    if (f) {      return f;    }  }  return NULL;}DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {  DisplayFontParam *dfp;  globalParamsLock;  dfp = (DisplayFontParam *)displayFonts->lookup(fontName);  globalParamsUnlock;  return dfp;}DisplayFontParam *GlobalParams::getDisplayCIDFont(GString *fontName,						  GString *collection) {  DisplayFontParam *dfp;  if (!fontName ||      !(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {    dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);  }  return dfp;}GString *GlobalParams::getPSFile() {  GString *s;  globalParamsLock;  s = psFile ? psFile->copy() : (GString *)NULL;  globalParamsUnlock;  return s;}int GlobalParams::getPSPaperWidth() {  int w;  globalParamsLock;

⌨️ 快捷键说明

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