Ignore:
Timestamp:
Sep 29, 2006, 4:52:37 PM (15 years ago)
Author:
Eugene Romanenko
Message:

poppler updated to version 0.5.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/GlobalParams.cc

    r2 r134  
    437437    fclose(f);
    438438  }
     439
     440  scanEncodingDirs();
    439441}
    440442
     
    486488        }
    487489      } else if (!cmd->cmp("nameToUnicode")) {
    488         parseNameToUnicode(tokens, fileName, line);
     490        if (tokens->getLength() != 2)
     491          error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
     492                fileName->getCString(), line);
     493        else
     494          parseNameToUnicode((GooString *) tokens->get(1));
    489495      } else if (!cmd->cmp("cidToUnicode")) {
    490496        parseCIDToUnicode(tokens, fileName, line);
     
    604610}
    605611
    606 void GlobalParams::parseNameToUnicode(GooList *tokens, GooString *fileName,
    607                                          int line) {
    608   GooString *name;
     612void GlobalParams::scanEncodingDirs() {
     613  GDir *dir;
     614  GDirEntry *entry;
     615
     616  dir = new GDir(POPPLER_DATADIR "/nameToUnicode", gFalse);
     617  while (entry = dir->getNextEntry(), entry != NULL) {
     618    parseNameToUnicode(entry->getFullPath());
     619    delete entry;
     620  }
     621  delete dir;
     622
     623  dir = new GDir(POPPLER_DATADIR "/cidToUnicode", gFalse);
     624  while (entry = dir->getNextEntry(), entry != NULL) {
     625    addCIDToUnicode(entry->getName(), entry->getFullPath());
     626    delete entry;
     627  }
     628  delete dir;
     629
     630  dir = new GDir(POPPLER_DATADIR "/unicodeMap", gFalse);
     631  while (entry = dir->getNextEntry(), entry != NULL) {
     632    addUnicodeMap(entry->getName(), entry->getFullPath());
     633    delete entry;
     634  }
     635  delete dir;
     636
     637  dir = new GDir(POPPLER_DATADIR "/cMap", gFalse);
     638  while (entry = dir->getNextEntry(), entry != NULL) {
     639    addCMapDir(entry->getName(), entry->getFullPath());
     640    toUnicodeDirs->append(entry->getFullPath()->copy());
     641    delete entry;
     642  }
     643  delete dir;
     644}
     645
     646void GlobalParams::parseNameToUnicode(GooString *name) {
    609647  char *tok1, *tok2;
    610648  FILE *f;
    611649  char buf[256];
    612   int line2;
     650  int line;
    613651  Unicode u;
    614652
    615   if (tokens->getLength() != 2) {
    616     error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
    617           fileName->getCString(), line);
    618     return;
    619   }
    620   name = (GooString *)tokens->get(1);
    621653  if (!(f = fopen(name->getCString(), "r"))) {
    622654    error(-1, "Couldn't open 'nameToUnicode' file '%s'",
     
    624656    return;
    625657  }
    626   line2 = 1;
     658  line = 1;
    627659  while (getLine(buf, sizeof(buf), f)) {
    628660    tok1 = strtok(buf, " \t\r\n");
     
    633665    } else {
    634666      error(-1, "Bad line in 'nameToUnicode' file (%s:%d)",
    635             name->getCString(), line2);
    636     }
    637     ++line2;
     667            name->getCString(), line);
     668    }
     669    ++line;
    638670  }
    639671  fclose(f);
     672}
     673
     674void GlobalParams::addCIDToUnicode(GooString *collection,
     675                                   GooString *fileName) {
     676  GooString *old;
     677
     678  if ((old = (GooString *)cidToUnicodes->remove(collection))) {
     679    delete old;
     680  }
     681  cidToUnicodes->add(collection->copy(), fileName->copy());
    640682}
    641683
    642684void GlobalParams::parseCIDToUnicode(GooList *tokens, GooString *fileName,
    643685                                     int line) {
    644   GooString *collection, *name, *old;
    645 
    646686  if (tokens->getLength() != 3) {
    647687    error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
     
    649689    return;
    650690  }
    651   collection = (GooString *)tokens->get(1);
    652   name = (GooString *)tokens->get(2);
    653   if ((old = (GooString *)cidToUnicodes->remove(collection))) {
    654     delete old;
    655   }
    656   cidToUnicodes->add(collection->copy(), name->copy());
     691  addCIDToUnicode((GooString *)tokens->get(1), (GooString *)tokens->get(2));
    657692}
    658693
     
    674709}
    675710
     711void GlobalParams::addUnicodeMap(GooString *encodingName, GooString *fileName)
     712{
     713  GooString *old;
     714
     715  if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
     716    delete old;
     717  }
     718  unicodeMaps->add(encodingName->copy(), fileName->copy());
     719}
     720
    676721void GlobalParams::parseUnicodeMap(GooList *tokens, GooString *fileName,
    677722                                   int line) {
    678   GooString *encodingName, *name, *old;
    679723
    680724  if (tokens->getLength() != 3) {
     
    683727    return;
    684728  }
    685   encodingName = (GooString *)tokens->get(1);
    686   name = (GooString *)tokens->get(2);
    687   if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
    688     delete old;
    689   }
    690   unicodeMaps->add(encodingName->copy(), name->copy());
     729  addUnicodeMap((GooString *)tokens->get(1), (GooString *)tokens->get(2));
     730}
     731
     732void GlobalParams::addCMapDir(GooString *collection, GooString *dir) {
     733  GooList *list;
     734
     735  if (!(list = (GooList *)cMapDirs->lookup(collection))) {
     736    list = new GooList();
     737    cMapDirs->add(collection->copy(), list);
     738  }
     739  list->append(dir->copy());
    691740}
    692741
    693742void GlobalParams::parseCMapDir(GooList *tokens, GooString *fileName, int line) {
    694   GooString *collection, *dir;
    695   GooList *list;
    696 
    697743  if (tokens->getLength() != 3) {
    698744    error(-1, "Bad 'cMapDir' config file command (%s:%d)",
     
    700746    return;
    701747  }
    702   collection = (GooString *)tokens->get(1);
    703   dir = (GooString *)tokens->get(2);
    704   if (!(list = (GooList *)cMapDirs->lookup(collection))) {
    705     list = new GooList();
    706     cMapDirs->add(collection->copy(), list);
    707   }
    708   list->append(dir->copy());
     748  addCMapDir((GooString *)tokens->get(1), (GooString *)tokens->get(2));
    709749}
    710750
Note: See TracChangeset for help on using the changeset viewer.