made config file path handling a little bit more robust
[swftools.git] / lib / pdf / xpdf-changes.patch
1 Index: Gfx.cc
2 ===================================================================
3 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Gfx.cc,v
4 retrieving revision 1.9
5 retrieving revision 1.10
6 diff -u -r1.9 -r1.10
7 --- Gfx.cc      3 Dec 2005 10:11:33 -0000       1.9
8 +++ Gfx.cc      3 Dec 2005 10:30:41 -0000       1.10
9 @@ -439,7 +439,11 @@
10    fontChanged = gFalse;
11    clip = clipNone;
12    ignoreUndef = 0;
13 -  out->startPage(pageNum, state);
14 +  if(cropBox) {
15 +      out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
16 +  } else {
17 +      out->startPage(pageNum, state, 0,0,0,0);
18 +  }
19    out->setDefaultCTM(state->getCTM());
20    out->updateAll(state);
21    for (i = 0; i < 6; ++i) {
22 @@ -450,7 +450,8 @@
23    abortCheckCbkData = abortCheckCbkDataA;
24  
25    // set crop box
26 -  if (cropBox) {
27 +#ifdef XPDFEXE
28 +  if (cropBox) {
29      state->moveTo(cropBox->x1, cropBox->y1);
30      state->lineTo(cropBox->x2, cropBox->y1);
31      state->lineTo(cropBox->x2, cropBox->y2);
32 @@ -459,7 +460,8 @@
33      state->clip();
34      out->clip(state);
35      state->clearPath();
36 -  }
37 +  }
38 +#endif
39  }
40  
41  Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
42 Index: GfxFont.h
43 ===================================================================
44 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxFont.h,v
45 retrieving revision 1.6
46 retrieving revision 1.7
47 diff -u -r1.6 -r1.7
48 --- GfxFont.h   3 Dec 2005 10:11:33 -0000       1.6
49 +++ GfxFont.h   3 Dec 2005 10:30:41 -0000       1.7
50 @@ -207,7 +207,7 @@
51    CharCodeToUnicode *getToUnicode();
52  
53    // Return the character name associated with <code>.
54 -  char *getCharName(int code) { return enc[code]; }
55 +  char *getCharName(int code) { return code>=256?0:enc[code]; }
56  
57    // Returns true if the PDF font specified an encoding.
58    GBool getHasEncoding() { return hasEncoding; }
59 Index: GfxState.cc
60 ===================================================================
61 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GfxState.cc,v
62 retrieving revision 1.10
63 retrieving revision 1.12
64 diff -u -r1.10 -r1.12
65 --- GfxState.cc 3 Dec 2005 10:11:33 -0000       1.10
66 +++ GfxState.cc 3 Dec 2005 12:41:32 -0000       1.12
67 @@ -21,6 +21,7 @@
68  #include "Array.h"
69  #include "Page.h"
70  #include "GfxState.h"
71 +#include "cmyk.h"
72  
73  //------------------------------------------------------------------------
74  
75 @@ -468,6 +469,18 @@
76                                 - 0.11 * color->c[2] + 0.5));
77  }
78  
79 +/*void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
80 +    unsigned char r,g,b;
81 +    float c = color->c[0];
82 +    float m = color->c[1];
83 +    float y = color->c[2];
84 +    float k = color->c[3];
85 +    convert_cmyk2rgb(c,m,y,k, &r,&g,&b);
86 +    rgb->r = r/255.0;
87 +    rgb->g = g/255.0;
88 +    rgb->b = b/255.0;
89 +}*/
90 +
91  void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
92    double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
93  
94 @@ -3099,6 +3112,7 @@
95    GfxIndexedColorSpace *indexedCS;
96    GfxSeparationColorSpace *sepCS;
97    int maxPixel, indexHigh;
98 +  int maxPixelForAlloc;
99    Guchar *lookup2;
100    Function *sepFunc;
101    Object obj;
102 @@ -3111,6 +3125,7 @@
103    // bits per component and color space
104    bits = bitsA;
105    maxPixel = (1 << bits) - 1;
106 +  maxPixelForAlloc = (1 << (bits>8?bits:8));
107    colorSpace = colorSpaceA;
108  
109    // get decode map
110 @@ -3163,7 +3178,7 @@
111      lookup2 = indexedCS->getLookup();
112      colorSpace2->getDefaultRanges(x, y, indexHigh);
113      for (k = 0; k < nComps2; ++k) {
114 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
115 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
116                                            sizeof(GfxColorComp));
117        for (i = 0; i <= maxPixel; ++i) {
118         j = (int)(decodeLow[0] + (i * decodeRange[0]) / maxPixel + 0.5);
119 @@ -3182,7 +3197,7 @@
120      nComps2 = colorSpace2->getNComps();
121      sepFunc = sepCS->getFunc();
122      for (k = 0; k < nComps2; ++k) {
123 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
124 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
125                                            sizeof(GfxColorComp));
126        for (i = 0; i <= maxPixel; ++i) {
127         x[0] = decodeLow[0] + (i * decodeRange[0]) / maxPixel;
128 @@ -3192,7 +3207,7 @@
129      }
130    } else {
131      for (k = 0; k < nComps; ++k) {
132 -      lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1,
133 +      lookup[k] = (GfxColorComp *)gmallocn(maxPixelForAlloc + 1,
134                                            sizeof(GfxColorComp));
135        for (i = 0; i <= maxPixel; ++i) {
136         lookup[k][i] = dblToCol(decodeLow[k] +
137 Index: GlobalParams.cc
138 ===================================================================
139 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.cc,v
140 retrieving revision 1.4
141 retrieving revision 1.7
142 diff -u -r1.4 -r1.7
143 --- GlobalParams.cc     3 Dec 2005 10:11:33 -0000       1.4
144 +++ GlobalParams.cc     18 Dec 2005 08:31:22 -0000      1.7
145 @@ -498,6 +498,29 @@
146    char buf[512];
147    FILE *f2;
148  
149 +  /* extract path */
150 +  if(fileName) {
151 +    char* cfgFileName = fileName->getCString();
152 +    char* pos1 = strrchr(cfgFileName, '/');
153 +    char* pos2 = strrchr(cfgFileName, '\\');
154 +    char* p = pos1>pos2?pos1:pos2;
155 +    int pos = p ? p-cfgFileName : -1;
156 +    GString*path = new GString(new GString(cfgFileName), 0, (pos < 0 ? strlen(cfgFileName): pos));
157 +    if(pos1>=0)
158 +       path->append('/');
159 +    else if(pos2>=0)
160 +       path->append('\\');
161 +    else
162 +#ifdef WIN32
163 +       path->append('\\');
164 +#else
165 +       path->append('/');
166 +#endif
167 +    this->path = path;
168 +  } else {
169 +    this->path = new GString();
170 +  }
171 +  
172    line = 1;
173    while (getLine(buf, sizeof(buf) - 1, f)) {
174  
175 @@ -1142,6 +1165,42 @@
176    deleteGList(tokens, GString);
177  }
178  
179 +static char is_absolute(char*filename)
180 +{
181 +    int l = strlen(filename);
182 +    if(filename[0] == '/' || filename[0] == '\\') 
183 +       return 1;
184 +    if(l>2 && filename[1]==':' && (filename[2]=='\\' || filename[2]=='/'))
185 +       return 1;
186 +    return 0;
187 +}
188 +
189 +static GString* qualify_filename(GString*path, GString*filename)
190 +{
191 +  GString*fullpath = 0;
192 +  char*prefix = "/usr/local/share/xpdf/";
193 +
194 +  if (!is_absolute(filename->getCString())) {
195 +    /* relative path */
196 +    fullpath = path->copy();
197 +    fullpath->append(filename);
198 +  } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) {
199 +    /* xpdf default path */
200 +    char*s = strchr(filename->getCString()+strlen(prefix), '/');
201 +    if(s) {
202 +       fullpath = path->copy();
203 +       fullpath->append(s+1);
204 +    } else {
205 +       fullpath = filename->copy();
206 +    }
207 +  } else {
208 +    /* absolute path */
209 +    fullpath = filename->copy();
210 +  }
211 +  //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString());
212 +  return fullpath;
213 +}
214 +
215  void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
216                                          int line) {
217    GString *name;
218 @@ -1156,10 +1215,10 @@
219           fileName->getCString(), line);
220      return;
221    }
222 -  name = (GString *)tokens->get(1);
223 +  name = qualify_filename(this->path, (GString *)tokens->get(1));
224    if (!(f = fopen(name->getCString(), "r"))) {
225 -    error(-1, "Couldn't open 'nameToUnicode' file '%s'",
226 -         name->getCString());
227 +    error(-1, "Couldn't open 'nameToUnicode' file '%s' using path '%s'",
228 +         name->getCString(), path->getCString());
229      return;
230    }
231    line2 = 1;
232 @@ -705,10 +754,12 @@
233    }
234    collection = (GString *)tokens->get(1);
235    name = (GString *)tokens->get(2);
236 +
237    if ((old = (GString *)cidToUnicodes->remove(collection))) {
238      delete old;
239    }
240 -  cidToUnicodes->add(collection->copy(), name->copy());
241 +
242 +  cidToUnicodes->add(collection->copy(), qualify_filename(this->path, name));
243  }
244  
245  void GlobalParams::parseUnicodeToUnicode(GList *tokens, GString *fileName,
246 @@ -725,7 +776,8 @@
247    if ((old = (GString *)unicodeToUnicodes->remove(font))) {
248      delete old;
249    }
250 -  unicodeToUnicodes->add(font->copy(), file->copy());
251 +
252 +  unicodeToUnicodes->add(font->copy(), qualify_filename(this->path, file));
253  }
254  
255  void GlobalParams::parseUnicodeMap(GList *tokens, GString *fileName,
256 @@ -742,7 +794,8 @@
257    if ((old = (GString *)unicodeMaps->remove(encodingName))) {
258      delete old;
259    }
260 -  unicodeMaps->add(encodingName->copy(), name->copy());
261 +
262 +  unicodeMaps->add(encodingName->copy(), qualify_filename(this->path, name));
263  }
264  
265  void GlobalParams::parseCMapDir(GList *tokens, GString *fileName, int line) {
266 @@ -760,23 +813,30 @@
267      list = new GList();
268      cMapDirs->add(collection->copy(), list);
269    }
270 -  list->append(dir->copy());
271 +
272 +  list->append(qualify_filename(this->path, dir));
273  }
274  
275  void GlobalParams::parseToUnicodeDir(GList *tokens, GString *fileName,
276                                      int line) {
277 +  GString *dir;
278 +
279    if (tokens->getLength() != 2) {
280      error(-1, "Bad 'toUnicodeDir' config file command (%s:%d)",
281           fileName->getCString(), line);
282      return;
283    }
284 -  toUnicodeDirs->append(((GString *)tokens->get(1))->copy());
285 +
286 +  dir = (GString *)tokens->get(1);
287 +
288 +  toUnicodeDirs->append(qualify_filename(this->path, dir));
289  }
290  
291  void GlobalParams::parseDisplayFont(GList *tokens, GHash *fontHash,
292                                     DisplayFontParamKind kind,
293                                     GString *fileName, int line) {
294    DisplayFontParam *param, *old;
295 +  GString *file;
296  
297    if (tokens->getLength() < 2) {
298      goto err1;
299 @@ -788,13 +848,15 @@
300      if (tokens->getLength() != 3) {
301        goto err2;
302      }
303 -    param->t1.fileName = ((GString *)tokens->get(2))->copy();
304 +    file = (GString *)tokens->get(2);
305 +    param->t1.fileName = qualify_filename(this->path, file);
306      break;
307    case displayFontTT:
308      if (tokens->getLength() != 3) {
309        goto err2;
310      }
311 -    param->tt.fileName = ((GString *)tokens->get(2))->copy();
312 +    file = (GString *)tokens->get(2);
313 +    param->tt.fileName = qualify_filename(this->path, file);
314      break;
315    }
316  
317 Index: Lexer.cc
318 ===================================================================
319 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Lexer.cc,v
320 retrieving revision 1.4
321 retrieving revision 1.5
322 diff -u -r1.4 -r1.5
323 --- Lexer.cc    3 Dec 2005 10:11:33 -0000       1.4
324 +++ Lexer.cc    14 Mar 2006 12:43:23 -0000      1.5
325 @@ -74,6 +74,7 @@
326      curStr.streamReset();
327    }
328  }
329 +static int illegalChars = 0;
330  
331  Lexer::~Lexer() {
332    if (!curStr.isNone()) {
333 @@ -83,6 +84,9 @@
334    if (freeArray) {
335      delete streams;
336    }
337 +  if(illegalChars)
338 +      error(0, "Illegal characters in hex string (%d)", illegalChars);
339 +  illegalChars = 0;
340  }
341  
342  int Lexer::getChar() {
343 @@ -330,7 +334,8 @@
344         } else if (c2 >= 'a' && c2 <= 'f') {
345           c += c2 - 'a' + 10;
346         } else {
347 -         error(getPos(), "Illegal digit in hex char in name");
348 +         illegalChars++;
349 +         //error(getPos(), "Illegal digit in hex char in name");
350         }
351        }
352       notEscChar:
353 @@ -384,8 +389,10 @@
354             c2 += c - 'A' + 10;
355           else if (c >= 'a' && c <= 'f')
356             c2 += c - 'a' + 10;
357 -         else
358 -           error(getPos(), "Illegal character <%02x> in hex string", c);
359 +         else {
360 +           illegalChars++;
361 +           //error(getPos(), "Illegal character <%02x> in hex string", c);
362 +         }
363           if (++m == 2) {
364             if (n == tokBufSize) {
365               if (!s)
366 @@ -421,7 +428,8 @@
367        tokBuf[2] = '\0';
368        obj->initCmd(tokBuf);
369      } else {
370 -      error(getPos(), "Illegal character '>'");
371 +      illegalChars++;
372 +      //error(getPos(), "Illegal character '>'");
373        obj->initError();
374      }
375      break;
376 @@ -430,7 +438,8 @@
377    case ')':
378    case '{':
379    case '}':
380 -    error(getPos(), "Illegal character '%c'", c);
381 +    //error(getPos(), "Illegal character '%c'", c);
382 +    illegalChars++;
383      obj->initError();
384      break;
385  
386 @@ -459,7 +468,6 @@
387      }
388      break;
389    }
390 -
391    return obj;
392  }
393  
394 Index: Link.cc
395 ===================================================================
396 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Link.cc,v
397 retrieving revision 1.5
398 retrieving revision 1.6
399 diff -u -r1.5 -r1.6
400 --- Link.cc     3 Dec 2005 10:11:33 -0000       1.5
401 +++ Link.cc     26 Mar 2006 08:26:59 -0000      1.6
402 @@ -430,10 +430,9 @@
403        delete dest;
404        dest = NULL;
405      }
406 -
407    // error
408    } else {
409 -    error(-1, "Illegal annotation destination");
410 +    error(-1, "Illegal annotation destination %d", destObj->getType());
411    }
412  }
413  
414 @@ -468,10 +467,9 @@
415        delete dest;
416        dest = NULL;
417      }
418 -
419    // error
420    } else {
421 -    error(-1, "Illegal annotation destination");
422 +    error(-1, "Illegal annotation destination %d", destObj->getType());
423    }
424  }
425  
426 Index: OutputDev.h
427 ===================================================================
428 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/OutputDev.h,v
429 retrieving revision 1.7
430 retrieving revision 1.9
431 diff -u -r1.7 -r1.9
432 --- OutputDev.h 3 Dec 2005 10:11:33 -0000       1.7
433 +++ OutputDev.h 3 Dec 2005 10:31:47 -0000       1.9
434 @@ -74,7 +74,7 @@
435    virtual void setDefaultCTM(double *ctm);
436  
437    // Start a page.
438 -  virtual void startPage(int pageNum, GfxState *state) {}
439 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
440  
441    // End a page.
442    virtual void endPage() {}
443 Index: Stream.cc
444 ===================================================================
445 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/Stream.cc,v
446 retrieving revision 1.7
447 retrieving revision 1.8
448 diff -u -r1.7 -r1.8
449 --- Stream.cc   3 Dec 2005 10:11:33 -0000       1.7
450 +++ Stream.cc   3 Dec 2005 10:30:41 -0000       1.8
451 @@ -17,6 +17,8 @@
452  #include <stddef.h>
453  #ifndef WIN32
454  #include <unistd.h>
455 +#else
456 +extern "C" int unlink(char *filename);
457  #endif
458  #include <string.h>
459  #include <ctype.h>
460 Index: config.h
461 --- config.h    2007-09-09 12:11:20.000000000 +0200
462 +++ config.h    2007-09-09 12:11:40.000000000 +0200
463 @@ -53,9 +53,9 @@
464  
465  // user config file name, relative to the user's home directory
466  #if defined(VMS) || defined(WIN32)
467 -#define xpdfUserConfigFile "xpdfrc"
468 +#define xpdfUserConfigFile "pdf2swf.conf"
469  #else
470 -#define xpdfUserConfigFile ".xpdfrc"
471 +#define xpdfUserConfigFile ".pdf2swf.conf"
472  #endif
473  
474  // system config file name (set via the configure script)
475 @@ -64,7 +64,7 @@
476  #else
477  // under Windows, we get the directory with the executable and then
478  // append this file name
479 -#define xpdfSysConfigFile "xpdfrc"
480 +#define xpdfSysConfigFile "pdf2swf.conf"
481  #endif
482  
483  //------------------------------------------------------------------------
484 Index: gfile.cc
485 ===================================================================
486 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.cc,v
487 retrieving revision 1.12
488 retrieving revision 1.13
489 diff -u -r1.12 -r1.13
490 --- gfile.cc    3 Dec 2005 10:11:33 -0000       1.12
491 +++ gfile.cc    3 Dec 2005 10:30:41 -0000       1.13
492 @@ -437,6 +437,52 @@
493  #endif
494  }
495  
496 +static char* getTempDir()
497 +{
498 +#ifdef WIN32
499 +    char*dir = getenv("TMP");
500 +    if(!dir) dir = getenv("TEMP");
501 +    if(!dir) dir = getenv("tmp");
502 +    if(!dir) dir = getenv("temp");
503 +    if(!dir) dir = "C:\\";
504 +#else
505 +    char* dir = "/tmp/";
506 +#endif
507 +    return dir;
508 +}
509 +
510 +char* mktmpname(char*ptr) {
511 +    static char tmpbuf[128];
512 +    char*dir = getTempDir();
513 +    int l = strlen(dir);
514 +    char*sep = "";
515 +    if(!ptr)
516 +       ptr = tmpbuf;
517 +    if(l && dir[l-1]!='/' && dir[l-1]!='\\') {
518 +#ifdef WIN32
519 +       sep = "\\";
520 +#else
521 +       sep = "/";
522 +#endif
523 +    }
524 +
525 + //   used to be mktemp. This does remove the warnings, but
526 + //   It's not exactly an improvement.
527 +#ifdef HAVE_LRAND48
528 +    sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
529 +#else
530 +#   ifdef HAVE_RAND
531 +       sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
532 +#   else
533 +       static int count = 1;
534 +       sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count);
535 +       count ++;
536 +#   endif
537 +#endif
538 +     return ptr;
539 +}
540 +
541 +
542  GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
543  #if defined(WIN32)
544    //---------- Win32 ----------
545 @@ -463,7 +509,7 @@
546    // with this file name after the tmpnam call and before the fopen
547    // call.  I will happily accept fixes to this function for non-Unix
548    // OSs.
549 -  if (!(s = tmpnam(NULL))) {
550 +  if (!(s = mktmpname(NULL))) {
551      return gFalse;
552    }
553    *name = new GString(s);
554 @@ -490,7 +536,7 @@
555      (*name)->append("/XXXXXX")->append(ext);
556      fd = mkstemps((*name)->getCString(), strlen(ext));
557  #else
558 -    if (!(s = tmpnam(NULL))) {
559 +    if (!(s = mktmpname(NULL))) {
560        return gFalse;
561      }
562      *name = new GString(s);
563 @@ -507,7 +553,7 @@
564      (*name)->append("/XXXXXX");
565      fd = mkstemp((*name)->getCString());
566  #else // HAVE_MKSTEMP
567 -    if (!(s = tmpnam(NULL))) {
568 +    if (!(s = mktmpname(NULL))) {
569        return gFalse;
570      }
571      *name = new GString(s);
572 Index: gfile.h
573 ===================================================================
574 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/gfile.h,v
575 retrieving revision 1.9
576 retrieving revision 1.10
577 diff -u -r1.9 -r1.10
578 --- gfile.h     3 Dec 2005 10:11:33 -0000       1.9
579 +++ gfile.h     3 Dec 2005 10:30:41 -0000       1.10
580 @@ -58,6 +58,9 @@
581  // Get current directory.
582  extern GString *getCurrentDir();
583  
584 +/* create a temporary filename */
585 +char* mktmpname(char*ptr);
586 +
587  // Append a file name to a path string.  <path> may be an empty
588  // string, denoting the current directory).  Returns <path>.
589  extern GString *appendToPath(GString *path, char *fileName);
590 Index: GlobalParams.h
591 ===================================================================
592 RCS file: /home/kramm/cvs/swftools.cache.cvsroot/swftools.cache/pdf2swf/xpdf/GlobalParams.h,v
593 retrieving revision 1.5
594 retrieving revision 1.6
595 diff -u -r1.5 -r1.6
596 --- GlobalParams.h      2006-10-10 19:54:29.000000000 +0200
597 +++ GlobalParams.h      2006-11-12 11:19:40.000000000 +0100
598 @@ -213,8 +213,8 @@
599    FILE *getUnicodeMapFile(GString *encodingName);
600    FILE *findCMapFile(GString *collection, GString *cMapName);
601    FILE *findToUnicodeFile(GString *name);
602 -  DisplayFontParam *getDisplayFont(GString *fontName);
603 -  DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
604 +  virtual DisplayFontParam *getDisplayFont(GString *fontName);
605 +  virtual DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
606    GString *getPSFile();
607    int getPSPaperWidth();
608    int getPSPaperHeight();
609 @@ -218,1 +218,1 @@
610 -  void parseFile(GString *fileName, FILE *f);
611 +public: void parseFile(GString *fileName, FILE *f); private:
612 @@ -246,6 +246,10 @@
613    GBool loadPlugin(char *type, char *name);
614  #endif
615  
616 +  //----- config file base path
617 +
618 +  GString*path;
619 +
620    //----- static tables
621  
622    NameToCharCode *             // mapping from char name to
623 --- SplashOutputDev.h   2006-11-12 12:07:22.000000000 +0100
624 +++ SplashOutputDev.h   2006-11-12 12:08:48.000000000 +0100
625 @@ -70,7 +70,7 @@
626    //----- initialization and control
627  
628    // Start a page.
629 -  virtual void startPage(int pageNum, GfxState *state);
630 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
631  
632    // End a page.
633    virtual void endPage();
634 --- SplashOutputDev.cc  2006-11-12 12:07:06.000000000 +0100
635 +++ SplashOutputDev.cc  2006-11-12 12:09:36.000000000 +0100
636 @@ -696,7 +696,7 @@
637    nT3Fonts = 0;
638  }
639  
640 -void SplashOutputDev::startPage(int pageNum, GfxState *state) {
641 +void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
642    int w, h;
643    double *ctm;
644    SplashCoord mat[6];
645 --- TextOutputDev.h     2006-11-12 12:23:01.000000000 +0100
646 +++ TextOutputDev.h     2006-11-12 12:25:31.000000000 +0100
647 @@ -578,7 +578,7 @@
648    //----- initialization and control
649  
650    // Start a page.
651 -  virtual void startPage(int pageNum, GfxState *state);
652 +  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
653  
654    // End a page.
655    virtual void endPage();
656 --- TextOutputDev.cc    2006-11-12 12:22:53.000000000 +0100
657 +++ TextOutputDev.cc    2006-11-12 12:25:03.000000000 +0100
658 @@ -3805,7 +3805,7 @@
659    }
660  }
661  
662 -void TextOutputDev::startPage(int pageNum, GfxState *state) {
663 +void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
664    text->startPage(state);
665  }
666  
667 --- CoreOutputDev.cc    2006-11-12 12:21:59.000000000 +0100
668 +++ CoreOutputDev.cc    2006-11-12 12:23:29.000000000 +0100
669 @@ -57,5 +57,5 @@
670  
671  void CoreOutputDev::clear() {
672    startDoc(NULL);
673 -  startPage(0, NULL);
674 +  startPage(0, NULL, 0,0,0,0);
675  }
676 --- SplashFTFontEngine.cc       2006-11-19 22:30:44.000000000 +0100
677 +++ SplashFTFontEngine.cc       2006-11-19 22:30:56.000000000 +0100
678 @@ -13,9 +13,7 @@
679  #endif
680  
681  #include <stdio.h>
682 -#ifndef WIN32
683  #  include <unistd.h>
684 -#endif
685  #include "gmem.h"
686  #include "GString.h"
687  #include "gfile.h"
688 --- SplashOutputDev.cc  2007-09-09 12:29:45.000000000 +0200
689 +++ SplashOutputDev.cc  2007-09-09 12:30:02.000000000 +0200
690 @@ -13,6 +13,7 @@
691  #endif
692  
693  #include <string.h>
694 +#include <unistd.h>
695  #include <math.h>
696  #include "gfile.h"
697  #include "GlobalParams.h"
698 --- SplashFontFile.cc   2007-09-09 12:33:00.000000000 +0200
699 +++ SplashFontFile.cc   2007-09-09 12:33:07.000000000 +0200
700 @@ -11,9 +11,7 @@
701  #endif
702  
703  #include <stdio.h>
704 -#ifndef WIN32
705 -#  include <unistd.h>
706 -#endif
707 +#include <unistd.h>
708  #include "GString.h"
709  #include "SplashFontFile.h"
710  #include "SplashFontFileID.h"
711 --- SplashFont.h        2007-09-09 14:23:47.000000000 +0200
712 +++ SplashFont.h        2007-09-09 14:24:28.000000000 +0200
713 @@ -73,6 +73,9 @@
714    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
715                           SplashGlyphBitmap *bitmap) = 0;
716  
717 +  // return the number of characters in this font
718 +  virtual int getNumChars() = 0;
719 +
720    // Return the path for a glyph.
721    virtual SplashPath *getGlyphPath(int c) = 0;
722  
723 --- SplashFTFont.h      2007-09-09 14:23:47.000000000 +0200
724 +++ SplashFTFont.h      2007-09-09 14:25:19.000000000 +0200
725 @@ -42,6 +42,9 @@
726    virtual GBool makeGlyph(int c, int xFrac, int yFrac,
727                           SplashGlyphBitmap *bitmap);
728  
729 +  // return the number of characters in this font
730 +  virtual int getNumChars();
731 +
732    // Return the path for a glyph.
733    virtual SplashPath *getGlyphPath(int c);
734  
735 --- SplashFTFont.cc.h   2007-09-09 14:23:50.000000000 +0200
736 +++ SplashFTFont.cc     2007-09-09 14:27:35.000000000 +0200
737 @@ -228,6 +228,12 @@
738    GBool needClose;
739  };
740  
741 +int SplashFTFont::getNumChars()
742 +{
743 +  SplashFTFontFile* ff = (SplashFTFontFile *)fontFile;
744 +  return ff->face->num_glyphs;
745 +}
746 +
747  SplashPath *SplashFTFont::getGlyphPath(int c) {
748    static FT_Outline_Funcs outlineFuncs = {
749  #if FREETYPE_MINOR <= 1
750 --- orig/GfxFont.h      2007-07-28 00:11:06.000000000 +0200
751 +++ GfxFont.h   2007-09-09 18:31:31.000000000 +0200
752 @@ -164,6 +164,7 @@
753    virtual int getNextChar(char *s, int len, CharCode *code,
754                           Unicode *u, int uSize, int *uLen,
755                           double *dx, double *dy, double *ox, double *oy) = 0;
756 +  virtual CharCodeToUnicode* getCTU() = 0;
757  
758  protected:
759  
760 @@ -204,6 +205,7 @@
761    virtual int getNextChar(char *s, int len, CharCode *code,
762                           Unicode *u, int uSize, int *uLen,
763                           double *dx, double *dy, double *ox, double *oy);
764 +  virtual CharCodeToUnicode* getCTU();
765  
766    // Return the encoding.
767    char **getEncoding() { return enc; }
768 @@ -266,6 +268,7 @@
769    virtual int getNextChar(char *s, int len, CharCode *code,
770                           Unicode *u, int uSize, int *uLen,
771                           double *dx, double *dy, double *ox, double *oy);
772 +  virtual CharCodeToUnicode* getCTU();
773  
774    // Return the writing mode (0=horizontal, 1=vertical).
775    virtual int getWMode();
776 --- orig/GfxFont.cc     2007-07-28 00:11:06.000000000 +0200
777 +++ GfxFont.cc  2007-09-09 18:33:37.000000000 +0200
778 @@ -925,6 +925,10 @@
779    return 1;
780  }
781  
782 +CharCodeToUnicode* Gfx8BitFont::getCTU() {
783 +    return ctu;
784 +}
785 +
786  CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
787    ctu->incRefCnt();
788    return ctu;
789 @@ -1417,6 +1421,10 @@
790    }
791  }
792  
793 +CharCodeToUnicode* GfxCIDFont::getCTU() {
794 +    return ctu;
795 +}
796 +
797  int GfxCIDFont::getNextChar(char *s, int len, CharCode *code,
798                             Unicode *u, int uSize, int *uLen,
799                             double *dx, double *dy, double *ox, double *oy) {
800 --- OutputDev.h Sat Jul 28 00:11:08 2007
801 +++ OutputDev.h Sun Sep  9 13:50:40 2007
802 @@ -17,6 +17,7 @@
803  
804  #include "gtypes.h"
805  #include "CharTypes.h"
806 +#include "Object.h"
807  
808  class GString;
809  class Gfx;
810 --- SplashOutputDev.h   2007-10-20 13:17:02.000000000 +0200
811 +++ SplashOutputDev.h   2007-10-20 13:17:23.000000000 +0200
812 @@ -206,6 +206,7 @@
813    virtual void setVectorAntialias(GBool vaa);
814  #endif
815  
816 +  void doUpdateFont(GfxState *state);
817  private:
818  
819    void setupScreenParams(double hDPI, double vDPI);
820 @@ -215,7 +216,6 @@
821    SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
822  #endif
823    SplashPath *convertPath(GfxState *state, GfxPath *path);
824 -  void doUpdateFont(GfxState *state);
825    void drawType3Glyph(T3FontCache *t3Font,
826                       T3FontCacheTag *tag, Guchar *data);
827    static GBool imageMaskSrc(void *data, SplashColorPtr line);
828 --- xpdf/GlobalParams.h 2007-10-20 13:18:03.000000000 +0200
829 +++ xpdf/GlobalParams.h 2007-10-20 13:25:52.000000000 +0200
830 @@ -196,7 +196,7 @@
831    // file.
832    GlobalParams(char *cfgFileName);
833  
834 -  ~GlobalParams();
835 +  virtual ~GlobalParams();
836  
837    void setBaseDir(char *dir);
838    void setupBaseFonts(char *dir);
839 --- xpdf/SplashOutputDev.h.orig 2007-10-21 17:43:29.000000000 +0200
840 +++ xpdf/SplashOutputDev.h      2007-11-19 10:07:27.000000000 +0100
841 @@ -197,6 +197,8 @@
842  #endif
843  
844    void doUpdateFont(GfxState *state);
845 +  
846 +  SplashPath *convertPath(GfxState *state, GfxPath *path);
847  private:
848  
849    void setupScreenParams(double hDPI, double vDPI);
850 @@ -205,7 +207,6 @@
851  #else
852    SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
853  #endif
854 -  SplashPath *convertPath(GfxState *state, GfxPath *path);
855    void drawType3Glyph(T3FontCache *t3Font,
856                       T3FontCacheTag *tag, Guchar *data);
857    static GBool imageMaskSrc(void *data, SplashColorPtr line);