Changeset 254


Ignore:
Timestamp:
Aug 26, 2008, 11:59:38 AM (13 years ago)
Author:
Eugene Romanenko
Message:

PDF plugin: Poppler library updated to version 0.8.6

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/plugins/lupoppler/lupoppler.cpp

    r253 r254  
    101101extern "C" char * EXPENTRY getDescription()
    102102{
    103     return "PDF plugin, based on poppler library v0.8.4";
     103    return "PDF plugin, based on poppler library v0.8.6";
    104104}
    105105
  • trunk/Lucide/changelog

    r253 r254  
    111.XX:
    2   - PDF plugin: Poppler (pdf rendering) library updated to version 0.8.4.
     2  - PDF plugin: Poppler (pdf rendering) library updated to version 0.8.6.
    33  - PDF plugin: freetype library updated to version 2.3.7.
    44
  • trunk/poppler/mypoppler/fofi/FoFiTrueType.cc

    r250 r254  
    2121#include "FoFiType1C.h"
    2222#include "FoFiTrueType.h"
     23#include "poppler/Error.h"
    2324
    2425//
     
    18751876  tables = (TrueTypeTable *)gmallocn(nTables, sizeof(TrueTypeTable));
    18761877  pos += 12;
     1878  int wrongTables = 0;
    18771879  for (i = 0; i < nTables; ++i) {
    18781880    tables[i].tag = getU32BE(pos, &parsedOk);
     
    18821884    if (tables[i].offset + tables[i].len < tables[i].offset ||
    18831885        tables[i].offset + tables[i].len > len) {
    1884       parsedOk = gFalse;
     1886      i--;
     1887      wrongTables++;
     1888      error(-1, "Found a bad table definition on true type definition, trying to continue...");
    18851889    }
    18861890    pos += 16;
    18871891  }
     1892  nTables -= wrongTables;
     1893  tables = (TrueTypeTable *)greallocn(tables, nTables, sizeof(TrueTypeTable));
    18881894  if (!parsedOk) {
    18891895    return;
  • trunk/poppler/mypoppler/poppler/Annot.cc

    r250 r254  
    11361136
    11371137  if (dict->lookup("IRT", &obj1)->isDict()) {
    1138     inReplyTo = obj1.getDict();
     1138    inReplyTo = new Dict(obj1.getDict());
    11391139  } else {
    11401140    inReplyTo = NULL;
     
    17121712  type = typeWidget;
    17131713  initialize(xrefA, catalog, dict);
     1714  widget = NULL;
    17141715}
    17151716
     
    18281829  GBool unicode = text->hasUnicodeMarker();
    18291830  CharCodeToUnicode *ccToUnicode = font->getToUnicode();
     1831  ccToUnicode->decRefCnt();
    18301832  GBool spacePrev;              // previous character was a space
    18311833
     
    29692971    annot->set("AP", &apObj);
    29702972    Dict* d = new Dict(annot);
     2973    d->decRef();
    29712974    Object dictObj;
    29722975    dictObj.initDict(d);
  • trunk/poppler/mypoppler/poppler/FontInfo.cc

    r250 r254  
    1919  fonts = NULL;
    2020  fontsLen = fontsSize = 0;
     21  visitedXObjects = NULL;
     22  visitedXObjectsLen = visitedXObjectsSize = 0;
    2123}
    2224
    2325FontInfoScanner::~FontInfoScanner() {
    2426  gfree(fonts);
     27  gfree(visitedXObjects);
    2528}
    2629
     
    7073
    7174void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
    72   Object obj1, obj2, xObjDict, xObj, resObj;
     75  Object obj1, obj2, xObjDict, xObj, xObj2, resObj;
    7376  Ref r;
    7477  GfxFontDict *gfxFontDict;
     
    123126  if (xObjDict.isDict()) {
    124127    for (i = 0; i < xObjDict.dictGetLength(); ++i) {
    125       xObjDict.dictGetVal(i, &xObj);
    126       if (xObj.isStream()) {
    127         xObj.streamGetDict()->lookup("Resources", &resObj);
    128         if (resObj.isDict() && resObj.getDict() != resDict) {
    129           scanFonts(resObj.getDict(), fontsList);
    130         }
    131         resObj.free();
     128      xObjDict.dictGetValNF(i, &xObj);
     129      if (xObj.isRef()) {
     130        GBool alreadySeen = gFalse;
     131        // check for an already-seen XObject
     132        for (int k = 0; k < visitedXObjectsLen; ++k) {
     133          if (xObj.getRef().num == visitedXObjects[k].num &&
     134              xObj.getRef().gen == visitedXObjects[k].gen) {
     135            alreadySeen = gTrue;
     136          }
     137        }
     138
     139        if (alreadySeen) {
     140          xObj.free();
     141          continue;
     142        }
     143
     144        if (visitedXObjectsLen == visitedXObjectsSize) {
     145          visitedXObjectsSize += 32;
     146          visitedXObjects = (Ref *)grealloc(visitedXObjects, visitedXObjectsSize * sizeof(Ref));
     147        }
     148        visitedXObjects[visitedXObjectsLen++] = xObj.getRef();
     149      }
     150
     151      xObj.fetch(doc->getXRef(), &xObj2);
     152
     153      if (xObj2.isStream()) {
     154        xObj2.streamGetDict()->lookup("Resources", &resObj);
     155        if (resObj.isDict() && resObj.getDict() != resDict) {
     156          scanFonts(resObj.getDict(), fontsList);
     157        }
     158        resObj.free();
    132159      }
    133160      xObj.free();
     161      xObj2.free();
    134162    }
    135163  }
  • trunk/poppler/mypoppler/poppler/FontInfo.h

    r250 r254  
    6464  int fontsSize;
    6565
     66  Ref *visitedXObjects;
     67  int visitedXObjectsLen;
     68  int visitedXObjectsSize;
     69
    6670  void scanFonts(Dict *resDict, GooList *fontsList);
    6771};
  • trunk/poppler/mypoppler/poppler/Link.cc

    r250 r254  
    207207  // initialize fields
    208208  left = bottom = right = top = zoom = 0;
     209  changeLeft = changeTop = changeZoom = gFalse;
    209210  ok = gFalse;
    210211
  • trunk/poppler/mypoppler/poppler/PDFDoc.cc

    r250 r254  
    553553
    554554  Guint uxrefOffset = outStr->getPos();
    555   uxref->writeToFile(outStr);
     555  uxref->writeToFile(outStr, gFalse /* do not write unnecessary entries */);
    556556
    557557  writeTrailer(uxrefOffset, objectsCount, outStr, gTrue);
     
    593593  }
    594594  Guint uxrefOffset = outStr->getPos();
    595   uxref->writeToFile(outStr);
     595  uxref->writeToFile(outStr, gTrue /* write all entries */);
    596596
    597597  writeTrailer(uxrefOffset, uxref->getSize(), outStr, gFalse);
     
    839839    //new file => same values for the two identifiers
    840840    obj2.arrayAdd(&obj1);
     841    obj1.initString(new GooString((const char*)digest, 16));
    841842    obj2.arrayAdd(&obj1);
    842843    trailerDict->set("ID", &obj2);
  • trunk/poppler/mypoppler/poppler/Page.cc

    r250 r254  
    236236  num = numA;
    237237  duration = -1;
     238  pageWidgets = NULL;
    238239
    239240  // get attributes
     
    467468  /* Get stream dict */
    468469  thumb.fetch(xref, &fetched_thumb);
    469   if (fetched_thumb.isNull()) {
     470  if (!fetched_thumb.isStream()) {
    470471    fetched_thumb.free();
    471472    return gFalse;
  • trunk/poppler/mypoppler/poppler/SplashOutputDev.cc

    r250 r254  
    11261126          ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
    11271127        if (! ff)
     1128        {
     1129          error(-1, "Couldn't create a font for '%s'",
     1130              gfxFont->getName() ? gfxFont->getName()->getCString()
     1131                                 : "(unnamed)");
    11281132          goto err2;
     1133        }
    11291134        codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
    11301135        delete ff;
  • trunk/poppler/mypoppler/poppler/XRef.cc

    r253 r254  
    414414        entries[i].obj.initNull ();
    415415        entries[i].updated = false;
     416        entries[i].gen = 0;
    416417      }
    417418      size = newSize;
     
    528529      entries[i].obj.initNull ();
    529530      entries[i].updated = false;
     531      entries[i].gen = 0;
    530532    }
    531533    size = newSize;
     
    624626      entries[i].obj.initNull ();
    625627      entries[i].updated = false;
     628      entries[i].gen = 0;
    626629    }
    627630    size = newSize;
     
    10051008
    10061009void XRef::add(int num, int gen, Guint offs, GBool used) {
    1007   size += 1;
    1008   entries = (XRefEntry *)greallocn(entries, size, sizeof(XRefEntry));
    1009   XRefEntry *e = &entries[size-1];
    1010 
     1010  if (num >= size) {
     1011    entries = (XRefEntry *)greallocn(entries, num + 1, sizeof(XRefEntry));
     1012    for (int i = size; i < num + 1; ++i) {
     1013      entries[i].offset = 0xffffffff;
     1014      entries[i].type = xrefEntryFree;
     1015      entries[i].obj.initNull ();
     1016      entries[i].updated = false;
     1017      entries[i].gen = 0;
     1018    }
     1019    size = num + 1;
     1020  }
     1021  XRefEntry *e = &entries[num];
    10111022  e->gen = gen;
    1012   e->num = num;
    10131023  e->obj.initNull ();
    10141024  e->updated = false;
     
    10271037    return;
    10281038  }
     1039  entries[r.num].obj.free();
    10291040  o->copy(&entries[r.num].obj);
    10301041  entries[r.num].updated = true;
     
    10321043
    10331044Ref XRef::addIndirectObject (Object* o) {
    1034   //Find the next free entry
    1035   // lastEntry is the last free entry we encountered,
    1036   // entry 0 is always free
    1037   int lastEntry = 0;
    1038   int newEntry = entries[0].offset;
    1039 
    1040   do {
    1041     lastEntry = newEntry;
    1042     newEntry = entries[newEntry].offset;
    1043     //we are looking for a free entry that we can reuse
    1044     //(=> gen number != 65535)
    1045   } while ((newEntry != 0) && (entries[newEntry].gen == 65535));
    1046 
    1047   //the linked list of free entry is empty => create a new one
    1048   if (newEntry == 0) {
    1049     newEntry = size;
     1045  int entryIndexToUse = -1;
     1046  for (int i = 1; entryIndexToUse == -1 && i < size; ++i) {
     1047    if (entries[i].type == xrefEntryFree) entryIndexToUse = i;
     1048  }
     1049
     1050  XRefEntry *e;
     1051  if (entryIndexToUse == -1) {
     1052    entryIndexToUse = size;
    10501053    size++;
    10511054    entries = (XRefEntry *)greallocn(entries, size, sizeof(XRefEntry));
    1052     entries[newEntry].gen = 0;
    1053     entries[newEntry].num = newEntry;
    1054   } else { //reuse a free entry
    1055     //'remove' the entry we are using from the free entry linked list
    1056     entries[lastEntry].offset = entries[newEntry].offset;
    1057     entries[newEntry].num = newEntry;
     1055    e = &entries[entryIndexToUse];
     1056    e->gen = 0;
     1057  } else {
     1058    //reuse a free entry
     1059    e = &entries[entryIndexToUse];
    10581060    //we don't touch gen number, because it should have been
    10591061    //incremented when the object was deleted
    10601062  }
    1061 
    1062   entries[newEntry].type = xrefEntryUncompressed;
    1063   o->copy(&entries[newEntry].obj);
    1064   entries[newEntry].updated = true;
     1063  e->type = xrefEntryUncompressed;
     1064  o->copy(&e->obj);
     1065  e->updated = true;
    10651066
    10661067  Ref r;
    1067   r.num = entries[newEntry].num;
    1068   r.gen = entries[newEntry].gen;
     1068  r.num = entryIndexToUse;
     1069  r.gen = e->gen;
    10691070  return r;
    10701071}
    10711072
    1072 
    1073 //used to sort the entries
    1074 int compare (const void* a, const void* b)
    1075 {
    1076   return (((XRefEntry*)a)->num - ((XRefEntry*)b)->num);
    1077 }
    1078 
    1079 void XRef::writeToFile(OutStream* outStr) {
    1080   qsort(entries, size, sizeof(XRefEntry), compare);
     1073void XRef::writeToFile(OutStream* outStr, GBool writeAllEntries) {
    10811074  //create free entries linked-list
    10821075  if (entries[0].gen != 65535) {
    10831076    error(-1, "XRef::writeToFile, entry 0 of the XRef is invalid (gen != 65535)\n");
    10841077  }
    1085   int lastFreeEntry = 0; 
     1078  int lastFreeEntry = 0;
    10861079  for (int i=0; i<size; i++) {
    10871080    if (entries[i].type == xrefEntryFree) {
    1088       entries[lastFreeEntry].offset = entries[i].num;
     1081      entries[lastFreeEntry].offset = i;
    10891082      lastFreeEntry = i;
    10901083    }
    10911084  }
    1092   //write the new xref
    1093   int j;
    1094   outStr->printf("xref\r\n");
    1095   for (int i=0; i<size; i++) {
    1096     for(j=i; j<size; j++) { //look for consecutive entries
    1097       if (j!=i && entries[j].num != entries[j-1].num+1)
    1098               break;
    1099     }
    1100     outStr->printf("%i %i\r\n", entries[i].num, j-i);
    1101     for (int k=i; k<j; k++) {
    1102       if(entries[k].gen > 65535) entries[k].gen = 65535; //cap generation number to 65535 (required by PDFReference)
    1103       outStr->printf("%010i %05i %c\r\n", entries[k].offset, entries[k].gen, (entries[k].type==xrefEntryFree)?'f':'n');
    1104     }
    1105     i = j-1;
    1106   }
    1107 }
    1108 
     1085
     1086  if (writeAllEntries) {
     1087    //write the new xref
     1088    outStr->printf("xref\r\n");
     1089    outStr->printf("%i %i\r\n", 0, size);
     1090    for (int i=0; i<size; i++) {
     1091      XRefEntry &e = entries[i];
     1092
     1093      if(e.gen > 65535) e.gen = 65535; //cap generation number to 65535 (required by PDFReference)
     1094      outStr->printf("%010i %05i %c\r\n", e.offset, e.gen, (e.type==xrefEntryFree)?'f':'n');
     1095    }
     1096  } else {
     1097    //write the new xref
     1098    outStr->printf("xref\r\n");
     1099    int i = 0;
     1100    while (i < size) {
     1101      int j;
     1102      for(j=i; j<size; j++) { //look for consecutive entries
     1103        if ((entries[j].type == xrefEntryFree) && (entries[j].gen == 0))
     1104          break;
     1105      }
     1106      if (j-i != 0)
     1107      {
     1108        outStr->printf("%i %i\r\n", i, j-i);
     1109        for (int k=i; k<j; k++) {
     1110          XRefEntry &e = entries[k];
     1111          if(e.gen > 65535) e.gen = 65535; //cap generation number to 65535 (required by PDFReference)
     1112          outStr->printf("%010i %05i %c\r\n", e.offset, e.gen, (e.type==xrefEntryFree)?'f':'n');
     1113        }
     1114        i = j;
     1115      }
     1116      else ++i;
     1117    }
     1118  }
     1119}
     1120
  • trunk/poppler/mypoppler/poppler/XRef.h

    r250 r254  
    3535  Guint offset;
    3636  int gen;
    37   int num;
    3837  XRefEntryType type;
    3938  bool updated;
     
    113112  Ref addIndirectObject (Object* o);
    114113  void add(int num, int gen,  Guint offs, GBool used);
    115   void writeToFile(OutStream* outStr);
     114  void writeToFile(OutStream* outStr, GBool writeAllEntries);
    116115
    117116private:
Note: See TracChangeset for help on using the changeset viewer.